Printing to Mac (OSX 10.2 - Jaguar) from Windows using SAMBA

 

Introduction:

 

This document provides detailed step by step instructions and supporting diagnostics that will allow a Windows PC to print to printers shared on a Mac running OSX 10.2 or later (Jaguar) using SAMBA. It assumes familiarity with the Terminal. This document may be found at http://homepage.mac.com/william_white/print_to_samba.html

 

For printing from Mac OSX to printers shared on a Windows computer, see the corresponding document at http://homepage.mac.com/william_white/print_to_windows.html

 

Shortened versions of these documents can be found on the Apple Discussion Forums under the User-submitted Frequently Asked Questions section:

 

How to Print to OSX 10.2 from Windows using SAMBA

How to Print to Windows using CUPS and SAMBA

 

This procedure has been tested on a variety of Mac systems with OSX 10.2.4. Printers included Epson Color Stylus 740i (USB) and HP LaserJet 4500N (PS). Hosts tested included Windows XP Home Edition, Windows XP Pro, Windows 98, Windows 2000 Pro and Mac OSX 10.2.4 (as a client). In the rigorous testing phase, the configurations were installed on a vanilla Apple OSX 10.2.4 system with only espgs and Gimp-Print drivers installed.

 

The method described in this document, “printing via SAMBA”, uses the Windows SMB protocol (ports 137, 138 and 139). SAMBA actually passes the file to CUPS for final processing. 

 

The current version of Samba 2.2.3a has been modified by security update 03-24-03 which has not currently been implemented or tested by the author. 

 

The author has since August, 2003 upgraded to 10.2.6 and finds that Samba 2.2.3a has been upgraded to “(Build 26)”. This release appears to be entirely satisfactory as regards printing TO the Mac from Windows clients. The opposite (printing TO Windows) does not work with the standard releases since 10.2.4. Work-arounds are described for these circumstances in the appropriate documents.

 

There exists an alternative method of printing to Mac OS X that bypasses SAMBA and goes directly to the CUPS printing daemon. The method, printing via CUPS, uses the IPP protocol (port 631).  However it does not provide a Windows browseable interface and seems to be slower in printing. Printing via CUPS requires “raw printing” to be enabled. For an overview and link to more information, see section 4.1 below.

 

The procedures described in this document will be easier if you have already been successful with Windows File Sharing and have successfully shared Mac folders to Windows clients. (See references below).

 

This document encourages users to take time with each step and to use the simple terminal commands after the completion of each step to verify correctness before moving onto the next step. This discipline will help isolate issues as they arise and also provide a better understanding of the underlying mechanisms.

 

I’d like to acknowledge the excellent investigative work by Ralph Johns in identifying the elusive client printer command that’s required in Mac OSX and not specifically documented.

 

Overview

 

1. Download and install ESP ghostscript and Gimp-Print drivers.

2. Configure non-postscript printer with a postscript printer driver.

3. Enable SAMBA printer sharing.

4. Configure the shared printer on the PC.

5. Alternative Samba Printer Configurations

 

If you have postscript printers connected to the Mac, you will skip all of steps 1 to 2.6 as these printers are all ready for sharing. Common inkjet printers (Epson, etc) are NOT postscript printers. Generally all the steps will be needed.

 

Additional Contents

 

5. Discussion on Samba [Printers] definition for OSX 10.2

6. Discussion on Windows users and guest client printer access.

7. Typical Samba and CUPS logs.

8. Other References.

 

 

1. Install Ghostscript and Gimp-print.

 

This step is only ever required once. However, it is recommended that the site be checked occasionally for new drivers. This step is not required if the Mac printer is a postscript printer. The only purpose is to provide postscript interfaces for non-postscript printers such as USB inkjet printers, or if you have a printer for which Apple does not provide any driver.

 

ESP (Easy Software Products) is the organization that distributes the CUPS Open Source printing system that is included in MAC OSX 10.2 (Jaguar). These drivers appear in the Print Center drivers’ drop down menu under ESP.

 

The Gimp-Print drivers appears under other folders in this menu. For instance, the Gimp-Print CUPS driver for the Epson printers will be found under EPSON.

 

Find the download links and comprehensive documentation at the gimp-print site here:

 

http://gimp-print.sourceforge.net/MacOSX.php3

 

You may want both the gimp-print drivers and the espgs software.

 

