Posted on Feb 17, 2010

Samba, CUPS and Windows 32/64 bit drivers

This post is provided to you by Walter “DaK_TaLeS”, my friend. So, everytime you read “I”, it refers to him and not to me.

Just to introduce you his home-computer environment, he owns an home server/desktop hybrid system that provides SAMBA file-sharing and CUPS to export his printers to the whole family computers.
As you may already imagine, other laptops run different versions of Windows (both 32 and 64 bits).

The goal that I’ve been finally able to achieve is a smart configuration setup in order to export Windows printers drivers through CUPS service using SAMBA to share the printers onto a Windows network. This is a feature that isn’t spread out, but kind of useful.
To say it shortly, the shared printers will be available and installed on Windows systems with a simple double click, no need to Google for drivers.

It’s a kind of magic. How to do so? There’s plenty of guides around the Internet so I won’t waste bits here explaining this (you can take a look at cupsaddsmb man page for further information). As the man-page states:

cupsaddsmb exports printers to the SAMBA software (version 2.2.0 or higher) for use with Windows clients. cupsaddsmb uses the new RPC-based printing support in SAMBA 2.2.x to provide printer drivers and PPD files to Windows client machines.

In order to get through the next part of the walk-through, make sure you have SAMBA and CUPS services already installed.
Let’s configure SAMBA to provide this service by editing/adding the following lines in /etc/samba/smb.conf:

[global]
  load printers = yes
  printing = cups
  printcap name = cups

 [printers]
  comment = All Printers
  path = /var/spool/samba
  browseable = no
  public = yes
  guest ok = yes
  writable = no
  printable = yes

 [print$]
  comment = Printer Drivers
  path = /etc/samba/drivers
  browseable = yes
  guest ok = no
  read only = yes
  write list = root

Of course, you should edit your share options according to your needs.
I feel comfortable creating an user on the server and make every service run with its credentials. This makes my family happier since they don’t have to rant against annoying login popups when accessing the printers.

[global]
  map to guest = bad user
  security = share
  guest ok = yes
  guest account = winsmb

Notice that I’ve set winsmb as guest account for accessing the sharing. If you’ve chosen another username, edit the configuration above accordingly.
At this point you should be able to see the shared printers from your Windows clients, but you won’t be able to automatically fetch the drivers through the LAN.

Now go to a Windows client (it’s important that it’s running Windows 2000 or newer).
These steps need to be performed for each kind of architecture in your Home facility. If you own two or more 32-bit version of Windows, you don’t need to do that more than once. You have to perform the following tasks once for 32-bit systems and once for 64-bit system. (If you do not own one type of architecture, just ignore).

Fire up your Windows clients and go to Windows\system32\spool\drivers\w32x86\pcc\ directory (for 32 bit systems) or go to Windows\system32\spool\drivers\x64\pcc\ (for 64 bit systems). and extract the following files from a cab file:

  ps5ui.dll
  pscript.hlp
  pscript.ntf
  pscript5.dll

The cab file should be named something like “ntprint.inf__.cab” [ is supposed to be x86 or amd64 according to the Windows version; is a random value]. Extract the files above.
You should own two copies of these files: one from the Windows 32 bit, and another one from Windows 64 bit. Put the files in your USB pen-drive and return to the Dark Side of Human Being (linux).

Those files have to be copied inside two different directories so pay attention:
Copy the 32 bit files into /usr/share/cups/drivers/.
Copy the 64 bit files into /usr/share/cups/drivers/x64/.

Make sure the filenames are lower-case since Linux is case-sensitive.

Now double check you’ve done everything right. Fire up your favorite browser, head to CUPS website , and download the Windows driver (it should be named something like cups-windows-6.0-1.i386.tar, of course version could be different). Uncompress it somewhere and copy the included file

  cups6.inf
  cups6.ini
  cupsps6.dll
  cupsui6.dll


