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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
diff -crB a/CHANGES b/CHANGES
*** a/CHANGES 1999-01-02 16:15:03.000000000 +1300
--- b/CHANGES 2011-01-27 09:56:40.202300708 +1300
***************
*** 1,4 ****
--- 1,15 ----
+ Changes to QuickPage from v3.3 to v3.3.1-unleash
+ ------------------------------------------------
+ Patch by Michael Fincham <michael@unleash.co.nz>
+ - The new "-b" option has been added to specify a bind address
+ for the qpage daemon.
+
+ - The default user the daemon runs as is now "qpage" instead
+ of "nobody".
+
+ - To be honest, the "-b" option doesn't sanitise input very well
+ so don't setuid root the qpage binary or anything dumb like that.
Changes to QuickPage from v3.2 to v3.3
---------------------------------------
diff -crB a/qpage.c b/qpage.c
*** a/qpage.c 1999-05-09 09:47:23.000000000 +1200
--- b/qpage.c 2011-01-21 14:50:55.995162759 +1300
***************
*** 17,22 ****
--- 17,23 ----
static char sccsid[] = "@(#)qpage.c 3.36 07/26/98 tomiii@qpage.org";
#endif
char *ConfigFile = NULL;
+ char *BindAddress = NULL;
int Debug = 0;
int Interactive = FALSE;
int Silent = FALSE;
***************
*** 29,35 ****
do_version(void)
{
printf("\n");
! printf("QuickPage v%s, Copyright 1995-98 by Thomas Dwyer III\n",
VERSION);
printf("\n");
}
--- 30,36 ----
do_version(void)
{
printf("\n");
! printf("QuickPage v%s, Copyright 1995-98 by Thomas Dwyer III. Modified for Unleash by Michael Fincham <michael@unleash.co.nz>.\n",
VERSION);
printf("\n");
}
***************
*** 46,51 ****
--- 47,55 ----
printf("\n");
printf("Options:\n");
printf(" -a [+]hhmm send the page at the specified time\n");
+ #ifndef CLIENT_ONLY
+ printf(" -b address bind only to this address (default: 0.0.0.0)\n");
+ #endif
printf(" -c coverage coverage area (service name) for pager\n");
printf(" -C config use an alternate configuration file\n");
printf(" -d debug mode\n");
***************
*** 339,345 ****
(void)memset((char *)&p, 0, sizeof(p));
! while ((c = getopt(argc, argv, "a:c:C:df:hil:mp:P:q:Qs:t:v")) != -1) {
switch (c) {
case 'a':
case 't':
--- 343,349 ----
(void)memset((char *)&p, 0, sizeof(p));
! while ((c = getopt(argc, argv, "a:b:c:C:df:hil:mp:P:q:Qs:t:v")) != -1) {
switch (c) {
case 'a':
case 't':
***************
*** 353,358 ****
--- 357,367 ----
needpager = TRUE;
break;
+ #ifndef CLIENT_ONLY
+ case 'b':
+ BindAddress = strdup(optarg);
+ break;
+ #endif
case 'c':
my_free(coverage);
coverage = strdup(optarg);
***************
*** 503,509 ****
if (optind < argc)
port = atoi(argv[optind]);
! (void)become_daemon(sleeptime, port);
/* NOT REACHED */
return(-1);
--- 512,518 ----
if (optind < argc)
port = atoi(argv[optind]);
! (void)become_daemon(sleeptime, port, BindAddress);
/* NOT REACHED */
return(-1);
diff -crB a/qpage.h b/qpage.h
*** a/qpage.h 1998-10-26 08:55:02.000000000 +1300
--- b/qpage.h 2011-01-21 14:51:22.682302352 +1300
***************
*** 26,32 ****
#define fprintf (void)fprintf
#endif
! #define VERSION "3.3"
#define COMMENTS_ANYWHERE
#ifndef QPAGE_CONFIG
--- 26,32 ----
#define fprintf (void)fprintf
#endif
! #define VERSION "3.3.1-unleash"
#define COMMENTS_ANYWHERE
#ifndef QPAGE_CONFIG
***************
*** 51,57 ****
#endif
#ifndef DAEMON_USER
! #define DAEMON_USER "nobody"
#endif
#define SNPP_SVC_NAME "snpp"
--- 51,57 ----
#endif
#ifndef DAEMON_USER
! #define DAEMON_USER "qpage"
#endif
#define SNPP_SVC_NAME "snpp"
***************
*** 278,284 ****
extern void qpage_log(int pri, char *fmt, ...);
extern time_t snpptime(char *arg);
extern time_t parse_time(char *str);
! extern int become_daemon(int sleeptime, short port);
extern int submit_page(PAGE *p, char *server);
extern int lock_file(int fd, int mode, int block);
extern int lock_queue(void);
--- 278,284 ----
extern void qpage_log(int pri, char *fmt, ...);
extern time_t snpptime(char *arg);
extern time_t parse_time(char *str);
! extern int become_daemon(int sleeptime, short port, char *BindAddress);
extern int submit_page(PAGE *p, char *server);
extern int lock_file(int fd, int mode, int block);
extern int lock_queue(void);
diff -crB a/qpage.man b/qpage.man
*** a/qpage.man 1999-05-09 10:07:31.000000000 +1200
--- b/qpage.man 2011-01-27 09:51:44.894302942 +1300
***************
*** 34,39 ****
--- 34,42 ----
] [
.BI \-C " config
]
+ ] [
+ .BI \-b " address
+ ]
.BI \-q " interval
.SH DESCRIPTION
.B QuickPage
***************
*** 91,96 ****
--- 94,104 ----
century. Otherwise assume the specified time is in the current
century.
.TP
+ .BI \-b
+ Specify an address for the qpage daemon to bind to. The default is
+ to bind to INETADDR_ANY and listen on all interfaces (the old
+ behaviour)
+ .TP
.BI \-c
Use a different coverage area or paging service. This option is
only useful if the recipient has more than one pager and/or more
diff -crB a/srvrsnpp.c b/srvrsnpp.c
*** a/srvrsnpp.c 1998-10-26 08:55:05.000000000 +1300
--- b/srvrsnpp.c 2011-01-21 14:49:17.647300794 +1300
***************
*** 1156,1162 ****
** -1 on error, otherwise never
*/
int
! become_daemon(int sleeptime, short port)
{
struct sockaddr_in addr;
struct servent *svc;
--- 1156,1162 ----
** -1 on error, otherwise never
*/
int
! become_daemon(int sleeptime, short port, char *BindAddress)
{
struct sockaddr_in addr;
struct servent *svc;
***************
*** 1221,1227 ****
len = sizeof(on);
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, len);
! addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_family = AF_INET;
addr.sin_port = port;
--- 1221,1227 ----
len = sizeof(on);
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, len);
! addr.sin_addr.s_addr = BindAddress != NULL ? inet_addr(BindAddress) : INADDR_ANY;
addr.sin_family = AF_INET;
addr.sin_port = port;
|