DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(creation_mode_verb, CreationMode);
-static int specifier_machine_id_safe(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
- int r;
-
- /* If /etc/machine_id is missing or empty (e.g. in a chroot environment) return a recognizable error
- * so that the caller can skip the rule gracefully. */
-
- r = specifier_machine_id(specifier, data, root, userdata, ret);
- if (IN_SET(r, -ENOENT, -ENOMEDIUM))
- return -ENXIO;
-
- return r;
+/* Different kinds of errors that mean that information is not available in the environment. */
+static inline bool ERRNO_IS_NOINFO(int r) {
+ return IN_SET(abs(r),
+ EUNATCH, /* os-release or machine-id missing */
+ ENOMEDIUM, /* machine-id or another file empty */
+ ENXIO); /* env var is unset */
}
static int specifier_directory(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
return r;
r = xdg_user_config_dir(&persistent_config, "/user-tmpfiles.d");
- if (r < 0 && r != -ENXIO)
+ if (r < 0 && !ERRNO_IS_NOINFO(r))
return r;
r = xdg_user_runtime_dir(&runtime_config, "/user-tmpfiles.d");
- if (r < 0 && r != -ENXIO)
+ if (r < 0 && !ERRNO_IS_NOINFO(r))
return r;
r = xdg_user_data_dir(&data_home, "/user-tmpfiles.d");
- if (r < 0 && r != -ENXIO)
+ if (r < 0 && !ERRNO_IS_NOINFO(r))
return r;
r = strv_extend_strv_concat(&res, config_dirs, "/user-tmpfiles.d");
{ 'B', specifier_os_build_id, NULL },
{ 'H', specifier_hostname, NULL },
{ 'l', specifier_short_hostname, NULL },
- { 'm', specifier_machine_id_safe, NULL },
+ { 'm', specifier_machine_id, NULL },
{ 'o', specifier_os_id, NULL },
{ 'v', specifier_kernel_release, NULL },
{ 'w', specifier_os_version_id, NULL },
i.try_replace = try_replace;
r = specifier_printf(path, PATH_MAX-1, specifier_table, arg_root, NULL, &i.path);
- if (r == -ENXIO)
+ if (ERRNO_IS_NOINFO(r))
return log_unresolvable_specifier(fname, line);
if (r < 0) {
if (IN_SET(r, -EINVAL, -EBADSLT))
if (!unbase64) {
/* Do specifier expansion except if base64 mode is enabled */
r = specifier_expansion_from_arg(specifier_table, &i);
- if (r == -ENXIO)
+ if (ERRNO_IS_NOINFO(r))
return log_unresolvable_specifier(fname, line);
if (r < 0) {
if (IN_SET(r, -EINVAL, -EBADSLT))
r = read_credential(i.argument, &i.binary_argument, &i.binary_argument_size);
if (IN_SET(r, -ENXIO, -ENOENT)) {
/* Silently skip over lines that have no credentials passed */
- log_syntax(NULL, LOG_INFO, fname, line, 0, "Credential '%s' not specified, skipping line.", i.argument);
+ log_syntax(NULL, LOG_INFO, fname, line, 0,
+ "Credential '%s' not specified, skipping line.", i.argument);
return 0;
}
if (r < 0)