blob: 56ab51e4d6c3080a17294f422f27b50ed831346f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
check for root after processing args so non-root can run --help
--- a/src/oftpd.c
+++ b/src/oftpd.c
@@ -56,12 +56,6 @@ int main(int argc, char *argv[])
exe_name = argv[0];
}
- /* verify we're running as root */
- if (geteuid() != 0) {
- fprintf(stderr, "%s: program needs root permission to run\n", exe_name);
- exit(1);
- }
-
/* default command-line arguments */
port = FTP_PORT;
user_ptr = NULL;
@@ -187,6 +181,12 @@ int main(int argc, char *argv[])
exit(1);
}
+ /* verify we're running as root */
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s: program needs root permission to run\n", exe_name);
+ exit(1);
+ }
+
/* become a daemon */
if (detach) {
daemonize();
|