Merge pull request #25080 from keszybz/search-paths

Refusing linking files underneath our hierarchy, improve error messages
This commit is contained in:
Yu Watanabe
2022-10-25 01:57:41 +09:00
committed by GitHub
5 changed files with 128 additions and 101 deletions
+7 -3
View File
@@ -2133,8 +2133,6 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) {
/* Create an error reply, using the error information from changes[]
* if possible, and fall back to generating an error from error code c.
* The error message only describes the first error.
*
* Coordinate with install_changes_dump() in install.c.
*/
static int install_error(
sd_bus_error *error,
@@ -2146,8 +2144,9 @@ static int install_error(
for (size_t i = 0; i < n_changes; i++)
switch (changes[i].type) {
/* When making changes here, make sure to also change install_changes_dump() in install.c. */
switch (changes[i].type) {
case 0 ... _INSTALL_CHANGE_TYPE_MAX: /* not errors */
break;
@@ -2172,6 +2171,11 @@ static int install_error(
"Unit %s is transient or generated.", changes[i].path);
goto found;
case -ETXTBSY:
r = sd_bus_error_setf(error, BUS_ERROR_UNIT_BAD_PATH,
"File %s is under the systemd unit hierarchy already.", changes[i].path);
goto found;
case -EUCLEAN:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"\"%s\" is not a valid unit name.",