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 06-18-2004, 01:47 AM   #1
nbjayme
Member
 
Registered: Sep 2003
Posts: 77

Rep: Reputation: 15
Question SMB SymLink




Hello folks,

I have successfully made a mount to an smb share in Linux.

In Windows, you can create a shortcut to a remote file/directory.

How do I create a symlink to a file or a directory on the smb share in my Linux box?

NBJayme
 
Old 06-18-2004, 03:01 AM   #2
nbjayme
Member
 
Registered: Sep 2003
Posts: 77

Original Poster
Rep: Reputation: 15
whooops!!!! sorry about that.

Probably I made a stupid typo on the command. Anyway it's working now.

The regular ln would work after you mounted it.

1) mount a network share

mount -t smbfs -o username=yournetname,password=yournetpassword \
,rw,lfs,user=youunixname \
//hostname/sharename /mnt/foodir

2) create a soft link to a network file or directory

ln -s /mnt/foodir/anydir/thisfile home/yourhome/Desktop/netfilelink


Which lead me to another questions:


(1) Is there a per user initrd kind of thing?

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) How can I run mount without being root?


NBJayme
 
Old 06-18-2004, 05:57 AM   #3
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
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.
 
Old 06-18-2004, 07:34 AM   #4
nbjayme
Member
 
Registered: Sep 2003
Posts: 77

Original Poster
Rep: Reputation: 15
hello,

thanks for the reply.

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.


NBJayme
 
Old 06-18-2004, 09:15 AM   #5
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
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.
 
Old 06-18-2004, 09:04 PM   #6
nbjayme
Member
 
Registered: Sep 2003
Posts: 77

Original Poster
Rep: Reputation: 15
hello andrewdodsworth,

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.)


NBJayme
 
Old 06-19-2004, 04:28 AM   #7
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
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.

Good luck
 
Old 06-20-2004, 11:25 PM   #8
nbjayme
Member
 
Registered: Sep 2003
Posts: 77

Original Poster
Rep: Reputation: 15
Hello again andrewdodsworth,

Sorry for my persistence.

===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.

NBJayme
 
Old 06-21-2004, 02:44 AM   #9
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
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.
 
  


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
smb mount folders disappear on mount & konqueror smb fails: network unreachable tisource Linux - Networking 1 10-17-2007 12:30 AM
SMB: More then one Windows user/ smb account? 1veedo Linux - Networking 2 03-15-2005 04:16 PM
smb+KDE= :-) smb+Gnome= :-( awing_pilot Linux - Software 3 03-10-2005 10:38 PM
Creating a SSL connection from smb clients to a smb server scottpioso General 0 11-17-2003 02:33 PM
making smb shares viewable from smb client via web browser scottpioso General 3 11-10-2003 04:25 PM

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

All times are GMT -5. The time now is 11:30 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