- Applied Russell Coker's selinux changes (bug #157856).

This commit is contained in:
Tim Waugh 2005-05-16 15:12:40 +00:00
parent e87740cc63
commit 641654e911
2 changed files with 16 additions and 25 deletions

View File

@ -623,13 +623,13 @@
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+#include <selinux/selinux.h> +#include <selinux/selinux.h>
+int selinux_enabled= 0; +
+static int print_scontext = 0; +static int print_scontext = 0;
+#define check_selinux() if (!selinux_enabled) { \ +
+ fprintf( stderr, "Sorry, this option can only be used " \ +
+ "on a SELinux kernel.\n" ); \ +
+ exit( EXIT_FAILURE ); \ +
+} +
+ +
+#endif +#endif
+ +
@ -774,18 +774,6 @@
} }
if (dir_defaulted) if (dir_defaulted)
@@ -1223,6 +1270,11 @@
/* Record whether there is an option specifying sort type. */
int sort_type_specified = 0;
+#ifdef WITH_SELINUX
+ /* 1 iff kernel has new selinux system calls */
+ selinux_enabled= (is_selinux_enabled()>0);
+#endif
+
qmark_funny_chars = 0;
/* initialize all switches to default settings */
@@ -1273,6 +1325,9 @@ @@ -1273,6 +1325,9 @@
all_files = 0; all_files = 0;
really_all_files = 0; really_all_files = 0;
@ -811,7 +799,7 @@
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+ case 'Z': + case 'Z':
+ check_selinux(); +
+ print_scontext = 1; + print_scontext = 1;
+ format = security_format; + format = security_format;
+ break; + break;
@ -826,17 +814,17 @@
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+ +
+ case CONTEXT_OPTION: /* new security format */ + case CONTEXT_OPTION: /* new security format */
+ check_selinux(); +
+ print_scontext = 1; + print_scontext = 1;
+ format = security_format; + format = security_format;
+ break; + break;
+ case LCONTEXT_OPTION: /* long format plus security context */ + case LCONTEXT_OPTION: /* long format plus security context */
+ check_selinux(); +
+ print_scontext = 1; + print_scontext = 1;
+ format = long_format; + format = long_format;
+ break; + break;
+ case SCONTEXT_OPTION: /* short form of new security format */ + case SCONTEXT_OPTION: /* short form of new security format */
+ check_selinux(); +
+ print_scontext = 0; + print_scontext = 0;
+ format = security_format; + format = security_format;
+ break; + break;
@ -880,7 +868,7 @@
err = stat (path, &f->stat); err = stat (path, &f->stat);
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+ if (err>=0) + if (err>=0)
+ if (selinux_enabled && (format == security_format || print_scontext)) + if (format == security_format || print_scontext)
+ getfilecon(path, &f->scontext); + getfilecon(path, &f->scontext);
+#endif +#endif
break; break;
@ -892,7 +880,7 @@
err = stat (path, &f->stat); err = stat (path, &f->stat);
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+ if (err>=0) + if (err>=0)
+ if (selinux_enabled && (format == security_format || print_scontext)) + if (format == security_format || print_scontext)
+ getfilecon(path, &f->scontext); + getfilecon(path, &f->scontext);
+#endif +#endif
@ -904,7 +892,7 @@
err = lstat (path, &f->stat); err = lstat (path, &f->stat);
+#ifdef WITH_SELINUX +#ifdef WITH_SELINUX
+ if (err>=0) + if (err>=0)
+ if (selinux_enabled && (format == security_format || print_scontext)) + if (format == security_format || print_scontext)
+ lgetfilecon(path, &f->scontext); + lgetfilecon(path, &f->scontext);
+#endif +#endif
break; break;

View File

@ -255,6 +255,9 @@ fi
/sbin/runuser /sbin/runuser
%changelog %changelog
* Mon May 16 2005 Tim Waugh <twaugh@redhat.com>
- Applied Russell Coker's selinux changes (bug #157856).
* Fri Apr 8 2005 Tim Waugh <twaugh@redhat.com> * Fri Apr 8 2005 Tim Waugh <twaugh@redhat.com>
- Fixed pam patch from Steve Grubb (bug #154946). - Fixed pam patch from Steve Grubb (bug #154946).
- Use better upstream patch for "stale utmp". - Use better upstream patch for "stale utmp".