Allow to use compressed modules without a compression extension
PATCH 1/1 Allow to use compressed modules without a compression extension
When a compressed module doesn't have two extensions with lang and compression, 'semodule -i <module>.<lang>' fails. This changes the language detection to allow to use modules only with .<lang> extension.
Fixes:
libsemanage.semanage_direct_install_file: Module does not have a valid extension. (No such file or directory).
Signed-off-by Petr Lautrbach <[email protected]>
--- libsemanage/src/direct_api.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
libsemanage/src/direct_api.c +10 -7
@@ -1435,7 +1435,7 @@ static int semanage_direct_install_file(semanage_handle_t * sh,int in_fd =-1 ;char *path =NULL ;char *filename; -char *lang_ext; +char *lang_ext =NULL ;char *separator;if ((in_fd =open (install_filename,O_RDONLY )) ==-1 ) {
@@ -1467,17 +1467,20 @@ static int semanage_direct_install_file(semanage_handle_t * sh, goto cleanup; } *separator ='\0' ; + lang_ext = separator +1 ; } separator =strrchr (filename,'.' );if (separator ==NULL ) { -ERR (sh,"Module does not have a valid extension." ); - retval =-1 ; - goto cleanup; +if (lang_ext ==NULL ) { +ERR (sh,"Module does not have a valid extension." ); + retval =-1 ; + goto cleanup; + } + }else { + *separator ='\0' ; + lang_ext = separator +1 ; } - *separator ='\0' ; - - lang_ext = separator +1 ; retval =semanage_direct_install (sh, data, data_len, filename, lang_ext);
Signature · 1 line
2.4.3
Quoted 10 lines · Petr Lautrbach
When a compressed module doesn't have two extensions with lang and compression, 'semodule -i <module>.<lang>' fails. This changes the language detection to allow to use modules only with .<lang> extension.
Fixes:
libsemanage.semanage_direct_install_file: Module does not have a valid extension. (No such file or directory).Signed-off-by Petr Lautrbach <[email protected]>
Thanks and applied.
Quoted 45 lines
--- libsemanage/src/direct_api.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)libsemanage/src/direct_api.c +10
-7@@ -1435,7 +1435,7 @@ static int semanage_direct_install_file(semanage_handle_t * sh,int in_fd =-1 ;char *path =NULL ;char *filename; -char *lang_ext; +char *lang_ext =NULL ;char *separator;if ((in_fd =open (install_filename,O_RDONLY )) ==-1 ) {@@ -1467,17 +1467,20 @@ static int semanage_direct_install_file(semanage_handle_t * sh, goto cleanup; } *separator ='\0' ; + lang_ext = separator +1 ; } separator =strrchr (filename,'.' );if (separator ==NULL ) { -ERR (sh,"Module does not have a valid extension." ); - retval =-1 ; - goto cleanup; +if (lang_ext ==NULL ) { +ERR (sh,"Module does not have a valid extension." ); + retval =-1 ; + goto cleanup; + } + }else { + *separator ='\0' ; + lang_ext = separator +1 ; } - *separator ='\0' ; - - lang_ext = separator +1 ; retval =semanage_direct_install (sh, data, data_len, filename, lang_ext);