1
0
mirror of https://github.com/systemd/systemd synced 2026-03-17 18:44:46 +01:00

Compare commits

..

No commits in common. "357f5b07ae79ba55ea91c01412e9c98279231327" and "3fe398cec036ac810344b5b13b07cddcca1acd49" have entirely different histories.

6 changed files with 9 additions and 26 deletions

View File

@ -528,9 +528,6 @@ int unit_name_from_path(const char *path, const char *suffix, char **ret) {
if (!s) if (!s)
return -ENOMEM; return -ENOMEM;
if (strlen(s) >= UNIT_NAME_MAX) /* Return a slightly more descriptive error for this specific condition */
return -ENAMETOOLONG;
/* Refuse this if this got too long or for some other reason didn't result in a valid name */ /* Refuse this if this got too long or for some other reason didn't result in a valid name */
if (!unit_name_is_valid(s, UNIT_NAME_PLAIN)) if (!unit_name_is_valid(s, UNIT_NAME_PLAIN))
return -EINVAL; return -EINVAL;
@ -562,9 +559,6 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha
if (!s) if (!s)
return -ENOMEM; return -ENOMEM;
if (strlen(s) >= UNIT_NAME_MAX) /* Return a slightly more descriptive error for this specific condition */
return -ENAMETOOLONG;
/* Refuse this if this got too long or for some other reason didn't result in a valid name */ /* Refuse this if this got too long or for some other reason didn't result in a valid name */
if (!unit_name_is_valid(s, UNIT_NAME_INSTANCE)) if (!unit_name_is_valid(s, UNIT_NAME_INSTANCE))
return -EINVAL; return -EINVAL;

View File

@ -1713,18 +1713,11 @@ static int mount_setup_unit(
.burst = 1, .burst = 1,
}; };
if (r == -ENAMETOOLONG)
return log_struct_errno( return log_struct_errno(
ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r, ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
"MESSAGE_ID=" SD_MESSAGE_MOUNT_POINT_PATH_NOT_SUITABLE_STR, "MESSAGE_ID=" SD_MESSAGE_MOUNT_POINT_PATH_NOT_SUITABLE_STR,
"MOUNT_POINT=%s", where, "MOUNT_POINT=%s", where,
LOG_MESSAGE("Mount point path '%s' too long to fit into unit name, ignoring mount point.", where)); LOG_MESSAGE("Failed to generate valid unit name from path '%s', ignoring mount point: %m", where));
return log_struct_errno(
ratelimit_below(&rate_limit) ? LOG_WARNING : LOG_DEBUG, r,
"MESSAGE_ID=" SD_MESSAGE_MOUNT_POINT_PATH_NOT_SUITABLE_STR,
"MOUNT_POINT=%s", where,
LOG_MESSAGE("Failed to generate valid unit name from mount point path '%s', ignoring mount point: %m", where));
} }
u = manager_get_unit(m, e); u = manager_get_unit(m, e);

View File

@ -1448,9 +1448,6 @@ int swap_process_device_new(Manager *m, sd_device *dev) {
int q; int q;
q = unit_name_from_path(devlink, ".swap", &n); q = unit_name_from_path(devlink, ".swap", &n);
if (IN_SET(q, -EINVAL, -ENAMETOOLONG)) /* If name too long or otherwise not convertible to
* unit name, we can't manage it */
continue;
if (q < 0) if (q < 0)
return q; return q;

View File

@ -1473,17 +1473,16 @@ static int unit_add_mount_dependencies(Unit *u) {
Unit *m; Unit *m;
r = unit_name_from_path(prefix, ".mount", &p); r = unit_name_from_path(prefix, ".mount", &p);
if (IN_SET(r, -EINVAL, -ENAMETOOLONG))
continue; /* If the path cannot be converted to a mount unit name, then it's
* not managable as a unit by systemd, and hence we don't need a
* dependency on it. Let's thus silently ignore the issue. */
if (r < 0) if (r < 0)
return r; return r;
m = manager_get_unit(u->manager, p); m = manager_get_unit(u->manager, p);
if (!m) { if (!m) {
/* Make sure to load the mount unit if it exists. If so the dependencies on /* Make sure to load the mount unit if
* this unit will be added later during the loading of the mount unit. */ * it exists. If so the dependencies
* on this unit will be added later
* during the loading of the mount
* unit. */
(void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m); (void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m);
continue; continue;
} }

View File

@ -146,7 +146,7 @@ static void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
} }
void cryptsetup_enable_logging(struct crypt_device *cd) { void cryptsetup_enable_logging(struct crypt_device *cd) {
/* It's OK to call this with a NULL parameter, in which case libcryptsetup will set the default log /* It's OK to call this with a NULL parameter, in which case libcryptsetup will set the defaut log
* function. * function.
* *
* Note that this is also called from dlopen_cryptsetup(), which we call here too. Sounds like an * Note that this is also called from dlopen_cryptsetup(), which we call here too. Sounds like an

View File

@ -130,7 +130,7 @@ static void test_unit_name_from_path(void) {
test_unit_name_from_path_one("///", ".mount", "-.mount", 0); test_unit_name_from_path_one("///", ".mount", "-.mount", 0);
test_unit_name_from_path_one("/foo/../bar", ".mount", NULL, -EINVAL); test_unit_name_from_path_one("/foo/../bar", ".mount", NULL, -EINVAL);
test_unit_name_from_path_one("/foo/./bar", ".mount", "foo-bar.mount", 0); test_unit_name_from_path_one("/foo/./bar", ".mount", "foo-bar.mount", 0);
test_unit_name_from_path_one("/waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ".mount", NULL, -ENAMETOOLONG); test_unit_name_from_path_one("/waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ".mount", NULL, -EINVAL);
} }
static void test_unit_name_from_path_instance_one(const char *pattern, const char *path, const char *suffix, const char *expected, int ret) { static void test_unit_name_from_path_instance_one(const char *pattern, const char *path, const char *suffix, const char *expected, int ret) {
@ -160,7 +160,7 @@ static void test_unit_name_from_path_instance(void) {
test_unit_name_from_path_instance_one("waldo", "..", ".mount", NULL, -EINVAL); test_unit_name_from_path_instance_one("waldo", "..", ".mount", NULL, -EINVAL);
test_unit_name_from_path_instance_one("waldo", "/foo", ".waldi", NULL, -EINVAL); test_unit_name_from_path_instance_one("waldo", "/foo", ".waldi", NULL, -EINVAL);
test_unit_name_from_path_instance_one("wa--ldo", "/--", ".mount", "wa--ldo@\\x2d\\x2d.mount", 0); test_unit_name_from_path_instance_one("wa--ldo", "/--", ".mount", "wa--ldo@\\x2d\\x2d.mount", 0);
test_unit_name_from_path_instance_one("waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "/waldo", ".mount", NULL, -ENAMETOOLONG); test_unit_name_from_path_instance_one("waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "/waldo", ".mount", NULL, -EINVAL);
} }
static void test_unit_name_to_path_one(const char *unit, const char *path, int ret) { static void test_unit_name_to_path_one(const char *unit, const char *path, int ret) {