[GRLUG] Question Related to Network Folders and Samba

Godwin geektoyz at gmail.com
Wed Sep 6 17:56:37 EDT 2006


Darn "word wrap" messed it up a bit...

G-



On 9/6/06, Godwin <geektoyz at gmail.com> wrote:
> Alright, I had a quick second...  This is quick and dirty w/o much
> checking for security (or exit unmount for that matter)...  Desktop
> Enviroments (KDE, XFCE, Gnome, etc.) generally allow you to run
> scripts at logon (and possibly logout).
>
> In Gnome, look at the "Sessions" properties and add this script per
> user account.  Put it somewhere accessible to each user and readonly
> by that user (oh, and edit it of course).
>
> ------------------------------------------------------------------------------------------
> #!/bin/bash
>
> # Quick and dirty...
> # "fusesmb" would likely be a much better option
> # http://www.ricardis.tudelft.nl/~vincent/fusesmb/
>
> # Disclaimer:
> # This is an insecure script to be used at home or in a secure
> # environment.  Don't come crying to me if you get hacked.
>
> # Have this script in the user's Autostart directory (may vary with
> Desktop Environment)
> # to automount a samba share on a local folder automatically - at login.
> # It's assumed that the usual home directories are being shared remotely.
>
> # Note: the utility to use is "smbmount", but it calls "smbmnt".
> # Both 'smbmount' and 'smbumount' must have the user sticky bit turned on.
> # chmod u+s /usr/bin/smbmnt /usr/bin/smbumount
> # the $USER variable is grabbed from the environment.
>
> # Godwin Pena - Grand Rapids User's Group
> # www.grlug.org   6-Sept-2006.
> # Free to use and modify...  ;-)
>
> # Local#!/bin/bash
>
> # Quick and dirty...
> # "fusesmb" would likely be a much better option
> # http://www.ricardis.tudelft.nl/~vincent/fusesmb/
>
> # Disclaimer:
> # This is an insecure script to be used at home or in a secure
> # environment.  Don't come crying to me if you get hacked.
>
> # Have this script in the user's Autostart directory (may vary with
> Desktop Environment)
> # to automount a samba share on a local folder automatically - at login.
> # It's assumed that the usual home directories are being shared remotely.
>
> # Note: the utility to use is "smbmount", but it calls "smbmnt".
> # Both 'smbmount' and 'smbumount' must have the user sticky bit turned on.
> # chmod u+s /usr/bin/smbmnt /usr/bin/smbumount
> # the $USER variable is grabbed from the environment.
>
> # Godwin Pena - Grand Rapids User's Group
> # www.grlug.org   6-Sept-2006.
> # Free to use and modify...  ;-)
>
> # Local username
> USER=`whoami`
>
> # Remote server
> SMBSRVR="remote.smb.server"
>
> # Remote userid to use for authentication.  Local permissions will be
> assigned based
> # on local userid.  So local user "me" will own files of remote userid "you".
> SMBUSER="remoteid"
> SMBPASS="remotepass"
>
> # Local folder where remote share is to be mounted (made accessible).
> LOCALDIR="/home/$USER/Desktop/$SMBSRVR"
>
> # If directory does not exist, create it (warning: no further checking
> is done - i.e. non-empty)
> if [ ! -d $LOCALDIR ]; then
>    mkdir -p $LOCALDIR
> fi
>
> /usr/bin/smbmount //$SMBSRVR/$SMBUSER $LOCALDIR -o
> username=$SMBUSER,password=$SMBPASS
>
> if [ $? = "0" ]; then
>    xmessage "Files on server $SMBSRVR have been mounted at $LOCALDIR."
> else
>    xmessage "Unable to mount files from $SMBSRVR."
> fi
>  username
> USER=`whoami`
>
> # Remote server
> SMBSRVR="remote.smb.server"
>
> # Remote userid to use for authentication.  Local permissions will be
> assigned based
> # on local userid.  So local user "me" will own files of remote userid "you".
> SMBUSER="remoteid"
> SMBPASS="remotepass"
>
> # Local folder where remote share is to be mounted (made accessible).
> LOCALDIR="/home/$USER/Desktop/$SMBSRVR"
>
> # If directory does not exist, create it (warning: no further checking
> is done - i.e. non-empty)
> if [ ! -d $LOCALDIR ]; then
>    mkdir -p $LOCALDIR
> fi
>
> /usr/bin/smbmount //$SMBSRVR/$SMBUSER $LOCALDIR \
>     -o username=$SMBUSER,password=$SMBPASS
>
> if [ $? = "0" ]; then
>    xmessage "Files on server $SMBSRVR have been mounted at $LOCALDIR."
> else
>    xmessage "Unable to mount files from $SMBSRVR."
> fi
>
> exit 0
> ------------------------------------------------------------------------------------------
>
> Homework:  Do some checking online for "logout script" to unmount the
> share automatically when logging out.  ;-)
>
> cheers,
> G-
>
> On 9/5/06, Justin Denick <justin.denick at gmail.com> wrote:
> >
> >
> >
> >
> > On 9/5/06, Benjamin Flanders <flanderb at gmail.com > wrote:
> > > Thank you Justin,
> > > Lets see if I have this straight.  This exports the /shared/home
> > > directory on the file server and overlays this on top of the home
> > > directory on the desktop, temporarily hiding the files already
> > > residing in the home dir on the desktop.
> >
> >
> >
> > yup
> >
> >
> > > Is it possible to export samba.server.name/home/user to
> > > /home/user/external? something like this in fstab where user is
> > > different depending on who logs in:
> > > samba.server.name:/home/user   /home/user/external   nfs   defaults   0 0
> >
> >
> >
> > I'm not sure that re-writting the fstab file each time a person logs in is
> > such a great idea.
> > Each user has a dedicated home dir that is specified in the /etc/passwd file
> > and that information is read when they log in.
> > So, if you want the home directory to be dependent on the username than this
> > is where the change need to occur.
> > One way would be to change the users default home directory to be
> >
> > /home/user/external where this is the mounted share and not the local file
> > system
> >
> >  You may even be able to accomplish this by linking, but using the useradd
> > utility would probably be better.
> >
> >
> >
> > > On 9/5/06, Justin Denick < justin.denick at gmail.com > wrote:
> > > > I'm not so sure I follow.
> > > > Setup is someting like:
> > > > -- 1Desktop PC running Ubuntu sometimes and Windows ate other
> > > > -- A file server that runs samba for the Windows user and the Unbuntu
> > user
> > > >
> > > > Why not handle the home directory with fstab on Ubuntu and drop the
> > Samba
> > > > Client.
> > > > Something like:
> > > >
> > > > samba.server.name:/shared/home   /home   nfs   defaults   0 0
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On 9/5/06, Benjamin Flanders < flanderb at gmail.com> wrote:
> > > > >
> > > > Background:
> > > > I have samba setup on my home network serving up a shared directory
> > > > and the home dir's on the file server of both my wife and I.  I can
> > > > access the shared dir and the respective home dir  of whoever is
> > > > logged into windows.  Works great.
> > > > The issue:
> > > > The desktop we use is a dual boot machine and when I use Ubuntu I can
> > > > only get to the shared directory and not my home dir.  Is it possible
> > > > to have Linux auto-mount the home directory on a file server of
> > > > whoever is logged into a separate workstation, like the samba setup I
> > > > mentioned above?
> > > > Some more details:
> > > > - In linux I have the samba deamon automatically mount the shared dir
> > via
> > > > fstab.
> > > > - If I remember correctly, the samba setup I have uses a file in
> > > > root's home dir on the desktop called something like .smbauth for the
> > > > samba username and password.  I believe this is where the issue lies,
> > > > it uses the same username and password for anyone who logs into the
> > > > desktop.
> > > >
> > > >
> > > > --
> > > > Share and Enjoy
> > > > _______________________________________________
> > > > grlug mailing list
> > > > grlug at grlug.org
> > > > http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > In vino veritas.
> > > >         [In wine there is truth.]
> > > >                 -- Pliny
> > > > _______________________________________________
> > > > grlug mailing list
> > > > grlug at grlug.org
> > > > http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> > > >
> > > >
> > >
> > >
> > > --
> > > Share and Enjoy
> > > _______________________________________________
> > > grlug mailing list
> > > grlug at grlug.org
> > > http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> > >
> >
> >
> >
> >
> >
> >
> > --
> >
> > In vino veritas.
> >         [In wine there is truth.]
> >                 -- Pliny
> > _______________________________________________
> > grlug mailing list
> > grlug at grlug.org
> > http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug
> >
> >
>
>
> --
>
> Ubber::Geek
> http://grlug.org/
>


-- 

Ubber::Geek
http://grlug.org/


More information about the grlug mailing list