ip/dhcpd, ip/tftpd: change default for tftp homedir to /
This commit is contained in:
parent
c458216121
commit
065c3557af
3 changed files with 37 additions and 17 deletions
|
@ -5,8 +5,10 @@ dhcpd, dhcp6d, dhcpleases, rarpd, tftpd \- Internet booting
|
||||||
.PP
|
.PP
|
||||||
.B ip/dhcpd
|
.B ip/dhcpd
|
||||||
.RB [ -dmnprsSZ ]
|
.RB [ -dmnprsSZ ]
|
||||||
|
.RB [ -h
|
||||||
|
.IR homedir ]
|
||||||
.RB [ -f
|
.RB [ -f
|
||||||
.IR ndb-file ]
|
.IR ndbfile ]
|
||||||
.RB [ -M
|
.RB [ -M
|
||||||
.IR secs ]
|
.IR secs ]
|
||||||
.RB [ -x
|
.RB [ -x
|
||||||
|
@ -23,7 +25,7 @@ dhcpd, dhcp6d, dhcpleases, rarpd, tftpd \- Internet booting
|
||||||
.B ip/dhcp6d
|
.B ip/dhcp6d
|
||||||
.RB [ -d ]
|
.RB [ -d ]
|
||||||
.RB [ -f
|
.RB [ -f
|
||||||
.IR ndb-file ]
|
.IR ndbfile ]
|
||||||
.RB [ -x
|
.RB [ -x
|
||||||
.IR netmtpt ]
|
.IR netmtpt ]
|
||||||
.PP
|
.PP
|
||||||
|
@ -177,6 +179,18 @@ The options are:
|
||||||
.B d
|
.B d
|
||||||
Print debugging to standard output.
|
Print debugging to standard output.
|
||||||
.TP
|
.TP
|
||||||
|
.B h
|
||||||
|
Change directory to
|
||||||
|
.IR homedir .
|
||||||
|
The default is
|
||||||
|
.BR / .
|
||||||
|
This should match the
|
||||||
|
.I homedir
|
||||||
|
setting of
|
||||||
|
.I tftpd
|
||||||
|
so that the existence check of non-rooted file names
|
||||||
|
is consistent.
|
||||||
|
.TP
|
||||||
.B f
|
.B f
|
||||||
Specify a file other than
|
Specify a file other than
|
||||||
.B /lib/ndb/local
|
.B /lib/ndb/local
|
||||||
|
@ -277,9 +291,12 @@ The default is
|
||||||
Change directory to
|
Change directory to
|
||||||
.IR homedir .
|
.IR homedir .
|
||||||
The default is
|
The default is
|
||||||
.BR /lib/tftpd .
|
.BR / .
|
||||||
All requests for files with non-rooted file names are served starting at this
|
All requests for files with non-rooted file names are served starting at this
|
||||||
directory.
|
directory. This needs to be consistent with the
|
||||||
|
.I homedir
|
||||||
|
setting of
|
||||||
|
.IR dhcpd .
|
||||||
.I Tftpd
|
.I Tftpd
|
||||||
supports only octet mode.
|
supports only octet mode.
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -49,9 +49,8 @@ struct Req
|
||||||
uchar buf[2*1024]; /* message buffer */
|
uchar buf[2*1024]; /* message buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TFTP "/lib/tftpd"
|
|
||||||
|
|
||||||
char *blog = "ipboot";
|
char *blog = "ipboot";
|
||||||
|
char *homedir = "/";
|
||||||
char *mysysname;
|
char *mysysname;
|
||||||
Ipifc *ipifcs;
|
Ipifc *ipifcs;
|
||||||
int debug;
|
int debug;
|
||||||
|
@ -209,7 +208,7 @@ timestamp(char *tag)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: dhcp [-dmnprsSZ] [-f directory] [-M minlease] "
|
fprint(2, "usage: dhcp [-dmnprsSZ] [-h homedir] [-f ndbfile] [-M minlease] "
|
||||||
"[-x netmtpt] [-Z staticlease] addr n [addr n] ...\n");
|
"[-x netmtpt] [-Z staticlease] addr n [addr n] ...\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
@ -239,6 +238,9 @@ main(int argc, char **argv)
|
||||||
case 'f':
|
case 'f':
|
||||||
ndbfile = EARGF(usage());
|
ndbfile = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
homedir = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
mute = 1;
|
mute = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -305,8 +307,8 @@ main(int argc, char **argv)
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir(TFTP) < 0)
|
if (chdir(homedir) < 0)
|
||||||
warning("can't change directory to %s: %r", TFTP);
|
warning("can't change to directory %s: %r", homedir);
|
||||||
fd = openlisten(net);
|
fd = openlisten(net);
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
|
@ -956,7 +958,7 @@ bootp(Req *rp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore if the file is unreadable */
|
/* ignore if the file is unreadable */
|
||||||
if((!rp->genrequest) && bp->file[0] && access(bp->file, 4) < 0){
|
if(!rp->genrequest && bp->file[0] && access(bp->file, 4) < 0){
|
||||||
warning("inaccessible bootfile1 %s", bp->file);
|
warning("inaccessible bootfile1 %s", bp->file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,9 +90,9 @@ void doserve(int);
|
||||||
char bigbuf[32768];
|
char bigbuf[32768];
|
||||||
char raddr[64];
|
char raddr[64];
|
||||||
|
|
||||||
char *dir = "/lib/tftpd";
|
|
||||||
char *dirsl;
|
char *dirsl;
|
||||||
int dirsllen;
|
int dirsllen;
|
||||||
|
char *homedir = "/";
|
||||||
char flog[] = "ipboot";
|
char flog[] = "ipboot";
|
||||||
char net[Maxpath];
|
char net[Maxpath];
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ main(int argc, char **argv)
|
||||||
dbg++;
|
dbg++;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
dir = EARGF(usage());
|
homedir = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
restricted = 1;
|
restricted = 1;
|
||||||
|
@ -142,9 +142,10 @@ main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "%s/", dir);
|
dirsllen = strlen(homedir);
|
||||||
dirsl = strdup(buf);
|
while(dirsllen > 0 && homedir[dirsllen-1] == '/')
|
||||||
dirsllen = strlen(dirsl);
|
dirsllen--;
|
||||||
|
dirsl = smprint("%.*s/", dirsllen, homedir);
|
||||||
|
|
||||||
fmtinstall('E', eipfmt);
|
fmtinstall('E', eipfmt);
|
||||||
fmtinstall('I', eipfmt);
|
fmtinstall('I', eipfmt);
|
||||||
|
@ -154,8 +155,8 @@ main(int argc, char **argv)
|
||||||
* "cd /usr/$user", so call setuser before chdir.
|
* "cd /usr/$user", so call setuser before chdir.
|
||||||
*/
|
*/
|
||||||
setuser();
|
setuser();
|
||||||
if(chdir(dir) < 0)
|
if(chdir(homedir) < 0)
|
||||||
sysfatal("can't get to directory %s: %r", dir);
|
sysfatal("can't get to directory %s: %r", homedir);
|
||||||
|
|
||||||
if(!dbg)
|
if(!dbg)
|
||||||
switch(rfork(RFNOTEG|RFPROC|RFFDG)) {
|
switch(rfork(RFNOTEG|RFPROC|RFFDG)) {
|
||||||
|
|
Loading…
Reference in a new issue