Does system-config-printer set printer's IPP attributes like "media-default"?
by Till Kamppeter
Hi,
when searching for a page size A4/Letter problem I have found entries like
Option media=na_letter_8.5x11in
Option output-bin face-down
Option page-bottom 43
Option page-left 19
Option page-right 20
Option page-top 13
Option print-color-mode color
Option print-quality 4
Option printer-resolution 300x300dpi
Option sides two-sided-long-edge
in the printer sections of the /etc/cups/printers.conf file. The "Option
media=na_letter_8.5x11in" makes the PageSize default being "Letter" when
in the PPD the default is set to A4.
See the mails cited below.
Mike Sweet tells that these are caused by programs setting IPP
attributes like "media-default". Does system-config-printer or some of
its auxiliary programs set such attributes?
Till
---------
From: Till Kamppeter
To: cups(a)easysw.com
Yesterday I have done some tests with a native PDF printer, using CUPS
1.5.2 and cups-filters 1.0.9 (if filters are in both CUPS and
cups-filters I have used the cups-filters versions) on Ubuntu Precise
(12.04). The PPD file contains only PJL options, including PageSize
being PJL as in contrary to PostScript option code cannot be embedded in
a PDF file.
I have set the default page size to A4 (all
"*Default{PageSize|PageRegion|ImageableArea|PaperDimension}:") via
lpadmin -p <printer> -o PageSize=A4
and send a JPG job via
lp -d <printer> -o PageSize=A4 -o scaling=100 file.jpg
Starngely enough, I got
CLJ3530pdf till 267 [26/Mar/2012:23:22:33 +0200] 1 1 - localhost
d08684-001 na_letter_8.5x11in -
in /var/log/cups/page_log and with
lpoptions -p <printer> -l
I got
PageSize/Page Size: *Letter A4 A5 A6 ISOB5 EnvC5 Env10 EnvDL 5x13 EnvC6
Executive B5 B6 Legal EnvMonarch 69x95mm Statement
but the job gets centered correctly on A4 paper.
A job without specifying A4 paper, like
lp -d <printer> -o scaling=100 file.jpg
does not get correctly centered.
So I have searched for ~/.cups/lpoptions and /etc/cups/lpoptions and did
not find anything. After that I have searched for a bug in CUPS, until I
found the line
Option media=na_letter_8.5x11in
and some other "Option=..." lines in the section for my printer in
/etc/cups/printers.conf. This printer and one other printer had these
lines (the second was the same printer but with the manufacturer's
PostScript PPD). After stopping CUPS, removing these lines and starting
CUPS again, the problem went away.
Where do these lines come from? Which program has inserted them? How can
I prevent such lines getting inserted?
Should CUPS get fixed by
lpadmin -p <printer> -o PageSize=A4
removing lines like this (Generally if setting the default for a certain
option, removing the "Option ..." line for this option as the default
gets set in the PPD)?
"Option ..." lines should only be there for non-PPD options, like
"number-up".
Till
---------
From: Mike Sweet
To: cups(a)easysw.com
Till,
On Mar 27, 2012, at 7:24 AM, Till Kamppeter <till.kamppeter(a)gmail.com>
wrote:
> ...
> So I have searched for ~/.cups/lpoptions and /etc/cups/lpoptions and did
> not find anything. After that I have searched for a bug in CUPS, until I
> found the line
>
> Option media=na_letter_8.5x11in
> ...
> Where do these lines come from? Which program has inserted them? How can
> I prevent such lines getting inserted?
At some point you (or some program) must have set the media-default
attribute for this printer, either through lpadmin or a corresponding
Set-Printer-Attributes/CUPS-Add-Modify-Printer request. The attribute
then sticks until reset or deleted (lpadmin -p printer -R media-default).
__________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair
12 years
Auth_fn callback memory leak
by Matt McDonald
Hello,
I tracked down a memory leak in the auth_fn callback in pysmbc-1.0.13.
It's a pretty slow leak. The result of the python auth callback
function is not properly decref'd. I attached a diff that fixes the
problem, the memory usage appears to be stable with this patch.
Cheers,
Matt McDonald
12 years, 1 month
[PATCH] First version of a firewalld patch.
by Jiri Popelka
I left Firewall class almost untouched, just renamed it to
SystemConfigFirewall because system-config-firewall is I
think the only service prividing
org.fedoraproject.Config.Firewall interface.
I added new FirewallD class with the same interface as
SystemConfigFirewall so it's transparent to a client.
SystemConfigFirewall works the way that it first discovers what's
allowed in firewall with one call (read()).
And then again with one call (write()) it allows what's necessary.
FirewallD class uses separate call for each service/port query or
modification.
The newly added services are allowed for 60s (could be changed to
whatever value you like).
The code suppose that there's only one active network zone [1] which
should be true under most conditions - what to do otherwise
will be evaluated later.
It works good here with either firewalld or system-config-firewall.
I've had only one problem so far that I would appreciate a help with -
for detailed description see comment in FirewallD.read() function.
[1] https://fedoraproject.org/wiki/Features/network-zones
---
firewall.py | 160 ++++++++++++++++++++++++++++++++++++++++++++++-------
newprinter.py | 12 ++--
serversettings.py | 6 +-
3 files changed, 150 insertions(+), 28 deletions(-)
diff --git a/firewall.py b/firewall.py
index f344a67..2d2be00 100644
--- a/firewall.py
+++ b/firewall.py
@@ -27,11 +27,132 @@ import dbus
import json
from debug import *
-class Firewall:
- ALLOW_IPP_CLIENT = "--service=ipp-client"
- ALLOW_IPP_SERVER = "--service=ipp"
- ALLOW_SAMBA_CLIENT = "--service=samba-client"
- ALLOW_MDNS = "--service=mdns"
+IPP_CLIENT_SERVICE = "ipp-client"
+IPP_CLIENT_PORT = "631"
+IPP_CLIENT_PROTOCOL = "udp"
+IPP_SERVER_SERVICE = "ipp"
+IPP_SERVER_PORT = "631"
+IPP_SERVER_PROTOCOL = "tcp"
+MDNS_SERVICE = "mdns"
+MDNS_PORT = "5353"
+MDNS_PROTOCOL = "udp"
+SAMBA_CLIENT_SERVICE = "samba-client"
+
+
+class FirewallD:
+ DBUS_INTERFACE = "org.fedoraproject.FirewallD1"
+ DBUS_INTERFACE_ZONE = DBUS_INTERFACE+".zone"
+ DBUS_PATH = "/org/fedoraproject/FirewallD1"
+
+ def __init__ (self):
+ try:
+ bus = dbus.SystemBus ()
+ obj = bus.get_object (self.DBUS_INTERFACE, self.DBUS_PATH)
+ self._firewall = dbus.Interface (obj, self.DBUS_INTERFACE_ZONE)
+ except (dbus.DBusException), e:
+ self._firewall = None
+ return
+
+ debugprint ("Using FirewallD")
+ self._fw_data = []
+ # TODO: fix to allow more than one active zone
+ self._zones=self._get_active_zones()[0]
+ self._timeout=60
+
+ def initialized (self):
+ return self._firewall != None
+
+ def _get_active_zones(self):
+ try:
+ return map (str, self._firewall.getActiveZones())
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD getting active zones failed")
+ return ""
+
+ def _addService(self, service):
+ try:
+ self._firewall.addService (self._zone, service, self._timeout)
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD allowing service %s failed" % service)
+ pass
+
+ def add_service (self, service):
+ self._fw_data.append (service)
+
+ def write (self):
+ map (self._addService, self._fw_data)
+ self._fw_data = []
+
+ def read (self, reply_handler=None, error_handler=None):
+ if reply_handler:
+ # Here I would like to just call the reply_handler() because we
+ # don't need to do anything else here, but if I remove the
+ # getServices() call and directly call reply_handler()
+ # the firewall dialog that the NewPrinterGUI.on_firewall_read()
+ # creates becomes unresponsive.
+
+ #reply_handler (self._fw_data)
+ self._firewall.getServices (self._zone,
+ reply_handler=reply_handler,
+ error_handler=error_handler)
+ return
+
+ def check_ipp_client_allowed (self):
+ try:
+ return (self._firewall.queryService(self._zone,
+ IPP_CLIENT_SERVICE)
+ or self._firewall.queryPort(self._zone,
+ IPP_CLIENT_PORT,
+ IPP_CLIENT_PROTOCOL))
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD query ipp-client service/port failed")
+ return True
+
+ def check_ipp_server_allowed (self):
+ try:
+ return (self._firewall.queryService(self._zone,
+ IPP_SERVER_SERVICE)
+ or self._firewall.queryPort(self._zone,
+ IPP_SERVER_PORT,
+ IPP_SERVER_PROTOCOL))
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD query ipp-server service/port failed")
+ return True
+
+ def check_samba_client_allowed (self):
+ try:
+ return self._firewall.queryService(self._zone,
+ SAMBA_CLIENT_SERVICE)
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD query samba-client service failed")
+ return True
+
+
+ def check_mdns_allowed (self):
+ try:
+ return (self._firewall.queryService(self._zone, MDNS_SERVICE)
+ or self._firewall.queryPort(self._zone, MDNS_PORT,
+ MDNS_PROTOCOL))
+ except (dbus.DBusException), e:
+ debugprint ("FirewallD query mdns service/port failed")
+ return True
+
+
+
+
+class SystemConfigFirewall:
+ DBUS_INTERFACE = "org.fedoraproject.Config.Firewall"
+ DBUS_PATH = "/org/fedoraproject/Config/Firewall"
+
+ def __init__(self):
+ try:
+ bus = dbus.SystemBus ()
+ obj = bus.get_object (self.DBUS_INTERFACE, self.DBUS_PATH)
+ self._firewall = dbus.Interface (obj, self.DBUS_INTERFACE)
+ debugprint ("Using system-config-firewall")
+ except (dbus.DBusException), e:
+ debugprint ("No firewall ")
+ self._firewall = None
def _get_fw_data (self, reply_handler=None, error_handler=None):
try:
@@ -45,12 +166,6 @@ class Firewall:
self._client_reply_handler (self._fw_data)
except AttributeError:
try:
- bus = dbus.SystemBus ()
- obj = bus.get_object ("org.fedoraproject.Config.Firewall",
- "/org/fedoraproject/Config/Firewall")
- iface = dbus.Interface (obj,
- "org.fedoraproject.Config.Firewall")
- self._firewall = iface
if reply_handler:
self._firewall.read (reply_handler=reply_handler,
error_handler=error_handler)
@@ -58,7 +173,7 @@ class Firewall:
p = self._firewall.read ()
self._fw_data = json.loads (p.encode ('utf-8'))
- except (dbus.DBusException, ValueError), e:
+ except (dbus.DBusException, AttributeError, ValueError), e:
self._fw_data = (None, None)
if error_handler:
debugprint ("D-Bus exception examining firewall")
@@ -101,27 +216,30 @@ class Firewall:
isect = set (search).intersection (set (args))
return len (isect) != 0
- def add_rule (self, rule):
+ def add_service (self, service):
try:
(args, filename) = self._fw_data
except AttributeError:
(args, filename) = self._get_fw_data ()
if filename == None: return
- args.append (rule)
+ args.append ("--service=" + service)
self._fw_data = (args, filename)
def check_ipp_client_allowed (self):
- return self._check_any_allowed (set(["--port=631:udp",
- self.ALLOW_IPP_CLIENT]))
+ return self._check_any_allowed (set(["--port=%s:%s" %
+ (IPP_CLIENT_PORT, IPP_CLIENT_PROTOCOL),
+ "--service=" + IPP_CLIENT_SERVICE]))
def check_ipp_server_allowed (self):
- return self._check_any_allowed (set(["--port=631:tcp",
- self.ALLOW_IPP_SERVER]))
+ return self._check_any_allowed (set(["--port=%s:%s" %
+ (IPP_SERVER_PORT, IPP_SERVER_PROTOCOL),
+ "--service=" + IPP_SERVER_SERVICE]))
def check_samba_client_allowed (self):
- return self._check_any_allowed (set([self.ALLOW_SAMBA_CLIENT]))
+ return self._check_any_allowed (set(["--service=" + SAMBA_CLIENT_SERVICE]))
def check_mdns_allowed (self):
- return self._check_any_allowed (set(["--port=5353:udp",
- self.ALLOW_MDNS]))
+ return self._check_any_allowed (set(["--port=%s:%s" %
+ (MDNS_PORT, MDNS_PROTOCOL),
+ "--service=" + MDNS_SERVICE]))
diff --git a/newprinter.py b/newprinter.py
index 595be04..b642910 100644
--- a/newprinter.py
+++ b/newprinter.py
@@ -1618,7 +1618,9 @@ class NewPrinterGUI(GtkGUI):
try:
if (self._host == 'localhost' or
self._host[0] == '/'):
- self.firewall = firewall.Firewall ()
+ self.firewall = firewall.FirewallD ()
+ if not self.firewall.initialized():
+ self.firewall = firewall.SystemConfigFirewall ()
debugprint ("Examining firewall")
self.firewall.read (reply_handler=self.on_firewall_read,
error_handler=lambda x:
@@ -1648,11 +1650,11 @@ class NewPrinterGUI(GtkGUI):
secondary_text += ("- " +
_("Allow all incoming IPP Browse packets") +
"\n")
- f.add_rule (f.ALLOW_IPP_CLIENT)
+ f.add_service (firewall.IPP_CLIENT_SERVICE)
if not mdns_allowed:
secondary_text += ("- " +
_("Allow all incoming mDNS traffic") + "\n")
- f.add_rule (f.ALLOW_MDNS)
+ f.add_service (firewall.MDNS_SERVICE)
if not allowed:
debugprint ("Asking for permission to adjust firewall:\n%s" %
@@ -1678,7 +1680,7 @@ class NewPrinterGUI(GtkGUI):
def adjust_firewall_response (self, dialog, response):
dialog.destroy ()
if response == gtk.RESPONSE_YES:
- self.firewall.add_rule (self.firewall.ALLOW_IPP_SERVER)
+ self.firewall.add_service (firewall.IPP_SERVER_SERVICE)
self.firewall.write ()
debugprint ("Fetching devices after firewall dialog response")
@@ -2090,7 +2092,7 @@ class NewPrinterGUI(GtkGUI):
dialog.destroy ()
if response == gtk.RESPONSE_YES:
- f.add_rule (f.ALLOW_SAMBA_CLIENT)
+ f.add_service (firewall.SAMBA_CLIENT_SERVICE)
f.write ()
except (dbus.DBusException, Exception):
nonfatalException ()
diff --git a/serversettings.py b/serversettings.py
index 62d345f..89b725e 100644
--- a/serversettings.py
+++ b/serversettings.py
@@ -526,7 +526,9 @@ class ServerSettings(GtkGUI):
try:
if (self._host == 'localhost' or
self._host[0] == '/'):
- f = firewall.Firewall ()
+ f = firewall.FirewallD ()
+ if not f.initialized():
+ f = firewall.SystemConfigFirewall ()
allowed = f.check_ipp_server_allowed ()
else:
# This is a remote server. Nothing we can do
@@ -549,7 +551,7 @@ class ServerSettings(GtkGUI):
dialog.destroy ()
if response == gtk.RESPONSE_YES:
- f.add_rule (f.ALLOW_IPP_SERVER)
+ f.add_service (fireall.IPP_SERVER_SERVICE)
f.write ()
except (dbus.DBusException, Exception):
nonfatalException ()
--
1.7.7.6
12 years, 1 month
system-config-printer 1.3.9
by Tim Waugh
I've just released system-config-printer 1.3.9. Here are the changes:
* Updated translations.
* Improved output from check-device-ids script.
* Don't warn about changed cupsGetPPD3 behaviour in CUPS 1.5.3.
* Avoid temporary file leaks.
* Handle file disappearances when caching PPDs (bug #786232).
* Fixed several debugprints (bug #785581).
Get it from here as usual:
http://cyberelk.net/tim/data/system-config-printer/1.3/
Tim.
*/
12 years, 1 month