4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
35 #pragma ident "%Z%%M% %I% %E% SMI"
40 #include <sys/types.h>
41 #include <netinet/in.h>
42 #include <sys/socket.h>
48 void fatal(char *prog
, char *s
);
57 struct sockaddr_storage sin
;
61 char *av
[MAXARGS
+ 1];
62 socklen_t len
= sizeof (sin
);
64 if (getpeername(0, (struct sockaddr
*)&sin
, &len
) < 0)
65 fatal(argv
[0], "getpeername");
67 if (fgets(line
, sizeof (line
), stdin
) == NULL
)
73 /* skip past leading white space */
78 * The finger protocol says a "/W" switch means verbose output.
79 * We explicitly set either the "long" or "short" output flags
80 * to the finger program so that we don't have to know what what
81 * the "finger" program's default is.
83 if (*sp
== '/' && (sp
[1] == 'W' || sp
[1] == 'w')) {
90 /* look for username arguments */
93 /* skip over leading white space */
97 /* check for end of "command line" */
101 /* pick up another name argument */
103 while ((*sp
!= '\0') && !isspace(*sp
))
106 /* check again for end of "command line" */
115 fatal(argv
[0], "pipe");
117 if ((pid
= fork()) == 0) {
123 execv("/usr/bin/finger", av
);
124 printf("No local finger program found\n");
128 if (pid
== (pid_t
)-1)
129 fatal(argv
[0], "fork");
131 if ((fp
= fdopen(p
[0], "r")) == NULL
)
132 fatal(argv
[0], "fdopen");
133 while ((i
= getc(fp
)) != EOF
) {
139 while ((w
= wait(&status
)) != pid
&& w
!= (pid_t
)-1)
149 fprintf(stderr
, "%s: ", prog
);