return false;
}
-static bool mount_is_credentials(Mount *m) {
+static bool mount_point_is_credentials(Manager *manager, const char *path) {
const char *e;
- assert(m);
+ assert(manager);
+ assert(path);
- /* Returns true if this is a credentials mount. We don't want automatic dependencies on credential
- * mounts, since they are managed by us for even the earliest services, and we never want anything to
- * be ordered before them hence. */
+ /* Returns true if this is a credentials mount. We don't want to generate mount units for them,
+ * since their lifetime is strictly bound to services. */
- e = path_startswith(m->where, UNIT(m)->manager->prefix[EXEC_DIRECTORY_RUNTIME]);
+ e = path_startswith(path, manager->prefix[EXEC_DIRECTORY_RUNTIME]);
if (!e)
return false;
return r;
/* If this is a tmpfs mount then we have to unmount it before we try to deactivate swaps */
- if (streq_ptr(p->fstype, "tmpfs") && !mount_is_credentials(m)) {
+ if (streq_ptr(p->fstype, "tmpfs")) {
r = unit_add_dependency_by_name(UNIT(m), UNIT_AFTER, SPECIAL_SWAP_TARGET,
/* add_reference= */ true, mask);
if (r < 0)
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Where= setting doesn't match unit name. Refusing.");
if (mount_point_is_api(m->where) || mount_point_ignore(m->where))
- return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Cannot create mount unit for API file system %s. Refusing.", m->where);
+ return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC),
+ "Cannot create mount unit for API file system '%s'. Refusing.", m->where);
+
+ if (mount_point_is_credentials(UNIT(m)->manager, m->where))
+ return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC),
+ "Cannot create mount unit for credential mount '%s'. Refusing.", m->where);
p = get_mount_parameters_fragment(m);
if (p && !p->what && !UNIT(m)->perpetual)
- return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC),
- "What= setting is missing. Refusing.");
+ return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "What= setting is missing. Refusing.");
if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP)
return log_unit_error_errno(UNIT(m), SYNTHETIC_ERRNO(ENOEXEC), "Unit has PAM enabled. Kill mode must be set to control-group'. Refusing.");
if (!m->where)
return 0;
- if (mount_is_credentials(m))
- UNIT(m)->default_dependencies = false;
-
/* Adds in all dependencies directly responsible for ordering the mount, as opposed to dependencies
* resulting from the ExecContext and such. */
assert(options);
assert(fstype);
- /* Ignore API mount points. They should never be referenced in
- * dependencies ever. */
- if (mount_point_is_api(where) || mount_point_ignore(where))
+ /* Ignore API and credential mount points. They should never be referenced in dependencies ever.
+ * Also check the comment for mount_point_is_credentials. */
+ if (mount_point_is_api(where) || mount_point_ignore(where) || mount_point_is_credentials(m, where))
return 0;
if (streq(fstype, "autofs"))