After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699942 - The printer applet doesn't detect network printer
The printer applet doesn't detect network printer
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Printers
3.8.x
Other Linux
: Normal major
: ---
Assigned To: Marek Kašík
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-08 16:44 UTC by romu
Modified: 2014-03-28 10:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Cups error log file (789.31 KB, application/octet-stream)
2014-03-25 19:38 UTC, romu
  Details
Don't fail when adding Samba printers with spaces (1.74 KB, patch)
2014-03-27 12:16 UTC, Marek Kašík
committed Details | Review

Description romu 2013-05-08 16:44:25 UTC
My old HP Deskjet 815C is connected to my wifi router. From the gnome-control-center, this is no way to make my printer detected.

I tried the IP address, the smb path, the name of the router, etc...nothing works.

But it works using system-config-printer.
Comment 1 romu 2013-05-08 16:45:13 UTC
Forgot to say I run Ubuntu Gnome 13.04 + the Gnome 3 ppa, 64 bit.
Comment 2 Marek Kašík 2014-03-13 09:40:06 UTC
Hi romu,

the router probably advertises the printer through LPD or JetDirect protocol. Could you run nmap on IP address of your wifi router and tell me whether there is port 515 or 9100 active? Maybe the model name of the router could help me too.

Regards

Marek
Comment 3 romu 2014-03-13 20:01:27 UTC
Hi Marek,
I run "nmap -n -sS <router ip>", and I can confirm there is no open port 515 nor 9100. My router is a Freebox, the box provided by Free, one of the main French ISP.

