semodule_expand: update
PATCH v2 1/4 semodule_expand: update
Drop unnecessary declarations.
Reduce scope of file global variable.
Mention -v argument in help usage message.
More strict integer conversion.
More strict argument count checking.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
Add help argument option -h.
Set close-on-exec flag in case of any sibling threads.
---
v2:
- address comments by Jim:
* drop exit() calls
* reduce to only one final return statement
- add help argument option -h
- set close-on-exec flag
--- .../semodule_expand/semodule_expand.8 | 5 +- .../semodule_expand/semodule_expand.c | 112 +++++++++++------- 2 files changed, 73 insertions(+), 44 deletions(-)
semodule-utils/semodule_expand/semodule_expand.8 +4 -1
@@ -3,7 +3,7 @@ semodule_expand \- Expand a SELinux policy module package. .SH SYNOPSIS -.B semodule_expand [-V ] [ -a ] [ -c [version]] basemodpkg outputfile +.B semodule_expand [-ahV] [ -c [version]] basemodpkg outputfile .br .SH DESCRIPTION .PP
@@ -17,6 +17,9 @@ together a set of packages into a single package). .SH "OPTIONS" .TP +.B \-h +show help +.TP .B \-V show version .TP
semodule-utils/semodule_expand/semodule_expand.c +69 -43
224 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH v2 2/4 semodule_link: update
Drop unnecessary declarations.
More verbose error messages and add missing trailing newline. More strict argument count checking.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
Add help argument option -h.
Set close-on-exec flag in case of any sibling thread.
---
v2:
- address comment from Jim
* avoid exit() calls
* reduce to one final return statement
* drop global variable progname
- add help argument option
- set close-on-exec flag
--- semodule-utils/semodule_link/semodule_link.8 | 5 +- semodule-utils/semodule_link/semodule_link.c | 87 +++++++++++--------- 2 files changed, 53 insertions(+), 39 deletions(-)
semodule-utils/semodule_link/semodule_link.8 +4 -1
@@ -3,7 +3,7 @@ semodule_link \- Link SELinux policy module packages together .SH SYNOPSIS -.B semodule_link [-Vv] [-o outfile] basemodpkg modpkg1 [modpkg2]... +.B semodule_link [-hVv] [-o outfile] basemodpkg modpkg1 [modpkg2]... .br .SH DESCRIPTION .PP
@@ -16,6 +16,9 @@ semodule_package. .SH "OPTIONS" .TP +.B \-h +show help +.TP .B \-V show version .TP
semodule-utils/semodule_link/semodule_link.c +49 -38
172 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH v2 3/4 semodule_package: update
In reply to Christian GöttscheDrop unnecessary declarations.
Add missing error messages.
More strict command line argument parsing.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
Set close-on-exec flag in case of any sibling thread.
---
v2:
- address comment from Jim
* drop exit() calls
* reduce to one final return statement
* drop unnecessary ? option handling
* drop global variable progname
- set close-on-exec flag
--- .../semodule_package/semodule_package.8 | 3 + .../semodule_package/semodule_package.c | 227 +++++++++++------- 2 files changed, 139 insertions(+), 91 deletions(-)
semodule-utils/semodule_package/semodule_package.8 +3 -0
@@ -42,6 +42,9 @@ File contexts file for the module (optional). .TP .B \-n \-\-nc <netfilter context file> netfilter context file to be included in the package. +.TP +.B \-h \-\-help +Show help message. .SH SEE ALSO .B checkmodule(8), semodule(8), semodule_unpackage(8)
semodule-utils/semodule_package/semodule_package.c +136 -91
343 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH v2 4/4 semodule_unpackage: update
In reply to Christian GöttscheDrop unnecessary declarations.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
---
v2:
address comments from Jim
* drop exit() calls
* reduce to one final return statement
* drop global variable progname
--- .../semodule_package/semodule_unpackage.c | 129 +++++++++++------- 1 file changed, 77 insertions(+), 52 deletions(-)
semodule-utils/semodule_package/semodule_unpackage.c +77 -52
@@ -11,46 +11,23 @@#include <fcntl.h> #include <errno.h> -char *progname =NULL ; -extern char *optarg; - -static __attribute__((__noreturn__))void usage (void ) +static void usage (const char *progname) {printf ("usage: %s ppfile modfile [fcfile]\n" , progname); -exit (1 ); -} - -static int file_to_policy_file (const char *filename,struct sepol_policy_file **pf,const char *mode) -{ -FILE *f; - -if (sepol_policy_file_create (pf)) { -fprintf (stderr,"%s: Out of memory\n" , progname); -return -1 ; - } - - f =fopen (filename, mode); -if (!f) { -fprintf (stderr,"%s: Could not open file %s: %s\n" , progname,strerror (errno), filename); -return -1 ; - } -sepol_policy_file_set_fp (*pf, f); -return 0 ; }int main (int argc,char **argv) { -struct sepol_module_package *pkg; -struct sepol_policy_file *in, *out; -FILE *fp; +struct sepol_module_package *pkg =NULL ; +struct sepol_policy_file *in =NULL , *out =NULL ; +FILE *fp =NULL ;size_t len; -char *ppfile, *modfile, *fcfile =NULL , *fcdata; - - progname = argv[0 ]; +const char *ppfile, *modfile, *fcfile =NULL , *fcdata; +int ret;if (argc <3 ) { -usage (); -exit (1 ); +usage (argv[0 ]); +return EXIT_FAILURE ; } ppfile = argv[1 ];
@@ -58,46 +35,94 @@ int main(int argc, char **argv)if (argc >=4 ) fcfile = argv[3 ]; -if (file_to_policy_file (ppfile, &in,"r" )) -exit (1 ); -if (sepol_module_package_create (&pkg)) { -fprintf (stderr,"%s: Out of memory\n" , progname); -exit (1 ); +fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); + goto failure; } -if (sepol_module_package_read (pkg, in,0 ) ==-1 ) { -fprintf (stderr,"%s: Error while reading policy module from %s\n" , - progname, ppfile); -exit (1 ); +if (sepol_policy_file_create (&in)) { +fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); + goto failure; } -if (file_to_policy_file (modfile, &out,"w" )) -exit (1 ); + fp =fopen (ppfile,"r" ); +if (!fp) { +fprintf (stderr,"%s: Could not open file %s: %s\n" , argv[0 ], ppfile,strerror (errno)); + goto failure; + } +sepol_policy_file_set_fp (in, fp); -if (sepol_policydb_write (sepol_module_package_get_policy (pkg), out)) { -fprintf (stderr,"%s: Error while writing module to %s\n" , progname, modfile); -exit (1 ); - } +if (sepol_module_package_read (pkg, in,0 ) ==-1 ) { +fprintf (stderr,"%s: Error while reading policy module from %s\n" , + argv[0 ], ppfile); + goto failure; + }sepol_policy_file_free (in); + in =NULL ; +fclose (fp); + fp =NULL ; + +if (sepol_policy_file_create (&out)) { +fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); + goto failure; + } + + fp =fopen (modfile,"w" ); +if (!fp) { +fprintf (stderr,"%s: Could not open file %s: %s\n" , argv[0 ], modfile,strerror (errno)); + goto failure; + } +sepol_policy_file_set_fp (out, fp); + +if (sepol_policydb_write (sepol_module_package_get_policy (pkg), out)) { +fprintf (stderr,"%s: Error while writing module to %s\n" , argv[0 ], modfile); + goto failure; + } + + ret =fclose (fp); + fp =NULL ; +if (ret) { +fprintf (stderr,"%s: Error while closing file %s: %s\n" , argv[0 ], modfile,strerror (errno)); + goto failure; + } +sepol_policy_file_free (out); + out =NULL ; len =sepol_module_package_get_file_contexts_len (pkg);if (fcfile && len) { fp =fopen (fcfile,"w" );if (!fp) { -fprintf (stderr,"%s: Could not open file %s: %s\n" , progname,strerror (errno), fcfile); -exit (1 ); +fprintf (stderr,"%s: Could not open file %s: %s\n" , argv[0 ], fcfile,strerror (errno)); + goto failure; } fcdata =sepol_module_package_get_file_contexts (pkg);if (fwrite (fcdata,1 , len, fp) != len) { -fprintf (stderr,"%s: Could not write file %s: %s\n" , progname,strerror (errno), fcfile); -exit (1 ); +fprintf (stderr,"%s: Could not write file %s: %s\n" , argv[0 ], fcfile,strerror (errno)); + goto failure; + } + + ret =fclose (fp); + fp =NULL ; +if (ret) { +fprintf (stderr,"%s: Could not close file %s: %s\n" , argv[0 ], fcfile,strerror (errno)); + goto failure; } -fclose (fp); } + ret =EXIT_SUCCESS ; + goto cleanup; + +failure: + ret =EXIT_FAILURE ; + +cleanup: +if (fp) +fclose (fp); +sepol_policy_file_free (out);sepol_module_package_free (pkg); -exit (0 ); +sepol_policy_file_free (in); + +return ret; }
Signature · 1 line
2.40.1
Quoted 13 lines · Christian Göttsche
Drop unnecessary declarations.
Reduce scope of file global variable.
Mention -v argument in help usage message.
More strict integer conversion.
More strict argument count checking.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
Add help argument option -h.
Set close-on-exec flag in case of any sibling threads.
Quoted 1 line
Signed-off-by Christian Göttsche <[email protected]>
For this series of four patches:
Quoted 272 lines
---
v2:
- address comments by Jim:
* dropexit()calls
* reduce to only one final return statement
- add help argument option -h
- set close-on-exec flag--- .../semodule_expand/semodule_expand.8 | 5 +- .../semodule_expand/semodule_expand.c | 112 +++++++++++------- 2 files changed, 73 insertions(+), 44 deletions(-)semodule-utils/semodule_expand/semodule_expand.8 +4
-1@@ -3,7 +3,7 @@ semodule_expand \- Expand a SELinux policy module package. .SH SYNOPSIS -.B semodule_expand [-V ] [ -a ] [ -c [version]] basemodpkg outputfile +.B semodule_expand [-ahV] [ -c [version]] basemodpkg outputfile .br .SH DESCRIPTION .PP@@ -17,6 +17,9 @@ together a set of packages into a single package). .SH "OPTIONS" .TP +.B \-h +show help +.TP .B \-V show version .TPsemodule-utils/semodule_expand/semodule_expand.c +69
-44@@ -21,32 +21,25 @@#include <unistd.h> #include <string.h> -extern char *optarg; -extern int optind; - -int policyvers =0 ; -#define EXPANDPOLICY_VERSION "1.0" -static __attribute__((__noreturn__))void usage (const char *program_name) +static void usage (const char *program_name) { -printf ("usage: %s [-V -a -c [version]] basemodpkg outputfile\n" , +printf ("usage: %s [-h -V -a -c [version] -v] basemodpkg outputfile\n" , program_name); -exit (1 ); }int main (int argc,char **argv) { -char *basename, *outname; -int ch, ret, show_version =0 , verbose =0 ; -struct sepol_policy_file *pf; -sepol_module_package_t *base; -sepol_policydb_t *out, *p; -FILE *fp, *outfile; -int check_assertions =1 ; -sepol_handle_t *handle; - -while ((ch =getopt (argc, argv,"c:Vva" )) !=EOF ) { +const char *basename, *outname; +int ch, ret, show_version =0 , verbose =0 , policyvers =0 , check_assertions =1 ; +struct sepol_policy_file *pf =NULL ; +sepol_module_package_t *base =NULL ; +sepol_policydb_t *out =NULL , *p; +FILE *fp =NULL , *outfile =NULL ; +sepol_handle_t *handle =NULL ; + +while ((ch =getopt (argc, argv,"c:Vvah" )) !=EOF ) {switch (ch) {case 'V' : show_version =1 ;@@ -54,14 +47,20 @@ int main(int argc, char **argv)case 'v' : verbose =1 ;break ; +case 'h' : +usage (argv[0 ]); +return EXIT_SUCCESS ;case 'c' :{ -long int n =strtol (optarg,NULL ,10 ); +long int n; + + errno =0 ; + n =strtol (optarg,NULL ,10 );if (errno) {fprintf (stderr,"%s: Invalid policyvers specified: %s\n" , argv[0 ], optarg);usage (argv[0 ]); -exit (1 ); +return EXIT_FAILURE ; }if (n <sepol_policy_kern_vers_min () || n >sepol_policy_kern_vers_max ()) {@@ -71,7 +70,7 @@ int main(int argc, char **argv)sepol_policy_kern_vers_min (), sepol_policy_kern_vers_max());usage (argv[0 ]); -exit (1 ); +return EXIT_FAILURE ; } policyvers = n;break ;@@ -82,6 +81,7 @@ int main(int argc, char **argv) }default :usage (argv[0 ]); +return EXIT_FAILURE ; } }@@ -92,84 +92,90 @@ int main(int argc, char **argv)if (show_version) {printf ("%s\n" ,EXPANDPOLICY_VERSION ); -exit (0 ); +return EXIT_SUCCESS ; }/* check args */ -if (argc <3 || !(optind != (argc -1 ))) { +if (argc <3 || argc - optind !=2 ) {fprintf (stderr,"%s: You must provide the base module package and output filename\n" , argv[0 ]);usage (argv[0 ]); +return EXIT_FAILURE ; } basename = argv[optind++]; outname = argv[optind]; handle =sepol_handle_create (); -if (!handle) -exit (1 ); +if (!handle) { +fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); + goto failure; + }if (sepol_policy_file_create (&pf)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; }/* read the base module */ if (sepol_module_package_create (&base)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; } - fp =fopen (basename,"r" ); + + fp =fopen (basename,"re" );if (!fp) {fprintf (stderr,"%s: Can't open '%s': %s\n" , argv[0 ], basename,strerror (errno)); -exit (1 ); + goto failure; } +sepol_policy_file_set_fp (pf, fp); ret =sepol_module_package_read (base, pf,0 );if (ret) {fprintf (stderr,"%s: Error in reading package from %s\n" , argv[0 ], basename); -exit (1 ); + goto failure; } +fclose (fp); + fp =NULL ;/* linking the base takes care of enabling optional avrules */ p =sepol_module_package_get_policy (base);if (sepol_link_modules (handle, p,NULL ,0 ,0 )) {fprintf (stderr,"%s: Error while enabling avrules\n" , argv[0 ]); -exit (1 ); + goto failure; }/* create the output policy */ if (sepol_policydb_create (&out)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; }sepol_set_expand_consume_base (handle,1 );if (sepol_expand_module (handle, p, out, verbose, check_assertions)) {fprintf (stderr,"%s: Error while expanding policy\n" , argv[0 ]); -exit (1 ); + goto failure; }if (policyvers) {if (sepol_policydb_set_vers (out, policyvers)) {fprintf (stderr,"%s: Invalid version %d\n" , argv[0 ], policyvers); -exit (1 ); + goto failure; } } -sepol_module_package_free (base); - - outfile =fopen (outname,"w" ); + outfile =fopen (outname,"we" );if (!outfile) { -perror (outname); -exit (1 ); +fprintf (stderr,"%s: Can't open '%s': %s\n" , + argv[0 ], outname,strerror (errno)); + goto failure; }sepol_policy_file_set_fp (pf, outfile);@@ -178,12 +184,32 @@ int main(int argc, char **argv)fprintf (stderr,"%s: Error while writing expanded policy to %s\n" , argv[0 ], outname); -exit (1 ); + goto failure; } -fclose (outfile); -sepol_handle_destroy (handle); + + ret =fclose (outfile); + outfile =NULL ; +if (ret) { +fprintf (stderr,"%s: Error closing policy file %s: %s\n" , + argv[0 ], outname,strerror (errno)); + goto failure; + } + + ret =EXIT_SUCCESS ; + goto cleanup; + +failure: + ret =EXIT_FAILURE ; + +cleanup: +if (outfile) +fclose (outfile);sepol_policydb_free (out); +if (fp) +fclose (fp); +sepol_module_package_free (base);sepol_policy_file_free (pf); +sepol_handle_destroy (handle); -return 0 ; +return ret; } --2.40.1
Quoted 16 lines · James Carter
Quoted 13 lines · Christian Göttsche
Drop unnecessary declarations.
Reduce scope of file global variable.
Mention -v argument in help usage message.
More strict integer conversion.
More strict argument count checking.
Check closing file for incomplete write.
Rework resource cleanup, so that all files and allocated memory are released in all branches, useful to minimize reports while debugging libsepol under valgrind(8) or sanitizers.
Add help argument option -h.
Set close-on-exec flag in case of any sibling threads.
Quoted 5 lines
Quoted 1 line
Signed-off-by Christian Göttsche <[email protected]>For this series of four patches:
Acked-by James Carter <[email protected]>
This series of four patches has been merged.
Thanks,
Jim
Quoted 272 lines
Quoted 272 lines
---
v2:
- address comments by Jim:
* dropexit()calls
* reduce to only one final return statement
- add help argument option -h
- set close-on-exec flag--- .../semodule_expand/semodule_expand.8 | 5 +- .../semodule_expand/semodule_expand.c | 112 +++++++++++------- 2 files changed, 73 insertions(+), 44 deletions(-)semodule-utils/semodule_expand/semodule_expand.8 +4
-1@@ -3,7 +3,7 @@ semodule_expand \- Expand a SELinux policy module package. .SH SYNOPSIS -.B semodule_expand [-V ] [ -a ] [ -c [version]] basemodpkg outputfile +.B semodule_expand [-ahV] [ -c [version]] basemodpkg outputfile .br .SH DESCRIPTION .PP@@ -17,6 +17,9 @@ together a set of packages into a single package). .SH "OPTIONS" .TP +.B \-h +show help +.TP .B \-V show version .TPsemodule-utils/semodule_expand/semodule_expand.c +69
-44@@ -21,32 +21,25 @@#include <unistd.h> #include <string.h> -extern char *optarg; -extern int optind; - -int policyvers =0 ; -#define EXPANDPOLICY_VERSION "1.0" -static __attribute__((__noreturn__))void usage (const char *program_name) +static void usage (const char *program_name) { -printf ("usage: %s [-V -a -c [version]] basemodpkg outputfile\n" , +printf ("usage: %s [-h -V -a -c [version] -v] basemodpkg outputfile\n" , program_name); -exit (1 ); }int main (int argc,char **argv) { -char *basename, *outname; -int ch, ret, show_version =0 , verbose =0 ; -struct sepol_policy_file *pf; -sepol_module_package_t *base; -sepol_policydb_t *out, *p; -FILE *fp, *outfile; -int check_assertions =1 ; -sepol_handle_t *handle; - -while ((ch =getopt (argc, argv,"c:Vva" )) !=EOF ) { +const char *basename, *outname; +int ch, ret, show_version =0 , verbose =0 , policyvers =0 , check_assertions =1 ; +struct sepol_policy_file *pf =NULL ; +sepol_module_package_t *base =NULL ; +sepol_policydb_t *out =NULL , *p; +FILE *fp =NULL , *outfile =NULL ; +sepol_handle_t *handle =NULL ; + +while ((ch =getopt (argc, argv,"c:Vvah" )) !=EOF ) {switch (ch) {case 'V' : show_version =1 ;@@ -54,14 +47,20 @@ int main(int argc, char **argv)case 'v' : verbose =1 ;break ; +case 'h' : +usage (argv[0 ]); +return EXIT_SUCCESS ;case 'c' :{ -long int n =strtol (optarg,NULL ,10 ); +long int n; + + errno =0 ; + n =strtol (optarg,NULL ,10 );if (errno) {fprintf (stderr,"%s: Invalid policyvers specified: %s\n" , argv[0 ], optarg);usage (argv[0 ]); -exit (1 ); +return EXIT_FAILURE ; }if (n <sepol_policy_kern_vers_min () || n >sepol_policy_kern_vers_max ()) {@@ -71,7 +70,7 @@ int main(int argc, char **argv)sepol_policy_kern_vers_min (), sepol_policy_kern_vers_max());usage (argv[0 ]); -exit (1 ); +return EXIT_FAILURE ; } policyvers = n;break ;@@ -82,6 +81,7 @@ int main(int argc, char **argv) }default :usage (argv[0 ]); +return EXIT_FAILURE ; } }@@ -92,84 +92,90 @@ int main(int argc, char **argv)if (show_version) {printf ("%s\n" ,EXPANDPOLICY_VERSION ); -exit (0 ); +return EXIT_SUCCESS ; }/* check args */ -if (argc <3 || !(optind != (argc -1 ))) { +if (argc <3 || argc - optind !=2 ) {fprintf (stderr,"%s: You must provide the base module package and output filename\n" , argv[0 ]);usage (argv[0 ]); +return EXIT_FAILURE ; } basename = argv[optind++]; outname = argv[optind]; handle =sepol_handle_create (); -if (!handle) -exit (1 ); +if (!handle) { +fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); + goto failure; + }if (sepol_policy_file_create (&pf)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; }/* read the base module */ if (sepol_module_package_create (&base)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; } - fp =fopen (basename,"r" ); + + fp =fopen (basename,"re" );if (!fp) {fprintf (stderr,"%s: Can't open '%s': %s\n" , argv[0 ], basename,strerror (errno)); -exit (1 ); + goto failure; } +sepol_policy_file_set_fp (pf, fp); ret =sepol_module_package_read (base, pf,0 );if (ret) {fprintf (stderr,"%s: Error in reading package from %s\n" , argv[0 ], basename); -exit (1 ); + goto failure; } +fclose (fp); + fp =NULL ;/* linking the base takes care of enabling optional avrules */ p =sepol_module_package_get_policy (base);if (sepol_link_modules (handle, p,NULL ,0 ,0 )) {fprintf (stderr,"%s: Error while enabling avrules\n" , argv[0 ]); -exit (1 ); + goto failure; }/* create the output policy */ if (sepol_policydb_create (&out)) {fprintf (stderr,"%s: Out of memory\n" , argv[0 ]); -exit (1 ); + goto failure; }sepol_set_expand_consume_base (handle,1 );if (sepol_expand_module (handle, p, out, verbose, check_assertions)) {fprintf (stderr,"%s: Error while expanding policy\n" , argv[0 ]); -exit (1 ); + goto failure; }if (policyvers) {if (sepol_policydb_set_vers (out, policyvers)) {fprintf (stderr,"%s: Invalid version %d\n" , argv[0 ], policyvers); -exit (1 ); + goto failure; } } -sepol_module_package_free (base); - - outfile =fopen (outname,"w" ); + outfile =fopen (outname,"we" );if (!outfile) { -perror (outname); -exit (1 ); +fprintf (stderr,"%s: Can't open '%s': %s\n" , + argv[0 ], outname,strerror (errno)); + goto failure; }sepol_policy_file_set_fp (pf, outfile);@@ -178,12 +184,32 @@ int main(int argc, char **argv)fprintf (stderr,"%s: Error while writing expanded policy to %s\n" , argv[0 ], outname); -exit (1 ); + goto failure; } -fclose (outfile); -sepol_handle_destroy (handle); + + ret =fclose (outfile); + outfile =NULL ; +if (ret) { +fprintf (stderr,"%s: Error closing policy file %s: %s\n" , + argv[0 ], outname,strerror (errno)); + goto failure; + } + + ret =EXIT_SUCCESS ; + goto cleanup; + +failure: + ret =EXIT_FAILURE ; + +cleanup: +if (outfile) +fclose (outfile);sepol_policydb_free (out); +if (fp) +fclose (fp); +sepol_module_package_free (base);sepol_policy_file_free (pf); +sepol_handle_destroy (handle); -return 0 ; +return ret; } --2.40.1