diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-06 17:15:57 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-06 17:15:57 +0000 |
commit | 1a93a15de3706849250d65e50e82d584574dc1e6 (patch) | |
tree | 5691f249c2e032f9633bca4984b22150d58e548a /sbin | |
parent | c129353176b72efbb567dc4e764cb6f6201aa477 (diff) |
Postpone pledge call until after the getopt switch and hoist the call to
readlabelfs over it. This avoids a pledge abort due to the fact that the
ioctl DIOCGDINFO may not be allowed on the given file: mount /dev/tty /tmp.
ok benno
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount/mount.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index ec70ae0e948..3a43dc4324b 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.70 2017/01/25 02:33:25 tb Exp $ */ +/* $OpenBSD: mount.c,v 1.71 2017/02/06 17:15:56 tb Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -109,9 +109,6 @@ main(int argc, char * const argv[]) int all, ch, forceall, i, mntsize, rval, new; char *options, mntpath[PATH_MAX]; - if (pledge("stdio rpath disklabel proc exec", NULL) == -1) - err(1, "pledge"); - all = forceall = 0; options = NULL; vfstype = "ffs"; @@ -168,6 +165,25 @@ main(int argc, char * const argv[]) argc -= optind; argv += optind; + if (typelist == NULL && argc == 2) { + /* + * If -t flag has not been specified, and spec contains either + * a ':' or a '@' then assume that an NFS filesystem is being + * specified ala Sun. If not, check the disklabel for a + * known filesystem type. + */ + if (strpbrk(argv[0], ":@") != NULL) + vfstype = "nfs"; + else { + char *labelfs = readlabelfs(argv[0], 0); + if (labelfs != NULL) + vfstype = labelfs; + } + } + + if (pledge("stdio rpath disklabel proc exec", NULL) == -1) + err(1, "pledge"); + #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) @@ -261,23 +277,7 @@ main(int argc, char * const argv[]) mntonname, options, fs->fs_mntops, skip); break; case 2: - /* - * If -t flag has not been specified, and spec contains either - * a ':' or a '@' then assume that an NFS filesystem is being - * specified ala Sun. If not, check the disklabel for a - * known filesystem type. - */ - if (typelist == NULL) { - if (strpbrk(argv[0], ":@") != NULL) - vfstype = "nfs"; - else { - char *labelfs = readlabelfs(argv[0], 0); - if (labelfs != NULL) - vfstype = labelfs; - } - } - rval = mountfs(vfstype, - argv[0], argv[1], options, NULL, 0); + rval = mountfs(vfstype, argv[0], argv[1], options, NULL, 0); break; default: usage(); |