Restart the Mac computer so that the CUPS daemon reloads printer information.

 

2. Configure your Printer with a postscript driver.

 

This step is also only required if you need to configure a postscript printer driver for your printer. In my example, the printer is an Epson Color Stylus 740i inkjet USB printer. We are going to replicate this printer and configure it as a second printer, but with a postscript driver.

 

First ensure that the printer is connected to the Mac and working normally, as we need it to show up in the Print Center menus later.

 

2.1 Open the Print Center and enable the Advanced menu by clicking the Add menu button while holding down the OPTION key (perhaps labeled the Alt key). The Print Center takes longer than usual while it collects the Advance printing options. Click on the drop down menu, scroll down to the bottom and select the option "Advanced". 

 

2.2 Under the menu item, "Device", scroll to the bottom of the drop-down where the name of your printer should be listed. Select it.

 

2.3 Give the device a name: this printer queue name is used both for the CUPS "Name" (as exported by Samba and used by Windows clients), and the CUPS "Description" (the Name listed in the Print Center). In my example, I used the name "PS740".

 

The Device name should be a unique printer name. Because it will be exported to Windows clients, the name should have no embedded spaces or special characters and no more than 8 characters in length.

 

2.4 The "Device URI" should have been completed for you automatically when you selected the printer Device in step 2.2. If you didn’t see the printer in 2.2, or if the URI is not filled out, then (a) there may already be something wrong, or (b), you may need to do this manually, in which case, get the URI by entering the command "lpinfo -v" in the Terminal window.

 

2.5 Select a driver from the "Printer Model" drop-down. For the Epson printer, I selected the ESP driver "Epson Stylus Color CUPS v1.1". I have also been successful with the Gimp-Print EPSON driver "EPSON Stylus Color 740, CUPS+Gimp-Print v4.2.5".

 

2.6 Click the Add button,  and the printer configuration will be complete.

 

2.7 Or use the CUPS web interface instead of the Print Center:

 

Alternatively, the exact same printer can be added using the CUPS web interface by pointing your browser to http://127.0.0.1:631 and going through the same steps. Quit the Print Center first. The main difference is that you can name the exported printer "Name" different from the "Description" name used in the Print Center.

 

More usefully, you can also click the "print a test page" button, which is sometimes a useful validation step.

 

Note that you can print to either printer from your Mac. Only the new one will be visible to the Windows clients as will all postscript printers including those you’ve configured that are on the network.

 

3. Enable SAMBA Printer Sharing

 

3.1 Add the [Printers] share to the Samba configuration file.

 

This step requires modification to the Samba configuration file. There are many ways to do this. Choose whether to edit the configuration file as the highly privileged root user, whether to run from the GUI or in the Terminal, or whether to trust third parties!

 

a) If you are comfortable with working as the root user from the OSX GUI, you can log in as root and edit /etc/smb.conf directly using TextEdit. You need to un-comment the lines (remove the semi-colons - ;) towards the bottom of the file starting with the share heading [printers]. You must also add the line, "use client driver = yes", at the bottom. The [printers] section will end up looking like:

 

[printers]

   comment = All Printers

   browseable = no

   printable = yes

   public = no

   writable = no

   create mode = 0700

   use client driver = yes

 

This share definition will work just fine, and involves the least amount of modification to the default Samba configuration file. However, there are some undesirable aspects of this definition in respect of some of the defaults (not shown). Discussion in Section 5 includes what is perhaps a more good form definition.

 

Section 5 also provides an alternative configuration for a dedicated print share. (The above [printers] exports all printers for all users. You might want to export only selected printers, such as those that are correctly configured to work with Windows clients, or control which users access specific shared printers)

 

b) You can also edit the file in the terminal using vi or pico with sudo.

 

c) You can install the excellent free GUI - SSP - and edit the file that way.

 

The site and download for SSP may be found at http://xamba.sourceforge.net/ssp/index.shtml

 

Note that, although this GUI has an option to "share printers", SSP produces an incorrect configuration file.  So after installing SSP, go to the sharing section, enable printing, then go to the textuals tab to make the final edits as in (a) above.  This is discussed in Section 5 below, if the background is of interest to you.

 

d) Another option is you can download and copy the required modified Samba template "smb.printer.conf" from the filesharing area at http://homepage.mac.com/william_white/

 

