All of lore.kernel.org
 help / color / mirror / Atom feed
* Adding alternate root patch to restorecon (setfiles?)
@ 2004-10-18 19:31 Daniel J Walsh
  2004-10-18 19:55 ` Stephen Smalley
  2004-10-18 20:51 ` Thomas Bleher
  0 siblings, 2 replies; 64+ messages in thread
From: Daniel J Walsh @ 2004-10-18 19:31 UTC (permalink / raw)
  To: Stephen Smalley, SELinux

We are beginning to look into how we could support clusters with SELinux. 
Usually in clusters you move your configuration off on to some shared 
storage.

So you might do a cp -a  /var/named /shared/var/named

We need some way of relabeling these directories with file context.  My 
idea is to add an alternate
root qualifier to restorecon

So in the above example you would do a

restorecon -R -p /shared /shared/var/named

I think this would work fairly well for chroot environments also.

Ideas?


Dan

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 64+ messages in thread
* Adding alternate root patch to restorecon (setfiles?)
@ 2004-10-18 19:36 Daniel J Walsh
  0 siblings, 0 replies; 64+ messages in thread
From: Daniel J Walsh @ 2004-10-18 19:36 UTC (permalink / raw)
  To: Stephen Smalley, SELinux

[-- Attachment #1: Type: text/plain, Size: 19 bytes --]

Forgot patch.

Dan

[-- Attachment #2: policycoreutils-altroot.patch --]
[-- Type: text/plain, Size: 2149 bytes --]

--- policycoreutils-1.17.6/restorecon/restorecon.c.altroot	2004-10-06 09:47:47.000000000 -0400
+++ policycoreutils-1.17.6/restorecon/restorecon.c	2004-10-18 15:35:41.124661316 -0400
@@ -8,11 +8,13 @@
  * to match the specification returned by matchpathcon.
  *
  * USAGE:
- * restorecon [-Rnv] pathname...
+ * restorecon [-Rnv] [ -o outputfile ] [ -p alt_root ] pathname...
  * 
+ * -R	recurse
  * -n	Do not change any file labels.
  * -v	Show changes in file labels.  
- * -o filename save list of files with incorrect context
+ * -o	filename save list of files with incorrect context
+ * -p	alternate root: strip off alt_root from pathname when doing matchfilecon
  *
  * pathname...	The file(s) to label 
  *
@@ -40,6 +42,8 @@
 static int verbose=0;
 static FILE *outfile=NULL;
 static char *progname;
+static char *alt_root=NULL;
+static int alt_len=0;
 static int errors=0;
 static int recurse;
 
@@ -52,6 +56,7 @@
 int restore(char *filename) {
   int retcontext=0;
   int retval=0;
+  char *target=NULL;
   security_context_t scontext;
   security_context_t prev_context;
   int len=strlen(filename);
@@ -99,9 +104,14 @@
     }
     filename = p;
   }
-  retval = matchpathcon(filename, st.st_mode, &scontext);
+
+  target=filename;
+  if (alt_len != 0 && strncmp(alt_root, filename, alt_len) == 0)
+	  target=&filename[alt_len];
+
+  retval = matchpathcon(target, st.st_mode, &scontext);
   if (retval < 0) {
-    fprintf(stderr,"matchpathcon(%s) failed %s\n", filename,strerror(errno));
+    fprintf(stderr,"matchpathcon(%s) failed %s\n", target,strerror(errno));
     return 1;
   } 
   if (strcmp(scontext,"<<none>>")==0) {
@@ -179,7 +189,7 @@
 
   memset(buf,0, sizeof(buf));
 
-  while ((opt = getopt(argc, argv, "Rnvf:o:")) > 0) {
+  while ((opt = getopt(argc, argv, "Rnvf:o:p:")) > 0) {
     switch (opt) {
     case 'n':
       change = 0;
@@ -187,6 +197,12 @@
     case 'R':
       recurse = 1;
       break;
+    case 'p':
+      alt_root=strdup(optarg);
+      alt_len=strlen(optarg);
+      if (alt_root[alt_len-1]=='/') 
+	      alt_len--;
+      break;
     case 'o':
       outfile = fopen(optarg,"w");
       if (!outfile) {

^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2004-12-13 12:30 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-18 19:31 Adding alternate root patch to restorecon (setfiles?) Daniel J Walsh
2004-10-18 19:55 ` Stephen Smalley
2004-10-18 20:11   ` Daniel J Walsh
2004-10-18 20:51 ` Thomas Bleher
2004-10-19 13:33   ` Daniel J Walsh
2004-10-19 18:36     ` Luke Kenneth Casson Leighton
2004-10-19 18:26       ` Stephen Smalley
2004-10-19 20:27         ` Luke Kenneth Casson Leighton
2004-10-25 15:35       ` Russell Coker
2004-10-25 15:38   ` Russell Coker
2004-10-25 21:31     ` Thomas Bleher
2004-10-26 14:36       ` Russell Coker
2004-11-05 21:39         ` James Carter
2004-11-06  5:23           ` Remaining changes from my patch excluding can_network changes Daniel J Walsh
2004-11-08 17:33             ` Small patch to allow pam_console handle /dev/pmu Daniel J Walsh
2004-11-08 21:21               ` James Carter
2004-11-08 21:21             ` Remaining changes from my patch excluding can_network changes James Carter
2004-11-06  5:33           ` can_network patch Daniel J Walsh
2004-11-09 21:34             ` James Carter
2004-11-09 22:15               ` Daniel J Walsh
2004-11-06 10:40           ` Adding alternate root patch to restorecon (setfiles?) Thomas Bleher
2004-11-10 23:11           ` Patches without the can_network patch Daniel J Walsh
2004-11-10 23:38             ` Thomas Bleher
2004-11-17 20:15             ` James Carter
2004-11-18 14:32               ` Daniel J Walsh
2004-11-18 19:43                 ` Thomas Bleher
2004-11-18 19:50                   ` Daniel J Walsh
2004-11-18 19:59                     ` Thomas Bleher
2004-11-19 22:05                 ` James Carter
2004-11-18 14:33               ` Daniel J Walsh
2004-11-23 18:52                 ` James Carter
2004-11-23 19:06                   ` Stephen Smalley
2004-11-23 19:37                     ` Daniel J Walsh
2004-11-23 20:07                       ` Stephen Smalley
2004-11-25 19:40                         ` Russell Coker
2004-11-26 11:55                           ` Daniel J Walsh
2004-11-24 16:22                   ` Daniel J Walsh
2004-11-24 16:39                     ` Stephen Smalley
2004-11-24 16:54                       ` Daniel J Walsh
2004-12-10 15:43                         ` Stephen Smalley
2004-12-10 17:06                           ` Daniel J Walsh
2004-12-10 17:10                             ` Stephen Smalley
2004-12-10 18:01                               ` Daniel J Walsh
2004-12-10 18:02                                 ` Stephen Smalley
2004-12-10 18:13                                   ` Daniel J Walsh
2004-12-10 18:11                                 ` Russell Coker
2004-12-10 19:11                                   ` Thomas Bleher
2004-12-10 20:23                                     ` James Carter
2004-12-10 21:39                                     ` Valdis.Kletnieks
2004-12-13 12:18                                       ` David Caplan
2004-12-10 21:01                                   ` Valdis.Kletnieks
2004-12-10 23:47                                     ` Russell Coker
2004-11-24 19:48                     ` James Carter
2004-11-24 20:24                       ` Daniel J Walsh
2004-11-30 21:19                       ` Reissue previous patch Daniel J Walsh
2004-12-02 13:54                         ` James Carter
2004-12-02 14:16                           ` Daniel J Walsh
2004-12-02 15:51                             ` Stephen Smalley
2004-12-02 18:35                               ` Daniel J Walsh
2004-12-02 17:51                             ` James Carter
2004-12-02 19:27                               ` Latest patch Daniel J Walsh
2004-12-03 13:40                                 ` James Carter
2004-11-17 23:35             ` Patches without the can_network patch Kodungallur Varma
2004-10-18 19:36 Adding alternate root patch to restorecon (setfiles?) Daniel J Walsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.