summarylogtreecommitdiffstats
path: root/02-cwd-interactive.patch
blob: 328e5014f9a3566b7414aff246abb68ba2003c96 (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
31
32
33
34
35
36
37
38
39
40
--- ftpdconfig.c
+++ ftpdconfig.c
@@ -299,16 +299,6 @@
       break;
     case OPT_COMMENT:
       break;
-    case OPT_ROOT:
-      if (strlen(serverroot)>MAXPATHLEN) {
-	printf("serverroot option argument is too long.");
-	fclose(fp);
-	return -1;
-      }
-      strcpy(serverroot,arg);
-      if (serverroot[strlen(serverroot)-1]=='/')
-	serverroot[strlen(serverroot)-1]=0;
-      break;
     case OPT_PORT:
       serverport=atoi(arg);
       break;
@@ -334,6 +324,20 @@
       strtoupper(arg);
       if (!strcmp(arg,"DAEMON")) daemonmode=1;
       break;
+    case OPT_ROOT:
+      if (strlen(serverroot)>MAXPATHLEN) {
+	printf("serverroot option argument is too long.");
+	fclose(fp);
+	return -1;
+      }
+      if (daemonmode==1)
+	strcpy(serverroot,arg);
+      else
+	getcwd(serverroot, sizeof(serverroot));
+
+      if (serverroot[strlen(serverroot)-1]=='/')
+	serverroot[strlen(serverroot)-1]=0;
+      break;
     case OPT_LOG:
       if (arg==NULL || strlen(arg)==0) break;
       logfile=fopen(arg,"a");