For a long time /root has been treated differently in Red Hat Distributions then upstream policy.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
We do not want to label /root the same as a users homedir. Because of this we have carried a patch in libsemanage/genhomedircon.c to ignore /root.
This patch adds a flag to semanage.conf, ignoredirs. That will allow distributions or users to specify directories that genhomedircon should ignore when setting up users homedir labeling.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAk7qE+cACgkQrlYvE4MpobMMNQCYxFzXOJL906yDItasgrulADeD 1ACgwXjQR0tbmgWlymn5E5ch68bx5DU=
=NteG
-----END PGP SIGNATURE-----
libsemanage/man/man5/semanage.conf.5 +5 -0
@@ -56,6 +56,11 @@ It controls whether the previously linked module is saved (with name "base.linke It can be set to either "true" or "false" and by default it is set to "false" (the previous module is deleted). .TP +.B ignoredirs +List, separated by ";", of directories to ignore when setting up users homedirs. +Some distributions use this to stop labeling /root as a homedir. + +.TP .B usepasswd Whether or not to enable the use getpwent() to obtain a list of home directories to label. It can be set to either "true" or "false". By default it is set to "true".
libsemanage/src/conf-parse.y +8 -1
@@ -58,7 +58,7 @@ static int parse_errors; } %token MODULE_STORE VERSION EXPAND_CHECK FILE_MODE SAVE_PREVIOUS SAVE_LINKED -%token LOAD_POLICY_START SETFILES_START DISABLE_GENHOMEDIRCON HANDLE_UNKNOWN USEPASSWD +%token LOAD_POLICY_START SETFILES_START DISABLE_GENHOMEDIRCON HANDLE_UNKNOWN USEPASSWD IGNOREDIRS %token BZIP_BLOCKSIZE BZIP_SMALL %token VERIFY_MOD_START VERIFY_LINKED_START VERIFY_KERNEL_START BLOCK_END %token PROG_PATH PROG_ARGS
@@ -84,6 +84,7 @@ single_opt: module_store | save_linked | disable_genhomedircon | usepasswd + | ignoredirs | handle_unknown | bzip_blocksize | bzip_small
@@ -166,6 +167,10 @@ usepasswd: USEPASSWD '=' ARG { free($3); } +ignoredirs: IGNOREDIRS '=' ARG { + current_conf->ignoredirs = strdup($3); + } + handle_unknown: HANDLE_UNKNOWN '=' ARG { if (strcasecmp($3, "deny") == 0) { current_conf->handle_unknown = SEPOL_DENY_UNKNOWN;
@@ -262,6 +267,7 @@ static int semanage_conf_init(semanage_conf_t * conf) { conf->store_type = SEMANAGE_CON_DIRECT; conf->store_path = strdup(basename(semanage_policy_root())); + conf->ignoredirs = NULL; conf->policyvers = sepol_policy_kern_vers_max(); conf->expand_check = 1; conf->handle_unknown = -1;
@@ -354,6 +360,7 @@ void semanage_conf_destroy(semanage_conf_t * conf) { if (conf != NULL) { free(conf->store_path); + free(conf->ignoredirs); semanage_conf_external_prog_destroy(conf->load_policy); semanage_conf_external_prog_destroy(conf->setfiles); semanage_conf_external_prog_destroy(conf->mod_prog);
libsemanage/src/conf-scan.l +1 -0
@@ -47,6 +47,7 @@ save-previous return SAVE_PREVIOUS; save-linked return SAVE_LINKED; disable-genhomedircon return DISABLE_GENHOMEDIRCON; usepasswd return USEPASSWD; +ignoredirs return IGNOREDIRS; handle-unknown return HANDLE_UNKNOWN; bzip-blocksize return BZIP_BLOCKSIZE; bzip-small return BZIP_SMALL;
libsemanage/src/direct_api.c +1 -1
@@ -992,7 +992,7 @@ static int semanage_direct_commit(semanage_handle_t * sh)* which requires the out policydb */ if (!sh->conf->disable_genhomedircon) {if (out && (retval = -semanage_genhomedircon (sh, out, sh->conf->usepasswd)) !=0 ) { +semanage_genhomedircon (sh, out, sh->conf->usepasswd, sh->conf->ignoredirs)) !=0 ) {ERR (sh,"semanage_genhomedircon returned error code %d." , retval); goto cleanup;
libsemanage/src/genhomedircon.c +64 -1
101 lines not on this page · raw message
libsemanage/src/genhomedircon.h +2 -1
@@ -23,6 +23,7 @@#include "utilities.h" int semanage_genhomedircon (semanage_handle_t * sh, -sepol_policydb_t * policydb,int usepasswd); +sepol_policydb_t * policydb,int usepasswd, +char *ignoredirs);#endif
libsemanage/src/semanage_conf.h +1 -0
@@ -43,6 +43,7 @@ typedef struct semanage_conf {mode_t file_mode;int bzip_blocksize;int bzip_small; +char *ignoredirs;/* ";" separated of list for genhomedircon to ignore */ struct external_prog *load_policy;struct external_prog *setfiles;struct external_prog *mod_prog, *linked_prog, *kernel_prog;