Bug 5598 - /sbin/mount.smb needs better permission flexibility
/sbin/mount.smb needs better permission flexibility
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: samba (Show other bugs)
6.0
All Linux
low Severity low
: ---
: ---
Assigned To: Trond Eivind Glomsrxd
:
: 6173 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-10-05 15:09 EDT by regs
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-11-11 16:07:10 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description regs 1999-10-05 15:09:39 EDT
Currently, you can only specify 'ro' or 'rw' in /etc/fstab
to set a mounted smb share's permissions (555 and 755
respectively).  There is no way to set it to 775, 777, 600,
or any other valid value.

Find below a diff and full script (that includes the bug
fix from bug #3239 for USER and PASSWORD order and the
$USER bug from bug #3290) that implements a 'perms' option
that allows said flexibility.

------ BEGIN DIFF ------
--- mount.smb.old       Tue Oct  5 13:44:54 1999
+++ /sbin/mount.smb     Tue Oct  5 14:00:54 1999
@@ -4,6 +4,24 @@
 #
 # Adapted from mount.smb by Greg Galperin, MAR99
<grg@ai.mit.edu>
 #
+# Adapted to take the perms option by Ari Gordon-
Schlosberg, OCT99
+#                                       <regs@nebcorp.com>
+#
+# Options:
+#              (Permissions, use only of the three)
+#              ro      -       read-only (perms 555)
+#              rw      -       read-write (perms 755)
+#              perms   -       in octal format, like 775
or 600
+#
+#              (Ownership, one or both or none)
+#              uid     -       user share should be
mounted as.
+#              gid     -       group share should be
mounted as.
+#
+# Sample /etc/fstab options (field 4) entries:
+#
+# uid=0,gid=99,ro              -       user root, group
nobody, perms 555
+# uid=foo,gid=users,perms=770  -       user foo, group
users, perms 770
+

 if [ $# != 4 -o "$3" != "-o" ]; then
        echo "unsupported commandline $0 $*"
@@ -14,21 +32,25 @@
 for arg in `echo $4 | tr ',' ' '`; do
         case "$arg" in
          "rw")
-             COMMAND="$COMMAND -f755 -d755"
+             PERMS=" -f755 -d755"
              ;;
          "ro")
-             COMMAND="$COMMAND -f555 -d555"
+             PERMS=" -f555 -d555"
+             ;;
+         perms=*)
+             PERMS=`echo $arg | cut -d '=' -f 2`
+             PERMS=" -f$PERMS -d$PERMS"
              ;;
           gid=*)
               MGID=`echo $arg | cut -d '=' -f 2`
-              COMMAND="$COMMAND -g$MGID"
+              MGID=" -g$MGID"
               ;;
           uid=*)
               MUID=`echo $arg | cut -d '=' -f 2`
-             COMMAND="$COMMAND -u$MUID"
+             MUID=" -u$MUID"
              ;;
          user=*)
-             USER="-U `echo $arg | cut -d '=' -f 2-`"
+             SMBUSER="-U `echo $arg | cut -d '=' -f 2-`"
              ;;
           passwd=*)
               PASSWD=`echo $arg | cut -d '=' -f 2-`
@@ -38,8 +60,10 @@
        esac
 done

+COMMAND="$COMMAND $PERMS $MUID $MGID"
+
 if [ -n "$PASSWD" ]; then
-      exec smbmount "$1" $USER $PASSWD -c "$COMMAND"
+      exec smbmount "$1" $PASSWD $SMBUSER -c "$COMMAND"
 else
-      exec smbmount "$1" -N $USER -c "$COMMAND"
+      exec smbmount "$1" -N $SMBUSER -c "$COMMAND"
 fi
------ END DIFF -----

------ BEGIN mount.smb ------
#!/bin/sh
#
# by Bill Nottingham <notting@redhat.com>
#
# Adapted from mount.smb by Greg Galperin, MAR99
<grg@ai.mit.edu>
#
# Adapted to take the perms option by Ari Gordon-
Schlosberg, OCT99
#                                        <regs@nebcorp.com>
#
# Options:
#               (Permissions, use only of the three)
#               ro      -       read-only (perms 555)
#               rw      -       read-write (perms 755)
#               perms   -       in octal format, like 775
or 600
#
#               (Ownership, one or both or none)
#               uid     -       user share should be
mounted as.
#               gid     -       group share should be
mounted as.
#
# Sample /etc/fstab options (field 4) entries:
#
# uid=0,gid=99,ro               -       user root, group
nobody, perms 555
# uid=foo,gid=users,perms=770   -       user foo, group
users, perms 770


