File system-config-printer-subprocess-no-shell.patch of Package system-config-printer.import5530
From 08dac9a6bc423166ee5593b56aa29a51c0b61584 Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@opensuse.org>
Date: Thu, 8 Dec 2011 10:24:24 +0100
Subject: [PATCH] Always use a sequence as args for timedops.TimedSubprocess()
This helps make sure there is never an issue where we forget to escape a
string.
See https://bugzilla.novell.com/show_bug.cgi?id=735322
Index: system-config-printer-1.2.5/system-config-printer.py
===================================================================
--- system-config-printer-1.2.5.orig/system-config-printer.py
+++ system-config-printer-1.2.5/system-config-printer.py
@@ -4902,11 +4902,13 @@ class NewPrinterGUI(GtkGUI):
self.add_devices (devices, current_uri, no_more=True)
def get_hpfax_device_id(self, faxuri):
- os.environ["URI"] = faxuri
- cmd = 'LC_ALL=C DISPLAY= hp-info -x -i -d"${URI}"'
- debugprint (faxuri + ": " + cmd)
+ new_environ = os.environ.copy()
+ new_environ['LC_ALL'] = "C"
+ new_environ['DISPLAY'] = ""
+ args = ["hp-info", "-x", "-i", "-d" + faxuri]
+ debugprint (faxuri + ": " + args)
try:
- p = subprocess.Popen (cmd, shell=True, close_fds=True,
+ p = subprocess.Popen (args, env=new_environ, close_fds=True,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -4933,15 +4935,14 @@ class NewPrinterGUI(GtkGUI):
return 'MFG:HP;MDL:Fax;DES:HP Fax;'
def get_hplip_uri_for_network_printer(self, host, mode):
- os.environ["HOST"] = host
if mode == "print": mod = "-c"
elif mode == "fax": mod = "-f"
else: mod = "-c"
- cmd = 'hp-makeuri ' + mod + ' "${HOST}"'
- debugprint (host + ": " + cmd)
+ args = ["hp-makeuri", mod, host]
+ debugprint (host + ": " + args)
uri = None
try:
- p = subprocess.Popen (cmd, shell=True, close_fds=True,
+ p = subprocess.Popen (args, close_fds=True,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -4977,12 +4978,11 @@ class NewPrinterGUI(GtkGUI):
host = device.uri[s:s+e]
# Try to get make and model via SNMP
if host:
- os.environ["HOST"] = host
- cmd = '/usr/lib/cups/backend/snmp "${HOST}"'
- debugprint (host + ": " + cmd)
+ args = ["/usr/lib/cups/backend/snmp", host]
+ debugprint (host + ": " + args)
stdout = None
try:
- p = subprocess.Popen (cmd, shell=True, close_fds=True,
+ p = subprocess.Popen (args, close_fds=True,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Index: system-config-printer-1.2.5/troubleshoot/CheckPrinterSanity.py
===================================================================
--- system-config-printer-1.2.5.orig/troubleshoot/CheckPrinterSanity.py
+++ system-config-printer-1.2.5/troubleshoot/CheckPrinterSanity.py
@@ -81,16 +81,17 @@ class CheckPrinterSanity(Question):
elif scheme == "smb":
u = smburi.SMBURI (uri)
(group, host, share, user, password) = u.separate ()
- os.environ['HOST'] = host
+ new_environ = os.environ.copy()
+ new_environ['LC_ALL'] = "C"
if group:
- os.environ['GROUP'] = group
- cmdline = 'LC_ALL=C nmblookup -W "$GROUP" "$HOST"'
+ args = ["nmblookup", "-W", group, host]
else:
- cmdline = 'LC_ALL=C nmblookup "$HOST"'
+ args = ["nmblookup", host]
try:
p = TimedSubprocess (parent=parent,
timeout=5000,
- args=cmdline, shell=True,
+ args=args,
+ env=new_environ,
close_fds=True,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
@@ -110,13 +111,15 @@ class CheckPrinterSanity(Question):
# Problem executing command.
pass
elif scheme == "hp":
- os.environ['URI'] = uri
+ new_environ = os.environ.copy()
+ new_environ['LC_ALL'] = "C"
+ new_environ['DISPLAY'] = ""
try:
p = TimedSubprocess (parent=parent,
timeout=3000,
- args='LC_ALL=C DISPLAY= hp-info -d"$URI"',
+ args=["hp-info", "-d" + uri,
close_fds=True,
- shell=True,
+ env=new_environ,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Index: system-config-printer-1.2.5/troubleshoot/CheckSELinux.py
===================================================================
--- system-config-printer-1.2.5.orig/troubleshoot/CheckSELinux.py
+++ system-config-printer-1.2.5/troubleshoot/CheckSELinux.py
@@ -45,17 +45,19 @@ class CheckSELinux(Question):
if not selinux.is_selinux_enabled():
return False
- paths = "/etc/cups/ /usr/lib/cups/ /usr/share/cups/"
+ paths = ["/etc/cups/", "/usr/lib/cups/", "/usr/share/cups/"]
null = file ("/dev/null", "r+")
parent = self.troubleshooter.get_window ()
contexts = {}
- restorecon_args = "LC_ALL=C " + RESTORECON + " -nvR " + paths
+ new_environ = os.environ.copy()
+ new_environ['LC_ALL'] = "C"
+ restorecon_args = [RESTORECON, "-nvR"].extend(paths)
try:
# Run restorecon -nvR
self.op = TimedSubprocess (parent=parent,
args=restorecon_args,
close_fds=True,
- shell=True,
+ env=new_environ,
stdin=null,
stdout=subprocess.PIPE,
stderr=null)
Index: system-config-printer-1.2.5/troubleshoot/CheckUSBPermissions.py
===================================================================
--- system-config-printer-1.2.5.orig/troubleshoot/CheckUSBPermissions.py
+++ system-config-printer-1.2.5/troubleshoot/CheckUSBPermissions.py
@@ -57,13 +57,16 @@ class CheckUSBPermissions(Question):
if not os.access (GETFACL, os.X_OK):
return False
+ new_environ = os.environ.copy()
+ new_environ['LC_ALL'] = "C"
+
# Run lsusb
parent = self.troubleshooter.get_window ()
try:
self.op = TimedSubprocess (parent=parent,
- args="LC_ALL=C " + LSUSB + " -v",
+ args=[LSUSB, "-v"],
close_fds=True,
- shell=True,
+ env=new_environ,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -141,10 +144,9 @@ class CheckUSBPermissions(Question):
for path in paths:
try:
self.op = TimedSubprocess (parent=parent,
- args="LC_ALL=C %s %s" % (GETFACL,
- path),
+ args=[GETFACL, path],
close_fds=True,
- shell=True,
+ env=new_environ,
stdin=file("/dev/null"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)