setfiles - patch
I've attached a little patch for setfiles which allows "-" to be specified instead of a file system name to make it read file names from stdin.
Stephen, if you include this in your source tree then please send me a patch of the way you do it so my next patch will apply cleanly.
Signature · 4 lines
If you send email to me or to a mailing list that I use which has >4 lines of legalistic junk at the end then you are specifically authorizing me to do whatever I wish with the message and all other messages from your domain, by posting the message you agree that your long legalistic sig is void.
setfiles/setfiles.c +36 -1
@@ -17,6 +17,7 @@* -d Show what specification matched each file. * -n Do not change any file labels. * -v Show changes in file labels. +* -m Don't warn about no matches. * -R Recreate the persistent label mappings from scratch. * Must reboot to take affect. * spec_file The specification file.
@@ -64,6 +65,7 @@#include <fs_secure.h> #include <ss.h> #include "psid.h" +#include <limits.h> struct psidtab *psids;
@@ -76,6 +78,7 @@* Command-line options. */ static int change =1 ; +static int warn_no_match =1 ;static int debug =0 ;static int verbose =0 ;static int reset =0 ;
@@ -455,11 +458,14 @@struct stat sb;/* Process any options. */ -while ((opt =getopt (argc, argv,"dnvR" )) >0 ) { +while ((opt =getopt (argc, argv,"dmnvR" )) >0 ) {switch (opt) {case 'd' : debug =1 ;break ; +case 'm' : + warn_no_match =0 ; +break ;case 'n' : change =0 ;break ;
@@ -700,6 +706,34 @@ } } +if (!strcmp (argv[optind],"-" )) + { +char buf[PATH_MAX ]; +while (fgets (buf,sizeof (buf), stdin)) + { +struct stat sb; +strtok (buf,"\r\n" ); +if (stat (buf, &sb)) +fprintf (stderr,"File %s not found.\n" , buf); +else + { +int flag; +switch (sb.st_mode) + { +case S_IFDIR : + flag =FTW_D ; +break ; +case S_IFLNK : + flag =FTW_SL ; +break ; +default : + flag =FTW_F ; + } +apply_spec (buf, &sb, flag,NULL ); + } + } + } +else /* Walk the file tree, calling apply_spec on each file. */ if (nftw (argv[optind], apply_spec, 1024,
@@ -723,6 +757,7 @@file_spec_destroy (); } +if (warn_no_match)for (i =0 ; i < nspec; i++) {if (spec[i].matches ==0 ) {if (spec[i].type_str) {