diff options
author | Andrej Shadura <andrewsh@debian.org> | 2018-09-05 10:47:38 +0200 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2018-09-05 10:47:38 +0200 |
commit | e17168f0a7640e397042f6b47fc056deb1cc9602 (patch) | |
tree | fc9b64c4c3b28e7231239c34c48aaa24d2a1edd4 | |
parent | 7b7a89d37947b4cf893d0d3b23fcd4f3f10b96d9 (diff) |
New upstream version 1.3+hg20170412
-rw-r--r-- | 9mount.1 | 12 | ||||
-rw-r--r-- | 9mount.c | 41 |
2 files changed, 42 insertions, 11 deletions
@@ -1,4 +1,4 @@ -.TH "9mount" "1" "04 September 2007" "9mount" "User commands" +.TH "9mount" "1" "23 July 2008" "9mount" "User commands" .SH NAME 9mount, 9bind, 9umount \- mount/unmount 9p filesystems .SH SYNOPSIS @@ -55,16 +55,20 @@ SPEC determines which file tree to mount when attaching to file servers that export multiple trees .TP -c CACHE -turns on caching using CACHE mode. Currently only +turns on caching using CACHE mode. Supported modes are .I loose -cache mode is available, which is suitable for exclusive read-only mounts. +(suitable for exclusive read-only mounts), +.IR fscache , +and +.IR mmap . .TP -d DEBUG comma seperated list of channels for which to enable debug output. Possible channels include: err, devel, 9p, vfs, conv, mux, trans, alloc, fcall. .TP -m MSIZE -specifies the maximum length of a single 9p message in bytes. +specifies the maximum length of a single 9p message in bytes. Must be less +than or equal to 8192 for non-root users. .PP .B 9bind performs a bind mount, making the tree visible at directory OLD also visible @@ -7,6 +7,7 @@ #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#include <limits.h> #include <sys/types.h> #include <sys/stat.h> @@ -18,6 +19,10 @@ #define nelem(x) (sizeof(x)/sizeof(*(x))) +enum { + Maxmsize = 8192, +}; + struct {char *mnemonic; int mask;} debug_flags[] = { {"err", 0x001}, {"devel", 0x002}, @@ -92,6 +97,11 @@ parsedial(char *dial, char **network, char **netaddr, int *port) if ((cp=strtok(NULL, "!"))) { errx(1, "%s: junk trailing dial string", cp); } + if (strcmp(*network, "unix") == 0) { + if (access(*netaddr, R_OK | W_OK)) { + err(1, "%s", *netaddr); + } + } } int @@ -134,6 +144,8 @@ main(int argc, char **argv) msize = getarg('m', cp, &argv); *cp-- = '\0'; break; + default: + errx(1, "unrecognised argument '%c'", *cp); } } } else if (!dial) { @@ -163,7 +175,7 @@ main(int argc, char **argv) if (strcmp(dial, "-") == 0) { proto = "fd"; addr = "nodev"; - append(&opts, "rfdno=0,wrfdno=1", &optlen); + append(&opts, "rfdno=0,wfdno=1", &optlen); } else { parsedial(dial, &proto, &addr, &port); } @@ -182,8 +194,10 @@ main(int argc, char **argv) } if (cache) { - if (strcmp(cache, "loose") != 0) { - errx(1, "%s: unknown cache mode (expecting loose)", cache); + if (strcmp(cache, "loose") != 0 + && strcmp(cache, "fscache") != 0 + && strcmp(cache, "mmap") != 0) { + errx(1, "%s: unknown cache mode (expecting loose, fscache, or mmap)", cache); } snprintf(buf, sizeof(buf), "cache=%s", cache); append(&opts, buf, &optlen); @@ -206,10 +220,16 @@ main(int argc, char **argv) } if (msize) { - if (strspn(msize, "0123456789") < strlen(msize)) { - errx(1, "%s: msize must be an integer", msize); + unsigned long nmsize; + char *end = NULL; + nmsize = strtoul(msize, &end, 10); + if (*end || nmsize == 0 || nmsize > INT_MAX) { + errx(1, "%s: msize must be a positive integer", msize); + } + if (pw->pw_uid != 0 && nmsize > Maxmsize) { + nmsize = Maxmsize; } - snprintf(buf, sizeof(buf), "msize=%s", msize); + snprintf(buf, sizeof(buf), "msize=%lu", nmsize); append(&opts, buf, &optlen); } @@ -238,6 +258,9 @@ main(int argc, char **argv) if (!dev) { append(&opts, "nodev", &optlen); } + if (pw->pw_uid != 0) { + append(&opts, "nosuid", &optlen); + } if (uidgid) { snprintf(buf, sizeof(buf), "uid=%d,gid=%d", getuid(), getgid()); append(&opts, buf, &optlen); /* < 2.6.24 */ @@ -251,8 +274,12 @@ main(int argc, char **argv) if (strcmp(proto, "tcp") == 0) { struct addrinfo *ai; + struct addrinfo aihints; int r; - if ((r=getaddrinfo(addr, NULL, NULL, &ai))) { + memset(&aihints, 0, sizeof(aihints)); + aihints.ai_family = AF_INET; + aihints.ai_socktype = SOCK_STREAM; + if ((r=getaddrinfo(addr, NULL, &aihints, &ai))) { errx(1, "getaddrinfo: %s", gai_strerror(r)); } if ((r=getnameinfo(ai->ai_addr, ai->ai_addrlen, buf, |