libamxrt  0.4.2
Ambiorix Run Time Library
amxrt_cap.c File Reference
#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <grp.h>
#include <cap-ng.h>
#include <amxrt/amxrt.h>
#include "amxrt_priv.h"

Go to the source code of this file.

Functions

static int32_t amxrt_get_user_id (amxc_var_t *user)
 
static int32_t amxrt_get_group_id (amxc_var_t *group)
 
int amxrt_caps_apply (void)
 Apply the user, group and capabilities as defined in the configuration. More...
 
void amxrt_caps_dump (void)
 Dumps the capabilities of the process. More...
 

Function Documentation

◆ amxrt_get_group_id()

static int32_t amxrt_get_group_id ( amxc_var_t *  group)
static

Definition at line 83 of file amxrt_cap.c.

83  {
84  int32_t gid = 0;
85 
86  if(amxc_var_type_of(group) == AMXC_VAR_ID_NULL) {
87  gid = -1;
88  } else if(amxc_var_type_of(group) == AMXC_VAR_ID_CSTRING) {
89  struct group* group_info = NULL;
90  group_info = getgrnam(GET_CHAR(group, NULL));
91  when_null_status(group_info, exit, gid = -1);
92  gid = group_info->gr_gid;
93  } else {
94  gid = GET_INT32(group, NULL);
95  }
96 
97 exit:
98  return gid;
99 }

◆ amxrt_get_user_id()

static int32_t amxrt_get_user_id ( amxc_var_t *  user)
static

Definition at line 65 of file amxrt_cap.c.

65  {
66  int32_t uid = 0;
67 
68  if(amxc_var_type_of(user) == AMXC_VAR_ID_NULL) {
69  uid = -1;
70  } else if(amxc_var_type_of(user) == AMXC_VAR_ID_CSTRING) {
71  struct passwd* user_info = NULL;
72  user_info = getpwnam(GET_CHAR(user, NULL));
73  when_null_status(user_info, exit, uid = -1);
74  uid = user_info->pw_uid;
75  } else {
76  uid = GET_INT32(user, NULL);
77  }
78 
79 exit:
80  return uid;
81 }