Bug 111978 - [patch] [request] make syspath list for mount(8) configurable at runtime
Summary: [patch] [request] make syspath list for mount(8) configurable at runtime
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Eugene Grosbein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-21 07:00 UTC by Eugene Grosbein
Modified: 2017-09-19 18:05 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2007-04-21 07:00:10 UTC
	There are sysutils/fusefs-* ports that extend FreeBSD support
	for several filesystem types. These ports install utilities
	into /usr/local hierarchy but mount(8) only looks to compiled-in
	_PATH_SYSPATH (/sbin:/usr/sbin) path when it searches
	for mount_XXX commands. Let's allow system administrator
	to redefine this list using environment variable SYSPATH
	(the exact name is discussible), so that f.e. mount_ntfs-3g
	may be found by "mount -t ntfs_3g ..." command.

Fix: The patch is for src/sbin/mount:



Eugene Grosbein--UjCfhzsxZdvBaZqdA1NhlowXBViLhQV18epFAkxgKrNaPMkp
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- mount.c.orig	Sat Apr 21 12:53:32 2007
+++ mount.c	Sat Apr 21 12:58:36 2007
@@ -438,7 +438,7 @@
 	struct statfs sf;
 	pid_t pid;
 	int argc, i, status;
-	char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX];
+	char *optbuf, *syspath, execname[PATH_MAX], mntpath[PATH_MAX];
 
 #if __GNUC__
 	(void)&optbuf;
@@ -511,10 +511,12 @@
 			exit(mount_ufs(argc, (char * const *) argv));
 
 		/* Go find an executable. */
-		execvP(execname, _PATH_SYSPATH, (char * const *)argv);
+		if ((syspath = getenv("SYSPATH")) == NULL)
+			syspath = _PATH_SYSPATH;
+		execvP(execname, syspath, (char * const *)argv);
 		if (errno == ENOENT) {
 			warn("exec mount_%s not found in %s", vfstype,
-			    _PATH_SYSPATH);
+			    syspath);
 		}
 		exit(1);
 		/* NOTREACHED */
--- mount.8.orig	Sat Apr 21 13:19:58 2007
+++ mount.8	Sat Apr 21 13:28:33 2007
@@ -342,7 +342,7 @@
 .Nm
 to execute the equivalent of:
 .Bd -literal -offset indent
-/sbin/mount_unionfs -b /sys $HOME/sys
+mount_unionfs -b /sys $HOME/sys
 .Ed
 .Pp
 Additional options specific to file system types
@@ -351,7 +351,7 @@
 .Fl t
 option below)
 may be described in the manual pages for the associated
-.Pa /sbin/mount_ Ns Sy XXX
+.Pa mount_ Ns Sy XXX
 utilities.
 .It Fl p
 Print mount information in
@@ -401,12 +401,12 @@
 If the type is not one of the internally known types,
 .Nm
 will attempt to execute a program in
-.Pa /sbin/mount_ Ns Sy XXX
+.Pa mount_ Ns Sy XXX
 where
 .Sy XXX
 is replaced by the type name.
 For example, nfs file systems are mounted by the program
-.Pa /sbin/mount_nfs .
+.Pa mount_nfs .
 .Pp
 Most file systems will be dynamically loaded by the kernel
 if not already present, and if the kernel module is available.
@@ -451,6 +451,15 @@
 (See
 .Xr issetugid 2
 for more information.)
+.It Ev SYSPATH
+If the environment variable
+.Ev SYSPATH
+is set, it is used as colon-separated list of paths to search for
+.Pa mount_ Ns Sy XXX
+utilities (see
+.Fl t
+option description). If it is not set, default value /sbin:/usr/sbin
+is assumed.
 .El
 .Sh FILES
 .Bl -tag -width /etc/fstab -compact
How-To-Repeat: 	N/A
Comment 1 Eugene Grosbein 2007-10-14 15:42:05 UTC
Hi!

Here is the same patch for 7.0-PRERELEASE:

--- sbin/mount/mount.8.orig	2007-06-25 13:06:54.000000000 +0800
+++ sbin/mount/mount.8	2007-10-14 18:00:42.000000000 +0800
@@ -342,7 +342,7 @@
 .Nm
 to execute the equivalent of:
 .Bd -literal -offset indent
-/sbin/mount_unionfs -b /sys $HOME/sys
+mount_unionfs -b /sys $HOME/sys
 .Ed
 .Pp
 Additional options specific to file system types
@@ -351,7 +351,7 @@
 .Fl t
 option below)
 may be described in the manual pages for the associated
-.Pa /sbin/mount_ Ns Sy XXX
+.Pa mount_ Ns Sy XXX
 utilities.
 .It Fl p
 Print mount information in
@@ -426,12 +426,12 @@
 will not call
 .Xr nmount 2
 directly and will instead attempt to execute a program in
-.Pa /sbin/mount_ Ns Sy XXX
+.Pa mount_ Ns Sy XXX
 where
 .Sy XXX
 is replaced by the file system type name.
 For example, nfs file systems are mounted by the program
-.Pa /sbin/mount_nfs .
+.Pa mount_nfs .
 .Pp
 Most file systems will be dynamically loaded by the kernel
 if not already present, and if the kernel module is available.
@@ -476,6 +476,15 @@
 (See
 .Xr issetugid 2
 for more information.)
+.It Ev SYSPATH
+If the environment variable
+.Ev SYSPATH
+is set, it is used as colon-separated list of paths to search for
+.Pa mount_ Ns Sy XXX
+utilities (see
+.Fl t
+option description). If it is not set, default value /sbin:/usr/sbin
+is assumed.
 .El
 .Sh FILES
 .Bl -tag -width /etc/fstab -compact
--- sbin/mount/mount.c.orig	2007-06-25 13:06:54.000000000 +0800
+++ sbin/mount/mount.c	2007-10-14 18:09:27.000000000 +0800
@@ -152,6 +152,7 @@
 {
 	pid_t pid;
 	int status;
+	char *syspath;
 
 	switch (pid = fork()) {
 	case -1:				/* Error. */
@@ -159,10 +160,12 @@
 		exit (1);
 	case 0:					/* Child. */
 		/* Go find an executable. */
-		execvP(execname, _PATH_SYSPATH, argv);
+ 		if ((syspath = getenv("SYSPATH")) == NULL)
+ 			syspath = _PATH_SYSPATH;
+ 		execvP(execname, syspath, argv);
 		if (errno == ENOENT) {
 			warn("exec %s not found in %s", execname,
-			    _PATH_SYSPATH);
+ 			    syspath);
 		}
 		exit(1);
 	default:				/* Parent. */
Comment 2 Eugene Grosbein freebsd_committer 2017-09-19 18:05:27 UTC
My PR.