You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
947 B

diff --git a/radvd.c b/radvd.c
index 07a64a1..9f86cf6 100644
--- a/radvd.c
+++ b/radvd.c
@@ -346,6 +346,15 @@ int main(int argc, char *argv[])
flog(LOG_WARNING, "IPv6 forwarding seems to be disabled, but continuing anyway");
}
+ if (username) {
+ if (drop_root_privileges(username) < 0) {
+ perror("drop_root_privileges");
+ flog(LOG_ERR, "unable to drop root privileges");
+ exit(1);
+ }
+ dlog(LOG_DEBUG, 3, "running as user: %s", username);
+ }
+
int const pidfd = open_and_lock_pid_file(daemon_pid_file_ident);
/*
@@ -421,15 +430,6 @@ int main(int argc, char *argv[])
}
#endif
- if (username) {
- if (drop_root_privileges(username) < 0) {
- perror("drop_root_privileges");
- flog(LOG_ERR, "unable to drop root privileges");
- exit(1);
- }
- dlog(LOG_DEBUG, 3, "running as user: %s", username);
- }
-
setup_ifaces(sock, ifaces);
ifaces = main_loop(sock, ifaces, conf_path);
stop_adverts(sock, ifaces);