Merge pull request #23048 from keszybz/Add-more-tests-for-specifiers
Add more tests for specifiers
This commit is contained in:
+10
-4
@@ -199,7 +199,7 @@ int specifier_boot_id(char specifier, const void *data, const char *root, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int specifier_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
int specifier_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
char *n;
|
||||
|
||||
assert(ret);
|
||||
@@ -212,7 +212,7 @@ int specifier_host_name(char specifier, const void *data, const char *root, cons
|
||||
return 0;
|
||||
}
|
||||
|
||||
int specifier_short_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
int specifier_short_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
char *n;
|
||||
|
||||
assert(ret);
|
||||
@@ -225,7 +225,7 @@ int specifier_short_host_name(char specifier, const void *data, const char *root
|
||||
return 0;
|
||||
}
|
||||
|
||||
int specifier_pretty_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
int specifier_pretty_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
|
||||
char *n = NULL;
|
||||
|
||||
assert(ret);
|
||||
@@ -276,12 +276,18 @@ int specifier_architecture(char specifier, const void *data, const char *root, c
|
||||
* installation. */
|
||||
|
||||
static int parse_os_release_specifier(const char *root, const char *id, char **ret) {
|
||||
char *v = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = parse_os_release(root, id, &v);
|
||||
if (r >= 0)
|
||||
/* parse_os_release() calls parse_env_file() which only sets the return value for
|
||||
* entries found. Let's make sure we set the return value in all cases. */
|
||||
*ret = v;
|
||||
|
||||
/* Translate error for missing os-release file to EUNATCH. */
|
||||
r = parse_os_release(root, id, ret);
|
||||
return r == -ENOENT ? -EUNATCH : r;
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -19,9 +19,9 @@ int specifier_real_directory(char specifier, const void *data, const char *root,
|
||||
|
||||
int specifier_machine_id(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_boot_id(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_short_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_pretty_host_name(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_short_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_pretty_hostname(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_kernel_release(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_architecture(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
int specifier_os_id(char specifier, const void *data, const char *root, const void *userdata, char **ret);
|
||||
@@ -70,30 +70,30 @@ int specifier_var_tmp_dir(char specifier, const void *data, const char *root, co
|
||||
* %V: the temporary directory for large, persistent stuff (e.g. /var/tmp, or $TMPDIR, $TEMP, $TMP)
|
||||
*/
|
||||
|
||||
#define COMMON_SYSTEM_SPECIFIERS \
|
||||
{ 'a', specifier_architecture, NULL }, \
|
||||
{ 'A', specifier_os_image_version,NULL }, \
|
||||
{ 'b', specifier_boot_id, NULL }, \
|
||||
{ 'B', specifier_os_build_id, NULL }, \
|
||||
{ 'H', specifier_host_name, NULL }, \
|
||||
{ 'l', specifier_short_host_name, NULL }, \
|
||||
{ 'q', specifier_pretty_host_name,NULL }, \
|
||||
{ 'm', specifier_machine_id, NULL }, \
|
||||
{ 'M', specifier_os_image_id, NULL }, \
|
||||
{ 'o', specifier_os_id, NULL }, \
|
||||
{ 'v', specifier_kernel_release, NULL }, \
|
||||
{ 'w', specifier_os_version_id, NULL }, \
|
||||
{ 'W', specifier_os_variant_id, NULL }
|
||||
#define COMMON_SYSTEM_SPECIFIERS \
|
||||
{ 'a', specifier_architecture, NULL }, \
|
||||
{ 'A', specifier_os_image_version, NULL }, \
|
||||
{ 'b', specifier_boot_id, NULL }, \
|
||||
{ 'B', specifier_os_build_id, NULL }, \
|
||||
{ 'H', specifier_hostname, NULL }, \
|
||||
{ 'l', specifier_short_hostname, NULL }, \
|
||||
{ 'q', specifier_pretty_hostname, NULL }, \
|
||||
{ 'm', specifier_machine_id, NULL }, \
|
||||
{ 'M', specifier_os_image_id, NULL }, \
|
||||
{ 'o', specifier_os_id, NULL }, \
|
||||
{ 'v', specifier_kernel_release, NULL }, \
|
||||
{ 'w', specifier_os_version_id, NULL }, \
|
||||
{ 'W', specifier_os_variant_id, NULL }
|
||||
|
||||
#define COMMON_CREDS_SPECIFIERS(scope) \
|
||||
{ 'g', specifier_group_name, INT_TO_PTR(scope) }, \
|
||||
{ 'G', specifier_group_id, INT_TO_PTR(scope) }, \
|
||||
{ 'u', specifier_user_name, INT_TO_PTR(scope) }, \
|
||||
{ 'U', specifier_user_id, INT_TO_PTR(scope) }
|
||||
#define COMMON_CREDS_SPECIFIERS(scope) \
|
||||
{ 'g', specifier_group_name, INT_TO_PTR(scope) }, \
|
||||
{ 'G', specifier_group_id, INT_TO_PTR(scope) }, \
|
||||
{ 'u', specifier_user_name, INT_TO_PTR(scope) }, \
|
||||
{ 'U', specifier_user_id, INT_TO_PTR(scope) }
|
||||
|
||||
#define COMMON_TMP_SPECIFIERS \
|
||||
{ 'T', specifier_tmp_dir, NULL }, \
|
||||
{ 'V', specifier_var_tmp_dir, NULL }
|
||||
#define COMMON_TMP_SPECIFIERS \
|
||||
{ 'T', specifier_tmp_dir, NULL }, \
|
||||
{ 'V', specifier_var_tmp_dir, NULL }
|
||||
|
||||
static inline char* specifier_escape(const char *string) {
|
||||
return strreplace(string, "%", "%%");
|
||||
|
||||
Reference in New Issue
Block a user