diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-06-24 15:01:34 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-06-24 15:01:34 +0000 |
commit | 6d5d61ad6033044a890eeecdcc60427f5e52d03d (patch) | |
tree | a44f28cb8ea13826ebf53e5db0b29ea56282128b /libc/sysdeps/unix/sysv/linux | |
parent | 88e95b91302a82653053490ef1064fa903e75c27 (diff) | |
download | eglibc2-6d5d61ad6033044a890eeecdcc60427f5e52d03d.tar.gz |
Merge changes between r10687 and r10807 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@10808 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/unix/sysv/linux')
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/getlogin.c | 5 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/getlogin_r.c | 32 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h | 2 |
9 files changed, 36 insertions, 15 deletions
diff --git a/libc/sysdeps/unix/sysv/linux/getlogin.c b/libc/sysdeps/unix/sysv/linux/getlogin.c index 4d15db093..58e37c4ab 100644 --- a/libc/sysdeps/unix/sysv/linux/getlogin.c +++ b/libc/sysdeps/unix/sysv/linux/getlogin.c @@ -32,8 +32,9 @@ char * getlogin (void) { - if (__getlogin_r_loginuid (name, sizeof (name)) == 0) - return name; + int res = __getlogin_r_loginuid (name, sizeof (name)); + if (res >= 0) + return res == 0 ? name : NULL; return getlogin_fd0 (); } diff --git a/libc/sysdeps/unix/sysv/linux/getlogin_r.c b/libc/sysdeps/unix/sysv/linux/getlogin_r.c index dad2671e8..7d4d6c0ed 100644 --- a/libc/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/libc/sysdeps/unix/sysv/linux/getlogin_r.c @@ -27,6 +27,10 @@ static int getlogin_r_fd0 (char *name, size_t namesize); #undef getlogin_r +/* Try to determine login name from /proc/self/loginuid and return 0 + if successful. If /proc/self/loginuid cannot be read return -1. + Otherwise return the error number. */ + int attribute_hidden __getlogin_r_loginuid (name, namesize) @@ -35,7 +39,7 @@ __getlogin_r_loginuid (name, namesize) { int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY); if (fd == -1) - return 1; + return -1; /* We are reading a 32-bit number. 12 bytes are enough for the text representation. If not, something is wrong. */ @@ -51,37 +55,38 @@ __getlogin_r_loginuid (name, namesize) || (uidbuf[n] = '\0', uid = strtoul (uidbuf, &endp, 10), endp == uidbuf || *endp != '\0')) - return 1; + return -1; size_t buflen = 1024; char *buf = alloca (buflen); bool use_malloc = false; struct passwd pwd; struct passwd *tpwd; + int result = 0; int res; - while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) != 0) + while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) == ERANGE) if (__libc_use_alloca (2 * buflen)) - extend_alloca (buf, buflen, 2 * buflen); + buf = extend_alloca (buf, buflen, 2 * buflen); else { buflen *= 2; char *newp = realloc (use_malloc ? buf : NULL, buflen); if (newp == NULL) { - fail: - if (use_malloc) - free (buf); - return 1; + result = ENOMEM; + goto out; } buf = newp; use_malloc = true; } - if (tpwd == NULL) - goto fail; + if (res != 0) + { + result = -1; + goto out; + } - int result = 0; size_t needed = strlen (pwd.pw_name) + 1; if (needed > namesize) { @@ -109,8 +114,9 @@ getlogin_r (name, namesize) char *name; size_t namesize; { - if (__getlogin_r_loginuid (name, namesize) == 0) - return 0; + int res = __getlogin_r_loginuid (name, namesize); + if (res >= 0) + return res; return getlogin_r_fd0 (name, namesize); } diff --git a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 669388954..944a3209b 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -102,6 +102,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index 33635fd9e..2189a9722 100644 --- a/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -99,6 +99,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index fea347bfc..ea760f64a 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -102,6 +102,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index aeb1e0fe9..05c7a3ba8 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -118,6 +118,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index 2a4123c61..df21f6af4 100644 --- a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -103,6 +103,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index 1dc45b7d8..bf8f3d60e 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -101,6 +101,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index aa04e0e49..ac029fdda 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -117,6 +117,8 @@ # define F_SETLEASE 1024 /* Set a lease. */ # define F_GETLEASE 1025 /* Enquire what lease is active. */ # define F_NOTIFY 1026 /* Request notfications on a directory. */ +# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ +# define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with |