Skip to content

Commit b2edf7a

Browse files
author
eugene
committed
Fixed daemon user creation on BSD systems with useradd
1 parent 9ca69cf commit b2edf7a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/sys_util.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ const char * OsLogHandle::s_category = "main";
1515
auto Identity::createDaemonUser(const sys_string & name) -> Identity {
1616

1717
#if HAVE_USERADD
18-
sys_string command = S("useradd -r -d " WSDDN_DEFAULT_CHROOT_DIR " -s /bin/false '") + name + S("'");
18+
#ifdef __linux__
19+
sys_string command = S("useradd -r -d " WSDDN_DEFAULT_CHROOT_DIR " -s /bin/false '") + name + S("'");
20+
#else
21+
sys_string command = S("useradd -L daemon -g =uid -d " WSDDN_DEFAULT_CHROOT_DIR " -s /sbin/nologin '") + name + S("'");
22+
createMissingDirs(WSDDN_DEFAULT_CHROOT_DIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP, Identity::admin());
23+
#endif
1924
#elif HAVE_PW
2025
sys_string command = S("pw adduser '") + name + S("' -d " WSDDN_DEFAULT_CHROOT_DIR " -s /bin/false -c \"WS-Discovery Daemon User\"");
2126
#endif

0 commit comments

Comments
 (0)