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]
22 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
28 * University Copyright- Copyright (c) 1982, 1986, 1988
29 * The Regents of the University of California
32 * University Acknowledgment- Portions of this document are derived from
33 * software developed by the University of California, Berkeley, and its
37 #pragma ident "%Z%%M% %I% %E% SMI"
41 * The server procedure for rwalld
49 #include <rpcsvc/rwall.h>
50 #include <sys/types.h>
55 #define WALL_PROG "/usr/sbin/wall"
57 static mutex_t wall_mutex
= DEFAULTMUTEX
;
62 wallproc_wall_1_svc(wrapstring
*argp
, void *res
, struct svc_req
*rqstp
)
72 * Do not wall the same message twice in case of a retransmission
73 * in the rare case that two walls arrive close enough with
74 * a retransmission we might get a duplicate, but that is OK.
76 (void) mutex_lock(&wall_mutex
);
77 if ((oldmsg
!= 0) && (strcmp(msg
, oldmsg
) == 0)) {
78 (void) mutex_unlock(&wall_mutex
);
86 rval
= stat(WALL_PROG
, &wall
);
89 * Make sure the wall programs exists, is executeable, and runs
91 if (rval
== -1 || (wall
.st_mode
& S_IXUSR
) == 0 ||
92 (fp
= popen(WALL_PROG
, "w")) == NULL
) {
94 "rwall message received but could not execute %s",
96 syslog(LOG_NOTICE
, "%s", msg
);
98 (void) fprintf(stderr
,
99 "rwall message received but could not execute %s",
101 (void) fprintf(stderr
, "%s", msg
);
103 (void) mutex_unlock(&wall_mutex
);
107 (void) fprintf(fp
, "%s", msg
);
109 (void) mutex_unlock(&wall_mutex
);
116 wallprog_1_freeresult(SVCXPRT
*transp
, xdrproc_t proc
, caddr_t arg
)