summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-12-02 12:20:17 +0000
committercharnier <charnier@FreeBSD.org>1997-12-02 12:20:17 +0000
commit5ea1ba746edd76baf3e0a313a47d11a63fba4b7b (patch)
tree974bfff998286683c0642a744e73882372f17dd8 /libexec
parentb0d805ea880eaef32bab030fc17577a8fd0cec3e (diff)
downloadFreeBSD-src-5ea1ba746edd76baf3e0a313a47d11a63fba4b7b.zip
FreeBSD-src-5ea1ba746edd76baf3e0a313a47d11a63fba4b7b.tar.gz
Document -n flag. Use err(3). Add usage.
Add syslog capability.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rpc.rwalld/rpc.rwalld.822
-rw-r--r--libexec/rpc.rwalld/rwalld.c67
2 files changed, 53 insertions, 36 deletions
diff --git a/libexec/rpc.rwalld/rpc.rwalld.8 b/libexec/rpc.rwalld/rpc.rwalld.8
index cbd64a9..31204f5 100644
--- a/libexec/rpc.rwalld/rpc.rwalld.8
+++ b/libexec/rpc.rwalld/rpc.rwalld.8
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: rpc.rwalld.8,v 1.3 1997/02/22 14:22:18 peter Exp $
.\"
.Dd June 7, 1993
.Dt RPC.RWALLD 8
@@ -41,8 +41,9 @@
.Nd write messages to users currently logged in server
.Sh SYNOPSIS
.Nm /usr/libexec/rpc.rwalld
+.Op Fl n
.Sh DESCRIPTION
-.Nm rpc.rwalld
+.Nm Rpc.rwalld
is a server which will send a message to users
currently logged in to the system. This server
invokes the
@@ -50,16 +51,27 @@ invokes the
command to actually write the messages to the
system.
.Pp
+The following option is available:
+.Bl -tag -width indent
+.It Fl n
+Do not become a daemon. This option is only available when
+.Nm
+is not invoked by
+.Xr inetd 8 .
+.El
+.Pp
Messages are sent to this server by the
.Xr rwall 1
command.
The
-.Nm rpc.rwalld
+.Nm
daemon is normally invoked by
.Xr inetd 8 .
.Pp
-.Nm rpc.rwalld
-uses an RPC protocol defined in
+.Nm Rpc.rwalld
+uses an
+.Tn RPC
+protocol defined in
.Pa /usr/include/rpcsvc/rwall.x .
.Sh SEE ALSO
.Xr rwall 1 ,
diff --git a/libexec/rpc.rwalld/rwalld.c b/libexec/rpc.rwalld/rwalld.c
index 90b0ffe..ec30870 100644
--- a/libexec/rpc.rwalld/rwalld.c
+++ b/libexec/rpc.rwalld/rwalld.c
@@ -28,20 +28,24 @@
*/
#ifndef lint
-static char rcsid[] = "$Id$";
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
-#include <unistd.h>
-#include <sys/types.h>
+#include <err.h>
#include <pwd.h>
+#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <sys/wait.h>
+#include <syslog.h>
#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
#include <rpcsvc/rwall.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
#ifdef OSF
#define WALL_CMD "/usr/sbin/wall"
@@ -52,10 +56,12 @@ static char rcsid[] = "$Id$";
void wallprog_1();
void possess();
void killkids();
+static void usage __P((void));
int nodaemon = 0;
int from_inetd = 1;
+int
main(argc, argv)
int argc;
char *argv[];
@@ -68,10 +74,8 @@ main(argc, argv)
if (argc == 2 && !strcmp(argv[1], "-n"))
nodaemon = 1;
- if (argc != 1 && !nodaemon) {
- printf("usage: %s [-n]\n", argv[0]);
- exit(1);
- }
+ if (argc != 1 && !nodaemon)
+ usage();
if (geteuid() == 0) {
struct passwd *pep = getpwnam("nobody");
@@ -96,45 +100,45 @@ main(argc, argv)
possess();
(void)pmap_unset(WALLPROG, WALLVERS);
- if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- perror("socket");
- exit(1);
- }
+ if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ err(1, "socket");
bzero((char *)&sa, sizeof sa);
- if (bind(s, (struct sockaddr *)&sa, sizeof sa) < 0) {
- perror("bind");
- exit(1);
- }
+ if (bind(s, (struct sockaddr *)&sa, sizeof sa) < 0)
+ err(1, "bind");
salen = sizeof sa;
- if (getsockname(s, (struct sockaddr *)&sa, &salen)) {
- perror("getsockname");
- exit(1);
- }
+ if (getsockname(s, (struct sockaddr *)&sa, &salen))
+ err(1, "getsockname");
pmap_set(WALLPROG, WALLVERS, IPPROTO_UDP, ntohs(sa.sin_port));
- if (dup2(s, 0) < 0) {
- perror("dup2");
- exit(1);
- }
+ if (dup2(s, 0) < 0)
+ err(1, "dup2");
(void)pmap_unset(WALLPROG, WALLVERS);
}
(void)signal(SIGCHLD, killkids);
+ openlog("rpc.rwalld", LOG_CONS|LOG_PID, LOG_DAEMON);
+
transp = svcudp_create(sock);
if (transp == NULL) {
- (void)fprintf(stderr, "cannot create udp service.\n");
+ syslog(LOG_ERR, "cannot create udp service");
exit(1);
}
if (!svc_register(transp, WALLPROG, WALLVERS, wallprog_1, proto)) {
- (void)fprintf(stderr, "unable to register (WALLPROG, WALLVERS, udp).\n");
+ syslog(LOG_ERR, "unable to register (WALLPROG, WALLVERS, %s)", proto?"udp":"(inetd)");
exit(1);
}
svc_run();
- (void)fprintf(stderr, "svc_run returned\n");
+ syslog(LOG_ERR, "svc_run returned");
exit(1);
+}
+static void
+usage()
+{
+ fprintf(stderr, "usage: rpc.rwalld [-n]\n");
+ exit(1);
}
void possess()
@@ -162,6 +166,7 @@ void *wallproc_wall_1(s)
exit(0);
}
}
+ return(NULL);
}
void
@@ -201,7 +206,7 @@ wallprog_1(rqstp, transp)
svcerr_systemerr(transp);
}
if (!svc_freeargs(transp, xdr_argument, &argument)) {
- (void)fprintf(stderr, "unable to free arguments\n");
+ syslog(LOG_ERR, "unable to free arguments");
exit(1);
}
leave:
OpenPOWER on IntegriCloud