Greenbone Vulnerability Management Libraries
11.0.0
|
Go to the documentation of this file.
29 #include <sys/types.h>
75 struct passwd *user_pw = NULL;
77 if ((user_pw = getpwnam (username)))
79 if (initgroups (username, user_pw->pw_gid) != 0)
82 "Failed to drop supplementary groups privileges!\n");
83 if (setgid (user_pw->pw_gid) != 0)
86 "Failed to drop group privileges!\n");
87 if (setuid (user_pw->pw_uid) != 0)
90 "Failed to drop user privileges!\n");
96 "Failed to get gid and uid for user %s.", username);
104 "Only root can drop its privileges.");
static gint drop_privileges_error(GError **error, gint errorcode, const gchar *message)
Sets an error and return errorcode.
#define GVM_DROP_PRIVILEGES_FAIL_DROP_UID
Definition of the return code FAIL_DROP_UID.
#define GVM_DROP_PRIVILEGES_ERROR_ALREADY_SET
Definition of the return code ERROR_ALREADY_SET.
int drop_privileges(gchar *username, GError **error)
Drop privileges.
#define GVM_DROP_PRIVILEGES_FAIL_NOT_ROOT
Definition of the return code FAIL_NOT_ROOT.
Privilege dropping header file.
#define GVM_DROP_PRIVILEGES_FAIL_SUPPLEMENTARY
Definition of the return code FAIL_SUPPLEMENTARY.
#define GVM_DROP_PRIVILEGES_FAIL_UNKNOWN_USER
Definition of the return code FAIL_UNKNOWN_USER.
#define GVM_DROP_PRIVILEGES_FAIL_DROP_GID
Definition of the return code FAIL_DROP_GID.
#define GVM_DROP_PRIVILEGES
The GQuark for privilege dropping errors.
#define GVM_DROP_PRIVILEGES_OK
Definition of the return code OK.