Pull request? properly recognize systemd on Debian

26 views
Skip to first unread message

Marco Marongiu

unread,
Jun 12, 2015, 11:37:51 AM6/12/15
to help-c...@googlegroups.com
In Debian Jessie, CFEngine doesn't recognize if systemd is used. I found
a simple way to make the agent properly recognize Debian's set-up:

http://syslog.me/2015/06/12/how-to-make-cfengine-recognize-if-systemd-is-used-in-debian/

Please let me know if I should make a pull request against
inventory/debian.cf in masterfiles. Thanks.

Have a good weekend everyone, ciao!
-- bronto

Alex Georgopoulos

unread,
Jun 12, 2015, 4:04:35 PM6/12/15
to help-c...@googlegroups.com
On my jessie box I looked at /proc/1/comm in my policy

cat /proc/1/comm
systemd


Seems a lot easier to me. I didn't realize it looked at cmdline.

Ted Zlatanov

unread,
Jun 13, 2015, 5:30:56 PM6/13/15
to help-c...@googlegroups.com
On Fri, 12 Jun 2015 13:04:35 -0700 (PDT) Alex Georgopoulos <ageo...@gmail.com> wrote:

AG> On my jessie box I looked at /proc/1/comm in my policy
AG> cat /proc/1/comm
AG> systemd

AG> Seems a lot easier to me. I didn't realize it looked at cmdline.

That's nice and fast. But is it guaranteed that if you run systemd,
procfs will be available?

Ted

Marco Marongiu

unread,
Jun 14, 2015, 6:11:08 AM6/14/15
to help-c...@googlegroups.com

If it's not, then you have a bigger problem because that's exactly how cfengine currently detects if systemd is the running init system

--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.

Brian Bennett

unread,
Jun 14, 2015, 6:52:16 AM6/14/15
to help-c...@googlegroups.com
I'm pretty sure procfs is required. Utilities like top and ps depend on procfs (not to mention many, many more).

Joyent has recently done a lot of work to get Linux binaries to run natively on SmartOS. A large portion of that was adding support for Linuxisms to the emulated procfs (since Linux uses procfs entirely differently than Unix does).

--
Brian Bennett
Looking for CFEngine training?
http://www.verticalsysadmin.com/

Ted Zlatanov

unread,
Jun 14, 2015, 6:58:11 AM6/14/15
to help-c...@googlegroups.com
On Sun, 14 Jun 2015 12:11:07 +0200 Marco Marongiu <bront...@gmail.com> wrote:

MM> On 13 Jun 2015 23:30, "Ted Zlatanov" <t...@lifelogs.com> wrote:

>> is it guaranteed that if you run systemd, procfs will be available?

MM> If it's not, then you have a bigger problem because that's exactly how
MM> cfengine currently detects if systemd is the running init system

That doesn't mean the question is invalid.

Ted

Ted Zlatanov

unread,
Jun 15, 2015, 9:28:34 AM6/15/15
to help-c...@googlegroups.com
On Sun, 14 Jun 2015 03:51:08 -0700 Brian Bennett <brian....@verticalsysadmin.com> wrote:

>> On Jun 13, 2015, at 2:30 PM, Ted Zlatanov <t...@lifelogs.com> wrote:

>> is it guaranteed that if you run systemd, procfs will be available?

BB> I'm pretty sure procfs is required. Utilities like top and ps depend on procfs (not to mention many, many more).

To be sure, I looked at the systemd source tree at
https://github.com/systemd/systemd and although procfs is not an
explicit dependency, it's used in many places, scripts and code. Thank
you.

Ted

Marco Marongiu

unread,
Jun 18, 2015, 10:03:52 AM6/18/15
to help-c...@googlegroups.com
>>> is it guaranteed that if you run systemd, procfs will be available?
>
> BB> I'm pretty sure procfs is required. Utilities like top and ps depend on procfs (not to mention many, many more).
>
> To be sure, I looked at the systemd source tree at
> https://github.com/systemd/systemd and although procfs is not an
> explicit dependency, it's used in many places, scripts and code. Thank
> you.

OK, so should I make a pull request so that we can have this out with
3.7.0 final??? Or it's so simple that you're fixing it "in house"?

Ciao
-- bronto

Ted Zlatanov

unread,
Jun 18, 2015, 11:34:29 AM6/18/15
to help-c...@googlegroups.com
On Thu, 18 Jun 2015 16:03:44 +0200 Marco Marongiu <bront...@gmail.com> wrote:

