mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
shared/install: nicer error message is symlinking chokes on an existing file
Fixes #1892. Previously: Failed to enable unit: Invalid argument Now: Failed to enable unit, file /etc/systemd/system/ssh.service already exists. It would be nice to include the unit name in the message too. I looked into this, but it would require major surgery on the whole installation logic, because we first create a list of things to change, and then try to apply them in a loop. To transfer the knowledge which unit was the source of each change, the data structures would have to be extended to carry the unit name over into the second loop. So I'm skipping this for now.
This commit is contained in:
parent
964b26fe21
commit
7d782f265d
@ -370,8 +370,14 @@ static int create_symlink(
|
||||
}
|
||||
|
||||
r = readlink_malloc(new_path, &dest);
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
/* translate EINVAL (non-symlink exists) to EEXIST */
|
||||
if (r == -EINVAL)
|
||||
r = -EEXIST;
|
||||
|
||||
unit_file_changes_add(changes, n_changes, r, new_path, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (path_equal(dest, old_path))
|
||||
return 0;
|
||||
@ -382,8 +388,10 @@ static int create_symlink(
|
||||
}
|
||||
|
||||
r = symlink_atomic(old_path, new_path);
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
unit_file_changes_add(changes, n_changes, r, new_path, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
unit_file_changes_add(changes, n_changes, UNIT_FILE_UNLINK, new_path, NULL);
|
||||
unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path);
|
||||
|
Loading…
Reference in New Issue
Block a user