Using PCLinuxOS 0.93a in a Windows Network
Back to
Advanced Topics
Go to
PCLinuxSamba if you are running PCLinuxOS 0.93 or below
THIS PAGE MOVED TO
http://docs.mypclinuxos.com/PCLinuxSamba093∞
Introduction
This wiki entry was written to help users of PCLinuxOS 0.93a share files with Windows computers. The Linux project that makes this possible is called Samba and so the software you must set up to share files is called a Samba server. The PCLinuxOS Control Center provides several graphical tools to configure your computer to share files on a Windows network. I've limited this page to discussing the configuration options that are available in the control center. These options should cover the needs of most home and small office users.
Background Information and Terminology
Microsoft's file sharing system protocol is often referred to as SMB/CIFS. SMB stands for Server Message Block and is the original core protocol of the system. Over the years, Microsoft added more features to SMB and in 1996 started calling their file sharing protocol "Common Internet File System" or CIFS. SMB/CIFS provided a way for applications to share data and a means of user authentication. SMB/CIFS runs on top of another protocol called NetBIOS. NetBIOS provides a way for the computers on a network to identify, browse and establish connections with each other. This is why the name of a computer on a Windows network is often referred to as its NetBIOS name. NetBIOS in turn, runs on top of a basic transport network protocol such as TCP/IP, IPX/SPX, or NetBEUI. Almost all computer networks now use TCP/IP. When setting up your Windows computers, it is best to bind only one of the transport protocols to your network interface, otherwise, you may have
problems browsing the network∞ according to the
Official Samba How To∞. Don't be discouraged by the length of the "Official Samba How To" as we will be using graphical dialog boxes to set everything up. In most cases, you will not need to read the Samba documentation at all. However, if you need help configuring your Windows computers, an
excellent guide∞ has been provided by the Samba project as part of their documentation.
I don't want to overwhelm users with technical details. However, there are some rather technical pieces of information that may be helpful to certain readers. These details wil be placed in boxes on the right side of the page, as you see to the right of this paragraph. Nothing in these boxes is required to get the Samba server configured and working under normal circumstances, so if you want to just skip them you may.
Accessing Shared Folders from PCLinuxOS
The Windows file sharing protocol is a client / server system. This means that some computers act as servers by making shared files available on the network, and there are programs that act as clients by requesting information from the servers. This means that if you only want to use PCLinuxOS to access files that have been shared from other computers, you do not need to set up the Samba Server software on your PCLinuxOS computer. You simply need to use one of the client programs listed below to access the shared folders.
- Smb4K - a nice graphical client for browsing a Windows network
- Konqueror - KDE's browser can act as a samba client. Just enter smb://hostname in the address bar, where "hostname" is the name of a computer on your network. Any shared files on that computer will appear in the browser window.
- You may configure a shared folder to automatically mount directly to your file tree so that it can be accessed as if it were part of your local file system. Describing how to do this is beyond the scope of this wiki page.
Installing Samba Server
Before you can begin to share files from your PCLinuxOS system, the Samba server software must be installed using Synaptic software manager. If you need help using Synaptic, see the
wiki page on Installing Software for screen shots and detailed instructions.
- Start Synaptic software manager
- Enter the root password in the "Query" dialog box and click the 'OK' button
- If a dialog box pops up asking if you want to reload the package information, it is best to click the 'Reload' button and allow Synaptic to download an updated package list.
- At the top of the "Synaptic" window, click on the 'Search' button.
- In the "Search" dialog box, type samba on the search line and then click the 'Search' button.
- In the search results, find the package called "samba-server". If the square next to it is green, it is already installed.
- If the square next to it is gray, follow the steps below to install the samba-server package.
- Right-click on the square and select the "Mark for Installation" option from the menu that pops up.
- Click the 'Apply' button at the top of the window.
- A "Summary" dialog box will appear. Click the 'Apply' button at the bottom of this dialog box.
- The package manager will now start to download and install the samba-server package
- When all operations have completed, close the Synaptic package manager.
Check Firewall and Host Name Settings
Configuring Other Firewalls
If you are using a firewall other than that provided in the PCLinuxOS Control Center, you must allow the following traffic into your computer from your local network.
- UDP packets on ports 137 and 138
- TCP packets on ports 139 and 445
Note: This applies only to the firewall running on the interface that connects your computer to the local network. You should
NOT open these ports on a firewall that stands between your network and the internet.
If you are running a firewall on the interface of your PCLinuxOS computer that connects to your local network, it must be told to allow incoming request through to the Samba server. The instructions below assume that you are using the firewall utility that is available in the PCLinuxOS Control Center.
You may skip this step if you are not running a firewall or if you are running the firewall on an interface that is used for internet traffic only and not your local network traffic. If you are using a different firewall program, see the box on the right.
- Start the PCLinuxOS Control Center.
- Enter the root password in the "Run as root" dialog box and click the 'OK' button.
- Click on the 'Security' button on the left side of the control center window.
- Click on the icon labeled "Set up a Personal Firewall to protect your computer and network".
- A list of services will be shown. You must click the box next to "Windows Files Sharing (Samba), so that there is an X in the box.
- Click the 'OK' button in the bottom left corner of the window to proceed to the next page.
- Here you are asked to identify the interface that you want to use the firewall on. This will most likely be an ethernet interface ( eth0 ) or your wireless network interface ( the naming of wireless interfaces varies). Once again, if you use a modem to connect to the internet, or have a separate ethernet card for your internet connection only, you should be running your firewall on that interface and do not need to do this step and should click the 'Cancel' button to exit.
- If you have selected the network interface for your local network, click the 'OK' button to save your firewall settings.
Now, you need to make sure that your computer has been given a host name. In a Windows network, all computers are identified by their name, which is known as a NetBIOS name. By default, Samba uses the host name of the computer as its NetBIOS name. To check your computers host name, complete the following steps.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Networking' button on the left side of the control center window.
- Click the icon labeled "Configure DNS settings for your Internet connection".
- If the line labeled "Host name (optional)" is blank, you must enter a name for your computer using alphabet characters only.
- Once the "Host name" line is filled in, click the 'OK' button in the lower right corner of the window.
- After changing the host name of the computer, you must reboot so that the environment variables and system configuration all use the new host name.
Initial Configuration of Samba Server
It's Not Magic, It's A Text File
The configuration settings you enter here, and the settings you enter when sharing folders, are all stored in a well commented text file at /etc/samba/smb.conf . Those who are curious can safely look at it with a text editor since it can only be changed by root. Running the command
testparm -s in a console window lets you see how Samba is interpreting the configuration file. To view the default settings in addition to the ones mentioned in the configuration file, run the command
testparm -sv in a console window. These commands are useful for advanced users who have manually edited the configuration file and want to check it for errors.
This step creates the configuration file for the Samba server after asking you to enter a few settings.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Sharing' button on the left side of the control center window.
- Click the icon labeled "Set up a cross-platform (Samba) file and print server".
- On the first page of the configuration wizard, select the radio button next to "Standalone" and then click the 'Next' button in the lower right corner of the window. (This wiki page does not cover how to use Samba in a domain environment as it does not apply to most home networks.)
- The next page asks for a Workgoup name. This is a name that identifies your Windows network. All computers on the network should use the same workgroup name. The default name on Windows computers is MSHOME. However, you can change it to any name you would like as long as it is set the same on all computers. The name should consist of only alphabetic characters in all capitals. After you have entered the workgroup name, click the 'Next' button in the lower right corner of the window.
- Now you are asked for a Banner. This is simply a descriptive phrase that is displayed alongside your computer name when your computer is displayed in the Network Neighborhood on Windows computers. The default is to display "Samba Server " and the version number of the server ( %v). You may find it useful to change this to something that describes your computer ( ie. Living room computer or Dad's Laptop ). This field cannot be left blank. When you have entered something, click the 'Next' button in the lower right corner of the window to continue.
- This page gives you options about how connections to the Samba server are logged. By default, a separate log file is created for each machine that connects, and the log files are kept at /var/log /samba/. I suggest you accept the defaults and continue by clicking the 'Next' button in the lower right corner of the window.
- This page displays a summary of the settings that will be written to the configuration file. You may go back to change something by clicking the 'Previous' button, or click the 'Next' button to write the configuration file.
- If all goes well, a page will be displayed that says that the wizard successfully configured your Samba server. Now you can click the 'Finish' button in the lower right corner of the window to close the wizard.
Now you need to tell the system to start the Samba server at boot.
- Start the PCLinuxOS Control Center.
- Enter the root password in the "Run as root" dialog box and click the 'OK' button.
- Click on the 'System' button on the left side of the control center window.
- Click on the icon labeled "Configure the system services". A window will open showing a list of services and whether they are running or stopped.
- In the first column, scroll down until you see the line for the service named "smb".
- In that line, click the check box labeled "On boot" so that it has an X in the box.
- In the same line, click the 'Start' button to start the Samba server. A small informational window will appear that says "Shutting down SMB services FAILED". This is normal because the control center attempts to stop the service before starting it, and since it was not running, stopping it failed. Below the FAILED message should be a line that says "Starting SMB services OK".
- Now click the 'OK' button in the lower left corner to close the Services window.
Congratulations, you now have Samba server running on your PCLinuxOS computer.
Sharing Folders with Guest Access
This section describes how to share a folder so that anyone can access the files in it, (the term folder refers to a directory containing files on your disk drive). There are three examples below that show how to share files in different circumstances.
- Sharing a folder in /var - this is the simplest example. It is followed by a good deal of explanation for new users.
- Sharing a folder in /home - this shows how to deal with folder permissions that keep resetting themselves.
- Sharing inside your personal folder - this shows how to share a folder inside your home folder without compromising security.
Sharing a Folder in /var
The /var directory is generally used to store system log files and other data that is generated or used by the operating system. However, some people choose to create a directory in /var to store archives or other data. Even if you don't intend to create a shared folder in /var, I encourage you to follow these instructions and read the explanation below so you better understand how Samba interacts with the file system permissions on your computer. This will help you have success creating shares in your /home directory later on.
First you must create the directory that you will share.
- In the start menu, go to Applications --> File tools --> File manger - Super User Mode
- Enter the root password in the "Run as root" dialog box and click the 'OK' button.
- Konqueror will open with Administrator privileges. Type /var in the "Location:" address bar and press enter.
- The folders in the /var directory will show on the right side of the window. Right-click in an empty area under the folders, and select Create New --> Folder... from the menu that pops up.
- A dialog box will appear where you can type the name of your new folder. Type shared_docs and then click the 'OK' button. ( You could use any name, but for this example I will use "shared_docs"
- The "shared_docs" folder will appear. Right-click on it and select "Properties" from the menu that pops up
- The Properties dialog box will open. Click on the Permissions tab
- In the drop-down box next to "Others:" select "Can View & Modify Content" and then click the 'OK' button at the bottom of the dialog box.
- Now close the Konqueror window by clicking the 'X' button at the very top right in the title bar. ( You don't want to use this instance of Konqueror for any other actions because it is running as root and does not provide the normal safeguards against changing system files.)
Now you will share your new folder on your Windows network.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Mount Points' button on the left side of the control center window.
- Click the icon labeled "Configure Samba". The "Samba Configuration" window will open.
- On the "File share" tab you will see one share called "homes" listed. We will cover it later, so you can ignore it for now.
- Click on the 'Add' button at the right of the window. A dialog box will open that asks for three pieces of information. None of the lines may be left blank.
- "Name of the share:" This is the name that you want remote users to see when they browse to the shared folder. It does not need to be the name of the folder, but should be composed only of characters that can be used in a file name on Windows machines. For this example, enter var_shared. If you have computers on your network running Windows ME or older, you should limit the length of the share name to 12 characters or less, otherwise your share will not be accessible on those computers.
- "Comment:" Enter a phrase that describes the folder you are sharing. For this example, I'll enter The first wiki example.
- "Path:" This must be the full path to the file folder that you are sharing. In this example the proper entry would be /var/shared_docs
- When you have filled out all three lines, clickthe 'OK' button at the bottom of the dialog box. Read the following two entries carefully to avoid a couple of unwanted behaviors in the user interface.
- If there is a problem with something you entered, you will get an error message and the dialog will close, requiring you to start over by clicking the 'Add' button again. However, if you misspell the path to the share and click 'OK' it appears that nothing happened and the dialog box stays open. What actually happens is that a folder is created with the name you entered and root as its owner. If you click 'OK' again the dialog box will close. To start over, you can highlight the share with the misspelled file name and then click the 'Remove' button. Then to get rid of the newly created folder, you will have to open Konqueror as super user and delete the folder that was accidentally created.
- If everything went well, you will see a dialog box that says "Congratulations". Don't click the 'OK' button in this box and don't try to close it with the 'X' ( close ) button in the title bar. Doing either of those things will crash the Samba configuration window and none of your changes will be saved. Just click on a visible area of the Samba Configuration window behind this dialog box. The problem dialog box will then be behind the main window, and you can just ignore it. This is a bug that I hope wil be gone in the next version of PCLinuxOS Control Center.
- Now, click on the line where your new share is listed so that it becomes highlighted and then click the 'Modify' button.
- The dialog box will open that allows you to change any settings except for the "Share name:". For now, we are only interested in the three drop-down boxes at the right of the dialog box.
- "Public:" This is where you allow guest access to the share. Set this box to "yes"
- "Writeable:" This lets you control whether remote users can modify files in this share. Set this box to "yes".
- "Browseable:" Set this box to "yes". If this is set to "no", the share will exist but will not show up in the list of available shared folders on this computer and only persons who know the name of the share will be able to access it.
- When done, click the 'Finish' button in the lower right corner of the dialog box.
- Now we are done, so click the 'OK' button in the lower left corner of the "Samba Configuration" dialog box. It is at this point that all of the changes you have made are written to the configuration file.
Congratulations, any user should now be able to browse to this folder from other computers on your network.
Understanding Samba Shares and File Permissions
The following five exercises demonstrate how file permissions affect whether others can access your shared files and what they are allowed to do. If you wish, try each exercise using the folder you just shared.
- Create a text folder as a local user on your PCLinuxOS computer and save it to /var/shared_docs. Browse to the file using Konqueror and right-click on it, select "Properties" and look at the permissions tab. "Other" should have read access only. Now try to access it from a different computer. You should be able to read it, but if you modify it and try to save it you will get "Permission denied"
- Now, using Konqueror, open the "Properties" dialog for the file you created and set the permissions for "Other" to "Forbidden". Try to read it from a remote computer now. You will not be able to open it.
- Next, using Konqueror, change the permissions on your file so that "Other" has "Read & Write" ability. Now from a different computer, you should be able to open the document, change it and resave it.
- From a different computer on your network, open the shared folder and try to save a new document. You should be able to. Now, on the PCLinuxOS computer, open the "Properties" dialog on the file you created from the other computer, click on the "Permissions" tab and look at the owner and group that the file belongs to. The owner is "nobody" and the group is "nogroup"
- Finally, open Konqueror as Super User ( it in the menu at Applications --> File tools --> File Manager - Super User Mode ), and change the permissions on the /var/shared_docs folder so that "Other" has only "Can View Content" permission. Now try to save a new file in the shared directory from a remote computer. You will get permission denied. Next, try opening the file that had "Other can Read & Write" permissions, modify it and then save it without changing the name of the file. You will be able to modify the file. When you are done with this, if you intend to use the /var/shared_docs folder, you may want to change the permissions on the folder back so that "Others can View & Modify".
What Really Happens When Users Connect to Shared Files
Below is brief outline of what samba does when someone on the network requests access to a shared folder. The process listening for the request is called smbd. When a request comes in, Samba examines any user name and password information provided in the request. If the password matches that of a user that Samba knows about (we'll cover this later), then smbd spawns another smbd process that is owned by that user. Otherwise, a check is made so see if the requested share allows guest access, if so, smbd spawns another smbd process with the User ID of "nobody". If no match is found and no guest access is allowed, a permission denied error is sent back over the network.
Once a remote user has been authenticated for access to a shared folder, all the actions he requests are sent to the smbd process that is running with his user ID, as explained above. So if I, as a guest, request to read a file in a shared folder, the request is sent to the smbd process created for me. smbd, which is running as user "nobody", then tries to read the file. This is where the Linux file permissions take effect. The Linux kernel sees the process trying to access a file, and checks whether the file's permissions allow a process running with a User ID of "nobody" to read the file. If it does not, the smbd process is told that access to the share is denied. The smbd process then sends a permission denied error back to the remote user that requested the file. However, if the permissions are such that user "nobody" can read the file, then the smbd process reads the file and transmits the contents to the remote user.
Since the most common problem new Samba users have is unexpected "Access Denied" errors, it is important that you understand why the five exercises above work the way they do before continuing to the next example. When having this problem, many user reason that they have shared the folder, they configured the share to allow "Public" access, so samba should just allow anyone to get to the files in the folder. They think file permissions shouldn't matter. But they do.
Windows provides a file sharing mode where folders are shared without concern for which user is trying to access them, although there is an option to require a password for access to any particular folder. This is called "Share" level security. However, Linux requires everyone who accesses the file system to have a valid User ID and Group ID that can be checked against the permissions on the files. If the user requesting files from the shared folder is known to Samba on your PCLinuxOS computer system, he is allowed on the system with his own user name. However, when guest access is allowed, a User and Group ID must be assigned to unknown users. On our Linux system, guest users are given the User ID of "nobody" and the Group ID of "nogroup" This explains why in the fourth exercise above, we saw that when our remote user created a new file in the shared folder it was owned by "nobody".
The permissions on regular files are easy to understand. In the exercises above, we were accessing all files as user "nobody". We did not have ownership and we weren't in the group that owned the files. So the permissions for others were the ones that affected our access. In the first example "Others" only had read access to the file, so we couldn't write to that file. In the second example, we made it so "Others" had no permissions for that file, and we couldn't even read it. In the third example, we gave "Others" both read and write access to the file, and thus we were able to read the file and alter it from the remote computer.
What Directory Permissions Mean
On regular files, read permission means you can view the contents of the file, write permission means you can modify the contents of the file, and execute means that you can have the operating system run commands in the file. Directories also have read, write and execute permission, but the meaning of these permissions is somewhat different.
- Execute only- Having only execute permission means that you can enter the directory and act on files in the directory by reading, modifying or executing them as their permissions allow. However, you will not be able to list the contents of the directory, nor can you create or delete files in the directory.
- Read and Execute - Adding read permissions allows you to list the files in a directory and see their attributes.
- Write and Execute - Adding write permission allows you to create and delete files in the directory.
A directory will never have read or write permissions without having execute permission. Read by itself only lets you see the names of the files in the directory, but not their attributes, and you will not be able to do anything with the files. Write by itself does nothing at all.
The fifth example demonstrates that the permissions on the shared folder affects the ability of remote users to access the files. In order to browse to a file, a user must have "execute" permissions on every directory in the path to the file. (To see the actual read, write, and execute permissions in Konqueror, you must click on the 'Advanced' button on the "Permissions" tab of the file properties dialog box.) So if I shared a file at /home/hankcurt/music/shared_music/file.mp3, in order for a guest to read the file.mp3, "Others" need to have execute permission on /home, /home/hankcurt, /home/hankcurt/music, and /home/hankcurt/music/shared_music. If the execute permission is not set on any of those directories, I would get a permission denied error when I tried to enter the shared_music folder. Finally, as was demonstrated above in the fifth exercise, if we take the "write" permission off of the shared folder, a remote user can still alter a file that already exists in that folder, provided they have write permission on the file itself. However, they are not allowed to create new files or delete existing files. ( See the box at the right for a further explanation of how directory permissions work.)
Sharing a folder in /home with Guest Access
Often there is data on your computer that you want all local and network users to be able to access. For instance, I have a large number of music files that I want everyone to be able to play. It would be logical to create a shared folder called shared_music in the /home directory, change the permissions so everyone has access, and then use Samba to share it on my local network. If I set this up, it will work fine for a few minutes, and then suddenly everyone starts getting "Access Denied" errors. When I check out the file permissions on /home/shared_music, I find that "Others" no longer have any permissions set. What happened?
The answer is that a security monitoring program called msec is doing its job. This program checks the permissions on certain files once an hour, and resets them if they have changed. By default, everything in the /home directory is reset so that "Owner" has all permissions, "Group" has read and execute permission, and "Others" have no permissions. We could disable msec, but that is not a good option because it does perform other functions that enhance the security of the operating system. Fortunately, there is a program called drakperm that we can use to tell msec that we want permissions set a certain way on specific directories. To see how this works, follow the steps below for setting up the /home/shared_music folder.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Mount Points' button on the left side of the control center window.
- Click the icon labeled "Configure Samba". The "Samba Configuration" window will open.
- The "File share" tab should be visible. If it is not, click on the "File share" tab so that it is visible
- Click on the 'Add' button at the right of the window. A dialog box will open that asks for the following three pieces of information. None of the lines may be left blank.
- "Name of the share:" This is the name that you want remote users to see when they browse to the shared folder. It does not need to be the name of the folder, but should be composed only of characters that can be used in a file name on Windows machines. For this example, enter Music_box
- "Comment:" Enter a phrase that describes the folder you are sharing. For this example, I'll enter Music shared for all users.
- "Path:" This must be the full path to the file folder that you are sharing. In this example the proper entry would be /home/shared_music
- When you have filled out all three lines, click the 'OK' button at the bottom of the dialog box to continue. If the file /home/shared_music didn't exist, it will be created when you click 'OK', and you will have to click the 'OK' button again to continue.
- If everything went well, you will see a dialog box that says "Congratulations". Don't click the 'OK' button in this box and don't try to close it with the 'X' ( close ) button in the title bar. Doing either of those things will crash the Samba configuration window and none of your changes will be saved. Just click on a visible area of the Samba Configuration window behind this dialog box. The problem dialog box will then be behind the main window, and you can just ignore it.
- Now, click on the line where your new share is listed so that it becomes highlighted and then click the 'Modify' button.
- The dialog box will open that allows you to change any settings except for the "Share name:". For now, we are only interested in the three drop-down boxes at the right of the dialog box.
- "Public:" This is where you allow guest access to the share. Set this box to "yes"
- "Writeable:" This lets you control whether remote users can modify files in this share. Set this box to "yes".
- "Browseable:" Set this box to "yes" If this is set to "no", the share will exist but will not show up in the list of available shared folders on this computer and only persons who know the name of the share will be able to access it.
- When done, click the 'Finish' button in the lower right corner of the dialog box.
- Now we are done, so click the 'OK' button in the lower left corner of the "Samba Configuration" dialog box to write the settings for the new share to the configuration file.
The next step is to tell msec how the permissions on our /home/shared_music folder are to be set.
- In the 'Start Menu', click on the "Run Command..." entry. The "Run Command" dialog box will open.
- Type kdesu drakperm in the "Command" text entry box and then click the 'OK' button.
- The "Run as Root" dialog box will open. Enter the root password and then click the 'OK' button.
- A "drakperm" window will open. In the middle of the window is a list box containing a list of all the files and folders that are being watched by msec.
- Click the button labeled 'Add a rule' that is under the list box. A dialog box will open.
- In the "Add a new rule" dialog box, make the following entries.
- In the "Path" text box, enter the path to the shared folder. In this example, it is /home/shared_music
- In the "Property" section, you can set a User and Group ID that you want the folder to have. I'm going to set both of these to "root". It doesn't really matter in this case since I am going to allow "Others" complete access anyway.
- In the "Permissions" section, you can select which permissions you wish to set by clicking on the boxes so that there is an X in the box. For this example, I am going to select read, write and execute for User, Group, and Others. The three boxes at the far right will be left unchecked.
- When you are done, click the 'OK' button in the lower left corner of the dialog box.
- Next, click the 'OK' button in the lower left corner of the "drakperm" window. This will save the settings you selected to a text file at /etc/security/msec/perm.local and then the window will close.
Now we can manually run msec to make sure it is setting the permissions on the shared folder the way we expect.
- In the 'Start Menu', click on the "Run Command..." entry. The "Run Command" dialog box will open.
- Type kdesu msec in the "Command" text entry box and then click the 'OK' button.
- The "Run as Root" dialog box will open. Enter the root password and then click the 'OK' button.
- The msec process runs in the background, so you will only observe a little hard disk activity.
- Now open Konqueror and type /home in the "Location" text box and then hit enter.
- Right-click on the "shared_music" file folder and select "Properties" from the pop up menu.
- Click on the permissions tab. You should see that "Others" have "Can View & Modify Content" for their access permissions.
Users on your local network should now be able to browse to the "Music_Box" folder and access files that are in /home/shared_music on your PCLinuxOS computer.
Sharing a Folder That is Inside Your Home Folder
Some people like to provide each user with a shared folder that is inside their own home folder. This allows users a convenient way to make documents available on the local network. For instance, in my case, I would create a folder at /home/hankcurt/network_shared where I could drop my documents so that others on the network could read them.
The guest user will be given the User ID of "nobody" and Group ID of "nogroup". So for the guest user to have access to the network_shared folder, both the /home folder and the /home/hankcurt folder must have execute permission set for "Others". However, msec is setting the permissions on the /home/hankcurt folder so that the "User" has all permissions, the "Group" has read and execute permission, and "Others" have no permissions. Thus a guest user will never be able to get access to the shared folder. We could solve the problem by telling msec that we want "Others" to have execute permission on /home/hankcurt, as we did in the previous section, but this causes another problem. If "Others" have execute permission on my personal folder, any local user can get into my personal folder and read or modify files. I don't want that.
There is a better solution. The "Group" ownership for every user's home folder is set to a group with the same name as the user who owns the folder. My user name is hankcurt and so my personal folder "Group" ownership is set to the group hankcurt. Since the "Group" permissions on my home folder are read and execute, anyone who is in the 'hankcurt' group could enter my home folder. I am the only person on the computer who is in the group 'hankcurt'. That keeps everyone else out of my personal folder. But, if I tell Samba that guest users who access my folder should be added to the 'hankcurt' group while they are connected, then they could enter my home folder and gain access to the network_shared folder without allowing everyone else access to my personal files. The steps below show how to set this up.
First, create the folder that will be shared.
- Open Konqueror and in your home folder create a folder called network_shared. So, in my case, I would create /home/hankcurt/network_shared.
- Right-click on the network-shared folder and click on "Properties" in the pop up menu.
- Click on the "Permissions" tab and check the following items
- Make sure that Permissions are set so that "Owner Can View & Modify Content" and "Group Can View Content"
- If you are creating folders in other users' home folders as root, be sure that you set the "Ownership" so that "User" and "Group" are both set to the user's name.
- Click on the 'OK' button when you have finished.
Next share the folder on the network.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Mount Points' button on the left side of the control center window.
- Click the icon labeled "Configure Samba". The "Samba Configuration" window will open.
- The "File share" tab should be visible. If it is not, click on the "File share" tab so that it is visible
- Click on the 'Add' button at the right of the window. A dialog box will open that asks for the following three pieces of information. None of the lines may be left blank.
- "Name of the share:" This is the name that you want remote users to see when they browse to the shared folder. It does not need to be the name of the folder, but should be composed only of characters that can be used in a file name on Windows machines. For this example, enter hankcurt_shared
- "Comment:" Enter a phrase that describes the folder you are sharing. For this example, I'll enter Documents shared by Hank.
- "Path:" This must be the full path to the file folder that you are sharing. In this example the proper entry would be /home/hankcurt/network_shared
- When you have filled out all three lines, click the 'OK' button at the bottom of the dialog box to continue.
- If everything went well, you will see a dialog box that says "Congratulations". Don't click the 'OK' button in this box and don't try to close it with the 'X' ( close ) button in the title bar. Doing either of those things will crash the Samba configuration window and none of your changes will be saved. Just click on a visible area of the Samba Configuration window behind this dialog box. The problem dialog box will then be behind the main window, and you can just ignore it.
- Now, click on the line where your new share is listed, so that it is highlighted and then click the 'Modify' button.
- The dialog box will open that allows you to change any settings except for the "Share name:". Enter settings into the following entry fields.
- "Public:" This is where you allow guest access to the share. Set this box to "yes"
- "Writeable:" Set this box to "no" if you don't want to allow others on the network to write to the shared folder. If you set this to "yes", the user can contol whether others can change his files by adding or removing "Group" write permission on the files themselves. If the user wants to allow others to create and delete files, he must add "Group" write permission to the network_shared folder.
- "Browseable:" Set this box to "yes" If this is set to "no", the share will exist but will not show up in the list of available shared folders on this computer and only persons who know the name of the share will be able to access it.
- In the "Advanced Options" portion of the dialog box, click on the line that says "User options" to display more settings.
- One of the text boxes is labeled "Force Group". Enter the group name that you want guest users to have. In my case I will enter hankcurt This will cause guest users to have a Group ID of "hankcurt" instead of "nogroup". Since guest users now belongs to the group "hankcurt", they will be allowed to enter my personal folder. The guests' User ID will still be "nobody".
- When done, click the 'Finish' button in the lower right corner of the dialog box.
- Now we are done, so click the 'OK' button in the lower left corner of the "Samba Configuration" dialog box to write the settings for the new share to the configuration file.
Others on the network will now be able to read files from the shared folder inside the user's home folder. If you chose to allow the remote user to create files, the files will be owned by "nobody" but the group ownership will be that of the user whose folder they are accessing. In my case a file created by a remote user would have Group ownership of "hankcurt".
How to Access Shared Folders With Your Own User ID
In the previous sections, we always assumed that Samba would not know who the remote user was, and thus would try to grant guest access to the shared folders. If the remote user has a user account on the PCLinuxOS machine, it is possible for Samba to recognize his user name and password and then grant him access to shared folders under his normal User ID, just as if he were logged onto the machine locally. There is extra incentive to configure this because the remote user will also be able to access his entire home folder, thanks to a special share definition called "Homes" that was created automatically when you first installed Samba.
To inform Samba that you are a user on the system, follow the steps below.
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Mount Points' button on the left side of the control center window.
- Click the icon labeled "Configure Samba". The "Samba Configuration" window will open.
- Click the "Samba Users" tab, so that it is visible in the window.
- The user "nobody" should be listed. It is added automatically because all unknown users are given the User ID of "nobody", so you never should remove this entry.
- Now click on the 'Add User' button on the right side of the window. A dialog box titled "Add Samba user" will open.
- Click the drop down box labeled "User name" and select the name of the user whom you want to grant access to Samba shares.
- Enter this user's password into the text box labeled "Password"
- Note: If this user changes his login password, you will have to come to this screen and highlight his user name and click the 'Change password' button to change it here also. It will not automatically change here when you change the user's password for the system.
- Repeat the previous three steps for any additional users whom you wish to allow to access Samba shares with their own User ID.
- When done, click the 'OK' button in the lower left corner of the window.
Why Samba Needs User Names and Passwords Re-entered
All of the user names and passwords have already been entered in the system when the user's accounts were set up, so you may wonder why must they be entered again for Samba. The answer has to do with how the passwords are stored. No modern operating system stores user passwords as plain text. Usually, the passwords are encrypted using an algorithm that can not be easily unencrypted and then the result of the encryption is stored. Then when someone enters a password to log on to the system, the password they enter is encrypted using the same algorithm and then is compared with the encrypted password that has been stored. If the two encrypted forms of the password match, the user is authenticated.
A problem arises because Linux stores passwords using one encryption method but the Windows network clients send passwords that are encrypted by an entirely different method. There is no way to compare the two passwords because they are encrypted differently. Since the passwords that have already been entered for use by Linux cannot be unencrypted, Samba requires that you re-enter the passwords in plain text. Then Samba will store the passwords using an encryption method that is compatible with the encryption used by the Windows network clients.
Now you probably want to see what you have gained by adding users to Samba. If you use the same user name and password on a remote computer on your network, you will be able to access your user's home directory. Your home directory may not show up when you browse the shares on the computer, but if you type
\\hostname\username in Windows explorer or
smb://hostname/username in Konqueror ( where "hostname" is the name of the computer and "username" is the user's name on that computer ), you should be allowed in to your home directory.
Also, you no longer have to allow guest access on folders you share on the network unless you want to. Just set the "Public" setting to "no" when configuring the shared folder in the PCLinuxOS Control Center and only users that have been added to Samba will be able to access the share. Or you can set the permissions on shared files so that guests can only read the files but authorized users can modify them. A user's group memberships also apply when that user access a shared folder over the network, so group ownership and permissions on the files can be used to allow access for one group of users while denying access to others. When a user that has been added to Samba creates files in a shared folder, those files will be owned by that user and have their group ownership set to that user's primary group.
Summary of Share Configuration Options
Not every samba configuration option available in the PCLinuxOS Control Center was covered in the text above. This summary will briefly explain all of the options that can be used to modify how a folder is shared on the network. These options are in the dialog box titled DrakSamba entry. You can get to this dialog box by following the steps below:
- Start the PCLinuxOS Control Center, and enter the root password in the "Run as Root" dialog box.
- Click on the 'Mount Points' button on the left side of the control center window.
- Click the icon labeled "Configure Samba". The "Samba Configuration" window will open.
- The "File share" tab should be visible. If it is not, click on the "File share" tab so that it is visible.
- Now, click on the name of the share you wish to configure; it will become highlighted. Then click the 'Modify' button.
- The DrakSamba entry dialog box will open.
This screen shot has been annotated with numbers to identify each section of the box to make it easy to find the description in the list below.
(1) Basic Samba Share Configuration
This is the basic portion of the configuration window that is always visible.
- Share name This is the name you have given to this share. It will be displayed on remote computers when they browse the shared folders on this computer. This cannot be changed from this dialog box.
- Directory This is the folder that is being shared. You may change the directory you are sharing by typing in the full path to a different directory or clicking the 'Open' button and browsing to the directory you wish to share.
- Comment The text entered in this box will appear on remote computers as a description of the shared folder. You may enter any text you like.
- Public If this field is set to 'yes' then remote users who only have guest access will be permitted to try to access this shared folder. Permissions on the shared directory and on the files it contains must also allow guest access, or the remote user will still get an "Access Denied" error. This option defaults to 'no'.
- Writable If this field is set to 'yes' then remote users will be allowed to try to create, delete, or modify files in the shared folder. Permissions on the shared directory and on the files it contains must also allow write access, or the remote user will still get a "Permission Denied" error. This option defaults to 'no'.
- Browseable If this is set to 'no', the shared folder will not appear in any listing on the remote computer when the remote user browses the shared folders on this computer. The remote user can still access this folder by explicitly typing in the share name. This option defaults to 'yes'.
(2) User Options - Samba user access
These options are not visible unless the "User Options" label is clicked. According to the documentation for Samba 3.0 and later, the 'Read List', 'Write List', and 'Admin users' options are not valid when using share level security. PCLinuxOS uses share level security by default, so
the first three options listed here will not work unless you change the "security = SHARE" line in the /etc/smb.conf file to "security = USER". The options in the section all take a space separated list of user names as entries. The user names entered here must also be added to Samba as described in the section above entitled "How to Access Shared Folders With Your Own User ID".
- Read List Users listed here will only be allowed to read files from the shared folder, even if the 'Writable' option is set to 'yes'. However, if the user is also in the 'Write List', the user will be allowed to write to the shared folder if the permissions on the folder allow it.
- Write List Users listed here will be allowed to write to the shared folder even if the user is also listed in the 'Read List' above. The users listed here will even be allowed to write to the shared folder even if the 'Writable' option for the share is set to 'no'.
- Admin users Users listed here will always access the shared folder as root. Any files they create will be owned by root, and they will be able to access all files in the share regardless of the permissions on the files.
- Valid users If no users are listed here, any user may access the shared folder if permissions on the directory and the files it contains allow access. However, if there is one or more user names listed here, only those users listed will be allowed to access the shared folder.
(3) Mask Options
These options are not visible unless the "User Options" label is clicked and the dialog box expands to display them. The configuration options in this section will affect the permissions and group ownership of files that are created in the shared folder by a remote user.
Numeric Representation of Permissions
The permissions for files and directories are primarily composed of either allowing or denying read, write and execute permission for each of three groups; user, group and others. There is a system that makes it easy to represent the permissions on a file with a four digit number like this 0764. This box will explain how to interpret these numbers.
The first of the four numbers represents special types of permissions that we don't have space to discuss here. Most of the time, this number will be zero, meaning that none of these special permissions is set. The second number represents the permissions for the user who owns the file. The third number represents the permissions for the group that owns the file. The fourth number represents the permissions for others.
To generate the numbers from the permissions, each permission is given a value and then the values are summed
- Read permission is 4
- Write permission is 2
- Execute permission is 1
So in our example, 0764, we can decipher what permissions each category of users has
- The second digit means User has read, write and execute permission, which sums as 4 + 2 + 1 = 7
- The third digit means Group has read and write permission, which sums as 4 + 2 = 6
- The fourth digit means Others have only read permission, which gives the value of 4
- Create mask This option accepts permissions in numeric form as an entry. (See box at right) When a file is created remotely with Samba, the Samba server looks at the Windows file attributes and uses them as a basis for setting the Linux permissions for user, group and others. The create mask filters out permissions that would otherwise be set. If a permission is not set in the 'Create mask', then it will not be set on the file. The 'Create mask' cannot add permissions that would otherwise not be set. For instance, if 0700 is entered in the 'Create mask', group and others will not have any permissions for any files created in the shared folder. However, if the system intends to give the user only read and write permissions, a create mask of 0700 will not add execute permission. If 'Create mask' is left blank, the default create mask of 0744 will apply.
- Directory mask This option is a create mask for directories. It accepts the numeric representation of permissions as an entry. When a directory is created in the shared folder, the available Windows attributes for the directory are used as a basis for setting permissions for user, group, and others. These permissions are then filtered through the 'Directory mask'. Any permissions not set in the 'Directory mask' not be set on the directory. The 'Directory mask' will not add permissions to the directory that the system would not otherwise set. If there is no entry in the 'Directory mask' field, the default directory mask of 0755 is applied to all newly created directories.
- Force Group This entry for this option should be a group name that is valid on the computer running Samba server. All users who access the shared folder will have their primary group set to this group for the purpose of create and accessing files on the shared folder. This means that any files or directories they create in the shared folder will be owned by this group. Also, when the system is determining whether the user has permission to access a file or directory, they will be treated as if they were members of this group.
- Force create group This option is mislabeled and does not set group ownership. The real name of this option is 'Force create mode' and it accepts numeric representation of permissions as an entry. Any permission set in the 'Force create mode' option will be set on all files created by remote users. The 'Force create mode' option will override the 'Create mask'. In other words, if a permission is filtered out by not being set in the 'Create mask', but is set in the 'Force create mode' option, it will be added back in. The default for this option is 0000.
- Inherit permissions If this option is set to 'yes', newly created files and directories inherit the permissions of the parent directory. This will override any settings in 'Create mask', 'Directory mask', and 'Force create mode'. Directories will inherit all of their permissions from the parent directory. Ordinary files inherit the read and write permissions of the parent directory, but execute permission is not inherited. This option is set to 'no' by default.
(4) Display Options
These options control whether certain files are displayed when clients browse the shared folder. Also, since Windows is generally case insensitive ( treats upper and lower case letters as equivalent in file names ) while Linux is case sensitive, there are options to control how capitalization is to be handled when a client creates a new file.
- Hide dot files In Linux, files that have names begining with a dot are hidden when the directory contents are listed. By setting this option to 'no' you can cause these files to appear in the directory listing on the remote computer. If this is set to 'yes', files begining with a dot will be hidden on the remote computer, like they are on the Linux system. The default setting is 'yes'
- Hide files This option accepts a list of file names that should be hidden from view on the remote computer. The names are case sensitive. The wild cards '*' and '?' can be used to substitute for any group of characters and any single character respectively so that a pattern can be created. Any file or directory name matching the pattern will have its Windows hidden file attribute set. The file names and patterns entered in this field should be separated with a / (forward slash) and not spaces, although spaces may be included in the file name. Files that are hidden using this option are still accessible if a remote user explicitly types in the file name.
- Default case This option determines whether file names sent by clients when creating new files should be forced to be upper or lower case if the 'Preserve case' option below is set to 'no'. If the 'Preserve case' option is set to 'yes', this option will not take affect. The default setting for this option is 'lower'.
- Preserve case This option determines whether file names sent by remote clients when creating new files should be forced to the default case, or if the capitalization sent by the remote client should be preserved. If this is set to 'yes', the file names will be written exactly as sent from the client and the 'Default case' setting will not have any effect. The default setting for this option is 'yes'.
There are 3 comments on this page. [Display comments]