Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.