All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow to use compressed modules without a compression extension
@ 2015-06-24 16:06 Petr Lautrbach
  2015-06-24 16:36 ` Steve Lawrence
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Lautrbach @ 2015-06-24 16:06 UTC (permalink / raw)
  To: selinux

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 <plautrba@redhat.com>
---
 libsemanage/src/direct_api.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
index e4f168e..d57f934 100644
--- a/libsemanage/src/direct_api.c
+++ b/libsemanage/src/direct_api.c
@@ -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);
 
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Allow to use compressed modules without a compression extension
  2015-06-24 16:06 [PATCH] Allow to use compressed modules without a compression extension Petr Lautrbach
@ 2015-06-24 16:36 ` Steve Lawrence
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Lawrence @ 2015-06-24 16:36 UTC (permalink / raw)
  To: Petr Lautrbach, selinux

On 06/24/2015 12:06 PM, Petr Lautrbach wrote:
> 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 <plautrba@redhat.com>

Ack-by: Steve Lawrence <slawrence@tresys.com>

Thanks and applied.

> ---
>  libsemanage/src/direct_api.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c
> index e4f168e..d57f934 100644
> --- a/libsemanage/src/direct_api.c
> +++ b/libsemanage/src/direct_api.c
> @@ -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);
>  
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-24 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-24 16:06 [PATCH] Allow to use compressed modules without a compression extension Petr Lautrbach
2015-06-24 16:36 ` Steve Lawrence

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.