9.2. Network-Based FilesystemsIn addition to working with physical filesystems, Mac OS X supports a set of network-based filesystem protocols. These are used when you mount a filesystem from a machine elsewhere on the network and, for the most part, make a remote filesystem appear as though it were local to your computer. The network filesystem protocols supported by Mac OS X are:
9.2.1. Mounting a Network FilesystemThe Finder's Go Connect to Server menu (-K), shown in Figure 9-1, gives you a simple interface for mounting remote disks locally. There are four ways to connect to a remote server. Figure 9-1. Connecting to a server with the Finder
Figure 9-2. The Network browser in the FinderWhen you connect to a network-based filesystem using Connect to Server, it shows up as a drive in the Finder and is mounted into the filesystem in the /Volumes directory. If you want to mount a network-based filesystem into a directory other than /Volumes, you'll need to use the mount command-line utility. The mount command has the following general syntax: mount -t filesystemtype url mountpoint The -t option lets you specify the type of filesystem you want to mount. The mountpoint must be a directory that already exists in the filesystem. For example, to mount a .Mac user's Public folder, issue the following commands: $ mkdir -r /Disks/iDisk $ mount -t webdav http://idisk.mac.com/runningosx-Public /Disks/iDisk The first command uses mkdir to create a directory and subdirectory in the filesystem that you can use for mounting a disk volume. The second command actually mounts the iDisk Public folder, which belongs to the .Mac member named runningosx, into the /Disks/iDisk directory. There are also specific mount command variants for each protocol. These are listed in Table 9-1.
9.2.2. Sharing a Network FilesystemOf course connecting to another machine's filesystem is only half of the equation. You also need a way to share out your Mac's disks to other users. Mac OS X's versatility makes it an excellent solution for cross-platform file sharing . Using System Preferences, you can enable several different protocols that clients can use to connect to your Mac. These protocols can be broken down into two main groups: those that are Internet-based and those intended for Local Area Networks (LANs). 9.2.2.1. Sharing to Internet usersThe two services provided with Mac OS X for Internet sharing are perhaps the most pervasive on the Web: FTP and HTTP. For HTTP, Apple has chosen the extremely popular Apache httpd daemon. Easily the most used web server on the Internet, Apache adds Mac OS X as yet another entry in its list of supported platforms. It's a reliable, proven Unix daemon whose complexity is belied by the simplicity of setting it up on your Mac. 9.2.2.2. Sharing to web usersWhen you enable Personal Web Sharing (System Preferences Sharing Services), the httpd web server daemon is started and starts serving pages from the following locations:
Apache's configuration file is located at /etc/httpd/httpd.conf. For the most part, this is a standard Apache configuration file, with just a few changes made to adapt it to Mac OS X. Any of the standard Apache configuration directives will work in this file. To access the locally installed documentation on how to configure Apache, browse to http://localhost/manual/ on your machine after turning on Personal Web Sharing. You can also find this documentation in the /Library/Documentation/Services/apache directory. For more information on configuring Apache, see Apache: The Definitive Guide, Third Edition, by Ben Laurie, et al. (O'Reilly), or the Apache Pocket Reference, by Andrew Ford (O'Reilly).
HTTP is the workhorse of the Web. For the most part, however, HTTP is intended to send data in a single directionout. A web browser requests a file, and the HTTP server sends it back. Even though WebDAV and HTML forms allow a user to push a file or information onto the server, the majority of HTTP transactions occur in one direction: server to client. This leaves administrators with a bit of a gap when it comes to putting data on the server. Long before HTTP came into the limelight, FTP was the primary way files were moved around Internet. Unfortunately, FTP was developed in a time when the Internet was still nascent and the worms, viruses, Trojan horses, and other baddies we see on the Net today were unheard of. Security was never a priority for FTP like it has been for its successors, sftp and rsync. Luckily, FTP is disabled by default on Mac OS X, and you may want to leave it that way. However, if you want to turn it on, you can in the Sharing preference panel. When you do, you can connect to your Mac with any FTP client, and you'll be able to access the contents of your entire system.
9.2.2.3. Sharing to local network usersThe Internet has ushered in a variety of tools for moving files around. Most of them also work on a local area network, but there are still other protocols that lend themselves particularly well to file sharing on a LAN. Mac OS X includes support for two of these protocols that are quite prevalent on today's networks. The Apple Filing Protocol (AFP) has been a part of Mac networking since the beginning. SMB (Server Message Blocks), implemented with the Samba package, has been the standard protocol for file sharing on Windows networks. This protocol support makes Mac OS X an excellent citizen on just about any kind of network environment you might come across. 9.2.2.4. Sharing to Mac clientsWhen you enable Personal File Sharing in the Sharing preference panel, Mac OS X starts the AppleFileServer process and sets up Bonjour so that other machines on the local network will be able to see that your machine will accept AFP requests. This makes your machine appear in the /Network folder in the Finder view of the other Macs on your local network and allows them to connect to your machine. The shares (locations in the filesystem that can be accessed by others) that your Mac exposes to other machines vary depending on how users log into your machine:
Mac OS X's Personal File Sharing feature works quite well on a network composed of all Mac clients. Sadly, such a network isn't nearly as common as some of us might hope. You're far more likely to find yourself on a network filled with Windows clients and servers. If you're behind enemy lines (or maybe just at the corporate office), Mac OS X's Windows Sharing will prove invaluable. 9.2.2.5. Sharing to Windows clientsWhen you enable the Windows Sharing checkbox in the Sharing preference panel, your Mac appears in the Network Neighborhood view of Windows Explorer, as shown in Figure 9-3. To connect to a Mac from a Windows machine, simply double-click the machine in Explorer and then enter the name and password of a user on the Mac. In the Network Neighborhood, you'll find that Windows machines organize themselves within domains or workgroups. Your Mac initially sets its SMB workgroup to be WORKGROUP, but this can be changed using the Directory Access (/Applications/Utilities) application. Open Directory Access and select the SMB/CIFS entry, and then click the Configure button. On this sheet, you can configure the SMB workgroup to be used, as well as the Windows Internet Name Service (WINS) server, as shown in Figure 9-4. Figure 9-3. Browsing a Mac share using Windows ExplorerFigure 9-4. Configuring SMB optionsBy default, when you enable Windows Sharing, only the Home folders of the users on the system will be shared and made available to other machines. You can easily modify this by editing the Samba configuration file located at /etc/smb.conf on your Mac. To edit the file, you'll need to use a command-line editor, such as nano, in conjunction with the sudo command to gain the necessary privileges: $ sudo nano -w /etc/smb.conf To share a folder on your Mac, you must create an entry for it in the /etc/smb.conf file. Example 9-1 shows the basic format for a Samba share's entry. In Example 9-1, the folder /Users/Shared has been shared out with read/write access. The browseable parameter controls whether the share appears in Windows Explorer. Even if the browseable property is set to no, users can still access the share using the UNC path to the share (e.g., \\RONIN\SHARED). Finally, the create mode defines what Unix permissions new files will have on the share when they are created.
Example 9-1. A sample smb.conf entry[shared] comment = Shared Directory path = /Users/Shared read only = no browseable = yes create mode = 755 For more information on configuring Samba, see either Using Samba, Second Edition, by Jay Ts, et al. (O'Reilly), or Samba Pocket Reference, Second Edition, by Jay Ts, et al. (O'Reilly). You can also find a wealth of information on Samba, including documentation and sample configuration files, at http://www.samba.org. |