Auto-scanned SMB-provided printers cannot be selected

Bug #127152 reported by Patrice Vetsel
6
Affects Status Importance Assigned to Milestone
system-config-printer (Fedora)
Fix Released
High
system-config-printer (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: system-config-printer

Using s-c-p 0.7.62-0ubuntu1 on Tribe3, I can not have access to printers shared on smb network.

Looking at sources, in pysmb.py, the detection use nmblookup. This is not working.

You should have a look at Bug #58403 that solve this problem on gnome-cups-manager using findsmb tool
https://bugs.launchpad.net/ubuntu/+source/gnome-cups-manager/+bug/58403

Revision history for this message
In , The (the-redhat-bugs) wrote :

Description of problem:
When adding new printer this tool does not display list if samba printers. I can
only set url manually (everything is fine in that case). It sees samba groups
but displays nothing in them.

Version-Release number of selected component (if applicable):
system-config-printer-0.7.63.1-1.fc7

How reproducible:
always

Steps to Reproduce:
1.
2.
3.

Actual results:

Expected results:

Additional info:

Revision history for this message
In , Tim (tim-redhat-bugs) wrote :

What output do you get when you run this command?:

python /usr/share/system-config-printer/pysmb.py

Revision history for this message
In , The (the-redhat-bugs) wrote :

{'IP': '192.168.0.2', 'DOMAIN': 'ITPROTECT'}

That's it.

Changed in system-config-printer:
status: Unknown → In Progress
Changed in system-config-printer:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
In , Patrice (patrice-redhat-bugs) wrote :

Same problem in Ubuntu look at #127152
(https://bugs.launchpad.net/fedora/+source/system-config-printer/+bug/127152)
for instructions how we solve it for gnome-cups-manager.

kagou@satori:~$ python /usr/share/system-config-printer/pysmb.py
{'IP': '192.168.1.100', 'DOMAIN': 'ENTREPRISE'}

kagou@satori:~$ findsmb
                                *=DMB
                                +=LMB
IP ADDR NETBIOS NAME WORKGROUP/OS/VERSION
---------------------------------------------------------------------
192.168.1.102 PATRICE [ ENTREPRISE ]
192.168.1.103 RENE [ ENTREPRISE ]
192.168.1.104 SECRETAIRE [ ENTREPRISE ]
192.168.1.105 JEANCLAUDE [ ENTREPRISE ]
kagou@satori:~$

and doing :
(for i in `export LC_ALL=C; findsmb 2> /dev/null | egrep
'^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | tr -s " " | cut -f2 -d ' ' | uniq | sort`;
do echo $i; echo ---------------; export LC_ALL=C; smbclient -N -L $i 2>
/dev/null | grep Printer; echo; done
)

output :
JEANCLAUDE
---------------

PATRICE
---------------
        HP 1120C A3 Printer

RENE
---------------

SECRETAIRE
---------------
        EPSON5700 Printer

kagou@satori:~$

Revision history for this message
Tim Waugh (twaugh) wrote : Re: Samba printers are not displayed

I'd love for someone to try implementing this.

However, I would suggest using rpcclient instead of smbclient, since smbclient truncates long names.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

How is rpcclient instead of smbclient used in theis command line:

for i in `export LC_ALL=C; findsmb 2> /dev/null | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | tr -s " " | cut -f2 -d ' ' | uniq | sort`; do echo $i; echo ---------------; export LC_ALL=C; smbclient -N -L $i 2> /dev/null | grep Printer; echo; done

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

findsmb is a Perl script which uses nmblookup for the actual work. Differences between s-c-p (/usr/share/system-config-printer/pysmb.py) and findsmb (/usr/bin/findsmb) are:

- s-c-p has WINS support, findsmb not
- s-c-p uses "nmblookup -M -- -" to get the domain master browers and "nmblookup -A <IP>" to get womain/workgroup and NetBIOS name for them. Then it looks up the available servers with "smbclient -N -L //<IP of domain master browser>". findsmb uses simply "nmblookup '*'" for getting a list of the IPs of all the available SMB servers and then "nmblookup -A <IP>" to get womain/workgroup and NetBIOS name for each server
- Both s-c-p and findsmb use "nmblookup -A <IP>" to get womain/workgroup and NetBIOS name for a given IP
- findsmb also uses "gethostbyaddr" to get the host name if a NetBIOS name was not found, s-c-p does not do this.

Perhaps the "smbclient -N -L //<IP of domain master browser>" needs to be replaced by some nmblookup call and also the "gethostbyaddr" needs to be implemented.

I cannot do these changes as I do not have a Windows box for testing. Tim or Patrice, can someone of you try? On my Samba server (Ubuntu Gutsy with default smb.conf) both s-c-p and findsmb work correctly.

Revision history for this message
In , Till (till-redhat-bugs) wrote :

Patrice, can you run the following commands and post the output here:

smbclient -N -L //192.168.1.100
nmblookup -R 'ENTREPRISE'
nmblookup -A 192.168.1.102
nmblookup -A 192.168.1.103
nmblookup -A 192.168.1.104
nmblookup -A 192.168.1.105

The first one is used by s-c-p and probably will not give any useful output for
you. The second one should give you the IPs of all servers in the domain
"ENTREPRISE" (which are the four IPs of the boxes findsmb has found for you).
The last four commands reveal the NetBIOS names of each of your four boxes.

Does this happen that way? Can you post the output here? With this we will be
able to fix s-c-p.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Patrice, can you run the following commands and post the output here:

smbclient -N -L //192.168.1.100
nmblookup -R 'ENTREPRISE'
nmblookup -A 192.168.1.102
nmblookup -A 192.168.1.103
nmblookup -A 192.168.1.104
nmblookup -A 192.168.1.105

The first one is used by s-c-p and probably will not give any useful output for you. The second one should give you the IPs of all servers in the domain "ENTREPRISE" (which are the four IPs of the boxes findsmb has found for you according to the bug report at Red Hat). The last four commands reveal the NetBIOS names of each of your four boxes.

Does this happen that way? Can you post the output here? With this we will be able to fix s-c-p.

Please test on both Ubuntu and Red Hat (if you have the two distros installed somewhere), to exclude distro-specific problems.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

@Till : i will do this Wednesday :)

Revision history for this message
Tim Waugh (twaugh) wrote :

Till: I don't remember how rpcclient is used, sorry. I haven't been able to get it to work without requiring a password.

However, smbclient gives truncated share names. Something more like this is interesting:

http://rc.quest.com/viewvc/samba/vendor/stable/source/python/examples/spoolss/enumprinters.py?revision=13&view=markup&pathrev=13

Is is an example of the experimental Samba Python bindings.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Ok, end of holidays, came back to work.

kagou@satori:~$ for i in `export LC_ALL=C; findsmb 2> /dev/null | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | tr -s " " | cut -f2 -d ' ' | uniq | sort`; do echo $i; echo ---------------; export LC_ALL=C; smbclient -N -L $i 2> /dev/null | grep Printer; echo; done
JEANCLAUDE
---------------

PATRICE
---------------
        HP 1120C A3 Printer

RENE
---------------

SECRETAIRE
---------------
        EPSON5700 Printer

kagou@satori:~$

kagou@satori:~$ findsmb

                                *=DMB
                                +=LMB
IP ADDR NETBIOS NAME WORKGROUP/OS/VERSION
---------------------------------------------------------------------
192.168.1.102 PATRICE +[ ENTREPRISE ]
192.168.1.103 JEANCLAUDE [ ENTREPRISE ]
192.168.1.104 SECRETAIRE [ ENTREPRISE ]
192.168.1.105 RENE [ ENTREPRISE ]
kagou@satori:~$

kagou@satori:~$ smbclient -N -L //192.168.1.100
Error connecting to 192.168.1.100 (Connection refused)
Connection to 192.168.1.100 failed
kagou@satori:~$ nmblookup -R 'ENTREPRISE'
querying ENTREPRISE on 192.168.1.255
192.168.1.102 ENTREPRISE<00>
192.168.1.105 ENTREPRISE<00>
192.168.1.103 ENTREPRISE<00>
192.168.1.104 ENTREPRISE<00>
kagou@satori:~$ nmblookup -A 192.168.1.102
Looking up status of 192.168.1.102
        PATRICE <00> - B <ACTIVE>
        ENTREPRISE <00> - <GROUP> B <ACTIVE>
        PATRICE <03> - B <ACTIVE>
        PATRICE <20> - B <ACTIVE>
        ENTREPRISE <1e> - <GROUP> B <ACTIVE>
        ENTREPRISE <1d> - B <ACTIVE>
        ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE>

        MAC Address = 00-80-C8-4C-5E-96

kagou@satori:~$ nmblookup -A 192.168.1.103
Looking up status of 192.168.1.103
        JEANCLAUDE <00> - B <ACTIVE>
        ENTREPRISE <00> - <GROUP> B <ACTIVE>
        JEANCLAUDE <03> - B <ACTIVE>
        JEANCLAUDE <20> - B <ACTIVE>
        JEAN CLAUDE <03> - B <ACTIVE>
        ENTREPRISE <1e> - <GROUP> B <ACTIVE>

        MAC Address = 00-80-C8-4C-67-15

kagou@satori:~$ nmblookup -A 192.168.1.104
Looking up status of 192.168.1.104
        SECRETAIRE <00> - B <ACTIVE>
        ENTREPRISE <00> - <GROUP> B <ACTIVE>
        SECRETAIRE <03> - B <ACTIVE>
        SECRETAIRE <20> - B <ACTIVE>
        ENTREPRISE <1e> - <GROUP> B <ACTIVE>
        VETSEL <03> - B <ACTIVE>

        MAC Address = 00-80-C8-4C-59-7C

kagou@satori:~$ nmblookup -A 192.168.1.105
Looking up status of 192.168.1.105
        RENE <00> - B <ACTIVE>
        ENTREPRISE <00> - <GROUP> B <ACTIVE>
        RENE <03> - B <ACTIVE>
        RENE <20> - B <ACTIVE>
        ENTREPRISE <1e> - <GROUP> B <ACTIVE>

        MAC Address = 00-80-C8-4C-5E-B1

kagou@satori:~$

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Patrice, the command

smbclient -N -L //192.168.1.100

has given "Connection refused" for you, but according to the Red Hat bug report it is domain server. Can you check this machine and try again?

Tim, how get share names truncated when smbclient is used to list shares? Are they cut to a certain maximum length? Or is the problem caused by spaces in the share names (as "HP 1120C A3" here).

Does Samba not provide any tool which

* Lists full share names (perhaps using a command line option)
* Allows guest account access (or generally access to accounts without password) without interactive password prompt

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Indeed, due to an update of the anti virus 192.168.1.100 was unreachable :/

Here are reseults :
kagou@satori:~$ smbclient -N -L //192.168.1.100
Domain=[ETUDES] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

        Sharename Type Comment
        --------- ---- -------
        PDFCreator Printer eDoc Printer
        Vu Disk
        IPC$ IPC IPC distant
        D$ Disk Partage par défaut
        Documents Disk
        print$ Disk Pilotes d'imprimantes
        ADMIN$ Disk Administration à distance
        C$ Disk Partage par défaut
session request to 192.168.1.100 failed (Called name not present)
session request to 192 failed (Called name not present)
Domain=[ETUDES] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

        Server Comment
        --------- -------

        Workgroup Master
        --------- -------
kagou@satori:~$

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Just for information about this lan.
Except 192.168.1.100 (Windows XP, and no printer share), others PC are under Windows 98SE, and 2 of them share printer.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

I forget to mention that there is no wins server. Each PC have just been configured to be in Entreprise workgroup that's all.

Changed in system-config-printer:
status: Confirmed → In Progress
Changed in system-config-printer:
status: In Progress → Fix Committed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

system-config-printer (0.7.71+-svn1415-0ubuntu1) gutsy; urgency=low

  * New upstream release
     o Subversion snapshot r1415
     o Search for SMB servers not only via "nmblookup -M -- -" but also with
       "nmblookup '*'" (LP: #127152).
     o Take into account that SMB share names can have spaces when scanning
       network for SMB-provided printers (LP: #128261).
     o Make sure that in case of the detected printer being unknown always
       the text-only printer is pre-selected (LP: #102389).
     o Let the generic PostScript PPD coming with CUPS have a higher priority
       than the generic PostScript PPD of Foomatic.
     o Fixed a traceback when trying to find a PPD for a printer with no
       digits in the model name and where the model name does not match
       any of the PPDs exactly.
  * debian/control: Added "Recommends: hal-cups-utils" (LP: #132994).

 -- Till Kamppeter <email address hidden> Tue, 21 Aug 2007 17:51:44 +0100

Changed in system-config-printer:
status: Fix Committed → Fix Released
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Patrice, can you check whether it really works for you now?

Revision history for this message
In , Till (till-redhat-bugs) wrote :

I have done a possible fix in the upstream Subversion repository of
system-config-printer now.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Till, of course i will check tomorrow.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote : Re: [Bug 127152] Re: Samba printers are not displayed

Patrice Vetsel wrote:
> Till, of course i will check tomorrow.
>

Thank you, please also check for your other bug report about the
truncated printer share names.

    Till

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote : Re: Samba printers are not displayed

Bug still here.

Changed in system-config-printer:
status: Fix Released → In Progress
Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Here is the process that i think it's should be implemented.

First : there is no wins !

1/ try to find domains -> get_domain_list ()
seems to work
return : {'IP': '192.168.1.101', 'DOMAIN': 'ENTREPRISE'}

2/trying to find hosts in domains : get_host_list
this function use IP and smbclient -N -L //ip

I think that it would be better to find hosts using 'DOMAIN': 'ENTREPRISE' with nmblookup -R 'DOMAIN'
nmblookup -R 'ENTREPRISE'
querying ENTREPRISE on 192.168.1.255
192.168.1.102 ENTREPRISE<00>
192.168.1.105 ENTREPRISE<00>
192.168.1.101 ENTREPRISE<00>
192.168.1.100 ENTREPRISE<00>
192.168.1.103 ENTREPRISE<00>

Here i have all my IP in my workgroup.

3/ We have to obtain Name instead of IP
i propose to do a :
nmblookup -A IP for each IP and extract the line where we have <20>

nmblookup -A 192.168.1.100 | grep "<20>"
--> SECRETAIRE <20> - B <ACTIVE>
SECRETAIRE is the NAME of IP=192.168.1.100

so we obtain a list of NAME

4/ Ask NAME to know if there is/are printer(s)
get_printer_list ({'IP': '192.168.1.100', 'NAME': 'SECRETAIRE'})
return
{'EPSON5700': ''}

so it's seems ok

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

For informations in pysmb.py

def get_host_list(dmbip) use an IP and pass it to smbclient
/usr/bin/smbclient -N -L //192.168.1.101 2>/dev/null

but result of this is not a list of hosts in the domain, but a list of shares in ONE host (PC).
May be my english is bad or the name of this function is not well chosen.

kagou@satori:~$ /usr/bin/smbclient -N -L //192.168.1.101 2>/dev/null

        Sharename Type Comment
        --------- ---- -------
        PDFCreator Printer eDoc Printer
        Vu Disk
        IPC$ IPC IPC distant
        D$ Disk Partage par défaut
        Documents Disk
        print$ Disk Pilotes d'imprimantes
        ADMIN$ Disk Administration à distance
        C$ Disk Partage par défaut
session request to 192.168.1.101 failed (Called name not present)
session request to 192 failed (Called name not present)

        Server Comment
        --------- -------

        Workgroup Master
        --------- -------

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Last words for this morning.
I have another bug for windows XP to report but i was waiting resolution of this to test if it's here again.

The process that i recommend, work well here (for windows 98 AND XP, can not test Vista)

find a list of domain:
nmblookup -M -- - --> list of possible domain
nmblookup -A IP --> find the name of GROUP

find hosts in a domain:
nmblookup -R 'GROUP' --> list of IP

find NAME for each IP:
nmblookup -A IP | grep "<20>" --> NAME

find shares and specially printers for each IP/NAME:
use of smbclient (works in pysmb.py)

I attach the results of all of this commands.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Fixed in upstream Subversion repositories.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Please put the files attached to this and to the next posting into /usr/share/system-config-printer/ overwriting the original files. Does this solve your problem?

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

It's FAR better :) But…

Now, under adding samba wizard, I can browse hosts (yes i can see all of them), open one and see the printer (works for all), but i can not select printer. I click on the printer but the selection refuse to be selected (background in brown).
Another bug is that all of hosts providing printers do not show that they contain printer (with the little triangle).

First screenshot show only PATRICE with a triangle, not for ETUDES and SECRETAIRE.
If i double-click on SECRETAIRE (same for ETUDES), triangle arrived, printer is shown but i can't click on it.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Second screenshot

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

For informations here output of your pysmb.py

{'IP': '192.168.1.101', 'DOMAIN': 'ENTREPRISE'}
{'ETUDES': {'IP': '192.168.1.101', 'DOMAIN': 'ENTREPRISE', 'NAME': 'ETUDES'}, 'SECRETAIRE': {'IP': '192.168.1.100', 'DOMAIN': 'ENTREPRISE', 'NAME': 'SECRETAIRE'}, 'JEANCLAUDE': {'IP': '192.168.1.103', 'DOMAIN': 'ENTREPRISE', 'NAME': 'JEANCLAUDE'}, 'PATRICE': {'IP': '192.168.1.102', 'DOMAIN': 'ENTREPRISE', 'NAME': 'PATRICE'}}
{'IP': '192.168.1.101', 'DOMAIN': 'ENTREPRISE', 'NAME': 'ETUDES'}
{'PDFCreator': 'eDoc Printer'}
{'IP': '192.168.1.100', 'DOMAIN': 'ENTREPRISE', 'NAME': 'SECRETAIRE'}
{'EPSON5700': ''}
{'IP': '192.168.1.103', 'DOMAIN': 'ENTREPRISE', 'NAME': 'JEANCLAUDE'}
{}
{'IP': '192.168.1.102', 'DOMAIN': 'ENTREPRISE', 'NAME': 'PATRICE'}
{'HP 1120C A3': ''}

------------------
(program exited with code: 0)
Press return to continue

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Don't be worry if you can't see 'RENE'. Host is shutdown

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I have fixed the GUI problem now. Try the attached file.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Update: The attached file fixes also bug 128261 and bug 133573.

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Your last system-config-printer.py close bug 127152 and bug 128261 (can not test bug 133573)

Very nice work Till ! Thanks.

Just a comment : with this last patch, all hosts showed have a triangle (JEANCLAUDE have a triangle but it not share printers). I don't know if this is a problem to report or not. But for the moment i think that you should upgrade s-c-p in repository with your patch for a great experience on printing under Gutsy :)

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Package on its way to Gutsy, here you can already download them for testing:

http://www.linux-foundation.org/~till/tmp/ubuntu/gutsy/system-config-printer/

Note that the triangle appears also at servers without printer shares as we scan only for printer shares if the user clicks the triangle. So at the time when we show the name of an SMB server we do not know yet whether it has printer shares. This way we make it faster (scan only what the user wants to see) and we give the possibility to rescan by closing and reopening a server/share list.

Changed in system-config-printer:
status: In Progress → Fix Committed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Patrice, thank you very much for the great cooperation. Your testing was really needed to solve these problems.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

system-config-printer (0.7.71+-svn1418-0ubuntu1) gutsy; urgency=low

  * New upstream release
     o Subversion snapshot r1418
     o Search all SMB servers for a given domain via "nmblookup -R '<DOMAIN>'".
       The former "smbclient -N -L //<DOMAIN IP>" is used as a fallback. Fixes
       LP: #127152
     o Made sure that all items in the tree list of SMB domains/servers/shares
       have the little triangle to show the sub-item list, even before the
       sub-items were scanned. Fixes LP: #127152
     o Quote/Unquote all elements of the SMB device URIs, as spaces are
       also allowed in SMB host and share names. Fixes LP: #128261
     o Handle exceptions raised by the browse_smb_hosts() function if it
       is called before the add-printer wizard window is open. Fixes
       LP: #133573
     o Scan SMB host list when in the main window the "Change" button for
       the URI is clicked and the URI is an SMB URI. This way the list
       of SMB domains/servers/shares in the dialog for setting the URI
       does not stay empty.

 -- Till Kamppeter <email address hidden> Thu, 23 Aug 2007 09:27:43 +0100

Changed in system-config-printer:
status: Fix Committed → Fix Released
Revision history for this message
In , Till (till-redhat-bugs) wrote :

My fix was confirmed now and it is part of system-config-printer 0.7.73. This
version will probably soon get RPMized by Tim.

Revision history for this message
In , Simon (simon-redhat-bugs) wrote :

It appears that 0.7.63 has just been released, did you mean that one?

Revision history for this message
In , Till (till-redhat-bugs) wrote :

The freshly released one with my fix is 0.7.73. If you got 0.7.63 you have an
old release still containing the bug. Perhaps Red Hat packaging did not catch up
yet.

Revision history for this message
In , Tim (tim-redhat-bugs) wrote :

No, 0.7.63 does not contain that fix.

Please try out this pysmb.py file:
https://bugzilla.redhat.com/show_bug.cgi?id=225351#c7

Changed in system-config-printer:
status: In Progress → Incomplete
Changed in system-config-printer:
status: Incomplete → Fix Released
Changed in system-config-printer (Fedora):
importance: Unknown → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.