* [SEMANAGE(tool)] Further exists/query bugfixes
@ 2005-12-24 21:28 Ivan Gyurdiev
0 siblings, 0 replies; only message in thread
From: Ivan Gyurdiev @ 2005-12-24 21:28 UTC (permalink / raw)
To: SELinux List; +Cc: Stephen Smalley, Daniel J Walsh
[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]
Changes:
- do not rely on query failure to check if a user exists - should use
exist function instead
(especially since the rc value is now not 0, and returns commit numbers
on success).
- Initialize level/range to "", not s0, in order for modify() to
correctly detect that the user didn't enter anything
(because it tests if serange == "", which it doesn't)
Note: I notice the rc value isn't checked in 95% of the semanage
functions being called.
Note2: The list function needs to be re-written somehow... not entirely
sure how. Delete function needs more work.
First, there should be an indication somewhere whether a record is build
into policy, or locally added, so the user will realize what he/she can
do with the record. Second, consider the following scenario, which
causes total confusion: (1) call list users, (2) call modify on root
(built-in), (3) call list users, (4) call delete root, (5) call list users.
Here's what happens:
1) lists all local users + builtin users (like root)
2) modify will succeed, because you can modify in-policy records by
writing a local record that overrides them
3) list will now show the modifications (and not show the original)
4) delete WILL succeed. Consider the checks I put in:
Does the user exist: yes
Does the user exist locally: yes
In this case, the effect of delete is to delete the local
modifications to the root user, but the in-policy copy remains behind.
5) now list shows the original root user
All of those problems are related to the fact that we're stacking local
modifications on top of policy. Libsemanage provides info about the
local data, and the end result (does not provide info about policy
alone). Semnage (the tool) provides info only about the end result, and
shows neither policy alone, nor local modifications alone.
[-- Attachment #2: semanage2.query_exists_bugfixes.diff --]
[-- Type: text/x-patch, Size: 1968 bytes --]
diff -Naurp --exclude-from excludes old/policycoreutils/semanage/semanage new/policycoreutils/semanage/semanage
--- old/policycoreutils/semanage/semanage 2005-12-24 15:24:02.000000000 -0500
+++ new/policycoreutils/semanage/semanage 2005-12-24 15:58:45.000000000 -0500
@@ -50,9 +50,10 @@ class loginRecords:
def modify(self, name, sename="", serange=""):
(rc,k)=semanage_seuser_key_create(self.sh, name)
- (rc,u)= semanage_seuser_query(self.sh, k)
- if rc !=0 :
+ (rc,exists) = semanage_seuser_exists(self.sh, k)
+ if not exists:
raise ValueError("SELinux user %s mapping is not defined." % name)
+ (rc,u)= semanage_seuser_query(self.sh, k)
if sename == "" and serange=="":
raise ValueError("Requires, seuser or serange")
if serange != "":
@@ -68,7 +69,7 @@ class loginRecords:
def delete(self, name):
(rc,k)=semanage_seuser_key_create(self.sh, name)
(rc,exists)= semanage_seuser_exists(self.sh, k)
- if rc !=0 :
+ if not exists:
raise ValueError("SELinux user %s mapping is not defined." % name)
semanage_begin_transaction(self.sh)
semanage_seuser_del(self.sh, k)
@@ -117,8 +118,6 @@ class seluserRecords:
if not exists:
raise ValueError("user %s is not defined" % name)
(rc,u)= semanage_user_query(self.sh, k)
- if rc !=0 :
- raise ValueError("User %s is not defined." % name)
if len(roles) == 0 and serange=="" and selevel=="":
raise ValueError("Requires, roles, level or range")
if serange != "":
@@ -133,7 +132,6 @@ class seluserRecords:
semanage_user_modify_local(self.sh, k, u)
if semanage_commit(self.sh) != 0:
raise ValueError("Failed to modify SELinux user")
-
def delete(self, name):
(rc,k)=semanage_user_key_create(self.sh, name)
@@ -251,8 +249,8 @@ semanage port [-admth] SELINUX_PORT_NAME
objectlist=("login", "user", "port")
input=sys.stdin
output=sys.stdout
- serange="s0"
- selevel="s0"
+ serange=""
+ selevel=""
roles=""
seuser=""
type=""
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-12-24 21:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-24 21:28 [SEMANAGE(tool)] Further exists/query bugfixes Ivan Gyurdiev
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.