Lines Matching +full:remote +full:- +full:pid

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
33 #include "lp.cdefs.h" /* A cross-platform version of <sys/cdefs.h> */
35 * lpd -- line printer daemon.
94 int from_remote; /* from remote socket */
113 #define LPD_NOPORTCHK 0001 /* skip reserved-port check */
142 while ((i = getopt(argc, argv, "cdlpswFW46")) != -1)
145 /* log all kinds of connection-errors to syslog */
154 case 'p': /* letter initially used for -s */
156 * This will probably be removed with 5.0-release.
162 case 'w': /* netbsd uses -w for maxwait */
165 * it conflicts with -w in netbsd's lpd. For now it
170 "NOTE: the -w option has been renamed -W");
172 "NOTE: please change your lpd config to use -W");
178 /* allow connections coming from a non-reserved port */
179 /* (done by some lpr-implementations for MS-Windows) */
196 * listed here to "reserve" them, because the option-letters
199 case 'b': /* set bind-addr */
201 case 'r': /* allow 'of' for remote ptrs */
209 argc -= optind;
222 argc--;
236 * then stopped. There should probably be a command-line flag to
240 pid_t pid;
242 pid = fork();
243 if (pid < 0) {
245 } else if (pid == 0) { /* child */
249 if (waitpid(pid, &status, 0) < 0) {
262 * if -F not specified
270 socket_debug ? " dbg" : "", sflag ? " net-secure" : "");
275 * open/creation. As of 1997-12-02, this is the case for commonly-
287 fcntl(lfd, F_SETFL, 0); /* turn off non-blocking mode */
326 #define SUN_LEN(unp) (strlen((unp)->sun_path) + 2)
355 * XXX - should be redone for multi-protocol
368 domain = -1; /* avoid compile-time warning */
369 s = -1; /* avoid compile-time warning */
392 * signal-handling routines, and may need to be
393 * changed when making changes to signal-handling.
434 * XXX syslog(3) is not signal-safe.
455 /* buffer to hold the client's machine-name */
480 if (cp >= &cbuf[sizeof(cbuf) - 1])
488 *--cp = '\0';
511 /* XXX - this all needs to be redone. */
584 int pid, status, more;
596 pp->printer);
597 if ((pid = fork()) < 0) {
599 pp->printer);
602 if (pid == 0) {
614 pp->printer ? pp->printer : "<noname?>");
629 spooldir = pp->spool_dir;
631 return (-1);
633 if (d->d_name[0] != 'c' || d->d_name[1] != 'f')
661 error = getnameinfo(f, f->sa_len, hostbuf, sizeof(hostbuf), NULL, 0,
665 error = getnameinfo(f, f->sa_len, hostbuf, sizeof(hostbuf),
669 "can not determine hostname for remote host (%d,%d)",
677 "Host name for remote host (%s) not known (%d)",
691 error = getnameinfo(f, f->sa_len, hostbuf, sizeof(hostbuf), NULL, 0,
711 asprintf(&syserr, "reverse lookup results in non-FQDN %s",
713 /* same message to both syslog and remote user */
732 for (r = res; good == 0 && r; r = r->ai_next) {
733 error = getnameinfo(r->ai_addr, r->ai_addrlen, ip, sizeof(ip),
741 asprintf(&syserr, "address for remote host (%s) not matched",
753 if (__ivaliduser_sa(hostf, f, f->sa_len, DUMMY, DUMMY) == 0) {
769 "Print-services are not available to your host (%s).", from_host);
775 return; /* skip the reserved-port check */
777 error = getnameinfo(f, f->sa_len, NULL, 0, serv, sizeof(serv),
780 /* same message to both syslog and remote user */
781 asprintf(&syserr, "malformed from-address (%d)", error);
787 /* same message to both syslog and remote user */
800 * for a remote user who may or may not be clueful, and may or may not be
801 * doing something nefarious. Some remote users (eg, MS-Windows...) may not
803 * start 'lpd' with the connection-errors also sent to syslog.
809 * These are Fatal host-connection errors, so this routine does not return.
830 * Now send the error message to the remote host which is trying
838 * sending-host). This is just in case that machine responds by
839 * INSTANTLY retrying (and instantly re-failing...). This may also
867 for (maxs = 0, r = res; r; r = r->ai_next, maxs++)
877 for (r = res; r; r = r->ai_next) {
878 *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol);
896 if (r->ai_family == AF_INET6) {
905 if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) {
929 fprintf(stderr, "usage: lpd [-cdlsFW46] [port#]\n");
931 fprintf(stderr, "usage: lpd [-cdlsFW] [port#]\n");