Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 71e19431ee497cf11e442b642c771018 > files > 11

hplip-3.9.2-0.1mdv2009.0.src.rpm

diff -up hplip-3.9.2/base/g.py.no-root-config hplip-3.9.2/base/g.py
--- hplip-3.9.2/base/g.py.no-root-config	2009-02-20 00:36:51.000000000 +0000
+++ hplip-3.9.2/base/g.py	2009-03-09 17:43:15.000000000 +0000
@@ -111,6 +111,10 @@ class ConfigBase(object):
 
     def read(self):
         if self.filename is not None:
+            filename = self.filename
+            if filename.startswith ("/root/") or filename.startswith ("/var/"):
+                # Don't try opening a file in root's home directory.
+                return
             try:
                 fp = open(self.filename, "r")
                 self.conf.readfp(fp)
@@ -120,6 +124,15 @@ class ConfigBase(object):
 
     def write(self):
         if self.filename is not None:
+            filename = self.filename
+            if filename.startswith ("/root/") or filename.startswith ("/var/"):
+                # Don't try writing a file in root's home directory.
+                return
+            elif filename.startswith ("/etc/"):
+                # Certainly don't try writing the system-wide config file!
+                # See bug #479178.
+                return
+
             try:
                 fp = open(self.filename, "w")
                 self.conf.write(fp)