Bug 245704 - sysutils/fusefs-smbnetfs script to mount using /etc/fstab
Summary: sysutils/fusefs-smbnetfs script to mount using /etc/fstab
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-17 17:55 UTC by David Fullard
Modified: 2020-04-18 06:20 UTC (History)
5 users (show)

See Also:
mi: maintainer-feedback-


Attachments
mount script (261 bytes, application/x-shellscript)
2020-04-17 17:55 UTC, David Fullard
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Fullard 2020-04-17 17:55:04 UTC
Created attachment 213507 [details]
mount script

I've written a short mount script for fusefs-smbnetfs to allow it to be used from /etc/fstab.

I'd like (if possible) to get it added to the sysutils/fusefs-smbnetfs port to allow others to use.

I know in the traditional sense that smbnetfs is supposed to be run per-user, but this would allow all users and processes to be able to use SMB shares. It does require configuration for fstab to be place in /.smb with the smbnetfs.conf, smbnetfs.auth (not required) and a copy of smb.conf (not required as defaults will be used). I've put this config in /usr/local/etc/smbnetfs and created a symlink to /.smb. It's possible to use the `-o config=/path/to/smbnetfs.conf`, but smbnetfs throws a warning about not being able to find smb.conf as it will be looking for it in $USER/.smb. Maybe this is something smbnetfs can be patched to handle.

The attached script is placed into /usr/local/sbin/mount_smbnetfs.

The line to add to /etc/fstab to use the script would then be:

    smbnetfs        /smb            smbnetfs        rw,late,failok,allow_other,mountprog=/usr/local/sbin/mount_smbnetfs     0       0

This would then create /smb as a special mount, allowing all users to browse SMB shares, for example:

    cd /smb/user:pass@host/share

If the smbnetfs.auth file is present and configured, then browsing to /smb/host/share would work.
Comment 1 Mikhail Teterin freebsd_committer 2020-04-17 21:56:58 UTC
The current smbnetfs itself can be used in fstab with the following trick:

-oallow_other   /smb            fusefs  rw,allow_other,failok,uid=105,late,direct_io,mountprog=/usr/local/bin/smbnetfs

That is, instead of "smbnetfs", the first column can contain simply one of the command-line options...

Your approach makes the fstab-entry look better, but is it worth the trouble of implementing at all? And, if it is, the options-parsing code inside smbnetfs itself should, probably, be patched instead.

As for your particular implementation, it would seem that $OPTS ends up containing all of the options in one argument -- instead of there being multiple arguments...

Also, the last line should begin with exec.

I'd do something like this (not tested):

SMBNETFS=%%PREFIX%%/bin/smbnetfs

if [ $# -gt 1 -a -n "${1##-*}" ]
then
        shift # Skip the non-option argument, if there are more than one
fi

exec $SBNETFS "$@"
Comment 2 David Fullard 2020-04-18 00:01:15 UTC
(In reply to Mikhail Teterin from comment #1)
The 'trick' is kind of kludge and took me a long time to Google the solution, where I found it at https://lists.freebsd.org/pipermail/freebsd-fs/2018-February/025800.html.

I thought I would try to simplify it and save others from having to Google for a solution by asking for it to be included since it's not documented anywhere.