mount: support DUIDs with -u

Tim van der Molen <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
mount -u does not allow file systems to be specified by DUID:

$ doas mount b987ffca8611b59f.a /mnt
$ doas mount -ur b987ffca8611b59f.a
mount: unknown special file or file system b987ffca8611b59f.a.

This diff fixes that. The isduid() check is not strictly necessary, but
perhaps skipping realpath() for DUIDs is a safe thing to do?

OK?

Index: mount.c
===================================================================
RCS file: /cvs/src/sbin/mount/mount.c,v
diff -p -u -r1.78 mount.c
--- mount.c	9 May 2024 08:35:40 -0000	1.78
+++ mount.c	24 Jun 2026 18:31:29 -0000
@@ -233,7 +233,7 @@ main(int argc, char * const argv[])
 		if (typelist != NULL)
 			usage();
 
-		if (realpath(*argv, mntpath) == NULL) 
+		if (isduid(*argv, 0) || realpath(*argv, mntpath) == NULL) 
 			strlcpy(mntpath, *argv, sizeof(mntpath));
 		if (hasopt(options, "update")) {
 			if ((mntbuf = getmntpt(mntpath)) == NULL)
@@ -630,6 +630,7 @@ getmntpt(const char *name)
 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
 	for (i = 0; i < mntsize; i++)
 		if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
+		    strcmp(mntbuf[i].f_mntfromspec, name) == 0 ||
 		    strcmp(mntbuf[i].f_mntonname, name) == 0)
 			return (&mntbuf[i]);
 	return (NULL);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.