- Add backin matchpathcon

This commit is contained in:
Daniel J Walsh 2005-04-21 14:20:57 +00:00
parent ce82f572f7
commit 4ff3f08454
2 changed files with 81 additions and 26 deletions

View File

@ -1,6 +1,5 @@
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_policy_root.3 libselinux-1.23.7/man/man3/selinux_policy_root.3 --- /dev/null 2005-04-20 05:34:52.522685192 -0400
--- nsalibselinux/man/man3/selinux_policy_root.3 1969-12-31 19:00:00.000000000 -0500 +++ libselinux-1.23.7/man/man3/selinux_policy_root.3 2005-04-21 09:54:24.000000000 -0400
+++ libselinux-1.23.7/man/man3/selinux_policy_root.3 2005-04-13 15:02:22.000000000 -0400
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
+.TH "selinux_policy_root" "3" "25 May 2004" "dwalsh@redhat.com" "SE Linux API documentation" +.TH "selinux_policy_root" "3" "25 May 2004" "dwalsh@redhat.com" "SE Linux API documentation"
+.SH "NAME" +.SH "NAME"
@ -19,24 +18,78 @@ diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_policy_root.
+On failure, NULL is returned. +On failure, NULL is returned.
+ +
+ +
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_policyroot.3 libselinux-1.23.7/man/man3/selinux_policyroot.3 --- libselinux-1.23.7/man/man8/matchpathcon.8.rhat 2005-04-21 10:05:45.000000000 -0400
--- nsalibselinux/man/man3/selinux_policyroot.3 2004-10-20 16:31:36.000000000 -0400 +++ libselinux-1.23.7/man/man8/matchpathcon.8 2005-04-21 10:12:24.000000000 -0400
+++ libselinux-1.23.7/man/man3/selinux_policyroot.3 1969-12-31 19:00:00.000000000 -0500 @@ -0,0 +1,20 @@
@@ -1,17 +0,0 @@ +.TH "matchpathcon" "8" "21 April 2005" "dwalsh@redhat.com" "SE Linux Command Line documentation"
-.TH "selinux_policyroot" "3" "25 May 2004" "dwalsh@redhat.com" "SE Linux API documentation" +.SH "NAME"
-.SH "NAME" +matchpathcon \- get the default security context for the specified path from the file contexts configuration.
-selinux_policyroot \- return the path of the SELinux policy files for this machine. +
-.SH "SYNOPSIS" +.SH "SYNOPSIS"
-.B #include <selinux/selinux.h> +.B matchpathcon [-n] filepath...
-.sp +
-.B char *selinux_policyroot(); +.SH "DESCRIPTION"
-.br +.B matchpathcon
- +Prints the file path and the default security context associated with it.
-.SH "DESCRIPTION" +.br
-.B selinux_policyroot +If the -n option is given, do not display path.
-Reads the contents of the /etc/selinux/config file to determine which policy files should be used for this machine. +
-.SH "RETURN VALUE" +.SH AUTHOR
-On success, returns a directory path containing the SELinux policy files. +This manual page was written by Dan Walsh <dwalsh@redhat.com>.
-On failure, NULL is returned. +.br
- +The program was written by NSA
- +
+.SH "SEE ALSO"
+.BR mathpathcon "(3), "
--- libselinux-1.23.7/utils/matchpathcon.c.rhat 2005-04-13 11:34:19.000000000 -0400
+++ libselinux-1.23.7/utils/matchpathcon.c 2005-04-21 10:02:04.000000000 -0400
@@ -1,25 +1,43 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <getopt.h>
#include <selinux/selinux.h>
+void usage(const char *progname)
+{
+ fprintf(stderr, "usage: %s [-n] path...\n", progname);
+ exit(1);
+}
+
int main(int argc, char **argv)
{
char *buf;
int rc, i;
+ int header=1, opt;
- if (argc < 2) {
- fprintf(stderr, "usage: %s path...\n", argv[0]);
- return 1;
- }
+ if (argc < 2) usage(argv[0]);
- for (i = 1; i < argc; i++) {
+ while ((opt = getopt(argc, argv, "n")) > 0) {
+ switch (opt) {
+ case 'n':
+ header=0;
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+ for (i = optind; i < argc; i++) {
rc = matchpathcon(argv[i], 0, &buf);
if (rc < 0) {
fprintf(stderr, "%s: matchpathcon(%s) failed\n", argv[0], argv[i]);
return 2;
}
- printf("%s\t%s\n", argv[i], buf);
+ if (header)
+ printf("%s\t%s\n", argv[i], buf);
+ else
+ printf("%s\n", buf);
+
freecon(buf);
}
return 0;

View File

@ -1,7 +1,7 @@
Summary: SELinux library and simple utilities Summary: SELinux library and simple utilities
Name: libselinux Name: libselinux
Version: 1.23.7 Version: 1.23.7
Release: 2 Release: 3
License: Public domain (uncopyrighted) License: Public domain (uncopyrighted)
Group: System Environment/Libraries Group: System Environment/Libraries
Source: http://www.nsa.gov/selinux/archives/%{name}-%{version}.tgz Source: http://www.nsa.gov/selinux/archives/%{name}-%{version}.tgz
@ -57,7 +57,6 @@ rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getconlist
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getenforcemode rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getenforcemode
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getfilecon rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getfilecon
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getpidcon rm -f ${RPM_BUILD_ROOT}%{_sbindir}/getpidcon
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/matchpathcon
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/mkdircon rm -f ${RPM_BUILD_ROOT}%{_sbindir}/mkdircon
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/policyvers rm -f ${RPM_BUILD_ROOT}%{_sbindir}/policyvers
rm -f ${RPM_BUILD_ROOT}%{_sbindir}/setfilecon rm -f ${RPM_BUILD_ROOT}%{_sbindir}/setfilecon
@ -86,6 +85,9 @@ rm -rf ${RPM_BUILD_ROOT}
%{_mandir}/man8/* %{_mandir}/man8/*
%changelog %changelog
* Thu Apr 21 2005 Dan Walsh <dwalsh@redhat.com> 1.23.7-3
- Add backin matchpathcon
* Wed Apr 13 2005 Dan Walsh <dwalsh@redhat.com> 1.23.7-2 * Wed Apr 13 2005 Dan Walsh <dwalsh@redhat.com> 1.23.7-2
- Fix selinux_policy_root man page - Fix selinux_policy_root man page