PDA

View Full Version : samba share setup on linux clients


jbkt23
17th January 2009, 11:30 PM
I have a samba server and a new linux client that the 5
members of the family will use. Prior to this the client was
a win2000 machine with the shares defined per user as mapped
drives. I would like to create a similar functionality on
the new linux setup.
What I want to achieve is to have these shares mapped when
they login so that when they open applications that store
data on the server the application finds the data.
The server has shares defined per user and per users who are
members of certain groups.
I use the gnome desktop on the client. In the nautilus
browser I can see the shares that are browseable and visit
them. I can mount the user shares by smb://server/sharename
and entering the password when asked. The user share mapping
established this way sometimes persists from session to
session, but I don't know if it will be dependable or
recognized by applications. I have been looking at the
gconf-editor to see if I could define the shares there but I
have not as of yet figured it out.

I would like to avoid setting up mount points in fstab. Is
there a tutorial on line to show how to setup what I want?

jbkt23
18th January 2009, 01:15 AM
Well doing my own testing I think I may have a work around if I can make it possible for the user to use the command
$ mount.cifs //server/sharename -o credentials=/pathtouserreadonlycredentialsfile

per man mount.cifs

The mount.cifs utility attaches the UNC name (exported network
resource) to the local directory mount-point. It is possible to set the
mode for mount.cifs to setuid root to allow non-root users to mount
shares to directories for which they have write permission.

So once I can figure this out I can add the mount command to the users .bash_profile and create the necessary mount points in their home directories.

So how do I make a user command setuid root?

jbkt23
18th January 2009, 01:33 AM
Found the this and I can now mount shares as user.

su -c 'chmod u+s /sbin/mount.cifs'
su -c 'chmod u+s /sbin/umount.cifs'

jbkt23
25th January 2009, 10:57 PM
I have cobbled some crude scripts together now, that mount samba shares when the user logs in, and then un-mount the shares and deletes the mount points on log out.

Here is the script to mount the shares. I will put a link to this with the name of the shares to mount in >System>Preferences>Personal>Sessions<.
################################################## ####
#!/bin/bash
# sharemount <sharename 1> <sharename 2>
# This script will test for bagend on the network and then mount shares or
# issue an error message

share="$@"

if ping -w 2 -c 1 bagend && smbclient -NL bagend; then
echo "bagend is present"
for share in "$@" ; do
mkdir ~/$share
mount.cifs //bagend/$share ~/$share -o credentials=~/.samba/.$USERNAME
done

else
echo "The server bagend could not be reached. Is it on?"
fi
################################################## #######

On the panel I have created an applet that runs the logout script that unmounts and deletes the mount points created with the first script.

################################################## ######
#!/bin/bash
# logout <share 1> <share 2>
# this program un-mounts network shares and then calls gnome-session-save
# with the --logout option

share="$@"

for share in "$@" ; do

if [ -d ~/$share ]; then
/sbin/umount.cifs /home/$USERNAME/$share
wait=1
rmdir /home/$USERNAME/$share
fi
done

/usr/bin/gnome-session-save --logout
################################################## #############

The scripts have worked for me without hangs.

Zotter
26th January 2009, 12:02 AM
Samba is used as a server for Windows Clients.

Though they can be shoe-horned into working, Linux's native sharing is done via NFS.

If you don't have any Windows clients - you'll likely save yourself some headache by switching servers. Or, if you do have windows clients - setup both. Samba for Windows, nfs for linux.

It's what I do and it saves what few hairs I have left.

jbkt23
26th January 2009, 01:00 AM
Samba isn't shoe horned here. It is a robust file server that is extremely well documented. I am running windows virtual guests on top of the linux host. I have been running a samba server for ten years and found it to be a flexible share access limiting setup.
I have set up NFS in the past and it worked, but the documentation I found was very limited.

Monumental Clock of Pachuca Travel Photos on Instagram - National Civil Rights Museum Instagram Photos - Honda (Tolima) Travel Photos on Instagram