diff --git libsemanage-2.4/src/direct_api.c libsemanage-2.4/src/direct_api.c index b0ed338..ba5f475 100644 --- libsemanage-2.4/src/direct_api.c +++ libsemanage-2.4/src/direct_api.c @@ -1355,7 +1355,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) { @@ -1387,17 +1387,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); diff --git libsemanage-2.4/tests/test_utilities.c libsemanage-2.4/tests/test_utilities.c index 4d25b07..32cc33c 100644 --- libsemanage-2.4/tests/test_utilities.c +++ libsemanage-2.4/tests/test_utilities.c @@ -45,7 +45,7 @@ void test_slurp_file_filter(void); char fname[] = { 'T', 'E', 'S', 'T', '_', 'T', 'E', 'M', 'P', '_', 'X', 'X', 'X', 'X', - 'X', 'X' + 'X', 'X', '\0' }; int fd; FILE *fptr; diff --git libsemanage-2.4/utils/semanage_migrate_store libsemanage-2.4/utils/semanage_migrate_store index 03b492e..6584002 100755 --- libsemanage-2.4/utils/semanage_migrate_store +++ libsemanage-2.4/utils/semanage_migrate_store @@ -221,7 +221,7 @@ def rebuild_policy(): def oldroot_path(): - return "/etc/selinux" + return "%s/etc/selinux" % ROOT def oldstore_path(store): return "%s/%s/modules/active" % (oldroot_path(), store) @@ -233,7 +233,7 @@ def disabledmodules_path(store): return "%s/disabled" % newmodules_path(store) def newroot_path(): - return PATH + return "%s%s" % (ROOT, PATH) def newstore_path(store): return "%s/%s/active" % (newroot_path(), store) @@ -260,6 +260,8 @@ if __name__ == "__main__": help="Disable rebuilding policy after migration (default: no)") parser.add_option("-P", "--path", dest="path", help="Set path for the policy store (default: /var/lib/selinux)") + parser.add_option("-r", "--root", dest="root", + help="Set an alternative root for the migration (default: /)") (options, args) = parser.parse_args() @@ -272,6 +274,10 @@ if __name__ == "__main__": if PATH is None: PATH = "/var/lib/selinux" + ROOT = options.root + if ROOT is None: + ROOT = "" + # List of paths that go in the active 'root' TOPPATHS = [ "commit_num",