Talk:CUPS/Samba

From Gentoo Linux Wiki

Jump to: navigation, search

Contents

[edit] Windows printing with share security

I was wondering how you get this working with a security setting of SHARE. I have XP Home and it would be much easier for family memebers to not have a password.

See Why SAMBA? below.
Also Why CUPS?

[edit] Why CUPS

CUPS is pretty much designed for complex print environments.

But it also may be useful for printing from linux to a non-postscript printer.

Most network printers now understand a bunch of network print protocols that you can print from windows and from linux and not need to install CUPS at all. The printer has its own print server built in.

Even if it doesn't, Windows now understands IPP and LPD and a bunch of stuff, you might manage without CUPS to print from Windows via Linux to a non-network printer.

But assuming you need CUPS, get CUPS 1.2 or later, or expect pain. Especially if you are on some proprietary Linux which has 'tuned' the CUPS server so that it does not conform to the large body of documentation out there, and does mysterious things while you're not looking.

[edit] Cups 6 drivers

These are a step in the right direction, and may be useful if your environment is pretty uniform.

They are pretty minimal. Which can be good, or bad, depending on your needs. For instance, they do understand duplex (you have to enable it manually or scriptfully), but they don't understand tray number => media type mappings.

Take a look at Cups-Windows for more information

[edit] Why Samba?

I don't understand why this HOWTO includes Samba functionality. It seems to me to be an inappropriate security risk, especially if your goals are simply what this HOWTO is addressing -- setting up a printer on a Gentoo box using CUPS, and using that printer natively with Windows.

Using IPP, you can axe everything in this HOWTO regarding printing via Samba. CUPS setup as per the HOWTO looks good. I use [OPTION 1] setup in my mixed-OS environment:

[OPTION 1] Generic PS Driver using MS Publisher Imagesetter driver

Windows: run Add Printer, select "Connect to a printer on the Internet..." and enter the URL for your printer (http://<computer-ip>:631/printers/<CUPS-printer-name>). When it asks for a printer manufacturer, select "Generic", and the printer "MS Publisher Imagesetter".

[OPTION 2] Generic PS Driver using Adobe PS driver

Use the Adobe Postscript driver: http://www.adobe.com/support/downloads/product.jsp?product=44&platform=Windows . Run the installer, select "Network Printer" and supply the URL of your printer queue (same as above).

[OPTION 3] Specific Windows printer-drivers for a particular printer model

If you want to use a specific Windows printer driver directly with the CUPS-connected printer, add a raw CUPS queue as per the HOWTO. Then run Add Printer, select "Connect to a printer on the Internet...", again enter the URL for your printer, and then select the printer driver you would use for the printer like you would for a locally connected printer.


That's it. All three options give different levels of "compatibility" and specific printer functions, but all three options specifically do not use Samba and Windows printer-shares.

Is there some reason why these options aren't a better solution to the above problem?

No. This is the best way to do it.
The only additional thing that can be done using the SAMBA share option is to automate the driver installation for the windows PC user ... they click 'add printer', browse, id the printer, and it installs. But I'm pretty sure they need the right privs ("Virus Installer"^H^H^H"Power User" or better).
And anyway, that sort of stuff is generally best-avoided, because for one thing the user may *expect* to get to choose what driver, secondly, if they want or need to choose some other driver, it becomes difficult.
Windows provides no proper way to uninstall print driver files from your PC, and this can make it hard to figure out which ones its using and where it got them from -- since next time, it will find the files and skip the selection process .. oh it already did that the first time because you automated the installation using SAMBA .. oh dear. You are in a pickle, aren't you?
All of these things are great when you're around to constantly admin, but having everything exported and automated via samba is nice when dealing with other people: they browse to \\the-print-server\ and double click the available printers -- no work for them.
Driver installation can be easily automated using a script and the RUNDLL32 command.
See here:

[edit] Script to automate installation of CUPS printer(s) on Windows

This is an example, you can adapt it for any of the 3 driver options described above in the Why SAMBA? section. Of course this requires admin privs to run properly. You're installing a driver, goddamit.

:: Example XP CMD script to install a cups printer.
:: 12 Oct 2006 I hereby place this script in the public domain, nyer.
:: ~~ The Anonymous Author (yes, me!).

:: The script will work happily from remote SAMBA shares even without 
:: mapping them to a drive letter. It expects the needed files to live
:: in subdirectories with names that you can figure out, see below.

:: Uses path variable %~dp0 documented at 
:: http://www.ss64.com/ntsyntax/parameters.html
:: This is because CMD doesn't like using a UNC path as the current
:: directory.

:: Note that XCOPY doesn't like \\ in the middle of a path.
:: %~dp0 includes \ at the end.
:: But %~dp0somefile.ext is unreadable to humans.
:: XCOPY doesn't mind \.\ in the middle of a path.
:: %~dp0.\somefile.ext is more visually readable.

:: Set some variables to make modifying this script easier.

:: Substitute values here to match your CUPS server.
SET SERVERNAME=cups
SET PRINT_SERVER=http://%SERVERNAME%.example.com
SET PRINT_BASE_URL=%PRINT_SERVER%:631/printers

:: Set the CUPS printer name here for the (first) printer to install.
SET PRINTERNAME=my_printer

:: Set file locations here. (Tests if the file is accessible too.)
SET INF=%~dp0.\cups_unified_driver\cups-windows-6.0\i386\cups6.inf
IF NOT EXIST "%INF%" EXIT /b 1

:: This next value matches something in the .inf file.
:: Easy to figure out what.
:: Tip: Use notepad to open your .inf and guess it.
SET STRING=CUPS Test Driver v6

:: You may want to shorten this a little, depends on your setup.
SET BASENAME=%PRINTERNAME%_using_cups_driver_on_%SERVERNAME%_ipp

:: This doesn't need change unless you have a wierd CUPS setup.
SET URL=%PRINT_BASE_URL%/%PRINTERNAME%

:: Now the action! Install the (first) printer.

:: Install and configure printer driver.
"%WINDIR%\System32\RUNDLL32.EXE" printui.dll,PrintUIEntry /b "%BASENAME%" /if /f "%INF%" /u /r "%URL%" /m "%STRING%"
IF NOT "ERRORLEVEL %ERRORLEVEL%"=="ERRORLEVEL 0" EXIT /b 1

:: You can add more printers in here...
:: .... repeat from "SET PRINTERNAME..." onwards if you want ...

:: Finally, once all printers added, restart the printer service.
START /WAIT "Stop spooler" "%WINDIR%\System32\SC.EXE" STOP spooler
IF NOT "ERRORLEVEL %ERRORLEVEL%"=="ERRORLEVEL 0" EXIT /b 1
START /WAIT "Start spooler" "%WINDIR%\System32\SC.EXE" START spooler
IF NOT "ERRORLEVEL %ERRORLEVEL%"=="ERRORLEVEL 0" EXIT /b 1

ECHO Completed %0, no errors detected.

[edit] HOWTO install the CUPS Windows driver manually to print via SAMBA

[edit] Get needed drivers

Get the drivers from http://cups.org/windows/software.php, unpack i386 folder, save them to a location on your windows client or linux server.

[edit] Install the driver

  • Make sure you have the "show add printer wizard = yes" setting in your smb.conf
  • Navigate to your samba server > Printers and fax...
  • Double click "Add Printer"
  • Click Next until you have to select the driver
  • Browse for driver
  • Select cups6.inf
  • Select CUPS Test Driver 6
  • Enter some fake printer name
  • Don't share the printer
  • See windows copying the files

[edit] Set the driver

Check if the driver has been installed:

# net rpc printer driver
Printer Driver Info 3:
       Version: [3]
       Driver Name: [CUPS Test Driver v6]
       Architecture: [Windows NT x86]
       Driver Path: [\\\\127.0.0.1\print$\W32X86\3\PSCRIPT5.DLL]
       Datafile: [\\\\127.0.0.1\print$\W32X86\3\CUPS6.PPD]
       Configfile: [\\\\127.0.0.1\print$\W32X86\3\PS5UI.DLL]
       Helpfile: [\\\\127.0.0.1\print$\W32X86\3\PSCRIPT.HLP]

       Dependentfiles: [\\\\127.0.0.1\print$\W32X86\3\CUPSUI6.DLL]
       Dependentfiles: [\\\\127.0.0.1\print$\W32X86\3\CUPSPS6.DLL]
       Dependentfiles: [\\\\127.0.0.1\print$\W32X86\3\CUPS6.INI]
       Dependentfiles: [\\\\127.0.0.1\print$\W32X86\3\PSCRIPT.NTF]

       Monitorname: []
       Defaultdatatype: []
Set the driver for a specific printer
 rpcclient -U root -c 'setdriver printername "CUPS Test Driver v6"' SAMBASRV

[edit] Test the driver

On your windows client, goto the printer share, connect to printer. Normally no prompt for drivers should be made. Try printing something :)

[edit] Feedback from J. Random User

[edit] Success!

That worked for me. Thanks!

Now any machine in my windows workgroup can print.

Except my linux server. How can I use the same printer for linux printing? What happens currently is I get postscript uninterpreted printouts. I assume this is due to "raw mode".

It may be because of MIME type being incorrectly set by the sending PC. Or screwy /etc/cups/mime.convs or mime.types.

[edit] at sign in cups password

my printers.conf shows: DeviceURI smb://prnuser:pass@word@hostname/printername

what's the best way, if possible, to encode that '@' in the password?

WTF? You made a password with '@' in it, and now you want help dealing with that? Change the password so that it can be passed on the URL.
Personal tools