[Reproducible-commits] [dpkg] 10/105: s-s-d: Switch kFreeBSD to use sysctl(3)

Niko Tyni ntyni at moszumanska.debian.org
Mon May 2 13:49:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

ntyni pushed a commit to branch ntyni/reproducible_builds
in repository dpkg.

commit a8dece2602dc4975becb62ddccd67f181ee0dec9
Author: Guillem Jover <guillem at debian.org>
Date:   Tue Oct 7 16:48:34 2014 +0200

    s-s-d: Switch kFreeBSD to use sysctl(3)
    
    Avoid libkvm-dev to make sure we always use the low-level sysctl(3)
    interface.
---
 debian/changelog          |   2 +
 debian/control            |   1 -
 utils/start-stop-daemon.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 255b623..d30b979 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -48,6 +48,8 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
       code, to make life easier for non-dpkg-based systems.
     - Move alternatives temporary extension out from update-alternatives code,
       to make life easier for non-dpkg-based systems.
+    - Switch start-stop-daemon on */kFreeBSD to use the low-level sysctl(3)
+      interface instead of libkvm-dev.
   * Perl modules:
     - Add new CTRL_REPO_RELEASE control block type to Dpkg::Control.
     - Add new CTRL_COPYRIGHT_HEADER, CTRL_COPYRIGHT_FILES and
diff --git a/debian/control b/debian/control
index 03071ab..b71f6ed 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,6 @@ Build-Depends: dpkg-dev (>= 1.17.14), debhelper (>= 9.20141010),
  gettext (>= 0.19), po4a (>= 0.41),
  zlib1g-dev, libbz2-dev, liblzma-dev,
  libselinux1-dev (>= 1.28-4) [linux-any],
- libkvm-dev [kfreebsd-any],
  libncursesw5-dev,
  libio-string-perl <!nocheck>
 
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index c558969..f78a29d 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -1518,6 +1518,27 @@ pid_is_child(pid_t pid, pid_t ppid)
 
 	return pst.pst_ppid == ppid;
 }
+#elif defined(OSFreeBSD)
+static bool
+pid_is_child(pid_t pid, pid_t ppid)
+{
+	struct kinfo_proc kp;
+	int rc, name[4];
+	size_t len = 0;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PID;
+	name[3] = pid;
+
+	rc = sysctl(name, 4, &kp, &len, NULL, 0);
+	if (rc != 0 && errno != ESRCH)
+		return false;
+	if (len == 0 || len != sizeof(kp))
+		return false;
+
+	return kp.ki_ppid == ppid;
+}
 #elif defined(HAVE_KVM_H)
 static bool
 pid_is_child(pid_t pid, pid_t ppid)
@@ -1582,6 +1603,27 @@ pid_is_user(pid_t pid, uid_t uid)
 		return false;
 	return ((uid_t)pst.pst_uid == uid);
 }
+#elif defined(OSFreeBSD)
+static bool
+pid_is_user(pid_t pid, uid_t uid)
+{
+	struct kinfo_proc kp;
+	int rc, name[4];
+	size_t len = 0;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PID;
+	name[3] = pid;
+
+	rc = sysctl(name, 4, &kp, &len, NULL, 0);
+	if (rc != 0 && errno != ESRCH)
+		return false;
+	if (len == 0 || len != sizeof(kp))
+		return false;
+
+	return kp.ki_ruid == uid;
+}
 #elif defined(HAVE_KVM_H)
 static bool
 pid_is_user(pid_t pid, uid_t uid)
@@ -1672,6 +1714,27 @@ pid_is_cmd(pid_t pid, const char *name)
 		return false;
 	return (strcmp(pst.pst_ucomm, name) == 0);
 }
+#elif defined(OSFreeBSD)
+static bool
+pid_is_cmd(pid_t pid, const char *name)
+{
+	struct kinfo_proc kp;
+	int rc, name[4];
+	size_t len = 0;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PID;
+	name[3] = pid;
+
+	rc = sysctl(name, 4, &kp, &len, NULL, 0);
+	if (rc != 0 && errno != ESRCH)
+		return false;
+	if (len == 0 || len != sizeof(kp))
+		return false;
+
+	return strcmp(kp.ki_comm, name) == 0;
+}
 #elif defined(HAVE_KVM_H)
 static bool
 pid_is_cmd(pid_t pid, const char *name)
@@ -1847,6 +1910,45 @@ do_procinit(void)
 
 	return prog_status;
 }
+#elif defined(OSFreeBSD)
+static enum status_code
+do_procinit(void)
+{
+	struct kinfo_proc *kp;
+	int rc, name[3];
+	size_t len = 0;
+	int nentries, i;
+	enum status_code prog_status = STATUS_DEAD;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PROC;
+
+	rc = sysctl(name, 3, NULL, &len, NULL, 0);
+	if (rc != 0 && errno != ESRCH)
+		return false;
+	if (len == 0)
+		return false;
+
+	kp = xmalloc(len);
+	rc = sysctl(name, 3, kp, &len, NULL, 0);
+	if (rc != 0 && errno != ESRCH)
+		return false;
+	if (len == 0)
+		return false;
+
+	for (i = 0; i < nentries; i++) {
+		enum status_code pid_status;
+
+		pid_status = pid_check(kp[i].ki_pid);
+		if (pid_status < prog_status)
+			prog_status = pid_status;
+	}
+
+	free(kp);
+
+	return prog_status;
+}
 #elif defined(HAVE_KVM_H)
 static enum status_code
 do_procinit(void)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list