To copy the file to the correct location on your Mac, open the Terminal Utility and login as an admin user. Enter the following commands. For [drag file here] you click on the downloaded file in the Finder and drag the image of the file into the terminal window. The Terminal will then substitute the correct file path name.

 

sudo rm /etc/smb.conf

 

sudo cp [drag file here] /etc/smb.conf

 

sudo chmod 755 /etc/smb.conf

 

Enter your admin password when/if prompted. The first command deletes the existing file. The second command copies the template. The third command makes sure it has the right permissions set.

 

3.2 Stop and (re‑)Start Windows File Sharing in the System Preferences Sharing control panel,. (Alternatively, use the command "killall –1 smbd" in the Terminal window).

 

THIS STEP IS REQUIRED EACH AND EVERY TIME YOU RESTART YOUR MAC SYSTEM.

 

Samba Printer sharing, although configured, is only enabled when the CUPS daemon is up and running. Mac OSX starts up cupsd only after smbd, hence this tedious step must be remembered. I have been contacted with some partial solutions to change OSX’s daemon startup order, but none of these are fully satisfactory. One day I will figure this out….

 

3.3 If you copied the template, or if this is your first time Windows File (and Printer) Sharing setup, open the Directory Access Utility and set your Workgroup name so it is identical to your Windows computers. (Copying the template, as in 3.1(d) will have over-ridden any Workgroup you previously set up)

 

3.4 Optional step - test everything is correctly set up on the Mac by entering the following command from the Terminal:

 

smbclient -NL localhost

 

You must see your Printer name listed in the shares along with the File Sharing shares - IPC$ and ADMIN$.  If you do not see the Printer name listed under the lists of shares, the Mac configuration is not correct and you should review the prior steps.

 

If you know, or if you think it’s a possibility, that your PC is going to send a Windows user name and password, then a stronger test with this command is:

 

smbclient –L localhost –U smbusername

 

Where smbusername is the Windows user name (and if you didn’t know, you had better have an identical user name on your Mac).

 

Enter the password when prompted. You should get the share list including the Printer and including smbusername’s home. Here’s a typical dialogue – notice the username is whitew which is also my home folder share name, and the printers.

 

[whitew-osx:~] whitew% smbclient -L localhost -U whitew

added interface ip=172.31.16.153 bcast=172.31.31.255 nmask=255.255.240.0

Password:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 2.2.3a (build 23)]

 

        Sharename      Type      Comment

        ---------      ----      -------

        IPC$           IPC       IPC Service (Samba 2.2.3a (build 23))

        ADMIN$         Disk      IPC Service (Samba 2.2.3a (build 23))

        mh141          Printer  

        mh153_color    Printer  

        mh153_cups     Printer  

        seaPS7SB       Printer  

        seaPS7SC       Printer  

        whitew         Disk      User Home Directories

 

        Server               Comment

        ---------            -------

 

        Workgroup            Master

        ---------            -------

[whitew-osx:~] whitew%

 

Note (see Section 5.2 below) you DO NOT NEED A LOGON to the Mac to print to the printers. Real guest printing is allowed. However, if the user has been enabled as a Windows sharing user, the passwords between the PC (or any SMB client) and the Mac must match. If the user has been disabled, the user access will fail: if the user has EVER been defined, it must be enabled and the password must match.

 

3.5 Optional step – this is the same test as the smbclient command, but from the PC command window. It is a really good idea at this stage, because there may be network configuration issues to resolve.

 

Once you know from the previous command that Mac OSX is correctly exporting the printer(s), including for the Windows user name of interest, then a successful result from this command on the PC will pretty much guarantee the rest will work smoothly. Go to Start > Run > Command (or cmd) and enter the command

 

net view \\macservername

 

And you should see the same list of Samba shares as in the above smbclient test, including the name of the Printer, eg PS740 in the earlier example, as well as the user’s home if a registered (non-guest) user.

 

You may need to replace macservername with the Mac IP Address if you don't have a working DNS. (And for a home network, you really should get a working DNS, or configure your Mac’s Samba to get a working WINS, to improve browsing and name resolution).

 

If this step does not display the macsername (or Mac IP Address) shares, but the smbclient command on the Mac displays the correct shares, then check the PC and Mac Network configurations, as well as the configuration of any DHCP server or router. This may need to be investigated beyond a simple ping. It may be an issue of Workgroup names, security, firewalls, correct router/switch ports, port-forwarding options, and so on. There appears to be subtleties in the various flavors of Windows OS that can affect the ability to list the Samba shares.

 

