diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-02 06:13:27 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-02 06:13:27 +0000 |
commit | a76d76d5b27889d7d0bec7d3f80c2b631e49bb49 (patch) | |
tree | 7c49a7daa8377d073416a8abfcce46d2806f837c /usr.sbin/inetd/inetd.c | |
parent | 15402cee96cc574d9e0657c6d2a53b9271ee5137 (diff) |
after rpc bind, getpeername() to update sin_port
Diffstat (limited to 'usr.sbin/inetd/inetd.c')
-rw-r--r-- | usr.sbin/inetd/inetd.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index f46ea93ed3a..af955521a38 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.14 1996/07/31 11:01:54 deraadt Exp $ */ +/* $OpenBSD: inetd.c,v 1.15 1996/08/02 06:13:26 deraadt Exp $ */ /* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static char rcsid[] = "$OpenBSD: inetd.c,v 1.14 1996/07/31 11:01:54 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: inetd.c,v 1.15 1996/08/02 06:13:26 deraadt Exp $"; #endif /* not lint */ /* @@ -798,9 +798,20 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) if (sep->se_user && (pwd = getpwnam(sep->se_user)) && pwd->pw_uid == 0) r = bindresvport(sep->se_fd, &sep->se_ctrladdr_in); - else + else { r = bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size); + if (r == 0) { + int len = sep->se_ctrladdr_size; + int saveerrno = errno; + + /* update se_ctrladdr_in.sin_port */ + r = getsockname(sep->se_fd, &sep->se_ctrladdr, + &len); + if (r <= 0) + errno = saveerrno; + } + } } else r = bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size); if (r < 0) { |