From: Ivan Gyurdiev <ivg2@cornell.edu>
To: selinux@tycho.nsa.gov
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
Joshua Brindle <jbrindle@tresys.com>
Subject: [ SEMANAGE ] Some seusers mapping validation
Date: Tue, 01 Nov 2005 00:59:40 -0500 [thread overview]
Message-ID: <4367044C.1000501@cornell.edu> (raw)
In-Reply-To: <4366F160.2070005@cornell.edu>
[-- Attachment #1: Type: text/plain, Size: 931 bytes --]
>
> You can see why I want (2), and most of (3) skipped in the case of
> seusers...need to add tracking of when the policy is modified.
Well... with the attached patch I need a policydb, regardless of whether
modifications occured.. otoh if no modifications, then I don't have to
call expand, which takes so long... can go through the policydb_cache
function instead (not sure if that's any faster, however..)
Changes:
- add some basic validation for seusers - abort the commit if the sename
is invalid (Selinux user does not exist). This will also prevent
deletion of users without deleting/changing the corresponding mappings
in the seusers file - it works out rather nicely.
We might also want to validate the MLS range, and the Unix name. I am
not clear on how to validate the MLS range - what's happening with the
old (local.users) MLS range? Is it deprecated? Are they supposed to
match? How to handle this?
[-- Attachment #2: libsemanage.seuser_validate.diff --]
[-- Type: text/x-patch, Size: 3341 bytes --]
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/policy_components.c new/libsemanage/src/policy_components.c
--- old/libsemanage/src/policy_components.c 2005-10-31 21:52:14.000000000 -0500
+++ new/libsemanage/src/policy_components.c 2005-11-01 00:37:31.000000000 -0500
@@ -2,6 +2,7 @@
#include "handle.h"
#include "database.h"
#include "modules.h"
+#include "seusers.h"
#include "debug.h"
#define MODE_SET 1
@@ -125,6 +126,10 @@ int semanage_commit_components(
semanage_seuser_dbase(handle)
};
+ /* Validate seusers */
+ if (semanage_seuser_validate(handle) < 0)
+ goto err;
+
for (i = 0; i < CCOUNT; i++) {
/* Flush to disk */
if (components[i]->dtable->flush(
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/seusers.c new/libsemanage/src/seusers.c
--- old/libsemanage/src/seusers.c 2005-10-31 11:09:39.000000000 -0500
+++ new/libsemanage/src/seusers.c 2005-11-01 00:46:31.000000000 -0500
@@ -5,9 +5,12 @@ typedef semanage_seuser_t record_t;
#define DBASE_RECORD_DEFINED
#include <stddef.h>
-#include <semanage/seusers.h>
+#include <semanage/user_record.h>
+#include <semanage/users_policy.h>
+#include "seusers.h"
#include "handle.h"
#include "database.h"
+#include "debug.h"
int semanage_seuser_add(
semanage_handle_t* handle,
@@ -88,3 +91,59 @@ int semanage_seuser_list(
dbase_config_t* dconfig = semanage_seuser_dbase(handle);
return dbase_list(handle, dconfig, records, count);
}
+
+
+struct validate_handler_arg {
+ semanage_handle_t* handle;
+};
+
+static int validate_handler(
+ semanage_seuser_t* seuser,
+ void* varg) {
+
+ struct validate_handler_arg* arg =
+ (struct validate_handler_arg*) varg;
+
+ const char* name = semanage_seuser_get_name(seuser);
+ const char* sename = semanage_seuser_get_sename(seuser);
+ const char* mls_range = semanage_seuser_get_mlsrange(seuser);
+
+ semanage_user_key_t* key = NULL;
+ int exists;
+ if (semanage_user_key_create(arg->handle, sename, &key) < 0)
+ goto err;
+
+ if (semanage_user_exists(arg->handle, key, &exists) < 0)
+ goto err;
+
+ if (!exists) {
+ ERR(arg->handle, "selinux user %s does not exist", sename);
+ goto invalid;
+ }
+
+ /* FIXME: check unix user? */
+ /* FIXME: add MLS checks */
+
+ semanage_user_key_free(key);
+ return 0;
+
+ err:
+ ERR(arg->handle, "could not check if the seuser mapping "
+ "%s -> (%s, %s) is valid", name, sename, mls_range);
+ semanage_user_key_free(key);
+ return -1;
+
+ invalid:
+ ERR(arg->handle, "seuser mapping %s -> (%s, %s) is invalid",
+ name, sename, mls_range);
+ semanage_user_key_free(key);
+ return -1;
+}
+
+int semanage_seuser_validate(
+ semanage_handle_t* handle) {
+
+ struct validate_handler_arg arg;
+ arg.handle = handle;
+ return semanage_seuser_iterate(handle, validate_handler, &arg);
+}
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/seusers.h new/libsemanage/src/seusers.h
--- old/libsemanage/src/seusers.h 1969-12-31 19:00:00.000000000 -0500
+++ new/libsemanage/src/seusers.h 2005-11-01 00:37:02.000000000 -0500
@@ -0,0 +1,9 @@
+#ifndef _SEUSERS_INTERNAL_H_
+#define _SEUSERS_INTERNAL_H_
+
+#include <semanage/seusers.h>
+
+extern int semanage_seuser_validate(
+ semanage_handle_t* handle);
+
+#endif
next prev parent reply other threads:[~2005-11-01 5:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-01 4:24 [ SEMANAGE ] Fix MLS parsing of users Ivan Gyurdiev
2005-11-01 4:38 ` Ivan Gyurdiev
2005-11-01 5:59 ` Ivan Gyurdiev [this message]
2005-11-01 6:03 ` [ SEMANAGE ] Some seusers mapping validation Ivan Gyurdiev
2005-11-01 17:17 ` Stephen Smalley
2005-11-01 19:50 ` Stephen Smalley
2005-11-02 8:20 ` Ivan Gyurdiev
2005-11-01 21:24 ` Stephen Smalley
2005-11-01 17:16 ` [ SEMANAGE ] Fix MLS parsing of users Stephen Smalley
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=4367044C.1000501@cornell.edu \
--to=ivg2@cornell.edu \
--cc=jbrindle@tresys.com \
--cc=sds@tycho.nsa.gov \
--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.