All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: SELinux List <SELinux@tycho.nsa.gov>
Cc: Stephen Smalley <sds@tycho.nsa.gov>, Daniel J Walsh <dwalsh@redhat.com>
Subject: [SEMANAGE(tool)] Further exists/query bugfixes
Date: Sat, 24 Dec 2005 16:28:41 -0500	[thread overview]
Message-ID: <43ADBD89.9080900@cornell.edu> (raw)

[-- 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=""

                 reply	other threads:[~2005-12-24 21:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=43ADBD89.9080900@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=SELinux@tycho.nsa.gov \
    --cc=dwalsh@redhat.com \
    --cc=sds@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.