summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-10-08 02:11:36 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-10-08 02:11:36 +0200
commit065c3557af8de1b20d94c2e86a4a29c5d33ccc67 (patch)
treec5795999a777120da7e35b05857a2d6d651d5ad4
parentc458216121d622858916387071cd9c13df31820a (diff)
ip/dhcpd, ip/tftpd: change default for tftp homedir to /
-rw-r--r--sys/man/8/dhcpd25
-rw-r--r--sys/src/cmd/ip/dhcpd/dhcpd.c14
-rw-r--r--sys/src/cmd/ip/tftpd.c15
3 files changed, 37 insertions, 17 deletions
diff --git a/sys/man/8/dhcpd b/sys/man/8/dhcpd
index 7c36c5385..9917772c3 100644
--- a/sys/man/8/dhcpd
+++ b/sys/man/8/dhcpd
@@ -5,8 +5,10 @@ dhcpd, dhcp6d, dhcpleases, rarpd, tftpd \- Internet booting
.PP
.B ip/dhcpd
.RB [ -dmnprsSZ ]
+.RB [ -h
+.IR homedir ]
.RB [ -f
-.IR ndb-file ]
+.IR ndbfile ]
.RB [ -M
.IR secs ]
.RB [ -x
@@ -23,7 +25,7 @@ dhcpd, dhcp6d, dhcpleases, rarpd, tftpd \- Internet booting
.B ip/dhcp6d
.RB [ -d ]
.RB [ -f
-.IR ndb-file ]
+.IR ndbfile ]
.RB [ -x
.IR netmtpt ]
.PP
@@ -177,6 +179,18 @@ The options are:
.B d
Print debugging to standard output.
.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
Specify a file other than
.B /lib/ndb/local
@@ -277,9 +291,12 @@ The default is
Change directory to
.IR homedir .
The default is
-.BR /lib/tftpd .
+.BR / .
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
supports only octet mode.
.TP
diff --git a/sys/src/cmd/ip/dhcpd/dhcpd.c b/sys/src/cmd/ip/dhcpd/dhcpd.c
index df7a0d2b8..f7a57c180 100644
--- a/sys/src/cmd/ip/dhcpd/dhcpd.c
+++ b/sys/src/cmd/ip/dhcpd/dhcpd.c
@@ -49,9 +49,8 @@ struct Req
uchar buf[2*1024]; /* message buffer */
};
-#define TFTP "/lib/tftpd"
-
char *blog = "ipboot";
+char *homedir = "/";
char *mysysname;
Ipifc *ipifcs;
int debug;
@@ -209,7 +208,7 @@ timestamp(char *tag)
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");
exits("usage");
}
@@ -239,6 +238,9 @@ main(int argc, char **argv)
case 'f':
ndbfile = EARGF(usage());
break;
+ case 'h':
+ homedir = EARGF(usage());
+ break;
case 'm':
mute = 1;
break;
@@ -305,8 +307,8 @@ main(int argc, char **argv)
exits(0);
}
- if (chdir(TFTP) < 0)
- warning("can't change directory to %s: %r", TFTP);
+ if (chdir(homedir) < 0)
+ warning("can't change to directory %s: %r", homedir);
fd = openlisten(net);
for(;;){
@@ -956,7 +958,7 @@ bootp(Req *rp)
}
/* 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);
return;
}
diff --git a/sys/src/cmd/ip/tftpd.c b/sys/src/cmd/ip/tftpd.c
index f17223dc3..1d3a9df85 100644
--- a/sys/src/cmd/ip/tftpd.c
+++ b/sys/src/cmd/ip/tftpd.c
@@ -90,9 +90,9 @@ void doserve(int);
char bigbuf[32768];
char raddr[64];
-char *dir = "/lib/tftpd";
char *dirsl;
int dirsllen;
+char *homedir = "/";
char flog[] = "ipboot";
char net[Maxpath];
@@ -127,7 +127,7 @@ main(int argc, char **argv)
dbg++;
break;
case 'h':
- dir = EARGF(usage());
+ homedir = EARGF(usage());
break;
case 'r':
restricted = 1;
@@ -142,9 +142,10 @@ main(int argc, char **argv)
usage();
}ARGEND
- snprint(buf, sizeof buf, "%s/", dir);
- dirsl = strdup(buf);
- dirsllen = strlen(dirsl);
+ dirsllen = strlen(homedir);
+ while(dirsllen > 0 && homedir[dirsllen-1] == '/')
+ dirsllen--;
+ dirsl = smprint("%.*s/", dirsllen, homedir);
fmtinstall('E', eipfmt);
fmtinstall('I', eipfmt);
@@ -154,8 +155,8 @@ main(int argc, char **argv)
* "cd /usr/$user", so call setuser before chdir.
*/
setuser();
- if(chdir(dir) < 0)
- sysfatal("can't get to directory %s: %r", dir);
+ if(chdir(homedir) < 0)
+ sysfatal("can't get to directory %s: %r", homedir);
if(!dbg)
switch(rfork(RFNOTEG|RFPROC|RFFDG)) {