- Parse /proc/1/cmdline to detect systemd
0001-Evaluate-proc-1-cmdline-and-check-for-systemd.patch OBS-URL: https://build.opensuse.org/package/show/systemsmanagement/cfengine?expand=0&rev=87
This commit is contained in:
parent
76f1d50926
commit
fbc1f08371
96
0001-Evaluate-proc-1-cmdline-and-check-for-systemd.patch
Normal file
96
0001-Evaluate-proc-1-cmdline-and-check-for-systemd.patch
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
From 66cfed74c4a14d89c9c7078c7ce1c16d26af5d1e Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
|
||||||
|
Date: Fri, 4 Apr 2014 22:03:29 +0200
|
||||||
|
Subject: [PATCH] Evaluate /proc/1/cmdline and check for systemd
|
||||||
|
|
||||||
|
Set 'systemd' class eventually.
|
||||||
|
---
|
||||||
|
libenv/sysinfo.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
1 file changed, 50 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libenv/sysinfo.c b/libenv/sysinfo.c
|
||||||
|
index 901791220855..64ca0aa5a880 100644
|
||||||
|
--- a/libenv/sysinfo.c
|
||||||
|
+++ b/libenv/sysinfo.c
|
||||||
|
@@ -114,6 +114,7 @@ static time_t GetBootTimeFromUptimeCommand(time_t); // Last resort
|
||||||
|
void CalculateDomainName(const char *nodename, const char *dnsname, char *fqname, char *uqname, char *domain);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
+static void Linux_Systemd(EvalContext *ctx);
|
||||||
|
static int Linux_Os_Release(EvalContext *ctx);
|
||||||
|
static int Linux_Fedora_Version(EvalContext *ctx);
|
||||||
|
static int Linux_Redhat_Version(EvalContext *ctx);
|
||||||
|
@@ -929,14 +930,17 @@ static void OSClasses(EvalContext *ctx)
|
||||||
|
#ifdef __linux__
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
-/* Mandrake/Mandriva, Fedora and Oracle VM Server supply /etc/redhat-release, so
|
||||||
|
- we test for those distributions first */
|
||||||
|
+ /* check for systemd init process */
|
||||||
|
+ Linux_Systemd(ctx);
|
||||||
|
|
||||||
|
if (stat("/etc/os-release", &statbuf) != -1)
|
||||||
|
{
|
||||||
|
Linux_Os_Release(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Mandrake/Mandriva, Fedora and Oracle VM Server supply /etc/redhat-release, so
|
||||||
|
+ we test for those distributions first */
|
||||||
|
+
|
||||||
|
if (stat("/etc/mandriva-release", &statbuf) != -1)
|
||||||
|
{
|
||||||
|
Linux_Mandriva_Version(ctx);
|
||||||
|
@@ -1220,6 +1224,50 @@ static void OSClasses(EvalContext *ctx)
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
|
||||||
|
+static void Linux_Systemd(EvalContext *ctx)
|
||||||
|
+{
|
||||||
|
+ char proc1[CF_MAXVARSIZE];
|
||||||
|
+ struct stat statbuf;
|
||||||
|
+ char *slash;
|
||||||
|
+
|
||||||
|
+ if (!ReadLine("/proc/1/cmdline", proc1, sizeof(proc1)))
|
||||||
|
+ {
|
||||||
|
+ UnexpectedError("Failed to read /proc/1/cmdline");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (lstat(proc1, &statbuf) != 0)
|
||||||
|
+ {
|
||||||
|
+ UnexpectedError("Failed to stat %s", proc1);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if (S_ISLNK(statbuf.st_mode))
|
||||||
|
+ {
|
||||||
|
+ int len;
|
||||||
|
+ len = readlink(proc1, proc1, sizeof(proc1));
|
||||||
|
+ if (len <= 0)
|
||||||
|
+ {
|
||||||
|
+ UnexpectedError("Failed to readlink %s", proc1);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ *(proc1 + len) = '\0';
|
||||||
|
+ }
|
||||||
|
+ Log(LOG_LEVEL_VERBOSE, "Init process: %s", proc1);
|
||||||
|
+ slash = strrchr(proc1, '/');
|
||||||
|
+ if (slash == NULL)
|
||||||
|
+ {
|
||||||
|
+ slash = proc1;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ slash++;
|
||||||
|
+ }
|
||||||
|
+ if (strcmp(slash, "systemd") == 0)
|
||||||
|
+ {
|
||||||
|
+ EvalContextClassPutHard(ctx, slash, "inventory,attribute_name=none,source=agent");
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int Linux_Os_Release(EvalContext *ctx)
|
||||||
|
{
|
||||||
|
#define OS_REL_FILENAME "/etc/os-release"
|
||||||
|
--
|
||||||
|
1.8.4.5
|
||||||
|
|
@ -9,6 +9,9 @@ Fri Apr 4 19:30:04 UTC 2014 - kkaempf@suse.com
|
|||||||
- Parse /etc/os-release for product and version
|
- Parse /etc/os-release for product and version
|
||||||
Add patch 0001-Check-etc-os-release-for-distribution-information.patch
|
Add patch 0001-Check-etc-os-release-for-distribution-information.patch
|
||||||
|
|
||||||
|
- Parse /proc/1/cmdline to detect systemd
|
||||||
|
0001-Evaluate-proc-1-cmdline-and-check-for-systemd.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Apr 3 13:10:56 UTC 2014 - kkaempf@suse.com
|
Thu Apr 3 13:10:56 UTC 2014 - kkaempf@suse.com
|
||||||
|
|
||||||
|
@ -78,6 +78,9 @@ Patch3: drop-revision.patch
|
|||||||
# parse /etc/os-release for product and version information, kkaempf@suse.de
|
# parse /etc/os-release for product and version information, kkaempf@suse.de
|
||||||
Patch4: 0001-Check-etc-os-release-for-distribution-information.patch
|
Patch4: 0001-Check-etc-os-release-for-distribution-information.patch
|
||||||
|
|
||||||
|
# parse /proc/1/cmdline to detect systemd
|
||||||
|
Patch5: 0001-Evaluate-proc-1-cmdline-and-check-for-systemd.patch
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildRequires: bison
|
BuildRequires: bison
|
||||||
BuildRequires: db-devel
|
BuildRequires: db-devel
|
||||||
@ -203,6 +206,7 @@ This package contains the files of the cfengine server.
|
|||||||
%endif
|
%endif
|
||||||
%patch3 -p1
|
%patch3 -p1
|
||||||
%patch4 -p1
|
%patch4 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
|
||||||
##### rpmlint
|
##### rpmlint
|
||||||
#### wrong-file-end-of-line-encoding
|
#### wrong-file-end-of-line-encoding
|
||||||
|
Loading…
Reference in New Issue
Block a user