core: restrict ImportCredential= globbing
Let's restrict how we apply credential globbing in ImportCredential=, so that we have some flexibility in automatically extending the glob expression with per-instance data eventually without getting into conflict with the globbing parts. In our current uses we only allow globbing at the end of the expression, and this is a new, unreleased feature hence let's be restrictive on this initially. We can still relax this later if we feel the need to after all. Fixes: #28022
This commit is contained in:
@@ -71,4 +71,51 @@ TEST(read_credential_strings) {
|
||||
assert_se(unsetenv("CREDENTIALS_DIRECTORY") >= 0);
|
||||
}
|
||||
|
||||
TEST(credential_name_valid) {
|
||||
char buf[NAME_MAX+2];
|
||||
|
||||
assert_se(!credential_name_valid(NULL));
|
||||
assert_se(!credential_name_valid(""));
|
||||
assert_se(!credential_name_valid("."));
|
||||
assert_se(!credential_name_valid(".."));
|
||||
assert_se(!credential_name_valid("foo/bar"));
|
||||
assert_se(credential_name_valid("foo"));
|
||||
|
||||
memset(buf, 'x', sizeof(buf)-1);
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
assert_se(!credential_name_valid(buf));
|
||||
|
||||
buf[sizeof(buf)-2] = 0;
|
||||
assert_se(credential_name_valid(buf));
|
||||
}
|
||||
|
||||
TEST(credential_glob_valid) {
|
||||
char buf[NAME_MAX+2];
|
||||
|
||||
assert_se(!credential_glob_valid(NULL));
|
||||
assert_se(!credential_glob_valid(""));
|
||||
assert_se(!credential_glob_valid("."));
|
||||
assert_se(!credential_glob_valid(".."));
|
||||
assert_se(!credential_glob_valid("foo/bar"));
|
||||
assert_se(credential_glob_valid("foo"));
|
||||
assert_se(credential_glob_valid("foo*"));
|
||||
assert_se(credential_glob_valid("x*"));
|
||||
assert_se(credential_glob_valid("*"));
|
||||
assert_se(!credential_glob_valid("?"));
|
||||
assert_se(!credential_glob_valid("*a"));
|
||||
assert_se(!credential_glob_valid("a?"));
|
||||
assert_se(!credential_glob_valid("a[abc]"));
|
||||
assert_se(!credential_glob_valid("a[abc]"));
|
||||
|
||||
memset(buf, 'x', sizeof(buf)-1);
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
assert_se(!credential_glob_valid(buf));
|
||||
|
||||
buf[sizeof(buf)-2] = 0;
|
||||
assert_se(credential_glob_valid(buf));
|
||||
|
||||
buf[sizeof(buf)-2] = '*';
|
||||
assert_se(credential_glob_valid(buf));
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_INFO);
|
||||
|
||||
Reference in New Issue
Block a user