diff --git libselinux-2.8/man/man3/selinux_boolean_sub.3 libselinux-2.8/man/man3/selinux_boolean_sub.3 index 308c268..a29a38d 100644 --- libselinux-2.8/man/man3/selinux_boolean_sub.3 +++ libselinux-2.8/man/man3/selinux_boolean_sub.3 @@ -1,6 +1,6 @@ .TH "selinux_boolean_sub" "3" "11 June 2012" "dwalsh@redhat.com" "SELinux API documentation" .SH "NAME" -selinux_boolean_sub \- +selinux_boolean_sub \- Search the translated name for a boolean_name record . .SH "SYNOPSIS" .B #include @@ -12,7 +12,7 @@ selinux_boolean_sub \- searches the .I \%/etc/selinux/{POLICYTYPE}/booleans.subs_dist file -for a maching boolean_name record. If the record exists the boolean substitution name is returned. If not +for a matching boolean_name record. If the record exists the boolean substitution name is returned. If not .BR \%selinux_boolean_sub () returns the original .IR \%boolean_name . diff --git libselinux-2.8/man/man3/selinux_restorecon_xattr.3 libselinux-2.8/man/man3/selinux_restorecon_xattr.3 index 7280c95..516d266 100644 --- libselinux-2.8/man/man3/selinux_restorecon_xattr.3 +++ libselinux-2.8/man/man3/selinux_restorecon_xattr.3 @@ -119,7 +119,7 @@ By default .BR selinux_restorecon_xattr (3) will use the default set of specfiles described in .BR files_contexts (5) -to calculate the initial SHA1 digest to be used for comparision. +to calculate the initial SHA1 digest to be used for comparison. To change this default behavior .BR selabel_open (3) must be called specifying the required diff --git libselinux-2.8/man/man5/selabel_file.5 libselinux-2.8/man/man5/selabel_file.5 index e738824..e97bd82 100644 --- libselinux-2.8/man/man5/selabel_file.5 +++ libselinux-2.8/man/man5/selabel_file.5 @@ -92,7 +92,7 @@ The optional local and distribution substitution files that perform any path ali .RE .sp The default file context series of files are: -.RS +.RS 6 .I /etc/selinux/{SELINUXTYPE}/contexts/files/file_contexts .br .I /etc/selinux/{SELINUXTYPE}/contexts/files/file_contexts.local diff --git libselinux-2.8/man/man8/selinux.8 libselinux-2.8/man/man8/selinux.8 index e37aee6..bf23b65 100644 --- libselinux-2.8/man/man8/selinux.8 +++ libselinux-2.8/man/man8/selinux.8 @@ -91,11 +91,13 @@ This manual page was written by Dan Walsh . .BR sepolicy (8), .BR system-config-selinux (8), .BR togglesebool (8), -.BR restorecon (8), .BR fixfiles (8), +.BR restorecon (8), .BR setfiles (8), .BR semanage (8), .BR sepolicy (8) +.BR seinfo (8), +.BR sesearch (8) Every confined service on the system has a man page in the following format: .br diff --git libselinux-2.8/src/audit2why.c libselinux-2.8/src/audit2why.c index 0331fdf..5a1e69a 100644 --- libselinux-2.8/src/audit2why.c +++ libselinux-2.8/src/audit2why.c @@ -354,7 +354,7 @@ static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args /* iterate over items of the list, grabbing strings, and parsing for numbers */ for (i=0; ilr.ctx_trans); } free(catalog); + fclose(filp); return NULL; } diff --git libselinux-2.8/src/label_file.c libselinux-2.8/src/label_file.c index 560d8c3..21c8d36 100644 --- libselinux-2.8/src/label_file.c +++ libselinux-2.8/src/label_file.c @@ -317,8 +317,10 @@ end_arch_check: goto out; } rc = next_entry(str_buf, mmap_area, entry_len); - if (rc < 0) + if (rc < 0) { + free(str_buf); goto out; + } if (str_buf[entry_len - 1] != '\0') { free(str_buf); diff --git libselinux-2.8/src/load_policy.c libselinux-2.8/src/load_policy.c index e9f1264..20052be 100644 --- libselinux-2.8/src/load_policy.c +++ libselinux-2.8/src/load_policy.c @@ -262,8 +262,10 @@ checkbool: rc = security_get_boolean_names(&names, &len); if (!rc) { values = malloc(sizeof(int) * len); - if (!values) + if (!values) { + free(names); goto unmap; + } for (i = 0; i < len; i++) values[i] = security_get_boolean_active(names[i]); diff --git libselinux-2.8/src/lsetfilecon.c libselinux-2.8/src/lsetfilecon.c index 1d3b28a..ea6d70b 100644 --- libselinux-2.8/src/lsetfilecon.c +++ libselinux-2.8/src/lsetfilecon.c @@ -9,8 +9,13 @@ int lsetfilecon_raw(const char *path, const char * context) { - int rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, - 0); + int rc; + if (! context) { + errno=EINVAL; + return -1; + } + + rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0); if (rc < 0 && errno == ENOTSUP) { char * ccontext = NULL; int err = errno; diff --git libselinux-2.8/src/selinux_config.c libselinux-2.8/src/selinux_config.c index 292728f..b06cb63 100644 --- libselinux-2.8/src/selinux_config.c +++ libselinux-2.8/src/selinux_config.c @@ -177,8 +177,7 @@ static void init_selinux_config(void) if (!strncasecmp(buf_p, SELINUXTYPETAG, sizeof(SELINUXTYPETAG) - 1)) { - selinux_policytype = type = - strdup(buf_p + sizeof(SELINUXTYPETAG) - 1); + type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1); if (!type) return; end = type + strlen(type) - 1; @@ -187,6 +186,11 @@ static void init_selinux_config(void) *end = 0; end--; } + if (setpolicytype(type) != 0) { + free(type); + return; + } + free(type); continue; } else if (!strncmp(buf_p, SETLOCALDEFS, sizeof(SETLOCALDEFS) - 1)) { @@ -212,13 +216,10 @@ static void init_selinux_config(void) fclose(fp); } - if (!type) { - selinux_policytype = type = strdup(SELINUXDEFAULT); - if (!type) - return; - } + if (!selinux_policytype && setpolicytype(SELINUXDEFAULT) != 0) + return; - if (asprintf(&selinux_policyroot, "%s%s", SELINUXDIR, type) == -1) + if (asprintf(&selinux_policyroot, "%s%s", SELINUXDIR, selinux_policytype) == -1) return; for (i = 0; i < NEL; i++) diff --git libselinux-2.8/src/selinux_restorecon.c libselinux-2.8/src/selinux_restorecon.c index ced4115..8714a70 100644 --- libselinux-2.8/src/selinux_restorecon.c +++ libselinux-2.8/src/selinux_restorecon.c @@ -350,12 +350,19 @@ static int add_xattr_entry(const char *directory, bool delete_nonmatch, new_entry->next = NULL; new_entry->directory = strdup(directory); - if (!new_entry->directory) + if (!new_entry->directory) { + free(new_entry); + free(sha1_buf); goto oom; + } new_entry->digest = strdup(sha1_buf); - if (!new_entry->digest) + if (!new_entry->digest) { + free(new_entry->directory); + free(new_entry); + free(sha1_buf); goto oom; + } new_entry->result = digest_result; @@ -849,6 +856,7 @@ int selinux_restorecon(const char *pathname_orig, if (lstat(pathname, &sb) < 0) { if (flags.ignore_noent && errno == ENOENT) { + free(xattr_value); free(pathdnamer); free(pathname); return 0; diff --git libselinux-2.8/src/setfilecon.c libselinux-2.8/src/setfilecon.c index d05969c..3f0200e 100644 --- libselinux-2.8/src/setfilecon.c +++ libselinux-2.8/src/setfilecon.c @@ -9,8 +9,12 @@ int setfilecon_raw(const char *path, const char * context) { - int rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, - 0); + int rc; + if (! context) { + errno=EINVAL; + return -1; + } + rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0); if (rc < 0 && errno == ENOTSUP) { char * ccontext = NULL; int err = errno; diff --git libselinux-2.8/utils/matchpathcon.c libselinux-2.8/utils/matchpathcon.c index 67e4a43..9756d7d 100644 --- libselinux-2.8/utils/matchpathcon.c +++ libselinux-2.8/utils/matchpathcon.c @@ -14,7 +14,7 @@ static __attribute__ ((__noreturn__)) void usage(const char *progname) { fprintf(stderr, - "usage: %s [-N] [-n] [-f file_contexts] [ -P policy_root_path ] [-p prefix] [-Vq] path...\n", + "usage: %s [-V] [-N] [-n] [-m type] [-f file_contexts_file] [-p prefix] [-P policy_root_path] filepath...\n", progname); exit(1); }