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.
I want the network mount to be executed only and made available
to a particular user. Meaning, when a particular user logs in, linux
will autoexecute a script file for that user to make the mount available.
2) Have a look at 'man mount' - the default settings are 'nouser' which only allows root to mount but you can change it to let an ordinary user mount.
1) What you could also do is define a private folder that can only be seen by the specified user and have it mounted normally in fstab. That way whenever you switch users without rebooting it will be instantly available. The only other person that could see it of course would be root.
The private folder could be a viable solution. Thanks for that, but I hope there is a way to autoexecute certain scripts on a per user basis.
I had a look at man mount but it only makes a known device mountable by ordinary users. In the case of SMB or Network files how do you allow ordinary users to use mount? I had to switch to root in order for me to mount a SMB share.
I'm not clear on what you're trying to achieve. Are you talking about users on the linux machine or remote users?
In my environment I use Samba server on my linux server as a PDC to allow remote Windows users access only to their own data. I can also use the Samba client on the linux machine to browse those shares and because it's using Samba they are restricted to whatever the Samba server rules allow them to see. However, because the Samba permissions sit on top of the linux permissions if you want to restrict access to certain directories as a linux user you have to do that as well as the samba stuff.
Sorry for the confusion. Allow me to clarify it though.
(1) So far, I was able to create a SymLink (using ln ) to a remote share. The symlink is stored in my linux box in Desktop to allow easy access.
(2) Now a problem I encountered in Symlink when that symlink is created in a Remote Share. To demonstrate:
# --- everything is done in a client linux box ---
mount -t smbfs -o username=mynetusername,password=mynetpassword \
,uid=unixuser,lfs,rw \
//netdomain/thisshare /mnt/smblocal
# --- assuming that foodir1 and foodir2 exists in a network share ---
cd /mnt/smblocal/foodir1
# ---- note that i am in a remote / network share now -----
ln -s /mnt/smblocal/foodir2 shortcut_foodir2
# ---- it does not work! ----
3) allow the mount command to be executed by ordinary user to mount an SMB share.
4) I have created a script to automate a mount. I want the script to run when a certain user logs in and possibly auto-matically free the resources when he/she logs out. I was hoping if there is some sort of an initrd on a per user basis. Much like having an Autoexec.bat on a per user basis (but of course, it does not automatically free the resources during log out).
(I may probably post this last problem on Fedora Forum.)
I think what you're trying to achieve is for different linux users on one machine to mount different remote windows folders dependant upon who they are.
I'm no expert but the usual linux way is for root to mount filesystems and restrict access to users using directory and file permissions. You can have user mountable drives - eg CD ROM drives have to be - but etc/fstab has to have the details with the 'user' flag.
I've tried out a few things to see what's possible and learn't a bit in the process - for instance I mounted a remote windows share manually months ago and it's still there despite the machine being turned off every night and no entry in fstab for it! Therefore if you do find a way of mounting as a user you will also have to find a way of umounting if you are relying on mounting alone to restrict visibility to remote folders.
I know it's not what you want to do but establishing a directory hierarchy on the linux machine (I have one located as /data/user1 /data/user2 etc) with permissions set so that only the specified user can even see their own data area allows you then to mount whatever you want either directly into the relevant users area or alternatively mount to a root only visible area with symbolic links to user data areas.
===quote===
I've tried out a few things to see what's possible and learn't a bit in the process - for instance I mounted a remote windows share manually months ago and it's still there despite the machine being turned off every night and no entry in fstab for it!
===quote ===
Can you please show how you were able to accomplish this?
Thanks in advance and I greatly appreciate your help.
Right here goes:
1)check mount - no smbfs share
2)check /etc/fstab - no entries for it
3)su
4)mount -t smbfs -o username=xxx,password=yyy //server/share /mountpoint
5)check mount again shows //server/share on /mountpoint type smbfs
6)reboot
....
now that's strange it's not there
....
Sorry what I said earlier about manual mounts persisting over a reboot is rubbish - I'd forgotten that although I don't mount that share explicitly I'd set up a backup script in /etc/cron.daily which mounts it and backs it up to the filserver. Obviously when I was replying to your post the machine had been on long enough for that script to run - I don't umount at the end of it - and therefore the mount was there.
Going back on your scripts for users if they are logging to a graphical front end this is runlevel 5 and when someone else logs out and logs in the system will switch (I think!) to runlevel 3 and then back to 5. Therefore you could write your own init script (read man init) using a template and make sure it runs as the last thing in runlevel 5 (when the user is known) and does some mounts there. Just a thought and I've not tried it and it's potentially dangerous - but then so is life!
I think I'll try it myself first as I'd like to find out if it works!
<edit>
I've had a look at the man pages and it looks possible but it's going to be very dependant on your distro as to where the scripts are and how you do it. SuSE for instance has a particular way of doing the symbolic links for starting processes and killing processes. It also has a skeleton init script. I'm NOT going to try this at the moment as I've only got my production linux server to hand and I haven't broken it in a long while!
Last edited by andrewdodsworth; 06-21-2004 at 03:26 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.