- Another go at avoiding AVC messages on boot (bug #244205).

This commit is contained in:
Tim Waugh 2007-06-28 15:34:25 +00:00
parent 3aab01c3fd
commit 26d55153b4
2 changed files with 11 additions and 13 deletions

View File

@ -1,28 +1,23 @@
--- hplip-1.7.4a/base/g.py.no-root-config 2007-06-14 15:40:43.000000000 +0100
+++ hplip-1.7.4a/base/g.py 2007-06-14 15:43:21.000000000 +0100
@@ -88,6 +88,16 @@
+++ hplip-1.7.4a/base/g.py 2007-06-28 16:33:47.000000000 +0100
@@ -88,6 +88,10 @@
dict.__setattr__(self, "config_obj", ConfigParser.ConfigParser())
dict.__setattr__(self, "filename", filename)
+ if filename.startswith ("/root/"):
+ import sys, posixpath
+ argv0 = sys.argv[0]
+ name = posixpath.basename (argv0)
+ if name == "hp" or name == "hpfax":
+ # Don't try opening a file in root's home directory. We are
+ # running as a CUPS backend, and doing so would cause an
+ # SELinux AVC message (bug #241776).
+ return
+ if filename.startswith ("/root/") or os.getuid () == 0:
+ # Don't try opening a file in root's home directory.
+ return
+
try:
pathmode = os.stat(filename)[stat.ST_MODE]
if pathmode & 0022 != 0:
@@ -129,7 +139,8 @@
@@ -129,7 +133,9 @@
prop.sys_config_file = '/etc/hp/hplip.conf'
prop.user_config_file = os.path.expanduser('~/.hplip.conf')
-if not os.path.exists(prop.user_config_file):
+if (not prop.user_config_file.startswith ("/root/") and
+ not os.getuid () == 0 and
+ not os.path.exists(prop.user_config_file)):
try:
file(prop.user_config_file, 'w').close()

View File

@ -1,7 +1,7 @@
Summary: HP Linux Imaging and Printing Project
Name: hplip
Version: 1.7.4a
Release: 2%{?dist}
Release: 3%{?dist}
License: GPL/MIT/BSD
Group: System Environment/Daemons
Conflicts: system-config-printer < 0.6.132
@ -289,6 +289,9 @@ fi
exit 0
%changelog
* Thu Jun 28 2007 Tim Waugh <twaugh@redhat.com> 1.7.4a-3
- Another go at avoiding AVC messages on boot (bug #244205).
* Thu Jun 14 2007 Tim Waugh <twaugh@redhat.com> 1.7.4a-2
- Don't try to write a /root/.hplip.conf file when running as a CUPS
backend (bug #244205).