if [ $# != 4 -o "$3" != "-o" ]; then
        echo "unsupported commandline $0 $*"
        exit -1
fi

COMMAND="mount $2"
for arg in `echo $4 | tr ',' ' '`; do
        case "$arg" in
          "rw")
              PERMS=" -f755 -d755"
              ;;
          "ro")
              PERMS=" -f555 -d555"
              ;;
          perms=*)
              PERMS=`echo $arg | cut -d '=' -f 2`
              PERMS=" -f$PERMS -d$PERMS"
              ;;
          gid=*)
              MGID=`echo $arg | cut -d '=' -f 2`
              MGID=" -g$MGID"
              ;;
          uid=*)
              MUID=`echo $arg | cut -d '=' -f 2`
              MUID=" -u$MUID"
              ;;
          user=*)
              SMBUSER="-U `echo $arg | cut -d '=' -f 2-`"
              ;;
          passwd=*)
              PASSWD=`echo $arg | cut -d '=' -f 2-`
              ;;
           *)
             ;;
        esac
done

COMMAND="$COMMAND $PERMS $MUID $MGID"

if [ -n "$PASSWD" ]; then
      exec smbmount "$1" $PASSWD $SMBUSER -c "$COMMAND"
else
      exec smbmount "$1" -N $SMBUSER -c "$COMMAND"
fi
------ END mount.smb ------
Comment 1 Bill Nottingham 1999-10-05 15:14:59 EDT
This won't work with the most recent samba releases
(2.0.5+), because smbmount no longer takes *any*
permission arguments.
Comment 2 regs 1999-10-05 15:36:59 EDT
From the samba.org cvs tree:

new smbmount and smbmnt code that is compatible with /bin/mount so you
can do:
	mount -t smb -o user=USER,passwd=PASSWORD //server/share /path

it also supports the following options:

        user=<arg>                      SMB username
        passwd=<arg>                    SMB password
        netbiosname=<arg>               source NetBIOS name
        uid=<arg>                       mount uid or username
        gid=<arg>                       mount gid or groupname
        port=<arg>                      remote SMB port number
        fmask=<arg>                     file umask
        dmask=<arg>                     directory umask
        debug=<arg>                     debug level
        ip=<arg>                        destination host or IP address
        workgroup=<arg>                 workgroup on destination
        sockopt=<arg>                   TCP socket options
        scope=<arg>                     NetBIOS scope
        guest                           don't prompt for a password
        ro                              mount read-only
        rw                              mount read-write

---- cut ----

Does 6.1 support this semantic and allow for setting umasks
in /etc/fstab?  If so, that's great.  My only issue is that I want to
be able to set the permissions on the mounted share in fstab... I
don't care if it's a mask or explicit permissions.
Comment 3 Bill Nottingham 1999-10-05 15:40:59 EDT
when is that as of?
Comment 4 regs 1999-10-05 15:51:59 EDT
Take a look at http://samba.org/cgi-
bin/cvsweb/samba/source/client/smbmnt.c?rev=1.6.2.3&content-
type=text/x-cvsweb-markup

Full revision history available at http://samba.org/cgi-
bin/cvsweb/samba/source/client/smbmnt.c
Comment 5 Bill Nottingham 1999-10-05 16:09:59 EDT
No, we're shipping base 2.0.5a + a couple of small patches.
We'll probably have this available in Raw Hide as soon
as 2.0.6 ships - we may upgrade it sooner, but I can't be
sure.
Comment 6 regs 1999-10-05 16:16:59 EDT
Sounds good to me.  However, are you saying that with the current
semantic (that I assume shipped with 6.1 (my 6.1 box is sitting at
home, not connected to the network for the first time in <I>months</I>
(it never fails, does it?))) there is no way to set permissions from
fstab?  If so, I would think that this would qualify for an errata
posting, there not even being a workaround with the stock packages.
Comment 7 Bill Nottingham 1999-10-21 13:44:59 EDT
*** Bug 6173 has been marked as a duplicate of this bug. ***

There appears to be an new version of the smbmount program
in this distribution which seems to not allow setting of
uid, gid, file mode, or dir mode.  To make matters worse,
the smbmount man page lists the options for the old version.
What gives?  Is smbmnt used at all now?  How to I send it
options?

Regards,

Dave Del Signore
Comment 8 Bill Nottingham 1999-11-11 16:04:59 EST
This should be fixed in samba-2.0.6-1, which will be in the
next Raw Hide release....

Note You need to log in before you can comment on or make changes to this bug.