Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199910051436.KAA70490@bekka.hipgraphics.com> X-Mailer: exmh version 2.0.2 2/24/98 To: cygwin AT sourceware DOT cygnus DOT com Subject: NFS like SAMBA setup for WinNT/cygwin mini-HOWTO Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_-17943097660" Date: Tue, 05 Oct 1999 10:36:24 -0400 From: Derek Ney Note-from-DJ: This may be spam --==_Exmh_-17943097660 Content-Type: text/plain; charset=us-ascii I come from a UNIX background and am used to having NFS mounts all over the place. I recently setup our NT system running cygwin so that it almost acts like our Unix system in regard to accessing network mounted disks. I am posting a description of how to do this, since it was not easy and perhaps others would like this setup. I do not profess to be an expert on any of this stuff. There may be much easier ways to do this, but I do not know of them. Your mileage may vary. 1. Goals I wanted to set things up so multiple user's could simultaneously use the same machine using telnet and console logins. Each user has a home directory which needed to be network mounted to the NT machine. I wanted to make sure that the ownership/permissions of the home directories was respected. I also had a number of shared network mounts (/usr/local) that were needed. The network disks are on Unix machines (IRIX and linux). I have Samba setup on the Unix machines. 2. Samba setup The first thing to do is make sure the samba setup is right on the serving machines. I recommend getting the latest samba version because there have been quite a few bug fixes lately. I happen to have my "shared" mounts on one machine and the home directories on other machines. I setup the shared mount machine with samba "security" set to "share". I setup the home machines with "security" set to "user". I understand there is a way to make one machine do both security modes, but have not tried that. It is important that the home directories have a "user" security setting or you will have ownership problems with files. Presumbaly you could have the shared mounts use "user" security mode as well if you wanted to. Here is a brief description of the two modes (as best as I understand it): user mode - on the NT machine, the user who mounts it (using "net use") is the only one who can access the share. In fact it seems that only the session that issued the "net use" command can access it (if you have two telnet sessions, you need to have a "net use" in each to access it). Files that get created on the share use the user's permissions and ownership. share mode - on the NT machine, the user who mounts it (using "net use") is used for all permission/ownership issues. However, any user can access the share. This is very bad for home directories if more than one user can be logged in. 3. NT machine setup I have set things up so that when a user logs in, scripts are run to mount all the necessary remote volumes. This works both for telnet and console logins. You must make sure your cygwin environment is in good shape before staring (you a mount entry for "/", you have the right environment setting in your registry for PATH, CYGWIN, and HOME, and /etc/passwd and telnet are setup). First put the attached file "nt-mount.sh" into /etc. Then create the files "/etc/profile" and "/etc/csh.login" and put this line in both of them (or simply insert it if you already have those files): /etc/nt-mount.sh $USER; cd . This causes login tcsh and bash (or sh) to run the script that mounts drives. The script nt-mount.sh uses a fstab like setup to control what is done by the mount script. Create a /etc/fstab for your config. Here is an example /etc/fstab: # format is: # sharepath mount-dir user # user is either a user name or "-share" # lines beginning with # are comments \\host1\derek /home/derek derek \\host2\lenny /home/lenny lenny \\shareserv\export\cygwin /usr/local -share \\shareserv\export\share /usr/local/share -share The first field is the network path that is used to connect to the samba server. The nt-mount.sh script will issue the command "net use \\xxx\yyy" where xxx is the hostname and yyy is the first element after the hostname to mount the share. It will then issue a cygwin "mount" command for the whole network path onto the mount-dir. The third field controls whether it is a shared mount or a private mount. If the username matches this field, the volume is mounted. If it is "-share", it is mounted for all users. Note that the private mounts require a password; the script prompts for this password (in non-echo mode). You then need to setup a script file for console login. Put the following script into "%SystemDrive%/winnt/system32/Repl/Import/Scripts/login.bat": @ECHO OFF SET PATH=%SystemDrive%\root\bin;%SystemDrive%\root\cygnus\CYGWIN~1\H-I586~1\bin ;%PATH% %SystemDrive%\root\bin\bash.exe /etc/nt-mount.sh %USERNAME% /home/%USERNAME% > %SystemDrive%\login.log Then, for each user, using the user manager program and the "profile" screen of the user properties, set the login script to be "login.bat". Then, each user needs to login and map as a network drive (it does not matter what drive letter) their home directory (and make sure it has "reconnect on login" set). 4. Testing If by some miracle NT has worked well for you well doing all this, things should now be working. When you login on the console, NT should mount your network drive as a drive letter first and then the nt-mount script will be run (you may see a MSDOS window popup briefly) and do the other mounts. When you telnet in, it should prompt you for a password to connect to you home directory and mount everything. Note that if you then start xterms from that telnet session you can avoid typing in your password everytime (assuming you are telnetting from an X windows host). --==_Exmh_-17943097660 Content-Type: application/x-sh ; name="nt-mount.sh" Content-Description: nt-mount.sh Content-Disposition: attachment; filename="nt-mount.sh" #!/bin/bash # automount like utility for logging on the NT machine # arg is: username # args are: network-path directory domount() { netpath="$1" dir="$2" if mount | grep -q $dir; then echo "$dir already mounted." return 0; else if mount "$netpath" "$dir"; then echo "$dir mounted." return 0; else echo "$netpath mount onto $dir failed." return 1; fi fi } # args are: username network-path type # type code is: username = private user dir, "-share" = shared dir netuse() { if net use "$2" >& /dev/null; then echo "$2 already available." return 0; fi if [ "$3" != "-share" ]; then echo "Connecting to user private directory $2..." echo -n "Enter network password: " stty -echo < /dev/tty read _passw < /dev/tty stty echo < /dev/tty echo if net use $2 $_passw /USER:$1; then _passw="xxxxxxxxxxxxx" unset _passw return 0; fi _passw="xxxxxxxxxxxxx" unset _passw else echo "Connecting to shared path $2..." if net use $2; then return 0; fi fi echo "Could not connect to share $2!" return 1; } # args are: username share netpath dir type dofstabmount() { user="$1" share="$2" netpath="$3" dir="$4" type="$5" if netuse $user $share $type; then if domount $netpath $dir; then return 0; fi fi return 1; } # args are: username fstab doautomount() { ( while true; do if read -r netpath dir type; then if [ "$netpath" = "#" ]; then continue; fi if [ -z "$netpath" ]; then continue; fi if [ -z "$dir" -o -z "$type" ]; then echo "Malformed fstab line: ${netpath} ${dir} ${type}" echo "format should be: sharepath mount-dir type" return 1; fi share=$(echo "$netpath" | awk -F '[\\\\]+' '{ printf "\\\\%s\\%s", $2, $3; }') if [ "$type" = "-share" ]; then dofstabmount "$1" "$share" "$netpath" "$dir" "$type" elif [ "$type" = "$1" ]; then dofstabmount "$1" "$share" "$netpath" "$dir" "$type" fi else break; fi done ) < $2 } doautomount $1 /etc/fstab --==_Exmh_-17943097660 Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com --==_Exmh_-17943097660--