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 + - 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 .\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;