systemd / systemd/systemd

systemctl disable doesn't remove symlink if it is present in a 'wants' directory that is itself symlinked

Open
#10,578 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

install needs-discussion 🤔
Dominant language
C
Stars
16.7k
Forks
4.7k
Avg merge
1d 6h
Merged PRs (30d)
140

Description

systemd version the issue has been seen with

systemd 239

Used distribution

Ubuntu 18.10

Expected behaviour you didn't see

systemctl disable should remove symlink created during systemctl enable, but it didn't if the symlink is in a 'wants' directory that is itself a symlink

Unexpected behaviour you saw

systemctl disable printed nothing and did not remove symlink created during systemctl enable

Steps to reproduce the problem

Steps performed as a non-root user on Ubuntu 18.10 with systemd 239 (also on 18.04 with systemd 237)

Works as expected when the 'wants' folder is not a symlink:

$ sudo bash -c 'echo -e "[Unit]\nDescription=Test unit\n\n[Install]\nWantedBy=my-target.target" > /lib/systemd/system/my-service.service'
$ systemctl enable my-service
Created symlink /etc/systemd/system/my-target.target.wants/my-service.service → /lib/systemd/system/my-service.service.
$ systemctl disable my-service
Removed /etc/systemd/system/my-target.target.wants/my-service.service.

Doesn't work when 'wants' directory is a symlink:

$ mkdir -p /tmp/etc/systemd/system/my-target.target.wants
$ sudo ln -s /tmp/etc/systemd/system/my-target.target.wants /etc/systemd/system/my-target.target.wants
$ systemctl enable my-service
Created symlink /etc/systemd/system/my-target.target.wants/my-service.service → /lib/systemd/system/my-service.service.
$ systemctl disable my-service
$ ls -l /etc/systemd/system/my-target.target.wants/my-service.service 
lrwxrwxrwx 1 root root 38 Oct 29 20:40 /etc/systemd/system/my-target.target.wants/my-service.service -> /lib/systemd/system/my-service.service

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with systemctl enable and systemctl disable using the symlinked /etc/systemd/system/my-target.target.wants directory and the unit at /lib/systemd/system/my-service.service. Trace the disable entry point and compare its handling of the symlinked wants directory with the non-symlinked case. Done means the service symlink is removed and the existing reproduction no longer leaves it behind.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.