{
#if defined(LINUX) && defined (FEAT_PRIVDROP)
SYS_Linux_DropRoot(uid, gid);
-#elif defined(NETBSD) && defined(FEAT_PRIVDROP)
+#elif (defined(NETBSD) || defined(FREEBSD)) && defined(FEAT_PRIVDROP)
SYS_NetBSD_DropRoot(uid, gid);
#elif defined(MACOSX) && defined(FEAT_PRIVDROP)
SYS_MacOSX_DropRoot(uid, gid);
=======================================================================
- Driver file for the NetBSD operating system.
+ Driver file for the NetBSD and FreeBSD operating system.
*/
#include "config.h"
UTI_DoubleToTimeval(-offset, &newadj);
- if (adjtime(&newadj, &oldadj) < 0)
+ if (PRV_AdjustTime(&newadj, &oldadj) < 0)
LOG_FATAL(LOGF_SysNetBSD, "adjtime() failed");
/* Add the old remaining adjustment if not zero */
UTI_TimevalToDouble(&oldadj, &offset);
if (offset != 0.0) {
UTI_AddDoubleToTimeval(&newadj, offset, &newadj);
- if (adjtime(&newadj, NULL) < 0)
+ if (PRV_AdjustTime(&newadj, NULL) < 0)
LOG_FATAL(LOGF_SysNetBSD, "adjtime() failed");
}
}
struct timeval remadj;
double adjustment_remaining;
- if (adjtime(NULL, &remadj) < 0)
+ if (PRV_AdjustTime(NULL, &remadj) < 0)
LOG_FATAL(LOGF_SysNetBSD, "adjtime() failed");
UTI_TimevalToDouble(&remadj, &adjustment_remaining);
void
SYS_NetBSD_DropRoot(uid_t uid, gid_t gid)
{
+#ifdef NETBSD
int fd;
+#endif
+ /* On NetBSD the helper is used only for socket binding, but on FreeBSD
+ it's used also for setting and adjusting the system clock */
PRV_StartHelper();
UTI_DropRoot(uid, gid);
+#ifdef NETBSD
/* Check if we have write access to /dev/clockctl */
fd = open("/dev/clockctl", O_WRONLY);
if (fd < 0)
LOG_FATAL(LOGF_SysNetBSD, "Can't write to /dev/clockctl");
close(fd);
+#endif
}
#endif