View | Details | Raw Unified | Return to bug 21268
Collapse All | Expand All

(-)libexec/tftpd/tftpd.c (-3 / +7 lines)
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)) {
(-)tftpd.8 (-2 / +10 lines)
Lines 44-49 Link Here
44
.Op Fl l
44
.Op Fl l
45
.Op Fl n
45
.Op Fl n
46
.Op Fl s Ar directory
46
.Op Fl s Ar directory
47
.Op Fl u Ar user
47
.Op Ar directory ...
48
.Op Ar directory ...
48
.Sh DESCRIPTION
49
.Sh DESCRIPTION
49
.Nm Tftpd
50
.Nm Tftpd
Lines 100-106 Link Here
100
.Nm
101
.Nm
101
as root.  However, if you chroot, then
102
as root.  However, if you chroot, then
102
.Nm
103
.Nm
103
will set its user id to nobody.
104
will set its user id to nobody or
105
.Fl u
106
argument.
104
.Pp
107
.Pp
105
The options are:
108
The options are:
106
.Bl -tag -width Ds
109
.Bl -tag -width Ds
Lines 119-125 Link Here
119
to chroot to
122
to chroot to
120
.Pa directory
123
.Pa directory
121
before accepting commands.  In addition, the user id is set to
124
before accepting commands.  In addition, the user id is set to
122
nobody.
125
nobody or argument of
126
.Fl u .
127
.It Fl u Ar user
128
User name instead of nobody if
129
.Fl s
130
used.
123
.Pp
131
.Pp
124
If you are not running
132
If you are not running
125
.Fl s ,
133
.Fl s ,

Return to bug 21268