Free maintains a bug tracker for its box, I can raise a bug report, but I would appreciate any help about the changes to request.
Comment 4 Bastien Nocera 2014-03-14 08:43:15 UTC
It uses SMB to advertise the printer:
http://www.freenews.fr/spip.php?article9778
Comment 5 Marek Kašík 2014-03-14 10:09:07 UTC
(In reply to comment #4)
> It uses SMB to advertise the printer:
> http://www.freenews.fr/spip.php?article9778

Thank you for the link.


romu,

could you try these commands and tell me whether they listed your printer?:

smbtree -N 

smbclient -L address-of-the-router -N

smbclient -L address-of-the-router --user=username-configured-on-the-page
 - this will ask you for the configured password

Btw, does nmap shows opened port 445 on the server? And just to be complete, do you have the sharing turned on on the page?

Regards

Marek
Comment 6 romu 2014-03-14 12:44:04 UTC
smbtree -N -> OK
	\\FREEBOX        		Freebox Server
		\\FREEBOX\IPC$           	IPC Service (Freebox Server)
		\\FREEBOX\Hewlett-Packard DeskJet 815C	

smbclient -L address-of-the-router -N -> OK
Domain=[XXXXXXX] OS=[Unix] Server=[Samba 3.0.37]

	Sharename       Type      Comment
	---------       ----      -------
	Hewlett-Packard DeskJet 815C Printer   


smbclient -L address-of-the-router --user=username-configured-on-the-page -> OK
Domain=[XXXXXXX] OS=[Unix] Server=[Samba 3.0.37]

	Sharename       Type      Comment
	---------       ----      -------
	Hewlett-Packard DeskJet 815C Printer   

Nmap
445/tcp  open   microsoft-ds

Yes sharing is allowed as the router includes a hard drive I can access from family computers.

So, as everything seems to work, I deleted the printer, and tried again, because I raised this bug a long time ago.

Now the printer is detected, it is shown with the path //<domain>//FREEBOX. So this part is fixed. But when I try to select the right printer and driver, the final result is "Adding new printer failed".
Comment 7 Marek Kašík 2014-03-19 08:06:27 UTC
Thank you for the info. Does gnome-control-center print a warning to console during the addition of the printer?
Comment 8 romu 2014-03-21 09:01:00 UTC
Hi Marek,
I've tried with both drivers proposed: CUPS+Guntenprint and hpcups, same results.

Here is the output:

(gnome-control-center:4922): printers-cc-panel-WARNING **: cups-pk-helper: addition of printer Hewlett-Packard-DeskJet-815C failed: client-error-not-possible

(gnome-control-center:4922): printers-cc-panel-WARNING **: Installation of the new printer failed.

In both cases, I get this trace.
Comment 9 Marek Kašík 2014-03-24 11:09:10 UTC
Hi,

thank you for the info, it seems that the new printer dialog is passing a directory instead of a file to a request.
Could you turn on debugging in CUPS and try to add the printer again and paste here the log (or send it to my email address if you don't want to publish it)?
You can turn the debugging on by setting "LogLevel debug" in "/etc/cups/cupsd.conf" and restarting cups by "service cups restart". The log is located in "/var/log/cups/error_log". Don't forget to turn the debugging off again after that ("LogLevel warn" is default) since it generates quite a lot of messages.

Regards

Marek
Comment 10 romu 2014-03-25 19:38:09 UTC
Created attachment 272899 [details]
Cups error log file
Comment 11 romu 2014-03-25 19:39:12 UTC
Find here the cups error file. Hope this helps.
Comment 12 Marek Kašík 2014-03-26 12:13:19 UTC
Thank you for the log. I see the cause probably. The name of the printer contains spaces which the new printer dialog passes through the printer's URI to CUPS. But there are no spaces allowed. I'll try to find a solution for this.
Comment 13 Marek Kašík 2014-03-27 12:16:12 UTC
Created attachment 273078 [details] [review]
Don't fail when adding Samba printers with spaces

Attached patch fixes the problem for me. It escapes URIs composed of names of the SMB servers and the SMB shares.
Comment 14 Bastien Nocera 2014-03-27 12:18:59 UTC
Review of attachment 273078 [details] [review]:

::: panels/printers/pp-samba.c
@@ +411,3 @@
 
+              uri = g_strdup_printf ("%s/%s", dirname, dirent->name);
+              device->device_uri = g_uri_escape_string (uri,

Is the "/" in the device uri supposed to be escaped as well? I guess not. So better is to escape each component of your URI separately and then concatenate them.
Comment 15 Marek Kašík 2014-03-27 12:24:38 UTC
(In reply to comment #14)
> Review of attachment 273078 [details] [review]:
> 
> ::: panels/printers/pp-samba.c
> @@ +411,3 @@
> 
> +              uri = g_strdup_printf ("%s/%s", dirname, dirent->name);
> +              device->device_uri = g_uri_escape_string (uri,
> 
> Is the "/" in the device uri supposed to be escaped as well? I guess not. So
> better is to escape each component of your URI separately and then concatenate
> them.

It is not supposed to be escaped and it is not escaped because it is included in the G_URI_RESERVED_CHARS_GENERIC_DELIMITERS.
Escaping the strings separately would mean to free 2 new strings instead of 1.
Comment 16 Bastien Nocera 2014-03-27 12:52:34 UTC
(In reply to comment #15)
> (In reply to comment #14)
> > Review of attachment 273078 [details] [review] [details]:
> > 
> > ::: panels/printers/pp-samba.c
> > @@ +411,3 @@
> > 
> > +              uri = g_strdup_printf ("%s/%s", dirname, dirent->name);
> > +              device->device_uri = g_uri_escape_string (uri,
> > 
> > Is the "/" in the device uri supposed to be escaped as well? I guess not. So
> > better is to escape each component of your URI separately and then concatenate
> > them.
> 
> It is not supposed to be escaped and it is not escaped because it is included
> in the G_URI_RESERVED_CHARS_GENERIC_DELIMITERS.
> Escaping the strings separately would mean to free 2 new strings instead of 1.

What happens if there's a '/' in the printer name?
Comment 17 Marek Kašík 2014-03-27 13:00:04 UTC
(In reply to comment #16)
> What happens if there's a '/' in the printer name?

It will not be escaped in that case. I'll test this tomorrow since I don't have any windows machine in office.
Comment 18 Marek Kašík 2014-03-28 09:53:51 UTC
Creation of SMB share with '/' in its name is not allowed on my Windows XP machine so I tested this with ':' and it prints well in both cases.
Comment 19 Bastien Nocera 2014-03-28 09:59:37 UTC
Fine by me then.
Comment 20 Marek Kašík 2014-03-28 10:07:46 UTC
Can I push it to 3.10, 3.12 and master?
Comment 21 Bastien Nocera 2014-03-28 10:08:44 UTC
Sure.
Comment 22 Marek Kašík 2014-03-28 10:15:46 UTC
Comment on attachment 273078 [details] [review]
Don't fail when adding Samba printers with spaces

Thank you all for your help. I've pushed the patch to 3.10 and master/3.12 branches.

Regards

Marek
Comment 23 romu 2014-03-28 10:19:46 UTC
If someone has to thank someone else, it's me. So many thanks to Marek. Et merci à Bastien.