Samba

Under Construction

There exists a freeware system called Samba which you can compile and run on your Solaris 8 Sparc 20 which greatly improves your ability to share data between the Sun and the rest of the PC's on your network. Samba is a UNIX based server program which speaks the SMB protocol which is what Microsoft Windows uses to share files and printers. It runs on almost all UNIX platforms and is shipped with source code. It is often used on Linux file machines. Samba can:

Getting Samba

Your can download the Samba binaries in pkgadd format from the Sun Freeware Site. This is often not the latest release of the source and may not be compiled with the options you want. The download comes with a free HTML version of the O'Reilly "Using Samba" book which is very useful in learning Samba.

If you already have gcc installed, it is sometimes better to recompile the source which can be downloaded from the samba.org site. This allows you to turn of features such as smbwrapper and smbsh which allows you to cd to a /smb pseudo file system on the sun and walk around in your PC network.

Compiling Samba

Before you compile samba, you need to run the configure script which figures out a bunch of things about your system and sets compile switches for Samba appropriately. It also builds the Makefile. On one good set of configure options for home networks is:

./configure --with-utmp    --with-automount --with-syslog --with-smbwrapper --with-pam --with-pam_smbpass

The Using Samba book describes in detail the various options you might want to compile in. A more conservative configure line might be:

./configure  --with-smbwrapper

Once the configure runs successfully, run:

make

to built the Samba binaries. Then, running as root, run:

make install

to install the files into /usr/local/samba/...

Congfiguring Samba

Most of the Using Samba book describes configuring Samba. The smb.conf file used on the Styma home network is:

# cat /usr/local/samba/lib/smb.conf
# Samba config file created using SWAT
# from localhost (127.0.0.1)
# Date: 2001/07/22 15:22:16

# Global parameters
[global]
        workgroup = STYMA
        encrypt passwords = Yes
        wins support = Yes
        server string = Samba %v on (%L)
        max log size = 1024
        domain master = yes
        prefered master = yes
        local master = yes
        security = user
        domain logons = yes

[homes]
        browseable = no
        map archive = yes
        writeable = Yes

[home]
        comment = Sun Home
        path = /home
        writeable = Yes
        guest ok = Yes
        browseable = yes

[disk2]
        comment = Sun Home
        path = /disk2
        writeable = Yes
        guest ok = Yes
        browseable = yes

[netlogon]
        comment = domain logon service
        path = /usr/local/samba/netlogon
        public = no
        writeable = no
        browsable = no

The above smb.conf file makes the Sun the Master Browser, the WINS server, and the Primary domain controller. As master browser the Sun keeps track of what PC's are exporting which shares (drives). Without a master browser, the PC's use subnet broadcasts to get this information each time they need it. As the WINS server, the Sun acts as the PC equivalent of a DNS server. As Primary domain controller, the PC allows you to logon to the PC network through it. You will need to set up a UNIX account for each person using a PC which is connected to the network. There are a lot of configuration options, you will need to look at the book to understand them all.

The [homes] section says that if a person who has logged on the network from a PC, opens the folder for the Sun machine, they will see a folder with their login name which is actually their UNIX home directory.

The [home] section allows access to /home on the Sun. This is somewhat redundant with the [homes] section but allows access to all the home directories. Note that UNIX permissions are observed.

The [disk2] section allows access to /disk2 on the Sun. This happens to be an externally mounted drive. The 'guest ok' parameter says the files are accessable even if you are not logged on.

The [netlogon] section identifies where to put the files used for being a primary domain controller.

Starting Samba

Once you have Samba installed, you will want to start it when the system boots. On Solaris, you will need to create /etc/init.d/nmbd.conf and /etc/init.d/smbd.conf. The samples linked to should work as is.

Then, logged in as root, in /etc/rc3.d, run:

ln /etc/init.d/nmbd S71nmbd
ln /etc/init.d/smbd S72nmbd

In /etc/rc2.d, run:

ln /etc/init.d/nmbd K71nmbd
ln /etc/init.d/smbd K72nmbd

These commands will cause Samba to start when the machine comes up to run level 3 and terminate when it goes down to run level 2. The logs for Samba will be in /usr/local/samba/var.

