Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Samba Question regarding Windows Shares
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
h0mer`-
Apprentice
Apprentice


Joined: 02 Aug 2004
Posts: 215

PostPosted: Thu Jul 26, 2007 9:20 am    Post subject: Samba Question regarding Windows Shares Reply with quote

I have a simple question.

When i want to access anothers workstation shares in a windowsnetwork i will just enter "\\name_of_workstation" via the Start/Run... command and the result is a new window with all the shares listed.

Is it possible to mount exactly that directory? And whats the exact path to it?
Back to top
View user's profile Send private message
rsa4046
l33t
l33t


Joined: 07 Feb 2005
Posts: 660
Location: The Big H, a bit SSW

PostPosted: Thu Jul 26, 2007 11:28 am    Post subject: Re: Samba Question regarding Windows Shares Reply with quote

h0mer`- wrote:
I have a simple question.

When i want to access anothers workstation shares in a windowsnetwork i will just enter "\\name_of_workstation" via the Start/Run... command and the result is a new window with all the shares listed.

Is it possible to mount exactly that directory? And whats the exact path to it?

Assuming the Windows PC is called NETBIOS_NAME with share = ShareName, you could try:
Code:
$ smbclient //NETBIOS_NAME/ShareName
To mount NETBIOS_NAME's share ShareName, you could use smbmount (you'd have to do this as root if the mount doesn't appear in /etc/fstab)
Code:
# mount -t cifs //NETBIOS_NAME/ShareName <MountPoint> -o username=<name>,password=<pass>
Back to top
View user's profile Send private message
h0mer`-
Apprentice
Apprentice


Joined: 02 Aug 2004
Posts: 215

PostPosted: Thu Jul 26, 2007 12:54 pm    Post subject: Reply with quote

Thanks for your reply but that is not what i was asking for.

I am familiar with the mounting of windows shares and the syntax of samba.

With the command "\\NETBIOS_NAME" typed into the Start/Run field, a new window opens with all the shares of the workstation i want access to. Its like the root directory of all the shares. What is the path of that directory? I mean there must be a way to mount this as it is accessible from every windows client.

NETBIOS_NAME
|
|--share1
|--share2
|--share2


I want to mount the directory from which i am able to see and access all the shares. Clear?
Back to top
View user's profile Send private message
Rob1n
l33t
l33t


Joined: 29 Nov 2003
Posts: 714
Location: Cambridge, UK

PostPosted: Thu Jul 26, 2007 1:02 pm    Post subject: Reply with quote

I'm pretty sure this isn't currently possible - what Windows shows isn't actually a real directory, it's just mapping the list of shares so they look that way (hence under XP you get a "Printers and Faxes" and a "Scheduled Tasks" folder, neither of which show when browsing from Win2k). You can see this list of shares by doing "smbclient -L //NETBIOS_NAME" but I'm not aware of any Linux file browser which maps these onto a directory tree as Windows does though.
Back to top
View user's profile Send private message
h0mer`-
Apprentice
Apprentice


Joined: 02 Aug 2004
Posts: 215

PostPosted: Thu Jul 26, 2007 1:36 pm    Post subject: Reply with quote

Hmm, well okay then.... this makes my plan a little more complicated. Thx
Back to top
View user's profile Send private message
zubb
n00b
n00b


Joined: 20 Jul 2007
Posts: 68
Location: Ukraine

PostPosted: Tue Aug 14, 2007 6:32 pm    Post subject: Reply with quote

I have the similar situation but I cant solve my problem

Here is the environment::
Share folders locates at server with FreeBSD.
One of the shares is accesible only with passwd
I want to mount all of them on demand as my current user (not root).

Here is a part of my fstab
Code:
//ADAM/vv       /home/vv/home        smbfs   credentials=/home/vv/.smbpasswd.home,user,noauto 0 0
//ADAM/exchange      /mnt/exchange        smbfs   credentials=/home/vv/.smbpasswd.exchange,user,noauto 0 0
/dev/sdb1       /mnt/usb                vfat    noauto,user


In the first case "smbpasswd" is filled with login & pwd, in the second it is without login & pwd

PS: I can mount the USB flash drive exactly in way I want. So guess it should work with smbfs
Back to top
View user's profile Send private message
tarpman
Veteran
Veteran


Joined: 04 Nov 2004
Posts: 1083
Location: Victoria, BC, Canada

PostPosted: Tue Aug 14, 2007 8:03 pm    Post subject: Re: Samba Question regarding Windows Shares Reply with quote

