libselinux patch
Fixes for rpm_execcon python binding
Manpage fix
Fix for erperm on getsebool.
man/man8/matchpathcon.8 +1 -1
@@ -28,4 +28,4 @@ .SH "SEE ALSO" .BR selinux "(8), " -.BR mathpathcon "(3), " +.BR matchpathcon "(3), "
src/selinuxswig.i +26 -1
@@ -115,9 +115,34 @@ extern const char *selinux_path(void); extern int selinux_check_passwd_access(access_vector_t requested); extern int checkPasswdAccess(access_vector_t requested); + +// This tells SWIG to treat char ** as a special case +%typemap(python,in) char ** { + /* Check if is a list */ + if (PyList_Check($input)) { + int size = PyList_Size($input); + int i = 0; + $1 = (char **) malloc((size+1)*sizeof(char *)); + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($input,i); + if (PyString_Check(o)) + $1[i] = PyString_AsString(PyList_GetItem($input,i)); + else { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($1); + return NULL; + } + } + $1[i] = 0; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + extern int rpm_execcon(unsigned int verified, const char *filename, - char *const argv[], char *const envp[]); + char **, char **); extern int is_context_customizable (security_context_t scontext);
src/selinuxswig_wrap.c +47 -17
82 lines not on this page · raw message
utils/getsebool.c +14 -8
@@ -72,17 +72,23 @@for (i =0 ; i < len; i++) { active =security_get_boolean_active (names[i]);if (active <0 ) { -fprintf (stderr,"Error getting active value for %s\n" , - names[i]); - rc =-1 ; - goto out; +if (errno !=EACCES ) { +fprintf (stderr,"Error getting active value for %s\n" , + names[i]); + rc =-1 ; + goto out; + } +continue ; } pending =security_get_boolean_pending (names[i]);if (pending <0 ) { -fprintf (stderr,"Error getting pending value for %s\n" , - names[i]); - rc =-1 ; - goto out; +if (errno !=EACCES ) { +fprintf (stderr,"Error getting pending value for %s\n" , + names[i]); + rc =-1 ; + goto out; + } +continue ; }if (pending != active) { printf("%s --> %s pending: %s\n", names[i],
Quoted 6 lines · Daniel J Walsh
Fixes for
rpm_execconpython bindingManpage fix
Fix for erperm on getsebool.
<snip>
Quoted 5 lines
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig.i libselinux-2.0.9/src/selinuxswig.i
src/selinuxswig.i +0
-0@@ -115,9 +115,34 @@ extern const char *selinux_path(void);
src/selinuxswig.i line 125
Quoted 10 lines
src/selinuxswig.i +8
-0extern int selinux_check_passwd_access(access_vector_t requested); extern int checkPasswdAccess(access_vector_t requested); + +// This tells SWIG to treat char ** as a special case +%typemap(python,in) char ** { + /* Check if is a list */ + if (PyList_Check($input)) { + int size = PyList_Size($input); + int i = 0; + $1 = (char **) malloc((size+1)*sizeof(char *));
What happens if the malloc fails?
<snip>
src/selinuxswig_wrap.c
Quoted 3 lines
diff --exclude-from=exclude -N -u -r
nsalibselinux/src/selinuxswig_wrap.clibselinux-2.0.9/src/selinuxswig_wrap.csrc/selinuxswig_wrap.c +0
-0
Don't need to send diffs on this file; will regenerate upstream upon changes to the .i file.
Quoted 8 lines
diff --exclude-from=exclude -N -u -r
nsalibselinux/utils/getsebool.clibselinux-2.0.9/utils/getsebool.cutils/getsebool.c +0
-1@@ -72,17 +72,23 @@for (i =0 ; i < len; i++) { active =security_get_boolean_active (names[i]);if (active <0 ) { - fprintf(stderr, "Error getting active value for %s\n",
utils/getsebool.c line 81
Quoted 10 lines
utils/getsebool.c +7
-3- names[i]); - rc =-1 ; - goto out; +if (errno !=EACCES ) { +fprintf (stderr,"Error getting active value for %s\n" , + names[i]); + rc =-1 ; + goto out; + } +continue ;
I think we had discussed only suppressing the errors if using getsebool -a; if the user explicitly specified a boolean name and it isn't accessible, they would presumably want to see an error message in that case.
}
Quoted 4 lines
utils/getsebool.c +0
-2pending =security_get_boolean_pending (names[i]);if (pending <0 ) { -fprintf (stderr,"Error getting pending value for %s\n" , - names[i]);
utils/getsebool.c line 92
Quoted 10 lines
utils/getsebool.c +7
-2- rc =-1 ; - goto out; +if (errno !=EACCES ) { +fprintf (stderr,"Error getting pending value for %s\n" , + names[i]); + rc =-1 ; + goto out; + } +continue ; }
Not sure we need this one, because a permission denial should't happen on pending if it didn't already happen on active.
Quoted 2 lines
utils/getsebool.c +0
-0if (pending != active) { printf("%s --> %s pending: %s\n", names[i],
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Second pass.
man/man8/matchpathcon.8 +1 -1
@@ -28,4 +28,4 @@ .SH "SEE ALSO" .BR selinux "(8), " -.BR mathpathcon "(3), " +.BR matchpathcon "(3), "
src/selinuxswig.i +30 -1
@@ -115,9 +115,38 @@ extern const char *selinux_path(void); extern int selinux_check_passwd_access(access_vector_t requested); extern int checkPasswdAccess(access_vector_t requested); + +// This tells SWIG to treat char ** as a special case +%typemap(python,in) char ** { + /* Check if is a list */ + if (PyList_Check($input)) { + int size = PyList_Size($input); + int i = 0; + $1 = (char **) malloc((size+1)*sizeof(char *)); + if ($1 == NULL) { + PyErr_SetString(PyExc_MemoryError,"Out of memory"); + return NULL; + } + for (i = 0; i < size; i++) { + PyObject *o = PyList_GetItem($input,i); + if (PyString_Check(o)) + $1[i] = PyString_AsString(PyList_GetItem($input,i)); + else { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($1); + return NULL; + } + } + $1[i] = 0; + } else { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + extern int rpm_execcon(unsigned int verified, const char *filename, - char *const argv[], char *const envp[]); + char **, char **); extern int is_context_customizable (security_context_t scontext);
utils/getsebool.c +4 -1
@@ -14,7 +14,7 @@int main (int argc,char **argv) { -int i, rc =0 , active, pending, len =0 , opt; +int i, get_all =0 , rc =0 , active, pending, len =0 , opt;char **names;while ((opt =getopt (argc, argv,"a" )) >0 ) {
@@ -39,6 +39,7 @@printf ("No booleans\n" );return 0 ; } + get_all =1 ;break ;default :usage (argv[0 ]);
@@ -72,6 +73,8 @@for (i =0 ; i < len; i++) { active =security_get_boolean_active (names[i]);if (active <0 ) { +if (! get_all && errno ==EACCES ) +continue ;fprintf (stderr,"Error getting active value for %s\n" , names[i]); rc =-1 ;
Quoted 26 lines · Daniel J Walsh
Second pass.
plain text document attachment (diff)
diff --exclude-from=exclude -N -u -r
nsalibselinux/utils/getsebool.clibselinux-2.0.9/utils/getsebool.cutils/getsebool.c +2
-1@@ -14,7 +14,7 @@int main (int argc,char **argv) { -int i, rc =0 , active, pending, len =0 , opt; +int i, get_all =0 , rc =0 , active, pending, len =0 , opt;char **names;while ((opt =getopt (argc, argv,"a" )) >0 ) {@@ -39,6 +39,7 @@printf ("No booleans\n" );return 0 ; } + get_all =1 ;break ;default :usage (argv[0 ]);
utils/getsebool.c line 77
Quoted 5 lines
utils/getsebool.c +2
-0@@ -72,6 +73,8 @@for (i =0 ; i < len; i++) { active =security_get_boolean_active (names[i]);if (active <0 ) { +if (! get_all && errno ==EACCES ) +continue ;
Shouldn't that be if (get_all && errno == EACCES)?
The goal is to only suppress the warnings upon getsebool -a, not the other way around.
Quoted 3 lines
utils/getsebool.c +0
-0fprintf (stderr,"Error getting active value for %s\n" , names[i]); rc =-1 ;
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 32 lines · Stephen Smalley
Quoted 30 lines · Daniel J Walsh
Second pass.
plain text document attachment (diff)
diff --exclude-from=exclude -N -u -r
nsalibselinux/utils/getsebool.clibselinux-2.0.9/utils/getsebool.cutils/getsebool.c +2
-1@@ -14,7 +14,7 @@int main (int argc,char **argv) { -int i, rc =0 , active, pending, len =0 , opt; +int i, get_all =0 , rc =0 , active, pending, len =0 , opt;char **names;while ((opt =getopt (argc, argv,"a" )) >0 ) {@@ -39,6 +39,7 @@printf ("No booleans\n" );return 0 ; } + get_all =1 ;break ;default :usage (argv[0 ]);@@ -72,6 +73,8 @@for (i =0 ; i < len; i++) { active =security_get_boolean_active (names[i]);
Quoted 10 lines
utils/getsebool.c
Quoted 4 lines
utils/getsebool.c +2
-0if (active <0 ) { +if (! get_all && errno ==EACCES ) +continue ;Shouldn't that be if (
get_all&& errno == EACCES)?
The goal is to only suppress the warnings upon getsebool -a, not the other way around.
Yes.
Quoted 4 lines
Quoted 4 lines
utils/getsebool.c +0
-0fprintf (stderr,"Error getting active value for %s\n" , names[i]);rc = -1;
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.