13 gboolean
set_uid_gid(SMSD_Parameters
*params
)
15 /* gid is set allways (either through fill_uid or by user */
16 if (setgid(params
->gid
) != 0)
20 if (params
->uid
== -1)
23 if (initgroups(params
->user
, params
->gid
) != 0)
26 if (setuid(params
->uid
) != 0)
29 if (seteuid(params
->uid
) != 0)
38 gboolean
set_gid(int gid
)
40 return setgid(gid
) == 0;
44 * Gets UID from string.
46 gboolean
fill_uid(SMSD_Parameters
*params
, const char *name
)
55 /* Try to handle it as a number */
56 uid
= strtol(name
, &endptr
, 10);
57 if (*endptr
== 0 && uid
> 0) {
63 params
->uid
= pwd
->pw_uid
;
64 params
->user
= strdup(pwd
->pw_name
);
65 if (params
->gid
== -1) {
66 params
->gid
= pwd
->pw_gid
;
75 * Gets GID from string.
77 gboolean
fill_gid(SMSD_Parameters
*params
, const char *name
)
85 /* Try to handle it as a number */
87 gid
= strtol(name
, &endptr
, 10);
88 if (*endptr
== 0 && gid
> 0) {
94 params
->gid
= grp
->gr_gid
;
95 params
->group
= strdup(grp
->gr_name
);