inside /usr/share/cups/drivers/. As you may notice, this driver is a 32-bit driver so you won’t be able to automagically install a printer on Windows 64-bit client system.

Here comes the part where I sweat blood and, thanks to me, you’re going to get through it smoothly.
The 64-bit driver is hosted on CUPS’s svn so you have to pick those directly from the nightly. So, go to the CUPS svn , copy all those files inside /usr/share/cups/drivers/x64/

That’s it. A piece of cake, uh?
Well, you have all what you need! cupsaddsmb needs you, temporarily, to switch to security = user; in /etc/samba/smb.conf.
Log in as root and issue cupsaddsmb -a -v (all and verbose, respectively). This command will export the driver inside the previously specified [print$] directory.
Once it terminates, let’s revert your old security thing inside smb.conf.

If you’ve chosen to create a dedicated user to the printers sharing, just add it to CUPS as authorized to print and restart CUPS service.

Well if you’ve done everything right, you’ll be able to use your printers from any kind of almost any Windows/Linux Operative system running any kind of architecture.

That’s it. Happy printing!

Well, I hope you’ve enjoyed the post. Kudos to Walter :)

Comments

  • Vike

    Thank you so very very much.

    To get ps5ui.dll, pscript.hlp, pscript.ntf, pscript5.dll on Windows XP Professional 64 bit edition:
    control panel -> printers
    right click, server properties
    driver tab
    add -> next -> “x64″ only -> next -> manufacturer “generic”, driver “MS publisher imagesetter” -> next -> finish

    Then the four files appear in C:\WINDOWS\system32\spool\drivers\x64\3

  • Vike

    By the way I bet that applies to Windows server 2003 64 bit edition too.

  • elbryan

    I’ve no way to test it with a Windows Server 2003 64bit but I’ve the same clue you have.

    However, thank you for your contribution

  • Alex

    Thanks for this great explanation!

    But I have one more question: what versions of CUPS and Samba did you use?

  • elbryan

    If I’m right (let’s wait dak to have a confirmation), he used samba-3.4.6 and CUPS-1.3.11

    However I’ll inquiry him just to be sure.

  • DaK_TaLeS

    Alex:

    Samba: 3.0.37
    Cups: 1.3.11

    Why do you ask?

  • Rem

    Great job!

  • Robert Spencer

    Thank you so much for this great post. After hours of just trying to get samba and windows 7 to play nice I then ran into the driver problem with HP officejet 6200. This post saved me some more hours of pain. It worked like a charm! :)

  • Alex

    Sorry for my late response.
    First I tried your explanation with Samba 3.0.24 and CUPS 1.2.8 but this did not work.
    With Samba 3.5.5 and Cups 1.4.4 everything works perfect now (with your help).
    So i guess my version of CUPS was too old.

    Thanks a lot!

  • Ådne

    Worked great for me. I have security = ads and just used the -U switch on cupsaddsmb to specify my domain user name and it went through swiftly. Cups 1.3.7 and Samba 3.0.33. The PS drivers from Win7 32/64 worked on win2003 as well.

    Thanks!

  • Benjamin

    Thanks a ton for this. I’m part of a primarily linux shop that has to deal with Windows for administrative machines and this blog was a life-saver.

    Also, I’ve invited Alexa’s bot (aka the wayback-machine) to crawl and archive your blog, because I don’t want this information to die.

  • RRG

    Thanks that’s great. cups seems to be the only option for a universal PS – Devicedriver (like AdobePS) for 32 AND 64 Bit Windows at this time.

    This can be important outside a Samba- Setup also. Point-and-Print for HP-Laserjet- VendorDrivers (32 and 64 bit) do not seem to work on a 32bit-Share very well

  • http://www.bucknelluniversity.net/tag/bucknell-university-address-2 bucknell university

    This is a good,common sense article.Very helpful to one who is just finding the resouces about this part.It will certainly help educate me.

  • Jason Knight

    For the life of me, I cannot get this to work. I’ve been at it for 3 days now on a business network with three printers. Can’t get a single driver loaded. When trying to run ‘cupsaddsmb -v -a’ I keep getting:

    Running command: rpcclient localhost -N -A /tmp/cups1AeTso -c ‘adddriver “Window s x64″ “Dell5100cn:pscript5.dll:Dell5100cn.ppd:ps5ui.dll:pscript.hlp:NULL:RAW:ps cript5.dll,Dell5100cn.ppd,ps5ui.dll,pscript.hlp,pscript.ntf,cups6.ini,cupsps6.dl l,cupsui6.dll”‘
    result was WERR_UNKNOWN_PRINTER_DRIVER

    This is probably understood for the 64 bit arch and the 32 bit arch seems to install:

    Running command: rpcclient localhost -N -A /tmp/cupsZK9f9I -c ‘adddriver “Window s NT x86″ “Dell5100cn:pscript5.dll:Dell5100cn.ppd:ps5ui.dll:pscript.hlp:NULL:RAW :pscript5.dll,Dell5100cn.ppd,ps5ui.dll,pscript.hlp,pscript.ntf,cups6.ini,cupsps6 .dll,cupsui6.dll”‘
    Printer Driver Dell5100cn successfully installed.

    But when I change my smb.conf back to security=share and restart smb, and connect from a 32 bit Win 7 machine, I get the error “No Driver Found”.

  • Jason Knight

    By the way, this is the best described way to set up CUPS that I’ve seen so far. I’ve been over and over cups.org, samba.org and many other sites, but did not get as clear of information.

  • Jason Knight

    Also, I’m running on CentOS 5.5, CUPS 1.3.7 and Samba 3.0.33. I’m going to give it a go on Ubuntu 10.10 which uses CUPS 1.4.4 and see what I get.

  • Jason Knight

    smb.conf

    use client driver = NO

    Unbelievable…

  • lightmaster

    I get all the way to the part about running “cupsaddsmb -a -v” before I have a problem. When I run that command, I get the following error message:
    ————————————————————
    root@zen:/etc/samba# cupsaddsmb -a -v
    Password for root required to access localhost via SAMBA:
    Running command: smbclient //localhost/print$ -N -A /tmp/03a6a4e13133f -c ‘mkdir W32X86;put /tmp/03a6a4e0ce4aa W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    tree connect failed: NT_STATUS_BAD_NETWORK_NAME

    Unable to copy Windows 2000 printer driver files (1)!
    Running command: smbclient //localhost/print$ -N -A /tmp/03a6a4e13c8e3 -c ‘mkdir W32X86;put /tmp/03a6a4e0ce4aa W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    tree connect failed: NT_STATUS_BAD_NETWORK_NAME

    Unable to copy Windows 2000 printer driver files (1)!
    Running command: smbclient //localhost/print$ -N -A /tmp/03a6a4e147ca0 -c ‘mkdir W32X86;put /tmp/03a6a4e0ce4aa W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    tree connect failed: NT_STATUS_BAD_NETWORK_NAME

    Unable to copy Windows 2000 printer driver files (1)!

  • elbryan

    Do the logfiles give you something more specific? Usually logfiles are stored in /var/log/samba directory

    That problem can be many things: a typo in the configuration file, a case-sensitivity issue, bad permissions on the configuration dir.

    You should try to investigate it a little bit more.

  • lightmaster

    The log file tells me:
    ——————————————————————
    [2011/06/25 11:20:30.309357, 0] smbd/service.c:988(make_connection_snum)
    canonicalize_connect_path failed for service print$, path /etc/samba/drivers
    [2011/06/25 11:20:30.334322, 0] smbd/service.c:988(make_connection_snum)
    canonicalize_connect_path failed for service print$, path /etc/samba/drivers
    [2011/06/25 11:20:30.358875, 0] smbd/service.c:988(make_connection_snum)
    canonicalize_connect_path failed for service print$, path /etc/samba/drivers
    ———————————————————————
    I then created the folder /etc/samba/drivers since it didn’t already exist and now I get the following error message:
    ———————————————————————
    root@zen:/var/log/samba# cupsaddsmb -a -v
    Password for root required to access localhost via SAMBA:
    Running command: smbclient //localhost/print$ -N -A /tmp/012324e115f94 -c ‘mkdir W32X86;put /tmp/012324e0e00e9 W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \W32X86
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/Officejet_Pro_8500_A909a.ppd
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/ps5ui.dll
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.hlp
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.ntf
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript5.dll

    Unable to copy Windows 2000 printer driver files (1)!
    Running command: smbclient //localhost/print$ -N -A /tmp/012324e11c443 -c ‘mkdir W32X86;put /tmp/012324e0e00e9 W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \W32X86
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/Officejet_Pro_8500_A909a.ppd
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/ps5ui.dll
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.hlp
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.ntf
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript5.dll

    Unable to copy Windows 2000 printer driver files (1)!
    Running command: smbclient //localhost/print$ -N -A /tmp/012324e122b7e -c ‘mkdir W32X86;put /tmp/012324e0e00e9 W32X86/Officejet_Pro_8500_A909a.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll’
    params.c:Parameter() – Ignoring badly formed line in configuration file: cupsys-client package.
    Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8]
    NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \W32X86
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/Officejet_Pro_8500_A909a.ppd
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/ps5ui.dll
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.hlp
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript.ntf
    NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \W32X86/pscript5.dll

    Unable to copy Windows 2000 printer driver files (1)!
    ————————————————————————–
    And the log file is:
    ————————————————————————–
    [2011/06/25 11:23:26.768245, 1] smbd/service.c:1070(make_connection_snum)
    zen (127.0.0.1) connect to service print$ initially as user nobody (uid=65534, gid=65534) (pid 4660)
    [2011/06/25 11:23:26.769932, 1] smbd/service.c:1251(close_cnum)
    zen (127.0.0.1) closed connection to service print$
    [2011/06/25 11:23:26.794603, 1] smbd/service.c:1070(make_connection_snum)
    zen (127.0.0.1) connect to service print$ initially as user nobody (uid=65534, gid=65534) (pid 4662)
    [2011/06/25 11:23:26.796223, 1] smbd/service.c:1251(close_cnum)
    zen (127.0.0.1) closed connection to service print$
    [2011/06/25 11:23:26.820840, 1] smbd/service.c:1070(make_connection_snum)
    zen (127.0.0.1) connect to service print$ initially as user nobody (uid=65534, gid=65534) (pid 4664)
    [2011/06/25 11:23:26.822607, 1] smbd/service.c:1251(close_cnum)
    zen (127.0.0.1) closed connection to service print$

  • DaK_TaLeS

    Hi, try setting:
    @[global] security = user@
    in smb.conf before running cupsaddsmb, then revert back to whatever you want.

  • lightmaster

    I already have “security = user” enabled. Could it make a difference that I’m connecting to my computer through ssh and not directly on it?

  • DaK_TaLeS

    @NT_STATUS_MEDIA_WRITE_PROTECTED making remote directory \W32X86@

    This seems to be the problem: cupsaddsmb can’t create W32X86 dir in /etc/samba/drivers.

    Maybe permission related?

  • elbryan

    I read somewhere that permissions should be 755 on the /etc/samba/drivers directory. Not sure if they are too much “loose” or they’re good.

  • http://www.cypress-systems.net Kinglok, Fong

    Thanks you so much. You really save my life in x64 bit CUPS driver!!

  • Benjamin

    The best info on the magic involved of cupsaddsmb (and cups workings in general) can actually be found in Samba’s documentation here: http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/CUPS-printing.html