4. On the PC, Configure the Shared Printer with a Driver.

 

The goal here is to configure the shared Mac printer as a postscript printer on the PC. Fortunately, most Windows OS include the Apple PS printer drivers and these we will use.

 

The starting point on the PC client will depend on whether or not the Mac server (the Mac computer with Windows File, and Printer, Sharing) is visible and accessible in the Network Neighborhood or Add Printer Wizard browser. Usually this requires a working DNS or WINS, or static IP addresses. 

 

Go to step 4.1 if the Mac server is visible in the Network Neighborhood (or equivalent), AND the expected shares are listed if you click on the Mac server name.  Go to step 4.2 if you want to use the Add Printer Wizard and browse for the printer.

 

Also go to step 4.2 if you do not see the Mac server, or if when you click on the server, you get an error message that the network path is not known. (These are typical where there is no effective WINS or DNS, common in small home networks, especially those with DHCP).

 

4.1 Navigate to the Mac server in Network Neighborhood and open the Printers folder. Right click the printer (for instance - PS740 - which is shown as a shared printer) and select connect. Select ok to download a driver from the server. Select ok to install a printer driver when told the printer driver is not correct. Then from the scroll lists, select a make and printer (driver). A driver to select is:

 

Make = Apple, Printer = Apple Color LS 12/660 PS

 

Note that in principle, ANY postscript driver should work, but the most reliable PC postscript drivers here are the Apple ones. For a color printer, any of the Color PS printers would probably do fine, and the one above is simply the first in the list!

 

Right-click again on the printer and select Properties, then “Print Test Page”, then “OK” (because it better have printed now).

 

It’s also possible (if you have raw printing enabled on the Mac) to use the actual driver for the printer, eg. Epson’s Color Stylus 740 PS/2. To use such a driver, it is necessary to enable “raw printing” on the Mac.  It then looks like there’s some negotiation between Samba on the Mac and the PC to ensure the PC produces a suitable file that Samba can then send to the CUPS backend only (usb, in this case). 

 

