Date: Sun, 20 Jun 1999 15:54:01 -0400 (EDT) From: Spike <spork@narcissus.net> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/12308: LPD can't be told not to bind to a TCP port. Message-ID: <Pine.BSF.4.05.9906201552410.4272-100000@nyc-ny63-18.ix.netcom.com1011>
next in thread | raw e-mail | index | archive | help
>Number: 12308
>Category: bin
>Synopsis: LPD can't be told not to bind to a TCP port.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Jun 20 13:00:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: Spike
>Release: FreeBSD 4.0-CURRENT i386
>Organization:
None.
>Environment:
FreeBSD nyc-ny63-18.ix.netcom.com1011 4.0-CURRENT FreeBSD
4.0-CURRENT #0: Sun May 30 00:29:24 EDT 1999
spork@pigstuy.penguinpowered.com:/usr/src/sys/compile/PIGSTUYCURRENT i386
>Description:
LPD can't be told not to bind to a TCP network socket even if
remote host printing isn't desired.
>How-To-Repeat:
Run lpd.
>Fix:
Apply the following patches:
============PATCH ONE===================
*** ./lpd.c Sun Jun 20 15:14:43 1999
--- ./lpd-new.c Sun Jun 20 15:16:12 1999
***************
*** 104,109 ****
--- 104,110 ----
#include "extern.h"
int lflag; /* log requests flag */
+ int sflag; /* do not bind to tcp flag. */
int from_remote; /* from remote socket */
int main __P((int, char **));
***************
*** 144,150 ****
errx(EX_NOPERM,"must run as root");
errs = 0;
! while ((i = getopt(argc, argv, "dl")) != -1)
switch (i) {
case 'd':
options |= SO_DEBUG;
--- 145,151 ----
errx(EX_NOPERM,"must run as root");
errs = 0;
! while ((i = getopt(argc, argv, "dls")) != -1)
switch (i) {
case 'd':
options |= SO_DEBUG;
***************
*** 152,157 ****
--- 153,161 ----
case 'l':
lflag++;
break;
+ case 's':
+ sflag++;
+ break;
default:
errs++;
}
***************
*** 277,299 ****
sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
FD_ZERO(&defreadfds);
FD_SET(funix, &defreadfds);
! listen(funix, 5);
! finet = socket(AF_INET, SOCK_STREAM, 0);
! if (finet >= 0) {
! if (options & SO_DEBUG)
! if (setsockopt(finet, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) {
! syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m");
! mcleanup(0);
! }
! memset(&sin, 0, sizeof(sin));
! sin.sin_family = AF_INET;
! sin.sin_port = sp->s_port;
! if (bind(finet, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
! syslog(LOG_ERR, "bind: %m");
! mcleanup(0);
! }
! FD_SET(finet, &defreadfds);
! listen(finet, 5);
}
/*
* Main loop: accept, do a request, continue.
--- 281,305 ----
sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
FD_ZERO(&defreadfds);
FD_SET(funix, &defreadfds);
! listen(funix, 5);
! if (sflag == 0) {
! finet = socket(AF_INET, SOCK_STREAM, 0);
! if (finet >= 0) {
! if (options & SO_DEBUG)
! if (setsockopt(finet, SOL_SOCKET, SO_DEBUG, 0, 0) < 0) {
! syslog(LOG_ERR, "setsockopt (SO_DEBUG): %m");
! mcleanup(0);
! }
! memset(&sin, 0, sizeof(sin));
! sin.sin_family = AF_INET;
! sin.sin_port = sp->s_port;
! if (bind(finet, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
! syslog(LOG_ERR, "bind: %m");
! mcleanup(0);
! }
! FD_SET(finet, &defreadfds);
! listen(finet, 5);
! }
}
/*
* Main loop: accept, do a request, continue.
***************
*** 318,324 ****
domain = AF_UNIX, fromlen = sizeof(fromunix);
s = accept(funix,
(struct sockaddr *)&fromunix, &fromlen);
! } else /* if (FD_ISSET(finet, &readfds)) */ {
domain = AF_INET, fromlen = sizeof(frominet);
s = accept(finet,
(struct sockaddr *)&frominet, &fromlen);
--- 324,330 ----
domain = AF_UNIX, fromlen = sizeof(fromunix);
s = accept(funix,
(struct sockaddr *)&fromunix, &fromlen);
! } else if (sflag == 0) {
domain = AF_INET, fromlen = sizeof(frominet);
s = accept(finet,
(struct sockaddr *)&frominet, &fromlen);
***************
*** 333,345 ****
continue;
}
if (fork() == 0) {
! signal(SIGCHLD, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
(void) close(funix);
! (void) close(finet);
dup2(s, 1);
(void) close(s);
if (domain == AF_INET) {
--- 339,352 ----
continue;
}
if (fork() == 0) {
! signal(SIGCHLD, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
(void) close(funix);
! if (sflag == 0)
! (void) close(finet);
dup2(s, 1);
(void) close(s);
if (domain == AF_INET) {
***************
*** 629,634 ****
static void
usage()
{
! fprintf(stderr, "usage: lpd [-dl] [port#]\n");
exit(EX_USAGE);
}
--- 636,641 ----
static void
usage()
{
! fprintf(stderr, "usage: lpd [-dls] [port#]\n");
exit(EX_USAGE);
}
=============END PATCH ONE=====================
=============PATCH TWO=========================
*** ./lpd.8.orig Sun Jun 20 11:00:40 1999
--- ./lpd.8 Sun Jun 20 10:59:34 1999
***************
*** 39,45 ****
.Nd line printer spooler daemon
.Sh SYNOPSIS
.Nm lpd
! .Op Fl dl
.Op Ar port#
.Sh DESCRIPTION
.Nm Lpd
--- 39,45 ----
.Nd line printer spooler daemon
.Sh SYNOPSIS
.Nm lpd
! .Op Fl dls
.Op Ar port#
.Sh DESCRIPTION
.Nm Lpd
***************
*** 72,77 ****
--- 72,83 ----
.Nm
to log valid requests received from the network. This can be useful
for debugging purposes.
+ .It Fl s
+ The
+ .Fl s
+ flag causes
+ .Nm
+ not to bind to a TCP socket. This is similar to the "-s" flag to syslogd.
.It Ar "port#"
The Internet port number used to rendezvous
with other processes is normally obtained with
============END PATCH TWO=======================
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9906201552410.4272-100000>
