add removable_context path
This commit is contained in:
parent
0474ff5fef
commit
dfa5fafe1b
@ -1,101 +1,64 @@
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchmediacon.c libselinux-1.17.10/src/matchmediacon.c
|
||||
--- nsalibselinux/src/matchmediacon.c 1969-12-31 19:00:00.000000000 -0500
|
||||
+++ libselinux-1.17.10/src/matchmediacon.c 2004-09-10 14:40:16.000000000 -0400
|
||||
@@ -0,0 +1,65 @@
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <string.h>
|
||||
+#include "selinux_internal.h"
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <ctype.h>
|
||||
+#include <errno.h>
|
||||
+#include <limits.h>
|
||||
+#include <regex.h>
|
||||
+#include <stdarg.h>
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/include/selinux/selinux.h libselinux-1.17.12/include/selinux/selinux.h
|
||||
--- nsalibselinux/include/selinux/selinux.h 2004-09-14 09:31:35.000000000 -0400
|
||||
+++ libselinux-1.17.12/include/selinux/selinux.h 2004-09-15 16:36:13.000000000 -0400
|
||||
@@ -197,6 +197,7 @@
|
||||
policy root directory. */
|
||||
extern const char *selinux_binary_policy_path(void);
|
||||
extern const char *selinux_failsafe_context_path(void);
|
||||
+extern const char *selinux_removable_context_path(void);
|
||||
extern const char *selinux_default_context_path(void);
|
||||
extern const char *selinux_user_contexts_path(void);
|
||||
extern const char *selinux_file_context_path(void);
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/src/compat_file_path.h libselinux-1.17.12/src/compat_file_path.h
|
||||
--- nsalibselinux/src/compat_file_path.h 2004-09-14 09:31:35.000000000 -0400
|
||||
+++ libselinux-1.17.12/src/compat_file_path.h 2004-09-15 16:41:01.000000000 -0400
|
||||
@@ -8,3 +8,5 @@
|
||||
S_(DEFAULT_TYPE, SECURITYDIR "/default_type")
|
||||
S_(BOOLEANS, SECURITYDIR "/booleans")
|
||||
S_(MEDIA_CONTEXTS, SECURITYDIR "/default_media")
|
||||
+S_(REMOVABLE_CONTEXT, SECURITYDIR "/removable_context")
|
||||
+
|
||||
+int matchmediacon(const char *media,
|
||||
+ security_context_t *con)
|
||||
+{
|
||||
+ const char *path = selinux_media_context_path();
|
||||
+ FILE *infile;
|
||||
+ char *ptr, *ptr2;
|
||||
+ char *target;
|
||||
+ int found=-1;
|
||||
+ char current_line[PATH_MAX];
|
||||
+ if ((infile = fopen(path, "r")) == NULL)
|
||||
+ return -1;
|
||||
+ while (!feof_unlocked (infile)) {
|
||||
+ if (!fgets_unlocked(current_line, sizeof(current_line), infile)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (current_line[strlen(current_line) - 1])
|
||||
+ current_line[strlen(current_line) - 1] = 0;
|
||||
+ /* Skip leading whitespace before the partial context. */
|
||||
+ ptr = current_line;
|
||||
+ while (*ptr && isspace(*ptr))
|
||||
+ ptr++;
|
||||
+
|
||||
+ if (!(*ptr))
|
||||
+ continue;
|
||||
+
|
||||
+
|
||||
+ /* Find the end of the media context. */
|
||||
+ ptr2 = ptr;
|
||||
+ while (*ptr2 && !isspace(*ptr2))
|
||||
+ ptr2++;
|
||||
+ if (!(*ptr2))
|
||||
+ continue;
|
||||
+
|
||||
+ *ptr2++=NULL;
|
||||
+ if (strcmp (media, ptr) == 0) {
|
||||
+ found = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (!found)
|
||||
+ return -1;
|
||||
+
|
||||
+ /* Skip whitespace. */
|
||||
+ while (*ptr2 && isspace(*ptr2))
|
||||
+ ptr2++;
|
||||
+ if (!(*ptr2)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *con = strdup(ptr2);
|
||||
+ return 0;
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/src/file_path_suffixes.h libselinux-1.17.12/src/file_path_suffixes.h
|
||||
--- nsalibselinux/src/file_path_suffixes.h 2004-09-14 09:31:35.000000000 -0400
|
||||
+++ libselinux-1.17.12/src/file_path_suffixes.h 2004-09-15 16:38:30.000000000 -0400
|
||||
@@ -8,3 +8,4 @@
|
||||
S_(DEFAULT_TYPE, "/contexts/default_type")
|
||||
S_(BOOLEANS, "/booleans")
|
||||
S_(MEDIA_CONTEXTS, "/contexts/files/media")
|
||||
+S_(REMOVABLE_CONTEXT, "/contexts/removable_context")
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_config.c libselinux-1.17.12/src/selinux_config.c
|
||||
--- nsalibselinux/src/selinux_config.c 2004-09-14 09:31:36.000000000 -0400
|
||||
+++ libselinux-1.17.12/src/selinux_config.c 2004-09-15 16:39:02.000000000 -0400
|
||||
@@ -25,7 +25,8 @@
|
||||
#define DEFAULT_TYPE 6
|
||||
#define BOOLEANS 7
|
||||
#define MEDIA_CONTEXTS 8
|
||||
-#define NEL 9
|
||||
+#define REMOVABLE_CONTEXT 9
|
||||
+#define NEL 10
|
||||
|
||||
/* New layout is relative to SELINUXDIR/policytype. */
|
||||
static char *file_paths[NEL];
|
||||
@@ -192,6 +193,11 @@
|
||||
}
|
||||
hidden_def(selinux_failsafe_context_path)
|
||||
|
||||
+const char *selinux_removable_context_path() {
|
||||
+ return get_path(REMOVABLE_CONTEXT);
|
||||
+}
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/utils/matchmediacon.c libselinux-1.17.10/utils/matchmediacon.c
|
||||
--- nsalibselinux/utils/matchmediacon.c 1969-12-31 19:00:00.000000000 -0500
|
||||
+++ libselinux-1.17.10/utils/matchmediacon.c 2004-09-10 14:40:17.000000000 -0400
|
||||
@@ -0,0 +1,28 @@
|
||||
+#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <selinux/selinux.h>
|
||||
+#include <errno.h>
|
||||
+#include <string.h>
|
||||
+hidden_def(selinux_removable_context_path)
|
||||
+
|
||||
+int main(int argc, char **argv)
|
||||
+{
|
||||
+ char *buf;
|
||||
+ int rc, i;
|
||||
+
|
||||
+ if (argc < 2) {
|
||||
+ fprintf(stderr, "usage: %s media...\n", argv[0]);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 1; i < argc; i++) {
|
||||
+ rc = matchmediacon(argv[i], &buf);
|
||||
+ if (rc < 0) {
|
||||
+ fprintf(stderr, "%s: matchmediacon(%s) failed: %s\n", argv[0], argv[i]);
|
||||
+ exit(2);
|
||||
+ }
|
||||
+ printf("%s\t%s\n", argv[i], buf);
|
||||
+ freecon(buf);
|
||||
+ }
|
||||
+ exit(0);
|
||||
+}
|
||||
const char *selinux_binary_policy_path() {
|
||||
return get_path(BINPOLICY);
|
||||
}
|
||||
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_internal.h libselinux-1.17.12/src/selinux_internal.h
|
||||
--- nsalibselinux/src/selinux_internal.h 2004-08-25 08:44:17.000000000 -0400
|
||||
+++ libselinux-1.17.12/src/selinux_internal.h 2004-09-15 16:32:14.000000000 -0400
|
||||
@@ -16,6 +16,7 @@
|
||||
hidden_proto(security_getenforce)
|
||||
hidden_proto(selinux_default_context_path)
|
||||
hidden_proto(selinux_failsafe_context_path)
|
||||
+hidden_proto(selinux_removable_context_path)
|
||||
hidden_proto(selinux_file_context_path)
|
||||
hidden_proto(selinux_user_contexts_path)
|
||||
hidden_proto(selinux_booleans_path)
|
||||
|
@ -1,10 +1,11 @@
|
||||
Summary: SELinux library and simple utilities
|
||||
Name: libselinux
|
||||
Version: 1.17.12
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: Public domain (uncopyrighted)
|
||||
Group: System Environment/Libraries
|
||||
Source: http://www.nsa.gov/selinux/archives/libselinux-%{version}.tgz
|
||||
Patch: libselinux-rhat.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
|
||||
|
||||
%description
|
||||
@ -33,6 +34,7 @@ needed for developing SELinux applications.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch -p1 -b .rhat
|
||||
|
||||
%build
|
||||
make CFLAGS="%{optflags}"
|
||||
@ -67,6 +69,9 @@ rm -rf ${RPM_BUILD_ROOT}
|
||||
%{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Thu Sep 16 2004 Dan Walsh <dwalsh@redhat.com> 1.17.12-2
|
||||
- Add selinux_removable_context_path
|
||||
|
||||
* Tue Sep 14 2004 Dan Walsh <dwalsh@redhat.com> 1.17.12-1
|
||||
- Update from NSA
|
||||
* Add matchmediacon
|
||||
|
Loading…
Reference in New Issue
Block a user