libselinux/utils: introduce getpolicyload
PATCH 1/1 libselinux/utils: introduce getpolicyload
Introduce a helper binary to print the number of policy reloads on the running system.
Print only a single number to ease the usage by scripts.
Signed-off-by Christian Göttsche <[email protected]>
--- libselinux/utils/getpolicyload.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libselinux/utils/getpolicyload.c
libselinux/utils/getpolicyload.c new file +29 -0
@@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <selinux/avc.h> + + +int main () { +int rc; + +/* +* Do not use netlink as fallback, since selinux_status_policyload(3) +* works only after a first message has been received. +*/ + rc =selinux_status_open (/*fallback=*/ 0 ); +if (rc <0 ) { +fprintf (stderr,"getpolicyload: failed to open SELinux status map: %m\n" ); +return EXIT_FAILURE ; + } + + rc =selinux_status_policyload (); +if (rc <0 ) +fprintf (stderr,"getpolicyload: failed to read policyload from SELinux status page: %m\n" ); +else +printf ("%d\n" , rc); + +selinux_status_close (); + +return (rc <0 ) ?EXIT_FAILURE :EXIT_SUCCESS ; +}
Signature · 1 line
2.40.1
Quoted 17 lines · Christian Göttsche
Introduce a helper binary to print the number of policy reloads on the running system.
Print only a single number to ease the usage by scripts.Signed-off-by Christian Göttsche <[email protected]>--- libselinux/utils/getpolicyload.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libselinux/utils/getpolicyload.clibselinux/utils/getpolicyload.c new file +0
-0
libselinux/utils/getpolicyload.c line 7
Quoted 7 lines
libselinux/utils/getpolicyload.c new file +7
-0@@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <selinux/avc.h> + + +int main () {
Should be:
int main(int argc __attribute__ ((unused)), char* argv[] __attribute__ ((unused))) {
libselinux/utils/getpolicyload.c line 10
Quoted 3 lines
libselinux/utils/getpolicyload.c new file +3
-0+int rc; + +/*
Extra whitespace after the "*"
libselinux/utils/getpolicyload.c line 16
Quoted 6 lines
libselinux/utils/getpolicyload.c new file +6
-0+* Do not use netlink as fallback, since selinux_status_policyload(3) +* works only after a first message has been received. +*/ + rc =selinux_status_open (/*fallback=*/ 0 ); +if (rc <0 ) { +fprintf (stderr,"getpolicyload: failed to open SELinux status map: %m\n" );
You should just use argv[0] here.
libselinux/utils/getpolicyload.c line 22
Quoted 6 lines
libselinux/utils/getpolicyload.c new file +6
-0+return EXIT_FAILURE ; + } + + rc =selinux_status_policyload (); +if (rc <0 ) +fprintf (stderr,"getpolicyload: failed to read policyload from SELinux status page: %m\n" );
You should just use argv[0] here as well.
Thanks,
Jim
Quoted 10 lines
libselinux/utils/getpolicyload.c new file +7
-1+else +printf ("%d\n" , rc); + +selinux_status_close (); + +return (rc <0 ) ?EXIT_FAILURE :EXIT_SUCCESS ; +} --2.40.1