version 1.7, 1996/04/24 14:54:06 |
version 1.7.4.1, 1997/01/26 05:25:58 |
Line 98 static char sccsid[] = "@(#)lpd.c 8.4 (B |
|
Line 98 static char sccsid[] = "@(#)lpd.c 8.4 (B |
|
#include "extern.h" |
#include "extern.h" |
|
|
int lflag; /* log requests flag */ |
int lflag; /* log requests flag */ |
|
int sflag; /* secure (no inet) flag */ |
int from_remote; /* from remote socket */ |
int from_remote; /* from remote socket */ |
|
|
static void reapchild __P((int)); |
static void reapchild __P((int)); |
Line 135 main(argc, argv) |
|
Line 136 main(argc, argv) |
|
case 'l': |
case 'l': |
lflag++; |
lflag++; |
break; |
break; |
|
case 's': |
|
sflag++; |
|
break; |
} |
} |
} |
} |
|
|
Line 147 main(argc, argv) |
|
Line 151 main(argc, argv) |
|
|
|
openlog("lpd", LOG_PID, LOG_LPR); |
openlog("lpd", LOG_PID, LOG_LPR); |
syslog(LOG_INFO, "restarted"); |
syslog(LOG_INFO, "restarted"); |
(void) umask(0); |
(void)umask(0); |
lfd = open(_PATH_MASTERLOCK, O_WRONLY|O_CREAT, 0644); |
lfd = open(_PATH_MASTERLOCK, O_WRONLY|O_CREAT, 0644); |
if (lfd < 0) { |
if (lfd < 0) { |
syslog(LOG_ERR, "%s: %m", _PATH_MASTERLOCK); |
syslog(LOG_ERR, "%s: %m", _PATH_MASTERLOCK); |
Line 163 main(argc, argv) |
|
Line 167 main(argc, argv) |
|
/* |
/* |
* write process id for others to know |
* write process id for others to know |
*/ |
*/ |
sprintf(line, "%u\n", getpid()); |
(void)snprintf(line, sizeof(line), "%u\n", getpid()); |
f = strlen(line); |
f = strlen(line); |
if (write(lfd, line, f) != f) { |
if (write(lfd, line, f) != f) { |
syslog(LOG_ERR, "%s: %m", _PATH_MASTERLOCK); |
syslog(LOG_ERR, "%s: %m", _PATH_MASTERLOCK); |
Line 174 main(argc, argv) |
|
Line 178 main(argc, argv) |
|
* Restart all the printers. |
* Restart all the printers. |
*/ |
*/ |
startup(); |
startup(); |
(void) unlink(_PATH_SOCKETNAME); |
(void)unlink(_PATH_SOCKETNAME); |
funix = socket(AF_UNIX, SOCK_STREAM, 0); |
funix = socket(AF_UNIX, SOCK_STREAM, 0); |
if (funix < 0) { |
if (funix < 0) { |
syslog(LOG_ERR, "socket: %m"); |
syslog(LOG_ERR, "socket: %m"); |
Line 188 main(argc, argv) |
|
Line 192 main(argc, argv) |
|
signal(SIGTERM, mcleanup); |
signal(SIGTERM, mcleanup); |
memset(&un, 0, sizeof(un)); |
memset(&un, 0, sizeof(un)); |
un.sun_family = AF_UNIX; |
un.sun_family = AF_UNIX; |
strcpy(un.sun_path, _PATH_SOCKETNAME); |
strncpy(un.sun_path, _PATH_SOCKETNAME, sizeof(un.sun_path) - 1); |
#ifndef SUN_LEN |
#ifndef SUN_LEN |
#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2) |
#define SUN_LEN(unp) (strlen((unp)->sun_path) + 2) |
#endif |
#endif |
Line 200 main(argc, argv) |
|
Line 204 main(argc, argv) |
|
FD_ZERO(&defreadfds); |
FD_ZERO(&defreadfds); |
FD_SET(funix, &defreadfds); |
FD_SET(funix, &defreadfds); |
listen(funix, 5); |
listen(funix, 5); |
finet = socket(AF_INET, SOCK_STREAM, 0); |
if (!sflag) |
|
finet = socket(AF_INET, SOCK_STREAM, 0); |
|
else |
|
finet = -1; /* pretend we couldn't open TCP socket. */ |
if (finet >= 0) { |
if (finet >= 0) { |
struct servent *sp; |
struct servent *sp; |
|
|
Line 260 main(argc, argv) |
|
Line 267 main(argc, argv) |
|
signal(SIGINT, SIG_IGN); |
signal(SIGINT, SIG_IGN); |
signal(SIGQUIT, SIG_IGN); |
signal(SIGQUIT, SIG_IGN); |
signal(SIGTERM, SIG_IGN); |
signal(SIGTERM, SIG_IGN); |
(void) close(funix); |
(void)close(funix); |
(void) close(finet); |
if (!sflag) |
|
(void)close(finet); |
dup2(s, 1); |
dup2(s, 1); |
(void) close(s); |
(void)close(s); |
if (domain == AF_INET) { |
if (domain == AF_INET) { |
from_remote = 1; |
from_remote = 1; |
chkhost(&frominet); |
chkhost(&frominet); |
Line 272 main(argc, argv) |
|
Line 280 main(argc, argv) |
|
doit(); |
doit(); |
exit(0); |
exit(0); |
} |
} |
(void) close(s); |
(void)close(s); |
} |
} |
} |
} |
|
|
|
|
fatal("Host name for your address (%s) unknown", |
fatal("Host name for your address (%s) unknown", |
inet_ntoa(f->sin_addr)); |
inet_ntoa(f->sin_addr)); |
|
|
(void) strncpy(fromb, hp->h_name, sizeof(fromb)); |
(void)strncpy(fromb, hp->h_name, sizeof(fromb) - 1); |
from[sizeof(fromb) - 1] = '\0'; |
from[sizeof(fromb) - 1] = '\0'; |
from = fromb; |
from = fromb; |
|
|
|
|
if (hostf) { |
if (hostf) { |
if (__ivaliduser(hostf, f->sin_addr.s_addr, |
if (__ivaliduser(hostf, f->sin_addr.s_addr, |
DUMMY, DUMMY) == 0) { |
DUMMY, DUMMY) == 0) { |
(void) fclose(hostf); |
(void)fclose(hostf); |
return; |
return; |
} |
} |
(void) fclose(hostf); |
(void)fclose(hostf); |
} |
} |
if (first == 1) { |
if (first == 1) { |
first = 0; |
first = 0; |