Hi,

I've attached a diff that implements the usershare option with
suggestions discussed previously.

I've reworked the postinst script to create the sambashare group and the
directory. I've also updated man pages (smb.conf and net) to not
include the steps to setup usershares. I've replaced it with a mention of
the sambashare group.

I haven't address the issue of adding an new option in the configuration
file.

--
Mathias
Index: debian/samba-common.postinst
===================================================================
--- debian/samba-common.postinst	(revision 1541)
+++ debian/samba-common.postinst	(working copy)
@@ -102,3 +102,18 @@
 db_stop
 
 #DEBHELPER#
+
+case "$1" in
+	configure)
+		# add the sambashare group
+		if ! getent group sambashare > /dev/null 2>&1
+		then
+			addgroup --system sambashare
+		fi
+
+		if [ ! -e /var/lib/samba/usershares ]
+		then
+			install -d -m 1775 -g sambashare /var/lib/samba/usershares
+		fi
+		;;
+esac
Index: debian/patches/usershare_man.patch
===================================================================
--- debian/patches/usershare_man.patch	(revision 0)
+++ debian/patches/usershare_man.patch	(revision 0)
@@ -0,0 +1,61 @@
+Index: samba-3.0.26a/docs/manpages/smb.conf.5
+===================================================================
+--- samba-3.0.26a.orig/docs/manpages/smb.conf.5	2007-10-22 12:46:16.000000000 -0400
++++ samba-3.0.26a/docs/manpages/smb.conf.5	2007-10-22 12:46:40.000000000 -0400
+@@ -254,6 +254,9 @@
+ usershare path
+ .RS 3n
+ Points to the directory containing the user defined share definitions. The filesystem permissions on this directory control who can create user defined shares.
++.sp
++Default:
++\fB\fIusershare path\fR = /var/lib/samba/usershares \fR
+ .RE
+ .PP
+ usershare prefix allow list
+@@ -271,32 +274,7 @@
+ Names a pre-existing share used as a template for creating new usershares. All other share parameters not specified in the user defined share definition are copied from this named share.
+ .RE
+ .PP
+-To allow members of the UNIX group
+-foo
+-to create user defined shares, create the directory to contain the share definitions as follows:
+-.PP
+-Become root:
+-
+-.nf
+-
+-mkdir /usr/local/samba/lib/usershares
+-chgrp foo /usr/local/samba/lib/usershares
+-chmod 1770 /usr/local/samba/lib/usershares
+-
+-.fi
+-.PP
+-Then add the parameters
+-
+-.sp
+-
+-.nf
+-
+-	usershare path = /usr/local/samba/lib/usershares
+-	usershare max shares = 10 # (or the desired number of shares)
+-
+-.fi
+-to the global section of your
+-\fIsmb.conf\fR. Members of the group foo may then manipulate the user defined shares using the following commands.
++Members of the \fBsambashare\fR group can manipulate the user defined shares using the following commands:
+ .PP
+ net usershare add sharename path [comment] [acl] [guest_ok=[y|n]]
+ .RS 3n
+Index: samba-3.0.26a/docs/manpages/net.8
+===================================================================
+--- samba-3.0.26a.orig/docs/manpages/net.8	2007-10-22 12:47:59.000000000 -0400
++++ samba-3.0.26a/docs/manpages/net.8	2007-10-22 12:47:12.000000000 -0400
+@@ -677,7 +677,7 @@
+ .PP
+ Starting with version 3.0.23, a Samba server now supports the ability for non-root users to add user define shares to be exported using the "net usershare" commands.
+ .PP
+-To set this up, first set up your smb.conf by adding to the [global] section : usershare path = /usr/local/samba/lib/usershares Next create the directory /usr/local/samba/lib/usershares, change the owner to root and set the group owner to the UNIX group who should have the ability to create usershares, for example a group called "serverops". Set the permissions on /usr/local/samba/lib/usershares to 01770. (Owner and group all access, no access for others, plus the sticky bit, which means that a file in that directory can be renamed or deleted only by the owner of the file). Finally, tell smbd how many usershares you will allow by adding to the [global] section of smb.conf a line such as : usershare max shares = 100. To allow 100 usershare definitions. Now, members of the UNIX group "serverops" can create user defined shares on demand using the commands below.
++Members of the UNIX group \fBsambashare\fR can create user defined shares on demand using the commands below.
+ .PP
+ The usershare commands are:
+ .IP "" 3n
Index: debian/patches/series
===================================================================
--- debian/patches/series	(revision 1541)
+++ debian/patches/series	(working copy)
@@ -1,3 +1,4 @@
+usershare_man.patch
 cups.patch
 documentation.patch
 fhs-newpaths.patch
Index: debian/smb.conf
===================================================================
--- debian/smb.conf	(revision 1541)
+++ debian/smb.conf	(working copy)
@@ -214,6 +214,13 @@
 ;   winbind enum groups = yes
 ;   winbind enum users = yes
 
+
+# Setup usershare options to enable non-root user to share folders
+# with the net usershare command.
+
+# Maximum number of usershare. 0 (default) means that usershare is disabled.
+   usershare max shares = 100
+
 #======================= Share Definitions =======================
 
 [homes]

Reply via email to