Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: mount: support DUIDs with -u
To:
Tim van der Molen <tim@kariliq.nl>
Cc:
tech@openbsd.org
Date:
Wed, 24 Jun 2026 13:38:10 -0600

Download raw body.

Thread
Looks good.

Tim van der Molen <tim@kariliq.nl> wrote:

> 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);
>