~ubuntu-branches/ubuntu/natty/openbsd-inetd/natty

« back to all changes in this revision

Viewing changes to debian/patches/setproctitle

  • Committer: Bazaar Package Importer
  • Author(s): Marco d'Itri
  • Date: 2008-12-15 02:00:52 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081215020052-gwpkva043fq6nb1s
Tags: 0.20080125-2
* Added dh_md5sums to debian/rules, since apparently people nowadays
  believe again that it is a good idea. (Closes: #484483)
* Fixed the init script to povide "openbsd-inetd" instead of "inetd".
  (Closes: #507119)
* Updated patches misc_portability and setproctitle with some missing
  prototypes.
* Updated patch misc_portability with missing arguments to two syslog(3)
  calls.
* Updated patch libwrap to fix a possibly uninitialized variable.
  The last three fixes are courtesy of Denis Zaitsev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/inetd.c
 
2
+++ b/inetd.c
 
3
@@ -167,6 +167,7 @@ static const char rcsid[] = "$OpenBSD: i
 
4
 #include <rpc/rpc.h>
 
5
 #include <rpc/pmap_clnt.h>
 
6
 #include "pathnames.h"
 
7
+#include "setproctitle.h"
 
8
 
 
9
 size_t strlcpy(char *, const char *, size_t);
 
10
 
 
11
@@ -331,7 +332,7 @@ fd_grow(fd_set **fdsp, int *bytes, int f
 
12
 struct sigaction sa, sapipe;
 
13
 
 
14
 int
 
15
-main(int argc, char *argv[])
 
16
+main(int argc, char *argv[], char *envp[])
 
17
 {
 
18
        fd_set *fdsrp = NULL;
 
19
        int readablen = 0, ch;
 
20
@@ -342,6 +343,8 @@ main(int argc, char *argv[])
 
21
        progname = strrchr(argv[0], '/');
 
22
        progname = progname ? progname + 1 : argv[0];
 
23
 
 
24
+       initsetproctitle(argc, argv, envp);
 
25
+
 
26
        while ((ch = getopt(argc, argv, "dR:")) != -1)
 
27
                switch (ch) {
 
28
                case 'd':
 
29
--- /dev/null
 
30
+++ b/setproctitle.c
 
31
@@ -0,0 +1,146 @@
 
32
+/*
 
33
+ * setproctitle implementation for linux.
 
34
+ * Stolen from sendmail 8.7.4 and bashed around by David A. Holland
 
35
+ */
 
36
+
 
37
+/*
 
38
+ * Copyright (c) 1983, 1995 Eric P. Allman
 
39
+ * Copyright (c) 1988, 1993
 
40
+ *     The Regents of the University of California.  All rights reserved.
 
41
+ *
 
42
+ * Redistribution and use in source and binary forms, with or without
 
43
+ * modification, are permitted provided that the following conditions
 
44
+ * are met:
 
45
+ * 1. Redistributions of source code must retain the above copyright
 
46
+ *    notice, this list of conditions and the following disclaimer.
 
47
+ * 2. Redistributions in binary form must reproduce the above copyright
 
48
+ *    notice, this list of conditions and the following disclaimer in the
 
49
+ *    documentation and/or other materials provided with the distribution.
 
50
+ * 3. All advertising materials mentioning features or use of this software
 
51
+ *    must display the following acknowledgement:
 
52
+ *     This product includes software developed by the University of
 
53
+ *     California, Berkeley and its contributors.
 
54
+ * 4. Neither the name of the University nor the names of its contributors
 
55
+ *    may be used to endorse or promote products derived from this software
 
56
+ *    without specific prior written permission.
 
57
+ *
 
58
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
59
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
60
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
61
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
62
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
63
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
64
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
65
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
66
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
67
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
68
+ * SUCH DAMAGE.
 
69
+ *
 
70
+ * From: @(#)conf.c    8.243 (Berkeley) 11/20/95
 
71
+ */
 
72
+char setproctitle_rcsid[] =
 
73
+  "$Id: setproctitle.c,v 1.3 1997/05/19 12:58:15 dholland Exp $";
 
74
+
 
75
+#include <stdlib.h>
 
76
+#include <string.h>
 
77
+#include <stdarg.h>
 
78
+#include <unistd.h>
 
79
+#include <stdio.h>
 
80
+
 
81
+#include "setproctitle.h"
 
82
+/*
 
83
+**  SETPROCTITLE -- set process title for ps
 
84
+**
 
85
+**     Parameters:
 
86
+**             fmt -- a printf style format string.
 
87
+**             a, b, c -- possible parameters to fmt.
 
88
+**
 
89
+**     Returns:
 
90
+**             none.
 
91
+**
 
92
+**     Side Effects:
 
93
+**             Clobbers argv of our main procedure so ps(1) will
 
94
+**             display the title.
 
95
+*/
 
96
+
 
97
+
 
98
+/*
 
99
+**  Pointers for setproctitle.
 
100
+**     This allows "ps" listings to give more useful information.
 
101
+*/
 
102
+
 
103
+static char **Argv = NULL;             /* pointer to argument vector */
 
104
+static char *LastArgv = NULL;          /* end of argv */
 
105
+static char Argv0[128];                        /* program name */
 
106
+
 
107
+void
 
108
+initsetproctitle(int argc, char **argv, char **envp)
 
109
+{
 
110
+       register int i;
 
111
+       char *tmp;
 
112
+
 
113
+       /*
 
114
+        **  Move the environment so setproctitle can use the space at
 
115
+       **  the top of memory.
 
116
+       */
 
117
+
 
118
+       for (i = 0; envp[i] != NULL; i++)
 
119
+               continue;
 
120
+       __environ = (char **) malloc(sizeof (char *) * (i + 1));
 
121
+       for (i = 0; envp[i] != NULL; i++)
 
122
+               __environ[i] = strdup(envp[i]);
 
123
+       __environ[i] = NULL;
 
124
+
 
125
+       /*
 
126
+       **  Save start and extent of argv for setproctitle.
 
127
+       */
 
128
+
 
129
+       Argv = argv;
 
130
+       if (i > 0)
 
131
+               LastArgv = envp[i - 1] + strlen(envp[i - 1]);
 
132
+       else
 
133
+               LastArgv = argv[argc - 1] + strlen(argv[argc - 1]);
 
134
+
 
135
+       tmp = strrchr(argv[0], '/');
 
136
+       if (!tmp) tmp = argv[0];
 
137
+       else tmp++;
 
138
+       strncpy(Argv0, tmp, sizeof(Argv0));
 
139
+       /* remember to take away one or we go outside the array space */
 
140
+       Argv0[sizeof(Argv0) - 1] = 0;
 
141
+}
 
142
+
 
143
+void
 
144
+setproctitle(const char *fmt, ...)
 
145
+{
 
146
+       register char *p;
 
147
+       register int i;
 
148
+       static char buf[2048];
 
149
+       va_list ap;
 
150
+
 
151
+       p = buf;
 
152
+
 
153
+       /* print progname: heading for grep */
 
154
+       /* This can't overflow buf due to the relative size of Argv0. */
 
155
+       (void) strcpy(p, Argv0);
 
156
+       (void) strcat(p, ": ");
 
157
+       p += strlen(p);
 
158
+
 
159
+       /* print the argument string */
 
160
+       va_start(ap, fmt);
 
161
+       (void) vsnprintf(p, sizeof(buf) - (p - buf), fmt, ap);
 
162
+       va_end(ap);
 
163
+
 
164
+       i = strlen(buf);
 
165
+
 
166
+       if (i > LastArgv - Argv[0] - 2)
 
167
+       {
 
168
+               i = LastArgv - Argv[0] - 2;
 
169
+               buf[i] = '\0';
 
170
+       }
 
171
+       (void) strcpy(Argv[0], buf);
 
172
+       p = &Argv[0][i];
 
173
+       while (p < LastArgv)
 
174
+               *p++ = ' ';
 
175
+       Argv[1] = NULL;
 
176
+}
 
177
+
 
178
--- /dev/null
 
179
+++ b/setproctitle.h
 
180
@@ -0,0 +1,4 @@
 
181
+/* Call this from main. */
 
182
+void initsetproctitle(int argc, char **argv, char **envp);
 
183
+
 
184
+void setproctitle(const char *fmt, ...);