7 * this section of code will drop all (Solaris) privileges including
8 * those normally granted to all userland process (basic privileges). The
9 * effect of this is that after running this code, the process will not able
10 * to fork(), exec(), etc. See privileges(5) for more information.
12 void drop_privileges(void) {
13 priv_set_t
*privs
= priv_str_to_set("basic", ",", NULL
);
16 perror("priv_str_to_set");
20 (void)priv_delset(privs
, PRIV_FILE_LINK_ANY
);
21 (void)priv_delset(privs
, PRIV_PROC_EXEC
);
22 (void)priv_delset(privs
, PRIV_PROC_FORK
);
23 (void)priv_delset(privs
, PRIV_PROC_INFO
);
24 (void)priv_delset(privs
, PRIV_PROC_SESSION
);
26 if (setppriv(PRIV_SET
, PRIV_PERMITTED
, privs
) != 0) {
27 perror("setppriv(PRIV_SET, PRIV_PERMITTED)");
33 if (setppriv(PRIV_SET
, PRIV_INHERITABLE
, privs
) != 0) {
34 perror("setppriv(PRIV_SET, PRIV_INHERITABLE)");
38 if (setppriv(PRIV_SET
, PRIV_LIMIT
, privs
) != 0) {
39 perror("setppriv(PRIV_SET, PRIV_LIMIT)");