deb-systemd-helper crashes while removing packages with unusual (but legal) Alias in unit config
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | init-system-helpers (Ubuntu) |
Medium
|
Martin Pitt | ||
Bug Description
While working on mysql-5.6 package we met unusual (maybe even partially incorrect) Alias option in systemd unit config:
Alias=mysql.service
It is unusual because mysql.service is the original name of the service which can be found inside /lib/systemd/
Installation went well and the following alias symlink has been created:
/etc/systemd/
Service was accessible via systemctl and everything was fine.
When you try to remove/purge the package you get the following error:
/usr/bin/
This happens because deb-systemd-helper tries to 'mask' service the following way:
sub mask_service {
my ($scriptname, $service_path) = @_;
my $mask_link = '/etc/systemd/
if (-e $mask_link) {
# If the link already exists, don’t do anything.
return if -l $mask_link && readlink(
debug "$mask_link already exists, not masking.";
return;
}
make_
symlink(
<...>
}
Check for '-e $mask_link' FAILS because symlink's TARGET (/lib/systemd/
WORKAROUND: If apt-get remove/purge crashes with the error mentioned above you need to manually remove symlink inside /etc/systemd/system (/etc/systemd/
I'm not sure if we want to fix that.
On one hand, this situation is pretty rare.
On other hand though, such Alias=<
This issue with Alias= has been fixed (by removing this useless Alias) in mysql-5.6 so that's not a blocker for us.
| description: | updated |
| tags: | added: systemd-boot |
| Martin Pitt (pitti) wrote : | #1 |
| Changed in init-system-helpers (Ubuntu): | |
| status: | New → Triaged |
| importance: | Undecided → Medium |
| assignee: | nobody → Martin Pitt (pitti) |
| Changed in init-system-helpers (Ubuntu): | |
| status: | Triaged → In Progress |
| Martin Pitt (pitti) wrote : | #2 |
I added a couple of test cases for existing functionality, and now added a test and a fix for this bug:
http://
| Changed in init-system-helpers (Ubuntu): | |
| status: | In Progress → Fix Committed |
| Launchpad Janitor (janitor) wrote : | #3 |
This bug was fixed in the package init-system-helpers - 1.22ubuntu9
---------------
init-system-helpers (1.22ubuntu9) vivid; urgency=medium
Cherry-pick tests and a bug fix from Debian git:
* t/001-deb-
* t/001-deb-
* t/001-deb-
uninstalled .service file (as in package postrm scripts).
* deb-systemd-helper: Ignore Also= and Alias= referring to itself, and avoid
mask symlink creation errors on systems where units with those have
already been installed. Add corresponding test to
001-
-- Martin Pitt <email address hidden> Thu, 09 Apr 2015 13:10:17 +0200
| Changed in init-system-helpers (Ubuntu): | |
| status: | Fix Committed → Fix Released |


Simple reproducer:
$ cat /lib/systemd/ system/ selfalias. service
[Unit]
Description=alias to self
[Service]
ExecStart=/bin/true
[Install] multi-user. target .service
WantedBy=
Alias=selfalias
$ sudo DPKG_MAINTSCRIP T_PACKAGE= 1 deb-systemd-helper enable selfalias.service system/ selfalias. service{ ,.removed} HELPER_ DEBUG=1 DPKG_MAINTSCRIP T_PACKAGE= 1 deb-systemd-helper mask selfalias.service
$ sudo mv /lib/systemd/
$ sudo _DEB_SYSTEMD_