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.
#include "refclock.h"
#include "clientlog.h"
#include "nameserv.h"
+#include "privops.h"
#include "smooth.h"
#include "tempcomp.h"
#include "util.h"
NCR_Finalise();
NIO_Finalise();
CAM_Finalise();
+ PRV_Finalise();
KEY_Finalise();
RCL_Finalise();
SRC_Finalise();
SRC_Initialise();
RCL_Initialise();
KEY_Initialise();
+ PRV_Initialise();
/* Open privileged ports before dropping root */
CAM_Initialise(address_family);
} u;
} PrvResponse;
-static int helper_fd = -1;
+static int helper_fd;
static pid_t helper_pid;
static int
/* ======================================================================= */
+void
+PRV_Initialise(void)
+{
+ helper_fd = -1;
+}
+
+/* ======================================================================= */
+
/* DAEMON - setup socket(s) then fork to run the helper */
/* must be called before privileges are dropped */
void
-PRV_Initialise(void)
+PRV_StartHelper(void)
{
pid_t pid;
int fd, sock_pair[2];
#ifdef PRIVOPS_HELPER
void PRV_Initialise(void);
+void PRV_StartHelper(void);
void PRV_Finalise(void);
+#else
+#define PRV_Initialise()
+#define PRV_StartHelper()
+#define PRV_Finalise()
#endif
#endif
#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));
SCH_RemoveTimeout(drift_removal_id);
clock_finalise();
-#ifdef FEAT_PRIVDROP
- PRV_Finalise();
-#endif
}
/* ================================================== */