summaryrefslogtreecommitdiff
path: root/www/kannel/patches/patch-aa
blob: f29dc5d844de877eaeea8908efd3a56ad81db440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$NetBSD: patch-aa,v 1.4 2002/08/25 21:52:11 jlam Exp $

--- utils/start-stop-daemon.c.orig	Mon Apr 23 16:52:29 2001
+++ utils/start-stop-daemon.c	Sun Jul  7 21:28:04 2002
@@ -34,8 +34,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>
@@ -607,6 +612,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)
 {
@@ -641,7 +686,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)
 {
@@ -859,7 +904,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 */