Skip to content

Commit

Permalink
Merge pull request #55 from ejoerns/v0/topic/check-local-files
Browse files Browse the repository at this point in the history
main: in case of local bundle, check for extension and existence
  • Loading branch information
jluebbe committed Jun 21, 2016
2 parents 8018d9b + 2db1954 commit 29d4771
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,23 @@ static gboolean install_start(int argc, char **argv)
} else {
bundlelocation = g_strdup(argv[2]);
}
g_clear_pointer(&bundlescheme, g_free);

/* If the URI parser returns NULL, assume bundle install with local path */
if (bundlescheme == NULL) {
/* A valid local bundle path name must end with `.raucb` */
if (!g_str_has_suffix(bundlelocation, ".raucb")) {
g_printerr("Bundle must have a .raucb extension: %s\n", bundlelocation);
g_clear_pointer(&bundlelocation, g_free);
goto out;
}

if (!g_file_test (bundlelocation, G_FILE_TEST_EXISTS)) {
g_printerr("No such file: %s\n", bundlelocation);
g_clear_pointer(&bundlelocation, g_free);
goto out;
}
}

g_debug("input bundle: %s", bundlelocation);

args = install_args_new();
Expand Down Expand Up @@ -162,6 +178,7 @@ static gboolean install_start(int argc, char **argv)
install_args_free(args);

out:
g_clear_pointer(&bundlescheme, g_free);

return TRUE;
}
Expand Down
6 changes: 6 additions & 0 deletions test/rauc.t
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ test_expect_success "rauc status" "
rauc -c $SHARNESS_TEST_DIRECTORY/test-temp.conf status mark-bad
"

test_expect_success "rauc install invalid local paths" "
test_must_fail rauc install foo &&
test_must_fail rauc install foo.raucb &&
test_must_fail rauc install /path/to/foo.raucb
"

test_done

0 comments on commit 29d4771

Please sign in to comment.