From: Russell Coker <rcoker@redhat.com>
To: SE Linux <selinux@tycho.nsa.gov>
Subject: genhomedircon
Date: Wed, 16 Jun 2004 16:08:40 +1000 [thread overview]
Message-ID: <200406161608.40075.rcoker@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
I have made some minor changes to genhomedircon (attached a diff against the
Fedora version and a copy of the modified script).
This improves the error handling code to make it clear when an error condition
is caused by bad parameters and when it's by an internal error. It also
fixes a bug so that now the following line in the "users" file will be
accepted and not cause the program to abort:
user root roles user_r;
Previously it demanded the following instead:
user root roles { user_r };
--
http://apac.redhat.com/disclaimer
See above URL for disclaimer.
[-- Attachment #2: g.diff --]
[-- Type: text/x-diff, Size: 1918 bytes --]
--- genhomedircon.orig 2004-06-16 16:04:11.000000000 +1000
+++ genhomedircon 2004-06-16 16:00:59.000000000 +1000
@@ -51,7 +51,10 @@
if user[1] == "user_u" or user[1] == "system_u":
continue
# !!! chooses first role in the list to use in the file context !!!
- role = user[4].split("_r")[0]
+ role = user[3]
+ if role == "{":
+ role = user[4]
+ role = role.split("_r")[0]
home = pwd.getpwnam(user[1])[5]
if home == "/":
continue
@@ -70,18 +73,24 @@
sys.stderr.flush()
sys.exit(1)
+def errorExit(error):
+ sys.stderr.write("%s exiting for: " % sys.argv[0])
+ sys.stderr.write("%s\n" % error)
+ sys.stderr.flush()
+ sys.exit(1)
+
def update(filecontext, user, prefs):
rc=commands.getstatusoutput("grep -h '^HOME_DIR' %s | grep -v vmware | sed -e 's|HOME_DIR|%s|' -e 's/ROLE/%s/' -e 's/system_u/%s/'" % (filecontext, prefs["home"], prefs["role"], user))
if rc[0] == 0:
print rc[1]
else:
- usage(rc[1])
+ errorExit(join("grep/sed error ", rc[1]))
return rc
try:
if len(sys.argv) != 3:
print len(sys.argv)
- usage()
+ usage("Incorrect parameters")
FILECONTEXTDIR=sys.argv[1]
prefixes = getPrefixes()
@@ -91,8 +100,7 @@
homedir = rc[1].split("=")[1]
else:
sys.stderr.write("%s\n" % (rc[1],))
- sys.stderr.write("You do not have access to /etc/default/useradd
-, default /home\n")
+ sys.stderr.write("You do not have access to /etc/default/useradd, default /home\n")
sys.stderr.flush()
homedir = "/home"
@@ -109,7 +117,7 @@
if rc[0] == 0:
print rc[1]
else:
- usage(rc[1])
+ errorExit(join("sed error ", rc[1]))
users = getUsers()
print "\n#\n# User-specific file contexts\n#\n"
@@ -118,6 +126,6 @@
for u in users.keys():
update(sys.argv[2], u, users[u])
except ValueError, error:
- usage(error)
+ errorExit(join("ValueError ", error))
except IndexError, error:
- usage()
+ errorExit("IndexError")
[-- Attachment #3: genhomedircon --]
[-- Type: application/x-python, Size: 4117 bytes --]
next reply other threads:[~2004-06-16 6:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-16 6:08 Russell Coker [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-07-19 13:02 genhomedircon Russell Coker
2004-08-20 11:52 genhomedircon Russell Coker
2006-05-19 10:28 genhomedircon Russell Coker
2006-05-19 14:09 ` genhomedircon Christopher J. PeBenito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200406161608.40075.rcoker@redhat.com \
--to=rcoker@redhat.com \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.