From 2c6cfe6853a30deb4af842aacc924fa298d0521a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 19 Dec 2005 12:11:38 +0000 Subject: Updated to fedora-glibc-20051219T1003 --- sysdeps/posix/euidaccess.c | 88 +++++++++++++++++++++---------------------- sysdeps/posix/getaddrinfo.c | 92 +++++++++++++++++++-------------------------- sysdeps/posix/profil.c | 4 +- sysdeps/posix/shm_open.c | 4 +- sysdeps/posix/shm_unlink.c | 4 +- sysdeps/posix/sprofil.c | 4 +- 6 files changed, 90 insertions(+), 106 deletions(-) (limited to 'sysdeps/posix') diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c index 8a2d826e95..5464bfb374 100644 --- a/sysdeps/posix/euidaccess.c +++ b/sysdeps/posix/euidaccess.c @@ -1,5 +1,5 @@ /* Check if effective user id can access file - Copyright (C) 1990,91,95,96,97,98,99,2000,01 Free Software Foundation, Inc. + Copyright (C) 1990,1991,1995-2001,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,26 +21,26 @@ Adapted for GNU C library by Roland McGrath. */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include #include #ifdef S_IEXEC -#ifndef S_IXUSR -#define S_IXUSR S_IEXEC -#endif -#ifndef S_IXGRP -#define S_IXGRP (S_IEXEC >> 3) -#endif -#ifndef S_IXOTH -#define S_IXOTH (S_IEXEC >> 6) -#endif +# ifndef S_IXUSR +# define S_IXUSR S_IEXEC +# endif +# ifndef S_IXGRP +# define S_IXGRP (S_IEXEC >> 3) +# endif +# ifndef S_IXOTH +# define S_IXOTH (S_IEXEC >> 6) +# endif #endif /* S_IEXEC */ -#if defined (HAVE_UNISTD_H) || defined (_LIBC) -#include +#if defined HAVE_UNISTD_H || defined _LIBC +# include #endif #ifndef _POSIX_VERSION @@ -55,35 +55,35 @@ gid_t getegid (); extern int errno; #endif #ifndef __set_errno -#define __set_errno(val) errno = (val) +# define __set_errno(val) errno = (val) #endif -#if defined(EACCES) && !defined(EACCESS) -#define EACCESS EACCES +#if defined EACCES && !defined EACCESS +# define EACCESS EACCES #endif #ifndef F_OK -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 #endif -#if !defined (S_IROTH) && defined (R_OK) +#if !defined S_IROTH && defined R_OK # define S_IROTH R_OK #endif -#if !defined (S_IWOTH) && defined (W_OK) +#if !defined S_IWOTH && defined W_OK # define S_IWOTH W_OK #endif -#if !defined (S_IXOTH) && defined (X_OK) +#if !defined S_IXOTH && defined X_OK # define S_IXOTH X_OK #endif #ifdef _LIBC -#define group_member __group_member -#define euidaccess __euidaccess +# define group_member __group_member +# define euidaccess __euidaccess #else @@ -93,14 +93,6 @@ static uid_t uid; /* The user's real group id. */ static gid_t gid; -#ifdef HAVE_GETGROUPS -int group_member (); -#else -#define group_member(gid) 0 -#endif - -#endif - /* The user's effective user id. */ static uid_t euid; @@ -110,6 +102,14 @@ static gid_t egid; /* Nonzero if UID, GID, EUID, and EGID have valid values. */ static int have_ids; +# ifdef HAVE_GETGROUPS +int group_member (); +# else +# define group_member(gid) 0 +# endif + +#endif + /* Return 0 if the user has permission of type MODE on file PATH; otherwise, return -1 and set `errno' to EACCESS. @@ -126,6 +126,9 @@ euidaccess (path, mode) int granted; #ifdef _LIBC + uid_t euid; + gid_t egid; + if (! __libc_enable_secure) /* If we are not set-uid or set-gid, access does the same. */ return __access (path, mode); @@ -157,12 +160,8 @@ euidaccess (path, mode) #ifdef _LIBC /* Now we need the IDs. */ - if (have_ids == 0) - { - have_ids = 1; - euid = __geteuid (); - egid = __getegid (); - } + euid = __geteuid (); + egid = __getegid (); #endif /* The super-user can read and write any file, and execute any file @@ -172,11 +171,12 @@ euidaccess (path, mode) return 0; if (euid == stats.st_uid) - granted = (unsigned) (stats.st_mode & (mode << 6)) >> 6; + granted = (unsigned int) (stats.st_mode & (mode << 6)) >> 6; else if (egid == stats.st_gid || group_member (stats.st_gid)) - granted = (unsigned) (stats.st_mode & (mode << 3)) >> 3; + granted = (unsigned int) (stats.st_mode & (mode << 3)) >> 3; else granted = (stats.st_mode & mode); + /* XXX Add support for ACLs. */ if (granted == mode) return 0; __set_errno (EACCESS); @@ -188,9 +188,9 @@ weak_alias (__euidaccess, euidaccess) #endif #ifdef TEST -#include -#include -#include "error.h" +# include +# include +# include "error.h" char *program_name; diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 81a56a0794..b9819bfc0a 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -121,7 +121,8 @@ struct gaih { int family; int (*gaih)(const char *name, const struct gaih_service *service, - const struct addrinfo *req, struct addrinfo **pai); + const struct addrinfo *req, struct addrinfo **pai, + unsigned int *naddrs); }; static const struct addrinfo default_hints = @@ -363,7 +364,8 @@ extern service_user *__nss_hosts_database attribute_hidden; static int gaih_inet (const char *name, const struct gaih_service *service, - const struct addrinfo *req, struct addrinfo **pai) + const struct addrinfo *req, struct addrinfo **pai, + unsigned int *naddrs) { const struct gaih_typeproto *tp = gaih_inet_typeproto; struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv; @@ -393,6 +395,7 @@ gaih_inet (const char *name, const struct gaih_service *service, } } + int port = 0; if (service != NULL) { if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0) @@ -445,63 +448,41 @@ gaih_inet (const char *name, const struct gaih_service *service, } else { - if (req->ai_socktype || req->ai_protocol) - { - st = __alloca (sizeof (struct gaih_servtuple)); - st->next = NULL; - st->socktype = tp->socktype; - st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY) - ? req->ai_protocol : tp->protocol); - st->port = htons (service->num); - } - else - { - /* Neither socket type nor protocol is set. Return all - socket types we know about. */ - struct gaih_servtuple **lastp = &st; - for (tp = gaih_inet_typeproto + 1; tp->name[0]; ++tp) - if ((tp->protoflag & GAI_PROTO_NOSERVICE) == 0) - { - struct gaih_servtuple *newp; - - newp = __alloca (sizeof (struct gaih_servtuple)); - newp->next = NULL; - newp->socktype = tp->socktype; - newp->protocol = tp->protocol; - newp->port = htons (service->num); - - *lastp = newp; - lastp = &newp->next; - } - } + port = htons (service->num); + goto got_port; } } - else if (req->ai_socktype || req->ai_protocol) - { - st = __alloca (sizeof (struct gaih_servtuple)); - st->next = NULL; - st->socktype = tp->socktype; - st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY) - ? req->ai_protocol : tp->protocol); - st->port = 0; - } else { - /* Neither socket type nor protocol is set. Return all socket types - we know about. */ - struct gaih_servtuple **lastp = &st; - for (++tp; tp->name[0]; ++tp) + got_port: + + if (req->ai_socktype || req->ai_protocol) { - struct gaih_servtuple *newp; + st = __alloca (sizeof (struct gaih_servtuple)); + st->next = NULL; + st->socktype = tp->socktype; + st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY) + ? req->ai_protocol : tp->protocol); + st->port = port; + } + else + { + /* Neither socket type nor protocol is set. Return all socket types + we know about. */ + struct gaih_servtuple **lastp = &st; + for (++tp; tp->name[0]; ++tp) + { + struct gaih_servtuple *newp; - newp = __alloca (sizeof (struct gaih_servtuple)); - newp->next = NULL; - newp->socktype = tp->socktype; - newp->protocol = tp->protocol; - newp->port = 0; + newp = __alloca (sizeof (struct gaih_servtuple)); + newp->next = NULL; + newp->socktype = tp->socktype; + newp->protocol = tp->protocol; + newp->port = port; - *lastp = newp; - lastp = &newp->next; + *lastp = newp; + lastp = &newp->next; + } } } @@ -1108,6 +1089,8 @@ gaih_inet (const char *name, const struct gaih_service *service, } *pai = NULL; + ++*naddrs; + ignore: at2 = at2->next; } @@ -1556,6 +1539,7 @@ getaddrinfo (const char *name, const char *service, else end = NULL; + unsigned int naddrs = 0; while (g->gaih) { if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC) @@ -1564,7 +1548,7 @@ getaddrinfo (const char *name, const char *service, if (pg == NULL || pg->gaih != g->gaih) { pg = g; - i = g->gaih (name, pservice, hints, end); + i = g->gaih (name, pservice, hints, end, &naddrs); if (i != 0) { /* EAI_NODATA is a more specific result as it says that @@ -1596,7 +1580,7 @@ getaddrinfo (const char *name, const char *service, if (j == 0) return EAI_FAMILY; - if (nresults > 1) + if (naddrs > 1) { /* Sort results according to RFC 3484. */ struct sort_result results[nresults]; diff --git a/sysdeps/posix/profil.c b/sysdeps/posix/profil.c index 3c2e1dfa07..f40faee33d 100644 --- a/sysdeps/posix/profil.c +++ b/sysdeps/posix/profil.c @@ -1,5 +1,5 @@ /* Low-level statistical profiling support function. Mostly POSIX.1 version. - Copyright (C) 1996,97,98,2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1996,97,98,2002, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,7 +25,7 @@ #ifndef SIGPROF -#include +#include #else diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c index b773d40db0..0a657fadfa 100644 --- a/sysdeps/posix/shm_open.c +++ b/sysdeps/posix/shm_open.c @@ -1,5 +1,5 @@ /* shm_open -- open a POSIX shared memory object. Generic POSIX file version. - Copyright (C) 2001,02 Free Software Foundation, Inc. + Copyright (C) 2001,2002,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,7 +20,7 @@ #include #if ! _POSIX_MAPPED_FILES -#include +#include #else diff --git a/sysdeps/posix/shm_unlink.c b/sysdeps/posix/shm_unlink.c index b67240f838..18ca416e16 100644 --- a/sysdeps/posix/shm_unlink.c +++ b/sysdeps/posix/shm_unlink.c @@ -1,5 +1,5 @@ /* shm_unlink -- remove a POSIX shared memory object. Generic POSIX version. - Copyright (C) 2001,02 Free Software Foundation, Inc. + Copyright (C) 2001,2002,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,7 +20,7 @@ #include #if ! _POSIX_MAPPED_FILES -#include +#include #else diff --git a/sysdeps/posix/sprofil.c b/sysdeps/posix/sprofil.c index 19787fa364..04ca1688ec 100644 --- a/sysdeps/posix/sprofil.c +++ b/sysdeps/posix/sprofil.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. Contributed by David Mosberger-Tang . This file is part of the GNU C Library. @@ -27,7 +27,7 @@ #include #ifndef SIGPROF -# include +# include #else #include -- cgit v1.2.3