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>
42 #include <netinet/in.h>
43 #include <sys/socket.h>
51 void fatal(char *prog
, char *s
);
60 struct sockaddr_storage sin
;
64 char *av
[MAXARGS
+ 1];
65 socklen_t len
= sizeof (sin
);
67 if (getpeername(0, (struct sockaddr
*)&sin
, &len
) < 0)
68 fatal(argv
[0], "getpeername");
70 if (fgets(line
, sizeof (line
), stdin
) == NULL
)
76 /* skip past leading white space */
81 * The finger protocol says a "/W" switch means verbose output.
82 * We explicitly set either the "long" or "short" output flags
83 * to the finger program so that we don't have to know what what
84 * the "finger" program's default is.
86 if (*sp
== '/' && (sp
[1] == 'W' || sp
[1] == 'w')) {
93 /* look for username arguments */
96 /* skip over leading white space */
100 /* check for end of "command line" */
104 /* pick up another name argument */
106 while ((*sp
!= '\0') && !isspace(*sp
))
109 /* check again for end of "command line" */
118 fatal(argv
[0], "pipe");
120 if ((pid
= fork()) == 0) {
126 execv("/usr/bin/finger", av
);
127 printf("No local finger program found\n");
131 if (pid
== (pid_t
)-1)
132 fatal(argv
[0], "fork");
134 if ((fp
= fdopen(p
[0], "r")) == NULL
)
135 fatal(argv
[0], "fdopen");
136 while ((i
= getc(fp
)) != EOF
) {
142 while ((w
= wait(&status
)) != pid
&& w
!= (pid_t
)-1)
152 fprintf(stderr
, "%s: ", prog
);