|
Lines 121-129
Link Here
|
| 121 |
struct sockaddr_in sin; |
121 |
struct sockaddr_in sin; |
| 122 |
char *chroot_dir = NULL; |
122 |
char *chroot_dir = NULL; |
| 123 |
struct passwd *nobody; |
123 |
struct passwd *nobody; |
|
|
124 |
char *chuser = "nobody"; |
| 124 |
|
125 |
|
| 125 |
openlog("tftpd", LOG_PID | LOG_NDELAY, LOG_FTP); |
126 |
openlog("tftpd", LOG_PID | LOG_NDELAY, LOG_FTP); |
| 126 |
while ((ch = getopt(argc, argv, "lns:")) != -1) { |
127 |
while ((ch = getopt(argc, argv, "lns:u:")) != -1) { |
| 127 |
switch (ch) { |
128 |
switch (ch) { |
| 128 |
case 'l': |
129 |
case 'l': |
| 129 |
logging = 1; |
130 |
logging = 1; |
|
Lines 134-139
Link Here
|
| 134 |
case 's': |
135 |
case 's': |
| 135 |
chroot_dir = optarg; |
136 |
chroot_dir = optarg; |
| 136 |
break; |
137 |
break; |
|
|
138 |
case 'u': |
| 139 |
chuser = optarg; |
| 140 |
break; |
| 137 |
default: |
141 |
default: |
| 138 |
syslog(LOG_WARNING, "ignoring unknown option -%c", ch); |
142 |
syslog(LOG_WARNING, "ignoring unknown option -%c", ch); |
| 139 |
} |
143 |
} |
|
Lines 226-233
Link Here
|
| 226 |
*/ |
230 |
*/ |
| 227 |
if (chroot_dir) { |
231 |
if (chroot_dir) { |
| 228 |
/* Must get this before chroot because /etc might go away */ |
232 |
/* Must get this before chroot because /etc might go away */ |
| 229 |
if ((nobody = getpwnam("nobody")) == NULL) { |
233 |
if ((nobody = getpwnam(chuser)) == NULL) { |
| 230 |
syslog(LOG_ERR, "nobody: no such user"); |
234 |
syslog(LOG_ERR, "%s: no such user", chuser); |
| 231 |
exit(1); |
235 |
exit(1); |
| 232 |
} |
236 |
} |
| 233 |
if (chroot(chroot_dir)) { |
237 |
if (chroot(chroot_dir)) { |