h0mer`- wrote:
I have a simple question.

When i want to access anothers workstation shares in a windowsnetwork i will just enter "\\name_of_workstation" via the Start/Run... command and the result is a new window with all the shares listed.

Is it possible to mount exactly that directory? And whats the exact path to it?

It is not an actual directory in the sense that you can browse it, although some Samba-aware file managers such as nautilus provide a similar feature. To list shares from the command line, check out smbtree(1).
_________________
Saving the world, one kilobyte at a time.
Back to top
View user's profile Send private message
tarpman
Veteran
Veteran


Joined: 04 Nov 2004
Posts: 1083
Location: Victoria, BC, Canada

PostPosted: Tue Aug 14, 2007 8:09 pm    Post subject: Reply with quote

zubb wrote:
Here is the environment::
Share folders locates at server with FreeBSD.
One of the shares is accesible only with passwd
I want to mount all of them on demand as my current user (not root).

Hi zubb,

First of all, smbfs has been deprecated, so you should consider switching to cifs - it's on the same page as smbfs in the kernel configuration.

I don't know if smbfs supports the user option - I couldn't find it in the man page for smbmount(8). I do know that cifs respects it, with the caveat that the mount point in question must belong to the user who wishes to mount it. You can find more details on that in the man page for mount.cifs(8).
_________________
Saving the world, one kilobyte at a time.
Back to top
View user's profile Send private message
the_isz
n00b
n00b


Joined: 24 Oct 2004
Posts: 32
Location: Siegen, Germany

PostPosted: Fri Aug 24, 2007 6:59 pm    Post subject: Reply with quote

Hi h0mer`- and everyone else!

I searched for the same as you did and couldn't find a satisfying solution either. So I started writing an own...

The following bash script I wrote gets the shares from a windows server, creates suitable folders for the shares and adds the shares to the /etc/fstab file.

Before executing the script, create a line in /etc/fstab starting with "#-----Samba Shares-----" (without the "). Everything following that line will be deleted by the script.

I don't take responsibility if this script harms your system! Use at your own risk.

Code:

#!/bin/bash

# IP of the windows machine
SERVER_IP=192.168.2.2
# TARGET_DIR is the directory you want to see the shares in and must not have a trailing "/" 
TARGET_DIR=/mnt/SAMBASRV

declare -a FOLDERS

# this command gets the shares from the server, extracts the share names and removes invalid shares (the ones
# with trailing $)
FOLDERS=( $(smbclient -g -N -L //$SERVER_IP 2>&1 | sed -e '/|/!d' -e 's/[^|]*|\([^\|]*\)|.*/\1/' -e '/\$$/d') )

# create TARGET_DIR if it doesnt exist
if [[ ! -d $TARGET_DIR ]]; then
        echo "target directory doesn't exist. trying to create..."
        mkdir -p $TARGET_DIR
        if [[ ! -d $TARGET_DIR ]]; then
                echo "could not create target directory. aborting."
                exit 1;
        fi
fi

# clean target directory
for folder in `ls $TARGET_DIR`
        do
        if [[ -d $folder ]]; then
                # check that $folder isn't currently mounted
                if [[ -z "`grep -i $TARGET_DIR/$folder`" ]]; then
                        rmdir $TARGET/$folder;
                else
                        echo "$TARGET_DIR/$folder is still mounted!"
                fi
        fi
done

# refill target directory
for folder in $(seq 0 $((${#FOLDERS[@]} -1 )))
        do
        if [[ ! -e $TARGET_DIR/${FOLDERS[$folder]} ]]; then
                mkdir $TARGET_DIR/${FOLDERS[$folder]}
        fi
done

# find special line in fstab marking the begin of the samba shares
FSTAB_LINE=`grep -nh "#-----Samba Shares-----" /etc/fstab | sed 's/\([0..9]*\):.*/\1/'`
if [[ -z $FSTAB_LINE ]]; then
        echo "special line in fstab not found! aborting operation."
        exit 1;
fi

(( FSTAB_LINE++ ))
# determine length of fstab file
FSTAB_MAX_LINE=`wc -l /etc/fstab | sed 's/\([0..9]*\) .*/\1/g'`

# delete all lines after FSTAB_LINE in /etc/fstab
if [[ $(( $FSTAB_MAX_LINE >= $FSTAB_LINE )) ]]; then
        sed -i "$FSTAB_LINE,$ d" /etc/fstab
fi

# add shares to fstab
# ToDo: convert spaces to \040
for folder in $(seq 0 $((${#FOLDERS[@]} -1 )))
        do
        echo "//$SERVER_IP/${FOLDERS[$folder]}  $TARGET_DIR/${FOLDERS[$folder]} cifs guest,noauto,users,noexec,iocharset=iso8859-1 0  0" >> /etc/fstab
done


One might want to setup a cron job that regularly executes this script.

Now the only problem that remains for me is that users can't mount cifs file systems if they don't own the mount points. This sucks...

Have fun with the script, I hope it helps someone.

Greetings,

Timo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum