Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly detect if systemd is used in Debian #488

Closed
wants to merge 1 commit into from
Closed

Correctly detect if systemd is used in Debian #488

wants to merge 1 commit into from

Conversation

brontolinux
Copy link

CFEngine 3.6 tries to understand if a Linux is using systemd as init system
by looking at the contents of /proc/1/cmdline, that happens in
bundle common inventory_linux. That's indeed a smart thing to do but unfortunately
fails on Debian Jessie, where you have:

root@cf-test-v10:~# ls -l /sbin/init
lrwxrwxrwx 1 root root 20 May 26 06:07 /sbin/init -> /lib/systemd/systemd

the pseudo-file in /proc will still report /sbin/init and as a result the systemd
class won't be set. This affects services promises negatively

This patch checks if /sbin/init is a link; if it is, and it points to systemd,
the systemd class is set

CFEngine 3.6 tries to understand if a Linux is using systemd as init system
by looking at the contents of /proc/1/cmdline, that happens in
bundle common inventory_linux. That's indeed a smart thing to do but unfortunately
fails on Debian Jessie, where you have:

root@cf-test-v10:~# ls -l /sbin/init
lrwxrwxrwx 1 root root 20 May 26 06:07 /sbin/init -> /lib/systemd/systemd

the pseudo-file in /proc will still report /sbin/init and as a result the systemd
class won't be set. This affects services promises negatively

This patch checks if /sbin/init is a link; if it is, and it points to systemd,
the systemd class is set
@cfengine-review-bot
Copy link

Can one of the admins verify this patch?

@@ -82,6 +87,12 @@ bundle common inventory_debian
comment => "derived from Debian",
meta => { "inventory", "attribute_name=none" };

init_is_link::
"systemd"
expression => regcmp("/lib/systemd/systemd",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be .*/systemd$ instead, to catch all possible paths where systemd might be installed?

@kacf
Copy link
Contributor

kacf commented Jun 24, 2015

+1!

Note that the same thing exists in C code (https://github.com/cfengine/core/blob/master/libenv/sysinfo.c#L993-L1012).

Ticket: https://dev.cfengine.com/issues/7297

@kacf
Copy link
Contributor

kacf commented Jun 24, 2015

See also cfengine/core#2249.

@brontolinux
Copy link
Author

No problem in matching the final part of the path. Currently it's /lib/systemd/systemd in jessie but a pattern matching is probably more future-proof.

@kacf
Copy link
Contributor

kacf commented Jun 26, 2015

In fact I don't think this is necessary anymore after cfengine/core#2252. Closing this to avoid having the detection in two places. Thanks for the Proof of Concept though! :-)

@kacf kacf closed this Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants