drop privileges when running as root
This commit is contained in:
11
fiche.c
11
fiche.c
@@ -36,6 +36,17 @@ int main(int argc, char **argv)
|
|||||||
time_seed = time(0);
|
time_seed = time(0);
|
||||||
|
|
||||||
parse_parameters(argc, argv);
|
parse_parameters(argc, argv);
|
||||||
|
|
||||||
|
if (getuid() == 0)
|
||||||
|
{
|
||||||
|
if (UID == -1)
|
||||||
|
error("ERROR: user not set");
|
||||||
|
if (setgid(GID) != 0)
|
||||||
|
error("ERROR: Unable to drop group privileges");
|
||||||
|
if (setuid(UID) != 0)
|
||||||
|
error("ERROR: Unable to drop user privileges");
|
||||||
|
}
|
||||||
|
|
||||||
if (BASEDIR == NULL)
|
if (BASEDIR == NULL)
|
||||||
set_basedir();
|
set_basedir();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user