Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/rexecd make it AF independent as much as possible
details: https://anonhg.NetBSD.org/src/rev/58c05e4aa4ee
branches: trunk
changeset: 532364:58c05e4aa4ee
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Jun 05 23:05:34 2002 +0000
description:
make it AF independent as much as possible
diffstat:
libexec/rexecd/rexecd.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diffs (94 lines):
diff -r 822f57c7ccc2 -r 58c05e4aa4ee libexec/rexecd/rexecd.c
--- a/libexec/rexecd/rexecd.c Wed Jun 05 22:50:08 2002 +0000
+++ b/libexec/rexecd/rexecd.c Wed Jun 05 23:05:34 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rexecd.c,v 1.10 2002/05/26 00:02:08 wiz Exp $ */
+/* $NetBSD: rexecd.c,v 1.11 2002/06/05 23:05:34 itojun Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "from: @(#)rexecd.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: rexecd.c,v 1.10 2002/05/26 00:02:08 wiz Exp $");
+__RCSID("$NetBSD: rexecd.c,v 1.11 2002/06/05 23:05:34 itojun Exp $");
#endif
#endif /* not lint */
@@ -68,7 +68,7 @@
void error __P((const char *, ...))
__attribute__((__format__(__printf__, 1, 2)));
int main __P((int, char **));
-void doit __P((int, struct sockaddr_in *));
+void doit __P((int, struct sockaddr *));
void getstr __P((char *, int, char *));
char username[32 + 1] = "USER=";
@@ -78,7 +78,6 @@
char *envinit[] = { homedir, shell, path, username, 0 };
char **environ;
int log;
-struct sockaddr_in asin = { AF_INET };
/*
* remote execute server:
@@ -92,7 +91,7 @@
int argc;
char **argv;
{
- struct sockaddr_in from;
+ struct sockaddr_storage from;
int fromlen, ch;
while ((ch = getopt(argc, argv, "l")) != -1)
@@ -109,14 +108,14 @@
if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0)
err(1, "getpeername");
- doit(0, &from);
+ doit(0, (struct sockaddr *)&from);
exit(0);
}
void
doit(f, fromp)
int f;
- struct sockaddr_in *fromp;
+ struct sockaddr *fromp;
{
struct pollfd fds[2];
char cmdbuf[NCARGS+1], *namep;
@@ -151,20 +150,25 @@
}
(void)alarm(0);
if (port != 0) {
- s = socket(AF_INET, SOCK_STREAM, 0);
+ s = socket(fromp->sa_family, SOCK_STREAM, 0);
if (s < 0) {
if (log)
syslog(LOG_ERR, "socket: %m");
exit(1);
}
- if (bind(s, (struct sockaddr *)&asin, sizeof (asin)) < 0) {
- if (log)
- syslog(LOG_ERR, "bind: %m");
+ (void)alarm(60);
+ switch (fromp->sa_family) {
+ case AF_INET:
+ ((struct sockaddr_in *)fromp)->sin_port = htons(port);
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *)fromp)->sin6_port = htons(port);
+ break;
+ default:
+ syslog(LOG_ERR, "unsupported address family");
exit(1);
}
- (void)alarm(60);
- fromp->sin_port = htons(port);
- if (connect(s, (struct sockaddr *)fromp, sizeof (*fromp)) < 0) {
+ if (connect(s, (struct sockaddr *)fromp, fromp->sa_len) < 0) {
if (log)
syslog(LOG_ERR, "connect: %m");
exit(1);
Home |
Main Index |
Thread Index |
Old Index