74d902b32d
Many bugfixes and feature additions since last update to numereous to list here.
83 lines
2.1 KiB
Text
83 lines
2.1 KiB
Text
$NetBSD: patch-aa,v 1.5 2005/01/24 13:59:47 wulf Exp $
|
|
|
|
--- utils/start-stop-daemon.c.orig 2004-01-23 00:38:25.000000000 +1030
|
|
+++ utils/start-stop-daemon.c 2005-01-22 13:43:30.000000000 +1030
|
|
@@ -90,8 +90,13 @@
|
|
#elif defined(__FreeBSD__) || defined(__APPLE__)
|
|
#define FreeBSD
|
|
#else
|
|
+#include <sys/param.h>
|
|
+#if (defined(BSD) && BSD >= 199306)
|
|
+#define OSBSD
|
|
+#else
|
|
#error Unknown architecture - cannot build start-stop-daemon
|
|
#endif
|
|
+#endif
|
|
|
|
#ifdef HAVE_HURH_H
|
|
#include <hurd.h>
|
|
@@ -663,6 +668,46 @@
|
|
}
|
|
#endif /*FreeBSD*/
|
|
|
|
+#if defined(BSD)
|
|
+/*
|
|
+pid_is_user, takes the pid and a uid, normally ours, but can be someone
|
|
+elses, to allow you to identify the process' owner. returns zero on success,
|
|
+and either true or the uid of the owner on failure (this may be undefined,
|
|
+or I may be misremembering.
|
|
+*/
|
|
+static int
|
|
+pid_is_user(int pid, int uid)
|
|
+{
|
|
+ struct stat sb;
|
|
+ char buf[32];
|
|
+
|
|
+ sprintf(buf, "/proc/%d", pid);
|
|
+ if (stat(buf, &sb) != 0)
|
|
+ return 0; /*I can stat it so it seems to be mine...*/
|
|
+ return ((int) sb.st_uid == uid);
|
|
+}
|
|
+
|
|
+/*
|
|
+pid_is_cmd, takes a pid, and a string representing the process' (supposed)
|
|
+name. Compares the process' supposed name with the name reported by the
|
|
+system. Returns zero on failure, and nonzero on success.
|
|
+*/
|
|
+static int
|
|
+pid_is_cmd(int pid, const char *name)
|
|
+{
|
|
+ char buf[64];
|
|
+ FILE *f;
|
|
+
|
|
+ sprintf(buf, "/proc/%d/status", pid);
|
|
+ f = fopen(buf, "r");
|
|
+ if (!f)
|
|
+ return 0;
|
|
+ fread(buf,sizeof(buf),1,f);
|
|
+ return (strncmp(buf, name, strlen(name)) == 0 && buf[strlen(name)] == ' ');
|
|
+}
|
|
+#endif /*OSBSD*/
|
|
+
|
|
+
|
|
static void
|
|
check(int pid)
|
|
{
|
|
@@ -697,7 +742,7 @@
|
|
|
|
/* WTA: this needs to be an autoconf check for /proc/pid existance.
|
|
*/
|
|
-#if defined(OSLinux) || defined (SunOS) || defined(FreeBSD)
|
|
+#if defined(OSLinux) || defined (SunOS) || defined(OSBSD)
|
|
static void
|
|
do_procinit(void)
|
|
{
|
|
@@ -915,7 +960,7 @@
|
|
close(fd);
|
|
chdir("/");
|
|
umask(022); /* set a default for dumb programs */
|
|
-#ifndef FreeBSD
|
|
+#ifndef OSBSD
|
|
setpgrp(); /* set the process group */
|
|
#else
|
|
setpgrp(0, runas_gid); /* set the process group */
|