summaryrefslogtreecommitdiff
path: root/sys/src/cmd/exportfs
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-02-10 23:31:26 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-02-10 23:31:26 +0100
commitd5305dc19943b98ce9e5a98110389d6800f56318 (patch)
treef66653e443621133146f75fe204f01fe8140eb55 /sys/src/cmd/exportfs
parent3a697585f05d68bda686b1c55d701a9e24693080 (diff)
exportfs: applying exportfs-chdir patch (from sources)
Fix the behavior of exportfs -r. Check the return of chdir(srv) to prevent exporting accidentally the current working directory when the directory specified with option -r doesn't exist. Also fix at the same time the missing trailing \n in error messages printed just before exits().
Diffstat (limited to 'sys/src/cmd/exportfs')
-rw-r--r--sys/src/cmd/exportfs/exportfs.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/src/cmd/exportfs/exportfs.c b/sys/src/cmd/exportfs/exportfs.c
index 75969f63e..ae9ad20d4 100644
--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -251,7 +251,12 @@ main(int argc, char **argv)
/* do nothing */
}
else if(srv) {
- chdir(srv);
+ if(chdir(srv) < 0) {
+ errstr(ebuf, sizeof ebuf);
+ fprint(0, "chdir(\"%s\"): %s\n", srv, ebuf);
+ DEBUG(DFD, "chdir(\"%s\"): %s\n", srv, ebuf);
+ exits(ebuf);
+ }
DEBUG(DFD, "invoked as server for %s", srv);
strncpy(buf, srv, sizeof buf);
}
@@ -261,15 +266,15 @@ main(int argc, char **argv)
n = read(0, buf, sizeof(buf)-1);
if(n < 0) {
errstr(buf, sizeof buf);
- fprint(0, "read(0): %s", buf);
- DEBUG(DFD, "read(0): %s", buf);
+ fprint(0, "read(0): %s\n", buf);
+ DEBUG(DFD, "read(0): %s\n", buf);
exits(buf);
}
buf[n] = 0;
if(chdir(buf) < 0) {
errstr(ebuf, sizeof ebuf);
- fprint(0, "chdir(%d:\"%s\"): %s", n, buf, ebuf);
- DEBUG(DFD, "chdir(%d:\"%s\"): %s", n, buf, ebuf);
+ fprint(0, "chdir(%d:\"%s\"): %s\n", n, buf, ebuf);
+ DEBUG(DFD, "chdir(%d:\"%s\"): %s\n", n, buf, ebuf);
exits(ebuf);
}
}