Skip to contentSkip to conversation

Allow to use compressed modules without a compression extension

PATCH In review Petr Lautrbach 2 participants 2 messages Jun 24, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

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).

---
 libsemanage/src/direct_api.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
libsemanage/src/direct_api.c +10 -7
index e4f168e..d57f934 100644
@@ -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
#1 lore raw
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).

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
index e4f168e..d57f934 100644
@@ -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);