Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [298]

By Root 1505 0
time. The format of the credentials file is very simple:

username=USERNAME

password=PASSWORD

where you must replace USERNAME and PASSWORD with the username and password needed for authentication with the Windows workgroup server or domain. The uid and gid options specify the owner and group to apply to the files in the share, just as we did when mounting an MS-DOS partition in the previous section. The difference is that here we are allowed to use either the username and group name or the numeric user ID and group ID. The fmask and dmask options allow permission masks to be logically ANDed with whatever permissions are allowed by the system serving the share. For further explanation of these options and how to use them, see the smbmount(8) manual page.

One problem with smbmount is that when the attempt to mount a shared directory fails, it does not really tell you what went wrong. This is where smbclient comes in handy—as we saw earlier. See the manual page for smbclient(1) for further details.

Once you have succeeded in mounting a shared directory using smbmount, you may want to add an entry in your /etc/fstab file to have the share mounted automatically during system boot. It is a simple matter to reuse the arguments from the smbmount command shown earlier to create an /etc/fstab entry such as the following (all on one line):

//maya/d /maya-d smbfs

credentials=/etc/samba/pw,uid=jay,gid=jay,fmask=600,dmask=700 0 0

Well, that was a lot of information to digest. Let's continue onto the next section, where we will work with the cifsfs kernel driver that is replacing smbfs.

Using Linux-kernel-based cifsfs

The cifsfs filesystem drive is a relatively recent replacement for the smbfs driver. Unlike its predecessor, cifsfs has support for Unicode characters in file and directory names. This new driver is fully maintained by an active development team.

If you have made sure that your kernel has support for the cifsfs module, as described previously in this chapter, try mounting a remote file share with a command like this:

linux:~ # mount -t cifs -ouser=lct,password=2bblue4u,uid=lct,gid=users \

//emacho/shareddocs /mnt

linux:~ # ls -ald /mnt

drwxrwxrwx 1 lct users 0 May 19 12:04 /mnt

If you compare the mount options with those used with the smbfs driver in the previous section, you'll see that the username parameter has changed to just user. The other parameters can be kept identical.

There is one apparent difference in a directory listing:

linux:~ # ls -al /mnt/CanoScanCSUv571a/

total 3684

drwxrwxrwx 1 lct users 0 May 20 02:58 .

drwxrwxrwx 1 lct users 0 May 19 12:04 ..

-rwxrwSrwt 1 lct users 3398144 Mar 13 2003 CanoScanCSUv571a.exe

-rwxrwSrwt 1 lct users 77824 Apr 26 2002 Deldrv1205.exe

-rwxrwSrwt 1 lct users 13644 May 21 2002 N122U.cat

-rwxrwSrwt 1 lct users 15311 May 21 2002 N122UNT.cat

drwxrwxrwx 1 lct users 0 May 19 12:10 N122USG

-rwxrwSrwt 1 lct users 6151 Apr 16 2002 N122u.inf

-rwxrwSrwt 1 lct users 8944 Jun 12 1998 USBSCAN.SYS

-rwxrwSrwt 1 lct users 240117 May 20 02:58 messages

Note that the directory node size is now reported as zero. Apart from this minor feature, the use of cifsfs to mount an SMB/CIFS resource cannot really be noticed, except when files that have multibyte (Unicode) characters in them are encountered.

The command used to mount the CIFS/SMB filesystem (mount -t cifs) actually causes the execution of the mount.cifs binary file. This file is built from the Samba sources, as we saw earlier in this chapter. There are no command-line tools, as there are with the smbfs kernel drivers and the smbmount group of tools provided by the Samba package.

Some network administrators insist that a password should never be passed to a Unix command on the command line because it poses a security risk. The good news is that mount.cifs permits an alternative to command-line options for obtaining the username and password credentials: it reads the environment variables USER, PASSWD, and PASSWD_FILE. In the variable USER, you can put the username of the person to be used when authenticating

Return Main Page Previous Page Next Page

®Online Book Reader