>>>> is it guaranteed that if you run systemd, procfs will be available?
>>
BB> I'm pretty sure procfs is required. Utilities like top and ps depend on procfs (not to mention many, many more).
>>
>> To be sure, I looked at the systemd source tree at
>> https://github.com/systemd/systemd and although procfs is not an
>> explicit dependency, it's used in many places, scripts and code. Thank
>> you.

MM> OK, so should I make a pull request so that we can have this out with
MM> 3.7.0 final??? Or it's so simple that you're fixing it "in house"?

You should make a PR.

Ted

Marco Marongiu

unread,
Jun 19, 2015, 8:26:41 AM6/19/15
to help-c...@googlegroups.com
On 18/06/15 17:34, Ted Zlatanov wrote:
> MM> OK, so should I make a pull request so that we can have this out with
> MM> 3.7.0 final??? Or it's so simple that you're fixing it "in house"?
>
> You should make a PR.

OK. I'll try and remember how to do that :-D

Marco Marongiu

unread,
Jun 19, 2015, 2:56:39 PM6/19/15
to help-c...@googlegroups.com
On 18/06/15 17:34, Ted Zlatanov wrote:
> MM> OK, so should I make a pull request so that we can have this out with
> MM> 3.7.0 final??? Or it's so simple that you're fixing it "in house"?
>
> You should make a PR.

there you go: https://github.com/cfengine/masterfiles/pull/488

Dimitrios Apostolou

unread,
Jun 19, 2015, 3:18:27 PM6/19/15
to Marco Marongiu, help-c...@googlegroups.com
Thanks Marco!

Currently CFEngine sets the "systemd" hard class in C code (sysinfo.c)
as following: read "/proc/1/cmdline", test if it ends with "/systemd".

What do you think is missing for the detection to work on Jessie? If
it is only the symlink dereference, that would be quite easy to fix.

Your pull request in masterfiles looks good, but I'm not sure if it
will be needed once a proper C code fix is in place, /maybe/ it will
be for proper inventory reports, but the masterfiles maintainers will
have the final word.


Thanks for reporting the bug!
Dimitris

P.S. is there a ticket open?

Marco Marongiu

unread,
Jun 19, 2015, 4:46:01 PM6/19/15
to help-c...@googlegroups.com
Hi Dimitrios

On 19/06/15 21:18, Dimitrios Apostolou wrote:
>> there you go: https://github.com/cfengine/masterfiles/pull/488
> Thanks Marco!
>
> Currently CFEngine sets the "systemd" hard class in C code (sysinfo.c)
> as following: read "/proc/1/cmdline", test if it ends with "/systemd".

Uhm... OK. I see it also in bundle common inventory_linux:

> has_proc_1_cmdline::
> "systemd" expression => strcmp(lastnode($(proc_1_process), "/"), "systemd"),
> comment => "Check if (the link target of) /proc/1/cmdline is systemd";



> What do you think is missing for the detection to work on Jessie? If
> it is only the symlink dereference, that would be quite easy to fix.

That's it


> Your pull request in masterfiles looks good, but I'm not sure if it
> will be needed once a proper C code fix is in place, /maybe/ it will
> be for proper inventory reports, but the masterfiles maintainers will
> have the final word.

Well, if it's an hard class, then maybe it makes sense to remove it from
the inventory, too.

If it's OK to have in both places or it should be only in the inventory,
then something in the lines of my patch should suffice.


> Thanks for reporting the bug!

My pleasure ;-)


> P.S. is there a ticket open?

Nope! You got the fix straight ;-)

Ciao!
-- bronto


Dimitrios Apostolou

unread,
Jun 22, 2015, 6:26:27 AM6/22/15
to Marco Marongiu, help-c...@googlegroups.com
On Fri, Jun 19, 2015 at 10:45 PM, Marco Marongiu <bront...@gmail.com> wrote:
>> P.S. is there a ticket open?
>
> Nope! You got the fix straight ;-)

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


Dimitris

Alex Georgopoulos

unread,
Jul 7, 2015, 2:50:29 PM7/7/15
to help-c...@googlegroups.com
I also want to add that cf-agent segfaults on 3.6 if /proc is missing.  I think it's safe to assume it's there.
Reply all
Reply to author
Forward
0 new messages