LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2007, 05:08 AM   #1
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Mount CIFS as normal user


Hi,
I'm running SuSE 10.2 and want to access SMB-Shares local on the computer.
SuSE has not included SMBFS support, so I have to use CIFS, but only root is able to mount CIFS.
The problem is I need it for business, and the user of the pc should not know the root-password. Also doing the mounts myself every morning is not possible, and I don't want to do that.
I thought of sudo, but don't know how to configure that correctly.

Any suggestions?
 
Old 04-04-2007, 06:28 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
why wouldn't you just put this in /etc/fstab? or even better (if your network isn't as stable as you'd want maybe) use autofs to mount the location on access by the user and unmount on a timeout.
 
Old 04-04-2007, 06:42 AM   #3
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Original Poster
Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
I tried doing it automatically on boot (wrote the commands in /etc/init.d/boot.local, don't know if that's the correct one though), but on reboot, the network crashed on that pc, which worked again after removing those commands again.

I'm using sudo at the moment, and it works, but woulf prefer other solutions.
 
Old 04-04-2007, 07:13 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well there's two i've given you, so have a look at those options.
 
Old 04-05-2007, 06:28 AM   #5
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Original Poster
Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Quote:
why wouldn't you just put this in /etc/fstab?
The program needed for mounting CIFS filesystems is mount.cifs, which is located in /usr/sbin, at least under SuSE. This program claims to be only executable by root, which let me discard the possibility to let the user himself mount the shares.
So I tried writing all the stuff in fstab and let it mount automatically on boot, after initalising the network, but unfortunately, something afterwards broke network establishing, which worked again, after removing the lines regarding the mounts.
Today, I recognized that, there's still something breaking the network establishing on boot, and it's definitely not the mounts. I'm investigating, and probably will come back to the fstab solution when I've found the error.

What I'm totally unfamiliar with is autofs. Could you please be more precise on that, would be interesting though.
 
Old 04-05-2007, 07:30 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that's not correct. any user should be able to mount anythign defined in fstab, just add the "user" option.
 
Old 04-05-2007, 09:16 AM   #7
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Consider using the automount to mount the shares “on demand.” Here’s how I have it set up on my Fedora systems, with some comments added in red:
Code:
$ cat /etc/auto.master | grep -v ^#
/smb    /etc/auto.cifs  --timeout=0 # 0 means "no timeout," otherwise "seconds."
+auto.master

#This tells automount to mount the CIFS files under /smb

$ cat /etc/auto.cifs | grep -v ^#
key="$1"
credfile="/etc/auto.smb.$key"
mountopts="-fstype=cifs,file_mode=0775,dir_mode=0775,uid=$USER,gid=smb"
# Note: This gives everyone in the smb group access to $USER's mounted shares.
smbclientopts=""
SMBCLIENT=$(whereis -b smbclient | cut --delimiter=\  --fields=2)
if ! [ -x $SMBCLIENT ]
then
    echo No smbclient executable found. Have you installed samba? >2
    exit 1
fi
if [ -r "$credfile" ]
then
        mountopts=$mountopts",credentials=$credfile"
        smbclientopts="-A "$credfile
else
        smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key\
   | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /^Disk[^$]*$/  { if (first) { print opts; first=0 };
                  sub(/ /, "\\ ", $2);
                  if (length($2)==1) sub(/ ^/, "", $2);
                  print " \\\n\t /" tolower($2), "://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }
        '

#The awk program creates the automount commands to mount each file share (ignoring any default shares) as /smb/<key>/<share_name>
#where (because we wanted it to) each share name is converted to lower case.

$ cat /etc/auto.smb.tss-1 | grep -v ^#
cat: /etc/auto.smb.tss-1: Permission denied
$ sudo cat /etc/auto.smb.tss-1 | grep -v ^#
Password:
username=PTrenholme
password=******** # Redacted: By company policy, passwords cannot be displayed in public.
domain=TSS
The last two commands show how the connection credentials are protected, even though they are stored in /etc

To auotomount the shares, all a user needs to do is try to access the share. For example, this script mounts all of my shares on the tss-1 XP box connected to the “T.S.S.” access point when it becomes available:
Code:
$ cat Scripts/MountSmb
#! /bin/bash

# Wait for the access point to become available
running=$(nm-tool eth1 | grep -r “*T.S.S.”)
while [ -z “$running” ];do
    sleep 5
    running=$(nm-tool eth1 | grep -r “*T.S.S.”)
done

# Access the shares to get them mounted
ls /smb/tss-1/* > /dev/null

Last edited by PTrenholme; 04-05-2007 at 09:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help please: mount -t smbfs -a fails as normal user, as root, doesn't mount anything thevic Linux - Networking 11 04-09-2007 03:09 AM
Mounting CIFS as normal user abovett Linux - Networking 2 05-18-2006 04:58 PM
cannot mount as normal user dave`2005 Linux - Newbie 3 03-16-2006 07:36 PM
Mount CIFS partition as user: Invalid or missing username paco36 Linux - General 2 07-04-2005 12:31 AM
normal user can mount? vacilus Linux - Software 1 12-22-2004 11:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration