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 :)

Posted on Jan 21, 2010

Metacity loses windows position

I finally found the end of skein! It's about 3 days that I'm googling and asking gentoo people trying to solve this annyoing problem I have. In practise, the applications that I minimize into the traybar, once restored, completely loses the postition that I gave to them.

I've so damn noticed that today when I played with Gwibber. It starts placed on the left, I place it on the right, then I minimize it into the traybar, I restore the apps after few seconds and it reappears on the left. With Compiz that didn't happen!

The solution? One frigging line command:

gconftool-2 --set -t boolean /apps/metacity/general/disable_workarounds false


It's quite funny the description of the key "Disable misfeatures that are required by old or broken applications". I think that there must be so many old and broken application nowadays..

Posted on Jan 20, 2010

Synchronize contacts: some advices

How much time did you spend about digging, testing email clients?

Once you think you've found your favorite unbeatible client comes the part where you import the contacts in your address book.

Well, in my previous post I've pointed out your attention to the "formats battle" between clients. This time I just want to indicate you a Thunderbird 3 extension that I've really enjoyed so much.

Time ago, I've decided to give Google Contacts a try. It's a really simple and clean service that hosts your Address Book.

Today I've tried to make Thunderbird cooperating with Google Accounts in order to have my Address Book synced. I did it!

The extension is called Zindus. It provides a clean GUI where you should put your credentials in. That's it.

Warning: I can't remember exactly how Zindus behaved at its first launch so I strongly suggest you to backup your Address Book before "just running it" since you might lose some contact.

Posted on Jan 2, 2010

Skype, Linux, Alsa & Bluetooth

Today I've been finally able to make my bluetooth headset working fine with Skype.
First of all I want to say that Skype for Linux quite sucks on what should be its main purpose: audio communications.
 

Check out your kernel configuration. Running "lsmod" here is my module configuration related to audio/bluetooth:

lsmod
Module Size Used by btusb 10883 2 rfcomm 32313 4 sco 7586 2 bnep 9474 2 l2cap 28147 16 rfcomm,bnep coretemp 4646 0 snd_pcm_oss 30288 0 snd_mixer_oss 12350 1 snd_pcm_oss snd_seq_oss 23147 0 snd_seq_midi_event 5516 1 snd_seq_oss snd_seq 43658 4 snd_seq_oss,snd_seq_midi_event snd_seq_device 5297 2 snd_seq_oss,snd_seq snd_hda_codec_realtek 256239 1 snd_hda_intel 19780 1 snd_hda_codec 61238 2 snd_hda_codec_realtek,snd_hda_intel snd_hwdep 5362 1 snd_hda_codec snd_pcm 61528 3 snd_pcm_oss,snd_hda_intel,snd_hda_codec snd_timer 16938 2 snd_seq,snd_pcm snd 51423 13 snd_pcm_oss,snd_mixer_oss,snd_seq_oss,snd_seq,snd_seq_device,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer soundcore 6040 1 snd snd_page_alloc 6813 2 snd_hda_intel,snd_pcm

In particular you should make sure to have bt-sco enabled in your kernel.

Now you should gather information about your device, in particular you need its bluetooth MAC address:

hcitool scan
Scanning ... 00:07:B0:11:81:83 BTC5

Write somewhere this xx:xx:xx:xx:xx:xx address, you’ll need it in a while.

Next step is to pair your bluetooth device with your computer.
I use gnome-bluetooth to manage bluetooth devices on my system so feel free to use anything that works for your system.
Look up for your device, start pairing it and issue the PIN (usually 0000 for handsets).

Pair

Once everything seems working fine, let’s configure ~/.asoundrc (Notice that this file should be placed in your user homedir).

Well, open that file (or create it) with your favorite text-editor:

vi ~/.asoundrc
pcm.bluetooth { type bluetooth device xx:xx:xx:xx:xx:xx # The device address gathered before }

This will tell your audio tools that exists another control named “bluetooth” that points out to the device address “xx:xx:xx:xx:xx:xx” (your bluetooth headset).

This should be enough, fire up skype and choose “bluetooth” for incoming and outcoming audio flows.

Note: Some issues you might encounter:

Please make sure you run skype from a terminal to collect more informations

  • This error shows up:
    ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL bluetooth



    Actually you might ignore this message. However, if you followed Bluez HOWTO/AudioDevices and you put something like

    pcm.bluetoothraw {
       type bluetooth
       device 00:11:22:33:44:55
    }
    pcm.bluetooth {
        type plug
        slave {
            pcm bluetoothraw
        }
    }

    in your ~/.asoundrc, then I can tell you that I had this issue before. I just removed this “workaround” and I simply used the “normal” configuration.


  • On Gentoo amd64 is possible that you get some errors regarding not found lib32 libs. This is “normal” (shouldn’t be, but happens). Just unmask and use app-emulation/emul-linux-x86-soundlibs-20091231. This ebuild contains lib32 alsa-bluetooth libraries you need.

Posted on Dec 4, 2009

Deluge 1.1.9 and zlib crash

Today I've rebooted my home-server and I discovered that deluged crashed at boot.

[ERROR   ] 11:43:01 main:207 can't decompress data; zlib not available
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/deluge/main.py", line 204, in start_daemon
    Daemon(options, args)
  File "/usr/lib/python2.6/site-packages/deluge/core/daemon.py", line 56, in __init__
    self.core = Core(options.port).run()
  File "/usr/lib/python2.6/site-packages/deluge/core/core.py", line 239, in run
    component.start()
  File "/usr/lib/python2.6/site-packages/deluge/component.py", line 198, in start
    _ComponentRegistry.start()
  File "/usr/lib/python2.6/site-packages/deluge/component.py", line 118, in start
    self.start_component(component)
  File "/usr/lib/python2.6/site-packages/deluge/component.py", line 125, in start_component
    self.start_component(depend)
  File "/usr/lib/python2.6/site-packages/deluge/component.py", line 125, in start_component
    self.start_component(depend)
  File "/usr/lib/python2.6/site-packages/deluge/component.py", line 130, in start_component
    self.components[name].start()
  File "/usr/lib/python2.6/site-packages/deluge/core/pluginmanager.py", line 69, in start
    self.enable_plugins()
  File "/usr/lib/python2.6/site-packages/deluge/pluginmanagerbase.py", line 84, in enable_plugins
    self.enable_plugin(name)
  File "/usr/lib/python2.6/site-packages/deluge/pluginmanagerbase.py", line 126, in enable_plugin
    egg.activate()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2149, in activate
    self.insert_on(path)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2252, in insert_on
    self.check_version_conflict()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2291, in check_version_conflict
    for modname in self._get_metadata('top_level.txt'):
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2143, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1144, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1136, in get_metadata
    return self._get(self._fn(self.egg_info,name))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1201, in _get
    return self.loader.get_data(path)
ZipImportError: can't decompress data; zlib not available
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
  File "/usr/lib/python2.6/site-packages/deluge/core/preferencesmanager.py", line 451, in run
  File "/usr/lib/python2.6/urllib.py", line 1228, in quote_plus
  File "/usr/lib/python2.6/urllib.py", line 1217, in quote
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
Unhandled exception in thread started by
Error in sys.excepthook:

 

There's an easy workaround to solve this issue, that consists in editing /usr/bin/deluged as follows:

--- deluged.old 2009-12-04 12:44:38.000000000 +0100
+++ /usr/bin/deluged 2009-12-04 12:00:52.000000000 +0100
@@ -2,6 +2,7 @@

 # EASY-INSTALL-ENTRY-SCRIPT: 'deluge==1.1.9','console_scripts','deluged'
 __requires__ = 'deluge==1.1.9'
 import sys
+import zlib

 from pkg_resources import load_entry_point
 
 sys.exit(

 

I asked the guys upstream and I've been told that it's currently already fixed in the new 1.2.0 rc4. Since this problem seems not to be reproducible on every system, this is still a dirty (working) fix.