However, to enable raw printing requires the CUPS mime.convs and mime.types files to be edited (as root) to un-comment (remove the hash/pound sign - #) lines beginning application/octet-streams….. .  If you want to go this route and need more information on enabling raw printing, see the Printing to Mac OSX 10.2 from Windows via CUPS FAQ on the Apple site.

 

4.2 To add a Printer via the Wizard, open the Printer Wizard and click “add Printer”. Select add a printer on the network.

 

If browsing is working, click Next and wait for the Printer Browser to list the available servers and click the Mac server. Then click the printer when it appears. Add an Apple PS printer driver when prompted - as in 4.1 – and print a test page.

 

If browsing is not working, enter an explicit printer address using the servername, if a working DNS is available, or the IP address, if not, as follows:

 

Network Printer Address:  \\servername\printqueuename

 

If DNS is not working use the IP address in place of the server name.  The printqueuename is the Mac print queue Name, as set up in 2.3. Add an Apple PS printer driver when prompted - as in 4.1 – and print a test page.

 

5. Alternative Samba Printer Configurations

 

5.1 The following is the basic [printers] share definition:

 

[printers]

   comment = All Printers

   browseable = no

   printable = yes

   public = no

   writable = no

   create mode = 0700

   use client driver = yes

 

However, as mentioned above, this is slightly incomplete as a testparm will show. Testparm will report that the printer path is not defined for the [printers] share. In Mac OS X 10.2, Samba uses the /tmp (or /private/tmp to which tmp is actually a symbolic link) to spool incoming job. This could be added to the share definition as follows:

 

[printers]

   comment = All Printers

   path = /private/tmp

   browseable = no

   printable = yes

   public = no

   writable = no

   create mode = 0700

   use client driver = yes

 

As an alternative dedicated printer share, try the following (by way of example – explanation follows:

 

[EPSON]

   printer = PS740

   comment = EPSON Stylus 740, Apple Color LS 12/660 PS

   browseable = yes

   printable = yes

   public = no

   writable = no

   create mode = 0700

   use client driver = yes

   valid users = admin, whitew

 

Notes:

 

The share name header, [EPSON], contains the name that will show up in the Windows Network Neighborhood printers share.

 

The “printer =”  parameter is required, in order to associate which print queue name in the Print Centre is to be associated with the share. In this case, the PS740 queue name is chosen, or whatever print queue name you defined in step 2.3 above.

 

I’ve chosen to provide the “comment =” parameter with the printer name and driver THAT THE WINDOWS CLIENT SHOULD USE. This comment will appear in the smbclient command and on Windows.

 

The standard [printers] share is a special one and all printers are automatically displayed in the Windows Network Neighborhood. In the case of a dedicated share it is necessary to explicitly make the share browseable (by contrast [Printers] is declared non-browseable). So the “browseable = yes” parameter is required here.

 

Like before “printable = yes” is required to tell Samba this is a print share not a folder share.

 

“valid users =” parameter is optional, and may be used to restrict which users may access the [EPSON] printer.

 

5.2 Enable quest printing

 

An alternative to “public = no” is “guest ok = yes” which will allow clients to the dedicated printer that are not registered users on the Mac host. This is a valid alternative for the [printers] share or any dedicated printer share.

 

REMAINING IS - WORK IN PROGRESS..

 

 

Note that the only option required in the Sharing System Preferences is Windows File Sharing. You do not need to enable Printer Sharing – that’s only for Mac OSX Printer Sharing. You do not even need to enable any user with privileges since Windows printing clients are treated as a guest user.

 

Raw printing and printing to CUPS (bypassing SAMBA interface)

 

The FAQ

 

How to Print to OSX 10.2 from Windows using CUPS

 

 

 

 

 

 

 

 

 

 

 

 

 

5.1        Monitor progress in the PC Printer queue window: double-click the printer to show the window.

 

5.2        Monitor progress in the Mac printer queue window: double-click the printer in the Print Center.

 

5.3        Monitor the CUPS daemon messages in the Mac terminal:

 

tail –f –n40 /var/log/cups/error_log

 

This command will continuously display and update the last “n” lines (40 in the example) of the CUPS error log. The log includes informative as well as error messages. Examples of messages posted to the log includes when printers are added (as in Step 3), when there are network connection or authentication problems (as in Step 5.1), and logs each filter step undertaken by the CUPS print daemon.

 

Example of output generated:

 

I [01/Mar/2003:18:41:51 -0600] Setting XP740 device-uri to "smb://whitew:*******@kenwhite/whitew-pc/XP740" (was "".)

I [01/Mar/2003:18:41:51 -0600] Setting XP740 printer-is-accepting-jobs to 1 (was 0.)

I [01/Mar/2003:18:41:51 -0600] Setting XP740 printer-state to 3 (was 5.)

I [01/Mar/2003:18:41:51 -0600] Saving printers.conf...

I [01/Mar/2003:18:41:51 -0600] New printer 'XP740' added by ''.

I [01/Mar/2003:18:42:18 -0600] Job 389 queued on 'XP740' by 'whitew'.

I [01/Mar/2003:18:42:18 -0600] Started filter /usr/libexec/cups/filter/cgpdftoraster (PID 3481) for job 389.

I [01/Mar/2003:18:42:18 -0600] Started filter /usr/libexec/cups/filter/rastertoepson (PID 3482) for job 389.

I [01/Mar/2003:18:42:18 -0600] Started backend /usr/libexec/cups/backend/smb (PID 3483) for job 389.

E [01/Mar/2003:18:43:37 -0600] PID 3483 stopped with status 1!

E [01/Mar/2003:18:43:37 -0600] Error writing file: SUCCESS - 0

E [01/Mar/2003:18:43:37 -0600] SUCCESS - 0 closing remote file Apple _ Discussions _ Apple Bluetooth

I [01/Mar/2003:18:43:48 -0600] Saving printers.conf...

I [01/Mar/2003:18:45:07 -0600] Job 389 was cancelled by 'whitew'.

I [01/Mar/2003:18:45:14 -0600] Saving printers.conf...

 

5.4        Example of smbclient dialogue as used in Step 3.5.

 

[whitew-osx:~] whitew% smbclient -L whitew-pc

added interface ip=192.168.1.102 bcast=192.168.1.255 nmask=255.255.255.0

Got a positive name query response from 192.168.1.105 ( 192.168.1.105 )

Password:

Domain=[KENWHITE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

 

        Sharename      Type      Comment

        ---------      ----      -------

        IPC$           IPC       Remote IPC

        print$         Disk      Printer Drivers

        pc-whitew      Disk     

      &n