privops: refactor initialisation/finalisation

Rename PRV_Initialise() to PRV_StartHelper() and add a new
initialisation function, which just sets the helper fd to -1. Move
the initialision/finalisation calls from the system drivers to main.c.
If privops is not included in the build, define empty macros for the
function names, so their calls don't have to be wrapped in #ifdefs.
This commit is contained in:
Miroslav Lichvar
2015-12-08 14:10:29 +01:00
parent aa9a4c697c
commit 610f234043
4 changed files with 19 additions and 6 deletions

View File

@@ -417,7 +417,7 @@ SYS_MacOSX_SetScheduler(int SchedPriority)
#ifdef FEAT_PRIVDROP
void SYS_MacOSX_DropRoot(uid_t uid, gid_t gid)
{
PRV_Initialise();
PRV_StartHelper();
if (setgroups(0, NULL))
LOG_FATAL(LOGF_SysMacOSX, "setgroups() failed : %s", strerror(errno));
@@ -457,9 +457,6 @@ SYS_MacOSX_Finalise(void)
SCH_RemoveTimeout(drift_removal_id);
clock_finalise();
#ifdef FEAT_PRIVDROP
PRV_Finalise();
#endif
}
/* ================================================== */