Patch's to make load_policy (and libsepol) be quiet.
load_policy/load_policy.c +4 -1
@@ -49,6 +49,7 @@break ;case 'q' : quiet =1 ; +sepol_debug (0 );break ;default :usage (argv[0 ]);
@@ -87,7 +88,9 @@ ret =sepol_genusers (map, sb.st_size,selinux_users_path (), &data, &data_size);if (ret <0 ) { -fprintf (stderr,_ ("%s: Error while setting user configuration from %s: %s\n" ), argv[0 ],selinux_users_path (),strerror (errno)); +/* No users file; non-fatal. */ +if (! quiet) +fprintf (stderr,_ ("%s: Error while setting user configuration from %s/{local.users,system.users}: %s\n" ), argv[0 ],selinux_users_path (),strerror (errno)); data = map; data_size = sb.st_size; }
include/sepol/sepol.h +2 -1
@@ -32,5 +32,6 @@/* Check context validity against currently set binary policy. */ extern int sepol_check_context (char *context); - +/* Turn on or off sepol error messages. */ +extern void sepol_debug (int on);#endif
src/genbools.c +7 -7
@@ -87,7 +87,7 @@ pf.data = data; pf.len = len;if (policydb_read (&policydb,&pf,0 )) { -fprintf (stderr,"Can't read binary policy: %s\n" , +__sepol_debug_printf ("Can't read binary policy: %s\n" ,strerror (errno));return -1 ; }
@@ -97,12 +97,12 @@sepol_set_policyvers (policydb.policyvers);if (load_booleans (&policydb, booleans) <0 ) { -fprintf (stderr,"Warning! Error while reading %s: %s\n" , +__sepol_debug_printf ("Warning! Error while reading %s: %s\n" , booleans,strerror (errno)); }if (evaluate_conds (&policydb) <0 ) { -fprintf (stderr,"Error while re-evaluating conditionals: %s\n" , +__sepol_debug_printf ("Error while re-evaluating conditionals: %s\n" ,strerror (errno));return -1 ; }
@@ -111,7 +111,7 @@ pf.len = len; rc =policydb_write (&policydb, &pf);if (rc) { -fprintf (stderr,"Can't write binary policy: %s\n" , +__sepol_debug_printf ("Can't write binary policy: %s\n" ,strerror (errno));return -1 ; }
@@ -129,7 +129,7 @@ pf.data = data; pf.len = len;if (policydb_read (&policydb,&pf,0 )) { -fprintf (stderr,"Can't read binary policy: %s\n" , +__sepol_debug_printf ("Can't read binary policy: %s\n" ,strerror (errno));return -1 ; }
@@ -154,7 +154,7 @@ }if (evaluate_conds (&policydb) <0 ) { -fprintf (stderr,"Error while re-evaluating conditionals: %s\n" , +__sepol_debug_printf ("Error while re-evaluating conditionals: %s\n" ,strerror (errno));return -1 ; }
@@ -163,7 +163,7 @@ pf.len = len; rc =policydb_write (&policydb, &pf);if (rc) { -fprintf (stderr,"Can't write binary policy: %s\n" , +__sepol_debug_printf ("Can't write binary policy: %s\n" ,strerror (errno));return -1 ; }
src/genusers.c +28 -15
138 lines not on this page · raw message
src/libsepol.map +1 -1
@@ -1,4 +1,4 @@ { - global: sepol_genbools*; sepol_set_policydb_from_file; sepol_check_context; sepol_genusers; + global: sepol_genbools*; sepol_set_policydb_from_file; sepol_check_context; sepol_genusers; sepol_debug; local: *; };
src/private.h +1 -0
@@ -25,6 +25,7 @@ };extern struct policydb_compat_info *policydb_lookup_compat (int version); +extern void __sepol_debug_printf (const char *fmt, ...);/* Reading from a policy "file". */ static inline void *next_entry (struct policy_file * fp,size_t bytes)