diff --git a/commands/Makefile b/commands/Makefile index f731122f1..aa9c0d42a 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -9,7 +9,7 @@ SUBDIR= add_route arp ash at backup basename btrace \ dd decomp16 DESCRIBE devmand devsize df dhcpd \ dhrystone diff dirname diskctl dumpcore \ eject env expand factor fbdctl \ - find fingerd fix fold format fortune fsck.mfs \ + find fix fold format fortune fsck.mfs \ gcore gcov-pull getty grep hexdump host \ hostaddr id ifconfig ifdef \ intr ipcrm ipcs irdpd isoread last \ diff --git a/commands/fingerd/Makefile b/commands/fingerd/Makefile deleted file mode 100644 index 01c9369cd..000000000 --- a/commands/fingerd/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -PROG= in.fingerd -SRCS= fingerd.c -MAN= - -.include diff --git a/commands/fingerd/fingerd.c b/commands/fingerd/fingerd.c deleted file mode 100644 index 92cacab7a..000000000 --- a/commands/fingerd/fingerd.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - */ - -#ifndef lint -static char sccsid[] = "@(#)in.fingerd.c 1.1 87/12/21 SMI"; /* from UCB 5.1 6/6/85 */ -#endif /* not lint */ - -/* - * Finger server. - */ -#include -#include -#include -#include -#include -#include -#include - -int main( int argc, char *argv[] ); -void fatal( char *prog, char *s ); - -int main(argc, argv) - char *argv[]; -{ - register char *sp; - char line[512]; - int i, p[2], pid, status; - FILE *fp; - char *av[4]; - - line[0] = '\0'; - fgets(line, sizeof(line), stdin); - sp = line + strlen(line); - if (sp > line && *--sp == '\n') *sp = '\0'; - sp = line; - av[0] = "finger"; - i = 1; - while (1) { - while (isspace(*sp)) - sp++; - if (!*sp) - break; - if (*sp == '/' && (sp[1] == 'W' || sp[1] == 'w')) { - sp += 2; - av[i++] = "-l"; - } - if (*sp && !isspace(*sp)) { - av[i++] = sp; - while (*sp && !isspace(*sp)) - sp++; - *sp = '\0'; - } - } - av[i] = 0; - if (pipe(p) < 0) - fatal(argv[0], "pipe"); - if ((pid = fork()) == 0) { - close(p[0]); - if (p[1] != 1) { - dup2(p[1], 1); - close(p[1]); - } - execv("/usr/bin/finger", av); - printf("No finger program found\n"); - fflush(stdout); - _exit(1); - } - if (pid == -1) - fatal(argv[0], "fork"); - close(p[1]); - if ((fp = fdopen(p[0], "r")) == NULL) - fatal(argv[0], "fdopen"); - while ((i = getc(fp)) != EOF) { - if (i == '\n') - putchar('\r'); - putchar(i); - } - fclose(fp); - while ((i = wait(&status)) != pid && i != -1) - ; - return(0); -} - -void fatal(prog, s) - char *prog, *s; -{ - - fprintf(stderr, "%s: ", prog); - perror(s); - exit(1); -} diff --git a/distrib/sets/lists/minix/mi b/distrib/sets/lists/minix/mi index e9d1814cf..54cb49020 100644 --- a/distrib/sets/lists/minix/mi +++ b/distrib/sets/lists/minix/mi @@ -128,6 +128,7 @@ ./lib minix-sys ./lib/cpp minix-sys ./libexec minix-sys +./usr/libexec/fingerd minix-sys ./usr/libexec/ftpd minix-sys ./libexec/ld.elf_so minix-sys ./libexec/ld-elf.so.1 minix-sys @@ -314,7 +315,6 @@ ./usr/bin/ifconfig minix-sys ./usr/bin/ifdef minix-sys ./usr/bin/indent minix-sys -./usr/bin/in.fingerd minix-sys ./usr/bin/infocmp minix-sys ./usr/bin/in.rshd minix-sys ./usr/bin/install minix-sys diff --git a/etc/rc.daemons.dist b/etc/rc.daemons.dist index 2bb8deaf3..7cd840bc3 100644 --- a/etc/rc.daemons.dist +++ b/etc/rc.daemons.dist @@ -2,3 +2,4 @@ daemonize talkd daemonize tcpd shell in.rshd daemonize tcpd telnet in.telnetd daemonize tcpd ftp /usr/libexec/ftpd +daemonize tcpd finger /usr/libexec/fingerd diff --git a/libexec/Makefile b/libexec/Makefile index fc47af434..6017ec658 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -4,7 +4,7 @@ .include SUBDIR= \ - ftpd \ + fingerd ftpd \ ld.elf_so .if defined(__MINIX) diff --git a/libexec/fingerd/Makefile b/libexec/fingerd/Makefile new file mode 100644 index 000000000..4ade1c2fb --- /dev/null +++ b/libexec/fingerd/Makefile @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.9 2005/01/10 02:58:58 lukem Exp $ +# from: @(#)Makefile 8.1 (Berkeley) 6/4/93 + +.include + +PROG= fingerd +MAN= fingerd.8 + +.if (${USE_INET6} != "no") +CPPFLAGS+=-DINET6 +.endif + +.include diff --git a/libexec/fingerd/fingerd.8 b/libexec/fingerd/fingerd.8 new file mode 100644 index 000000000..e38d8f917 --- /dev/null +++ b/libexec/fingerd/fingerd.8 @@ -0,0 +1,175 @@ +.\" $NetBSD: fingerd.8,v 1.20 2003/11/02 11:27:49 wiz Exp $ +.\" +.\" Copyright (c) 1980, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)fingerd.8 8.1 (Berkeley) 6/4/93 +.\" +.Dd September 12, 2002 +.Dt FINGERD 8 +.Os +.Sh NAME +.Nm fingerd +.Nd remote user information server +.Sh SYNOPSIS +.Nm +.Op Fl 8ghlmpSsu +.Op Fl P Ar filename +.Sh DESCRIPTION +.Nm +is a simple protocol based on RFC 1288 +that provides an interface to the +Name and Finger programs at several network sites. +The program is supposed to return a friendly, +human-oriented status report on either the system at the moment +or a particular person in depth. +There is no required format and the +protocol consists mostly of specifying a single +.Dq command line . +.Pp +.Nm +is started by +.Xr inetd 8 , +which listens for +.Tn TCP +requests at port 79. +Once handed a connection, +.Nm +reads a single command line +terminated by a +.Aq Tn CRLF +which it then passes to +.Xr finger 1 . +.Nm +closes its connections as soon as the output is finished. +.Pp +If the line is null (i.e., just a +.Aq Tn CRLF +is sent) then +.Xr finger 1 +returns a +.Dq default +report that lists all people logged into +the system at that moment. +.Pp +If a user name is specified (e.g., +.Pf eric Aq Tn CRLF ) +then the +response lists more extended information for only that particular user, +whether logged in or not. +Allowable +.Dq names +in the command line include both +.Dq login names +and +.Dq user names . +If a name is ambiguous, all possible derivations are returned. +.Pp +The following options may be passed to +.Nm +as server program arguments in +.Pa /etc/inetd.conf : +.Bl -tag -width XPXfilenameX +.It Fl 8 +Enable 8-bit output. +.It Fl g +Do not show any gecos information besides the users' real names. +.It Fl h +Display the name of the remote host in short mode, +instead of the office location and office phone. +.It Fl l +Enable logging. +The name of the host originating the query, and the actual request +is reported via +.Xr syslog 3 +at LOG_NOTICE priority. +A request of the form +.Sq /W +or +.Sq /w +will return long output. +Empty requests will return all currently logged in users. +All other requests look for specific users. +See RFC 1288 for details. +.It Fl m +Prevent matching of +.Ar user +names. +.Ar User +is usually a login name; however, matching will also be done on the +users' real names, unless the +.Fl m +option is supplied. +.It Fl P Ar filename +Use an alternate program as the local information provider. +The default local program executed by +.Nm +is +.Xr finger 1 . +By specifying a customized local server, this option allows a system manager +to have more control over what information is provided to remote sites. +.It Fl p +Prevents +.Xr finger 1 +from displaying the contents of the +.Dq Pa .plan +and +.Dq Pa .project +files. +.It Fl S +Prints user information in short mode, one line per user. +This overrides the +.Dq Pa Whois switch +that may be passed in from the remote client. +.It Fl s +Disable forwarding of queries to other remote hosts. +.It Fl u +Queries without a user name are rejected. +.El +.Sh SEE ALSO +.Xr finger 1 , +.Xr inetd 8 +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.3 . +.Sh BUGS +Connecting directly to the server from a +.Tn TIP +or an equally narrow-minded +.Tn TELNET Ns -protocol +user program can result +in meaningless attempts at option negotiation being sent to the +server, which will foul up the command line interpretation. +.Nm +should be taught to filter out +.Tn IAC Ns 's +and perhaps even respond +negatively +.Pq Tn IAC WON'T +to all option commands received. diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c new file mode 100644 index 000000000..9b7e7c645 --- /dev/null +++ b/libexec/fingerd/fingerd.c @@ -0,0 +1,233 @@ +/* $NetBSD: fingerd.c,v 1.27 2012/03/15 02:02:21 joerg Exp $ */ + +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1983, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "from: @(#)fingerd.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: fingerd.c,v 1.27 2012/03/15 02:02:21 joerg Exp $"); +#endif +#endif /* not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "pathnames.h" + +__dead static void my_err(const char *, ...) __printflike(1, 2); + +int +main(int argc, char *argv[]) +{ + FILE *fp; + int ch, ac = 2; + char *lp = NULL /* XXX gcc */; + struct sockaddr_storage ss; + int p[2], logging, no_forward, user_required, short_list; + socklen_t sval; +#define ENTRIES 50 + char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog, *s; +#if 0 + const char *av[ENTRIES + 1], **comp; + const char *prog; +#endif + char hostbuf[MAXHOSTNAMELEN]; + + prog = __UNCONST(_PATH_FINGER); + logging = no_forward = user_required = short_list = 0; + openlog("fingerd", LOG_PID, LOG_DAEMON); + opterr = 0; + while ((ch = getopt(argc, argv, "gsluShmpP:8")) != -1) { + switch (ch) { + case 'l': + logging = 1; + break; + case 'P': + prog = optarg; + break; + case 's': + no_forward = 1; + break; + case 'u': + user_required = 1; + break; + case 'S': + short_list = 1; + av[ac++] = __UNCONST("-s"); + break; + case 'h': + av[ac++] = __UNCONST("-h"); + break; + case 'm': + av[ac++] = __UNCONST("-m"); + break; + case 'p': + av[ac++] = __UNCONST("-p"); + break; + case 'g': + av[ac++] = __UNCONST("-g"); + break; + case '8': + av[ac++] = __UNCONST("-8"); + break; + case '?': + default: + my_err("illegal option -- %c", optopt); + } + if (ac >= ENTRIES) + my_err("Too many options provided"); + } + + + if (logging) { + sval = sizeof(ss); + if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0) + my_err("getpeername: %s", strerror(errno)); + (void)getnameinfo((struct sockaddr *)&ss, sval, + hostbuf, sizeof(hostbuf), NULL, 0, 0); + lp = hostbuf; + } + + if (!fgets(line, sizeof(line), stdin)) { + if (logging) + syslog(LOG_NOTICE, "query from %s", lp); + exit(1); + } + while ((s = strrchr(line, '\n')) != NULL || + (s = strrchr(line, '\r')) != NULL) + *s = '\0'; + + if (logging) { + if (*line == '\0') + syslog(LOG_NOTICE, "query from %s", lp); + else + syslog(LOG_NOTICE, "query from %s: %s", lp, line); + } + + if (ac >= ENTRIES) + my_err("Too many options provided"); + av[ac++] = __UNCONST("--"); + comp = &av[1]; + for (lp = line, ap = &av[ac]; ac < ENTRIES;) { + if ((*ap = strtok(lp, " \t\r\n")) == NULL) + break; + lp = NULL; + if (no_forward && strchr(*ap, '@')) { + (void) puts("forwarding service denied\r\n"); + exit(1); + } + + ch = strlen(*ap); + while ((*ap)[ch-1] == '@') + (*ap)[--ch] = '\0'; + if (**ap == '\0') + continue; + + /* RFC1196: "/[Ww]" == "-l" */ + if ((*ap)[0] == '/' && ((*ap)[1] == 'W' || (*ap)[1] == 'w')) { + if (!short_list) { + av[1] = __UNCONST("-l"); + comp = &av[0]; + } + } else { + ap++; + ac++; + } + } + av[ENTRIES - 1] = NULL; + + if ((lp = strrchr(prog, '/'))) + *comp = ++lp; + else + *comp = prog; + + if (user_required) { + for (ap = comp + 1; strcmp("--", *(ap++)); ); + if (*ap == NULL) { + (void) puts("must provide username\r\n"); + exit(1); + } + } + + if (pipe(p) < 0) + my_err("pipe: %s", strerror(errno)); + + switch(fork()) { + case 0: + (void) close(p[0]); + if (p[1] != 1) { + (void) dup2(p[1], 1); + (void) close(p[1]); + } + execv(prog, comp); + my_err("execv: %s: %s", prog, strerror(errno)); + _exit(1); + case -1: + my_err("fork: %s", strerror(errno)); + } + (void) close(p[1]); + if (!(fp = fdopen(p[0], "r"))) + my_err("fdopen: %s", strerror(errno)); + while ((ch = getc(fp)) != EOF) { + if (ch == '\n') + putchar('\r'); + putchar(ch); + } + exit(0); +} + +static void +my_err(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + (void) vsyslog(LOG_ERR, fmt, ap); + va_end(ap); + exit(1); + /* NOTREACHED */ +} diff --git a/libexec/fingerd/pathnames.h b/libexec/fingerd/pathnames.h new file mode 100644 index 000000000..0c374332a --- /dev/null +++ b/libexec/fingerd/pathnames.h @@ -0,0 +1,34 @@ +/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:46:38 agc Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)pathnames.h 5.3 (Berkeley) 6/1/90 + */ + +#define _PATH_FINGER "/usr/bin/finger" diff --git a/man/man8/Makefile b/man/man8/Makefile index 440c44076..4b370ad98 100644 --- a/man/man8/Makefile +++ b/man/man8/Makefile @@ -1,6 +1,6 @@ MAN= add_route.8 backup.8 boot.8 btrace.8 \ cdprobe.8 chown.8 cleantmp.8 config.8 cron.8 \ - dhcpd.8 diskctl.8 fbdctl.8 fdisk.8 fingerd.8 \ + dhcpd.8 diskctl.8 fbdctl.8 fdisk.8 \ getty.8 halt.8 hgfs.8 httpd.8 ifconfig.8 inet.8 init.8 \ intr.8 irdpd.8 loadramdisk.8 MAKEDEV.8 \ netconf.8 newroot.8 nonamed.8 \ diff --git a/man/man8/fingerd.8 b/man/man8/fingerd.8 deleted file mode 100644 index c5684c69a..000000000 --- a/man/man8/fingerd.8 +++ /dev/null @@ -1,53 +0,0 @@ -.\" Copyright (c) 1980 Regents of the University of California. -.\" All rights reserved. The Berkeley software License Agreement -.\" specifies the terms and conditions for redistribution. -.\" -.\" @(#)fingerd.8c 6.1 (Berkeley) 5/23/86 -.\" -.TH FINGERD 8 "May 23, 1986" -.UC 6 -.SH NAME -fingerd, in.fingerd \- remote user information server -.SH SYNOPSIS -.B "finger stream tcp nowait nobody /usr/sbin/in.fingerd in.fingerd" -.br -.B "tcpd finger /usr/sbin/in.fingerd in.fingerd" -.SH DESCRIPTION -.B Fingerd -is a simple protocol based on RFC742 that provides an interface to the -Name and Finger programs at several network sites. -The program is supposed to return a friendly, -human-oriented status report on either the system at the moment -or a particular person in depth. -There is no required format and the -protocol consists mostly of specifying a single ``command line''. -.PP -.B Fingerd -listens for TCP requests at port 79. -Once connected it reads a single command line -terminated by a which is passed to -.BR finger (1). -.B Fingerd -closes its connections as soon as the output is finished. -.PP -If the line is null (i.e. just a is sent) then -.B finger -returns a ``default'' report that lists all people logged into -the system at that moment. -.PP -If a user name is specified (e.g. eric) then the -response lists more extended information for only that particular user, -whether logged in or not. -Allowable ``names'' in the command line include both ``login names'' -and ``user names''. -If a name is ambiguous, all possible derivations are returned. -.SH SEE ALSO -.BR finger (1). -.SH BUGS -Connecting directly to the server from a TIP -or an equally narrow-minded TELNET-protocol user program can result -in meaningless attempts at option negotiation being sent to the -server, which will foul up the command line interpretation. -.B Fingerd -should be taught to filter out IAC's and perhaps even respond -negatively (IAC WON'T) to all option commands received. diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index 23300f91a..317234489 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -59,6 +59,7 @@ 2011/05/26 00:00:00,external/public-domain/xz 2012/10/17 12:00:00,external/README 2012/10/17 12:00:00,include +2013/05/31 12:00:00,libexec/fingerd 2012/10/17 12:00:00,libexec/ftpd 2012/10/17 12:00:00,libexec/ld.elf_so 2012/10/17 12:00:00,libexec/Makefile