* [PATCH -trunk][RFC] libselinux: drop setlocaldefs and preservebools support
@ 2007-04-19 18:20 Stephen Smalley
2007-04-19 18:31 ` Joshua Brindle
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2007-04-19 18:20 UTC (permalink / raw)
To: selinux; +Cc: Joshua Brindle, Karl MacMillan, Darrel Goeddel
This an RFC only, not for merging yet. It naturally depends on the kernel patch
for preserving booleans atomically, and it also likely requires a bump in the .so version.
But you need it to test the kernel support without interference from libselinux.
---
Drop setlocaldefs and preservebools support from the policy loading
code in libselinux on the trunk.
setlocaldefs (patching local user definitions and boolean settings
into the in-memory policy at load time) is obsoleted by libsemanage and
managed policy.
preservebools (preserving boolean values across a policy reload rather
than resetting to the policy defaults) will be handled by the kernel
going forward.
---
libselinux/src/load_policy.c | 47 +-------------------------------------
libselinux/src/selinux_config.c | 5 ----
libselinux/src/selinux_internal.h | 1
3 files changed, 2 insertions(+), 51 deletions(-)
Index: policyrep/libselinux/src/selinux_config.c
===================================================================
--- policyrep/libselinux/src/selinux_config.c (revision 2357)
+++ policyrep/libselinux/src/selinux_config.c (working copy)
@@ -15,7 +15,6 @@
#define SELINUXDEFAULT "targeted"
#define SELINUXTYPETAG "SELINUXTYPE="
#define SELINUXTAG "SELINUX="
-#define SETLOCALDEFS "SETLOCALDEFS="
#define REQUIRESEUSERS "REQUIRESEUSERS="
/* Indices for file paths arrays. */
@@ -165,10 +164,6 @@
end--;
}
continue;
- } else if (!strncmp(buf_p, SETLOCALDEFS,
- sizeof(SETLOCALDEFS) - 1)) {
- value = buf_p + sizeof(SETLOCALDEFS) - 1;
- intptr = &load_setlocaldefs;
} else if (!strncmp(buf_p, REQUIRESEUSERS,
sizeof(REQUIRESEUSERS) - 1)) {
value = buf_p + sizeof(REQUIRESEUSERS) - 1;
Index: policyrep/libselinux/src/load_policy.c
===================================================================
--- policyrep/libselinux/src/load_policy.c (revision 2357)
+++ policyrep/libselinux/src/load_policy.c (working copy)
@@ -39,8 +39,6 @@
hidden_def(security_load_policy)
-int load_setlocaldefs hidden = 1;
-
int selinux_mkload_policy(int preservebools)
{
int vers = sepol_policy_kern_vers_max();
@@ -49,7 +47,7 @@
struct stat sb;
size_t size;
void *map, *data;
- int fd, rc = -1, *values, len, i, prot;
+ int fd, rc = -1, *values, len, i;
sepol_policydb_t *policydb;
sepol_policy_file_t *pf;
@@ -70,12 +68,8 @@
if (fstat(fd, &sb) < 0)
goto close;
- prot = PROT_READ;
- if (load_setlocaldefs || preservebools)
- prot |= PROT_WRITE;
-
size = sb.st_size;
- data = map = mmap(NULL, size, prot, MAP_PRIVATE, fd, 0);
+ data = map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (map == MAP_FAILED)
goto close;
@@ -107,43 +101,6 @@
sepol_policydb_free(policydb);
}
- if (load_setlocaldefs) {
- void *olddata = data;
- size_t oldsize = size;
- rc = sepol_genusers(olddata, oldsize, selinux_users_path(),
- &data, &size);
- if (rc < 0) {
- /* Fall back to the prior image if genusers failed. */
- data = olddata;
- size = oldsize;
- rc = 0;
- } else {
- if (olddata != map)
- free(olddata);
- }
- }
-
- if (preservebools) {
- rc = security_get_boolean_names(&names, &len);
- if (!rc) {
- values = malloc(sizeof(int) * len);
- if (!values)
- goto unmap;
- for (i = 0; i < len; i++)
- values[i] =
- security_get_boolean_active(names[i]);
- (void)sepol_genbools_array(data, size, names, values,
- len);
- free(values);
- for (i = 0; i < len; i++)
- free(names[i]);
- free(names);
- }
- } else if (load_setlocaldefs) {
- (void)sepol_genbools(data, size,
- (char *)selinux_booleans_path());
- }
-
rc = security_load_policy(data, size);
unmap:
Index: policyrep/libselinux/src/selinux_internal.h
===================================================================
--- policyrep/libselinux/src/selinux_internal.h (revision 2357)
+++ policyrep/libselinux/src/selinux_internal.h (working copy)
@@ -79,6 +79,5 @@
hidden_proto(security_get_initial_context);
hidden_proto(security_get_initial_context_raw);
-extern int load_setlocaldefs hidden;
extern int require_seusers hidden;
extern int selinux_page_size hidden;
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH -trunk][RFC] libselinux: drop setlocaldefs and preservebools support
2007-04-19 18:20 [PATCH -trunk][RFC] libselinux: drop setlocaldefs and preservebools support Stephen Smalley
@ 2007-04-19 18:31 ` Joshua Brindle
2007-04-24 17:20 ` Stephen Smalley
0 siblings, 1 reply; 3+ messages in thread
From: Joshua Brindle @ 2007-04-19 18:31 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux, Karl MacMillan, Darrel Goeddel
Stephen Smalley wrote:
> This an RFC only, not for merging yet. It naturally depends on the kernel patch
> for preserving booleans atomically, and it also likely requires a bump in the .so version.
> But you need it to test the kernel support without interference from libselinux.
>
> ---
>
> Drop setlocaldefs and preservebools support from the policy loading
> code in libselinux on the trunk.
>
> setlocaldefs (patching local user definitions and boolean settings
> into the in-memory policy at load time) is obsoleted by libsemanage and
> managed policy.
>
> preservebools (preserving boolean values across a policy reload rather
> than resetting to the policy defaults) will be handled by the kernel
> going forward.
>
>
you should also remove the -b option from load_policy
> ---
>
> libselinux/src/load_policy.c | 47 +-------------------------------------
> libselinux/src/selinux_config.c | 5 ----
> libselinux/src/selinux_internal.h | 1
> 3 files changed, 2 insertions(+), 51 deletions(-)
>
> Index: policyrep/libselinux/src/selinux_config.c
> ===================================================================
> --- policyrep/libselinux/src/selinux_config.c (revision 2357)
> +++ policyrep/libselinux/src/selinux_config.c (working copy)
> @@ -15,7 +15,6 @@
> #define SELINUXDEFAULT "targeted"
> #define SELINUXTYPETAG "SELINUXTYPE="
> #define SELINUXTAG "SELINUX="
> -#define SETLOCALDEFS "SETLOCALDEFS="
> #define REQUIRESEUSERS "REQUIRESEUSERS="
>
> /* Indices for file paths arrays. */
> @@ -165,10 +164,6 @@
> end--;
> }
> continue;
> - } else if (!strncmp(buf_p, SETLOCALDEFS,
> - sizeof(SETLOCALDEFS) - 1)) {
> - value = buf_p + sizeof(SETLOCALDEFS) - 1;
> - intptr = &load_setlocaldefs;
> } else if (!strncmp(buf_p, REQUIRESEUSERS,
> sizeof(REQUIRESEUSERS) - 1)) {
> value = buf_p + sizeof(REQUIRESEUSERS) - 1;
> Index: policyrep/libselinux/src/load_policy.c
> ===================================================================
> --- policyrep/libselinux/src/load_policy.c (revision 2357)
> +++ policyrep/libselinux/src/load_policy.c (working copy)
> @@ -39,8 +39,6 @@
>
> hidden_def(security_load_policy)
>
> -int load_setlocaldefs hidden = 1;
> -
> int selinux_mkload_policy(int preservebools)
> {
> int vers = sepol_policy_kern_vers_max();
> @@ -49,7 +47,7 @@
> struct stat sb;
> size_t size;
> void *map, *data;
> - int fd, rc = -1, *values, len, i, prot;
> + int fd, rc = -1, *values, len, i;
> sepol_policydb_t *policydb;
> sepol_policy_file_t *pf;
>
> @@ -70,12 +68,8 @@
> if (fstat(fd, &sb) < 0)
> goto close;
>
> - prot = PROT_READ;
> - if (load_setlocaldefs || preservebools)
> - prot |= PROT_WRITE;
> -
> size = sb.st_size;
> - data = map = mmap(NULL, size, prot, MAP_PRIVATE, fd, 0);
> + data = map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
> if (map == MAP_FAILED)
> goto close;
>
> @@ -107,43 +101,6 @@
> sepol_policydb_free(policydb);
> }
>
> - if (load_setlocaldefs) {
> - void *olddata = data;
> - size_t oldsize = size;
> - rc = sepol_genusers(olddata, oldsize, selinux_users_path(),
> - &data, &size);
> - if (rc < 0) {
> - /* Fall back to the prior image if genusers failed. */
> - data = olddata;
> - size = oldsize;
> - rc = 0;
> - } else {
> - if (olddata != map)
> - free(olddata);
> - }
> - }
> -
> - if (preservebools) {
> - rc = security_get_boolean_names(&names, &len);
> - if (!rc) {
> - values = malloc(sizeof(int) * len);
> - if (!values)
> - goto unmap;
> - for (i = 0; i < len; i++)
> - values[i] =
> - security_get_boolean_active(names[i]);
> - (void)sepol_genbools_array(data, size, names, values,
> - len);
> - free(values);
> - for (i = 0; i < len; i++)
> - free(names[i]);
> - free(names);
> - }
> - } else if (load_setlocaldefs) {
> - (void)sepol_genbools(data, size,
> - (char *)selinux_booleans_path());
> - }
> -
> rc = security_load_policy(data, size);
>
> unmap:
> Index: policyrep/libselinux/src/selinux_internal.h
> ===================================================================
> --- policyrep/libselinux/src/selinux_internal.h (revision 2357)
> +++ policyrep/libselinux/src/selinux_internal.h (working copy)
> @@ -79,6 +79,5 @@
> hidden_proto(security_get_initial_context);
> hidden_proto(security_get_initial_context_raw);
>
> -extern int load_setlocaldefs hidden;
> extern int require_seusers hidden;
> extern int selinux_page_size hidden;
>
>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH -trunk][RFC] libselinux: drop setlocaldefs and preservebools support
2007-04-19 18:31 ` Joshua Brindle
@ 2007-04-24 17:20 ` Stephen Smalley
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2007-04-24 17:20 UTC (permalink / raw)
To: Joshua Brindle; +Cc: selinux, Karl MacMillan, Darrel Goeddel
On Thu, 2007-04-19 at 14:31 -0400, Joshua Brindle wrote:
> Stephen Smalley wrote:
> > This an RFC only, not for merging yet. It naturally depends on the kernel patch
> > for preserving booleans atomically, and it also likely requires a bump in the .so version.
> > But you need it to test the kernel support without interference from libselinux.
> >
> > ---
> >
> > Drop setlocaldefs and preservebools support from the policy loading
> > code in libselinux on the trunk.
> >
> > setlocaldefs (patching local user definitions and boolean settings
> > into the in-memory policy at load time) is obsoleted by libsemanage and
> > managed policy.
> >
> > preservebools (preserving boolean values across a policy reload rather
> > than resetting to the policy defaults) will be handled by the kernel
> > going forward.
> >
> >
> you should also remove the -b option from load_policy
Yes, thanks - just committed the patch below to do that.
After a bit, we'll remove the b option from the getopt call altogether
(as well as drop the other warnings that already exist for older usage
styles) and turn them all into fatal errors, but for now, we'll warn the
user to catch any lingering uses.
Index: trunk/policycoreutils/load_policy/load_policy.c
===================================================================
--- trunk/policycoreutils/load_policy/load_policy.c (revision 2357)
+++ trunk/policycoreutils/load_policy/load_policy.c (working copy)
@@ -19,13 +19,13 @@
void usage(char *progname)
{
- fprintf(stderr, _("usage: %s [-bq]\n"), progname);
+ fprintf(stderr, _("usage: %s [-q]\n"), progname);
exit(1);
}
int main(int argc, char **argv)
{
- int ret, opt, quiet = 0, preservebools = 1, nargs;
+ int ret, opt, quiet = 0, nargs;
#ifdef USE_NLS
setlocale(LC_ALL, "");
@@ -36,7 +36,8 @@
while ((opt = getopt(argc, argv, "bq")) > 0) {
switch (opt) {
case 'b':
- preservebools = 0;
+ fprintf(stderr, "%s: Warning! The -b option is no longer supported, booleans are always preserved across reloads. Continuing...\n",
+ argv[0]);
break;
case 'q':
quiet = 1;
@@ -61,7 +62,7 @@
argv[0], argv[optind++]);
}
- ret = selinux_mkload_policy(preservebools);
+ ret = selinux_mkload_policy(1);
if (ret < 0) {
fprintf(stderr, _("%s: Can't load policy: %s\n"),
argv[0], strerror(errno));
Index: trunk/policycoreutils/load_policy/load_policy.8
===================================================================
--- trunk/policycoreutils/load_policy/load_policy.8 (revision 2357)
+++ trunk/policycoreutils/load_policy/load_policy.8 (working copy)
@@ -4,19 +4,17 @@
.SH SYNOPSIS
.B load_policy
-[-bq]
+[-q]
.br
.SH DESCRIPTION
.PP
-load_policy is the tool used to load/replace the policy in the kernel.
-By default, load_policy will preserve the current policy boolean values
-when loading the policy.
+load_policy loads the installed policy file into the kernel.
+The existing policy boolean values are automatically preserved
+across policy reloads rather than being reset to the default
+values in the policy file.
.SH "OPTIONS"
.TP
-.B \-b
-reset the policy boolean values to the saved policy settings.
-.TP
.B \-q
suppress warning messages.
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-24 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-19 18:20 [PATCH -trunk][RFC] libselinux: drop setlocaldefs and preservebools support Stephen Smalley
2007-04-19 18:31 ` Joshua Brindle
2007-04-24 17:20 ` Stephen Smalley
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.