summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-04-21 11:56:10 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-04-21 11:56:10 +0000
commit6932159d346b49ea755b81675374652ac175ba9b (patch)
tree0a74928f58435564feaf9ece60103e2df73bde34 /sbin
parentb160131f8a73b7482c6ed0a1780d3bcf7921ee9e (diff)
Check both f_mntfromname and f_mntfromspec when looking for a mounted
filesystem. This makes umount via DUID possible. ok krw@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/umount/Makefile5
-rw-r--r--sbin/umount/umount.c16
2 files changed, 14 insertions, 7 deletions
diff --git a/sbin/umount/Makefile b/sbin/umount/Makefile
index eddfcb28bf1..8ab00fd7482 100644
--- a/sbin/umount/Makefile
+++ b/sbin/umount/Makefile
@@ -1,6 +1,9 @@
-# $OpenBSD: Makefile,v 1.3 1997/09/21 11:38:25 deraadt Exp $
+# $OpenBSD: Makefile,v 1.4 2013/04/21 11:56:09 jsing Exp $
PROG= umount
MAN= umount.8
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+
.include <bsd.prog.mk>
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c
index 1d58291e001..5ce0928639a 100644
--- a/sbin/umount/umount.c
+++ b/sbin/umount/umount.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umount.c,v 1.22 2012/05/29 18:44:40 landry Exp $ */
+/* $OpenBSD: umount.c,v 1.23 2013/04/21 11:56:09 jsing Exp $ */
/* $NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $ */
/*-
@@ -48,6 +48,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
typedef enum { MNTON, MNTFROM } mntwhat;
@@ -153,7 +154,7 @@ umountfs(char *oname)
char *delimp, *hostp, *mntpt;
char *name, *newname, rname[MAXPATHLEN], type[MFSNAMELEN];
- if (realpath(oname, rname) == NULL)
+ if (isduid(oname, 0) || realpath(oname, rname) == NULL)
mntpt = name = oname;
else
mntpt = name = rname;
@@ -211,7 +212,7 @@ umountfs(char *oname)
}
if (verbose)
- (void)printf("%s: unmount from %s\n", name, mntpt);
+ printf("%s: unmount from %s\n", name, mntpt);
if (unmount(mntpt, fflag) < 0) {
warn("%s", mntpt);
@@ -259,13 +260,16 @@ getmntname(char *name, mntwhat what, char *type)
return (NULL);
}
for (i = 0; i < mntsize; i++) {
- if ((what == MNTON) && !strcmp(mntbuf[i].f_mntfromname, name)) {
+ if ((what == MNTON) &&
+ (strncmp(mntbuf[i].f_mntfromname, name, MNAMELEN) == 0 ||
+ strncmp(mntbuf[i].f_mntfromspec, name, MNAMELEN) == 0)) {
if (type)
memcpy(type, mntbuf[i].f_fstypename,
sizeof(mntbuf[i].f_fstypename));
return (mntbuf[i].f_mntonname);
}
- if ((what == MNTFROM) && !strcmp(mntbuf[i].f_mntonname, name)) {
+ if ((what == MNTFROM) &&
+ (strncmp(mntbuf[i].f_mntonname, name, MNAMELEN) == 0)) {
if (type)
memcpy(type, mntbuf[i].f_fstypename,
sizeof(mntbuf[i].f_fstypename));
@@ -367,7 +371,7 @@ xdr_dir(XDR *xdrsp, char *dirp)
void
usage(void)
{
- (void)fprintf(stderr,
+ fprintf(stderr,
"usage: %s\n %s\n",
"umount [-fv] special | node",
"umount -a [-fv] [-h host] [-t type]");