Configuring Samba With SWAT

Samba provides a web based configuration utility called swat. You can use SWAT to configure samba using point a click. The SWAT program is distributed with samba. To use it, you will need to update your /etc/services and /etc/inetd.conf files as follows:

In /etc/services, add the line:


swat            901/tcp                         # Samba swat server

In /etc/inetd.conf, add the lines:


#
# Samba
#
netbios-ssn     stream  tcp     nowait  root    /usr/local/samba/bin/smbd       smbd
netbios-ns              dgram   udp     wait    root    /usr/local/samba/bin/nmbd       nmbd
#
swat                    stream  tcp     nowait  root    /usr/local/samba/bin/swat       swat

Note that inetd.conf lines also set up the smbd and nmbd Samba server to be started by inetd.

To access SWAT point your browser to: http://localhost:901
You will be prompted for the root password on your sun system. The SWAT comes with it's own help pages, but it helps to look at the Using Samba book to first.

Making your PC connected printer work from your Sun

You can print normal text files to a windows based printer with samba. The file examples/printing/smbprint.sysv in the Samba base directory will can be used to implement this function. The file contains documentation on how to tailor it and run it for your application. The Using Samba book also gives instructions. Here is the contents of the file tailored to print on the: HP930 printer on windows machine styma4.

#!/bin/sh
#
# @(#) smbprint.sysv version 1.0 Ross Wakelin <r.wakelin@march.co.uk>
#
#      Version 1.0 13 January 1995
#               modified from the original smbprint (bsd) script
#
# this script is a System 5 printer interface script. It 
# uses the smbclient program to print the file to the specified smb-based 
# server and service. 
# 
# To add this to your lp system, copy this file into your samba directory 
# (the example here is /opt/samba), modify the server and service variables 
# and then execute the following command (as root) 
#
# lpadmin -punixprintername -v/dev/null -i/opt/samba/smbprint 
# 
# where unixprintername is the name that the printer will be known as 
# on your unix box. 
# 
# the script smbprint will be copied into your printer administration 
# directory (/usr/lib/lp or /etc/lp) as a new interface 
# (interface/unixprintername)
# Then you have to enable unixprintername and accept unixprintername
#
# This script will then be called by the lp service to print the files
# This script will have 6 or more parameters passed to it by the lp service.
# The first five will contain details of the print job, who queued it etc,
# while parameters 6 onwards are a list of files to print.  We just
# cat these at the samba client.
#
# Set these to the server and service you wish to print to 
# In this example I have a WfWg PC called "lapland" that has a printer 
# exported called "printer" with no password.
#
# clear out the unwanted parameters
shift;shift;shift;shift;shift
# now the argument list is just the files to print

server=styma4
service="HP 930C"
password=""

(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
       echo translate
        echo "print -"
        cat $*
) | /opt/samba/smbclient "\\\\$server\\$service" $password -N -P  > /dev/null
exit $?

Accessing Samba nodes from NT or another Samba machine

It may happen that you have NT nodes on your network or a second UNIX machine such as a PC running Linux. You may want to set that machine up to be able to authenticate to the PDC running on your Sun solaris box. Doing this is a 2 step process. First you have to add a machine trust account on the Solaris box running the PDC and then you have to join the domain from the Windows NT box or the other box running Samba.

Add the Machine Trust Account

In the /etc/passwd file of your Solaris Samba server (the PDC we will authenticate to), add a line for each subbordinate machine:

styma6$:*:1001:900:Trust Account:/dev/null:/dev/null 

Make up a unique UID (2nd number) for each entry. In this case styma6 is the name of the machine. Note the $ at the end of the name. This is required. Then execute the command:

smbpasswd -a -m  styma6

This will add the machine trust account.

Join the Domain

On the subordinate machine, In this case styma6, run the command:

smbpasswd -j STYMA -r STYMA5

Where STYMA is the name of the domain you identified in the smb.conf file of the PDC machine (the workgroup name) and STYMA5 is the name of the PDC machine.

What we have just done is added UNIX machine styma6 to the workgroup/domain STYMA controlled by PDC styma5.



Back to Sun At Home Home Page
Last Maintained, 01/31/2008 by R. E. Styma