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