*
* @APPLE_LICENSE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
+ * Reserved. This file contains Original Code and/or Modifications of
+ * Original Code as defined in and that are subject to the Apple Public
+ * Source License Version 1.1 (the "License"). You may not use this file
+ * except in compliance with the License. Please obtain a copy of the
+ * License at http://www.apple.com/publicsource and read it before using
+ * this file.
*
* The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/socket.h>
#include <sys/stat.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
-#include <netinfo/ni_util.h>
#include <signal.h>
#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#include <time.h>
#ifdef YP
#include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
-#include <arpa/nameser8_compat.h>
+
+#include <arpa/nameser_compat.h>
+#include <nameser.h>
/* wrapper for KAME-special getnameinfo() */
#ifndef NI_WITHSCOPEID
} else {
char num[8];
int s2 = rresvport_af(&lport, ai->ai_family), s3;
- int len = ai->ai_addrlen;
+ unsigned int len = ai->ai_addrlen;
int nfds;
if (s2 < 0)
int __check_rhosts_file = 1;
char *__rcmd_errstr;
+/* Guess at the size of a password buffer for getpwnam_r (see lookup.subproj/lu_group.c) */
+#define MAXPWBUF (MAXLOGNAME + 1 + _PASSWORD_LEN + 1 + MAXPATHLEN + 1 + MAXPATHLEN + 1 + 4098)
+
/*
* AF independent extension of iruserok.
*
{
register char *cp;
struct stat sbuf;
- struct passwd *pwd;
+ struct passwd p, *pwd;
FILE *hostf;
uid_t uid;
- int first;
+ int first, status;
char pbuf[MAXPATHLEN];
const struct sockaddr *raddr;
struct sockaddr_storage ss;
+ char pwbuf[MAXPWBUF];
/* avoid alignment issue */
if (rlen > sizeof(ss))
}
if (first == 1 && (__check_rhosts_file || superuser)) {
first = 0;
- if ((pwd = getpwnam(luser)) == NULL)
- return (-1);
+
+ memset(&p, 0, sizeof(struct passwd));
+ memset(pwbuf, 0, sizeof(pwbuf));
+ pwd = NULL;
+
+ status = getpwnam_r(luser, &p, pwbuf, MAXPWBUF, &pwd);
+ if (status != 0) return -1;
+
(void)strcpy(pbuf, pwd->pw_dir);
(void)strcat(pbuf, "/.rhosts");