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
39 * The server procedure for rwalld
47 #include <rpcsvc/rwall.h>
48 #include <sys/types.h>
53 #define WALL_PROG "/usr/sbin/wall"
55 static mutex_t wall_mutex
= DEFAULTMUTEX
;
60 wallproc_wall_1_svc(wrapstring
*argp
, void *res
, struct svc_req
*rqstp
)
70 * Do not wall the same message twice in case of a retransmission
71 * in the rare case that two walls arrive close enough with
72 * a retransmission we might get a duplicate, but that is OK.
74 (void) mutex_lock(&wall_mutex
);
75 if ((oldmsg
!= 0) && (strcmp(msg
, oldmsg
) == 0)) {
76 (void) mutex_unlock(&wall_mutex
);
83 rval
= stat(WALL_PROG
, &wall
);
86 * Make sure the wall programs exists, is executeable, and runs
88 if (rval
== -1 || (wall
.st_mode
& S_IXUSR
) == 0 ||
89 (fp
= popen(WALL_PROG
, "w")) == NULL
) {
91 "rwall message received but could not execute %s",
93 syslog(LOG_NOTICE
, "%s", msg
);
95 (void) fprintf(stderr
,
96 "rwall message received but could not execute %s",
98 (void) fprintf(stderr
, "%s", msg
);
100 (void) mutex_unlock(&wall_mutex
);
104 (void) fprintf(fp
, "%s", msg
);
106 (void) mutex_unlock(&wall_mutex
);
113 wallprog_1_freeresult(SVCXPRT
*transp
, xdrproc_t proc
, caddr_t arg
)