From 2864e767053317538feafa815046fff89e5a16be Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 10 Nov 1999 02:42:49 +0000 Subject: Update. 1999-11-09 Ulrich Drepper * elf/dl-load.c (_dl_dst_count): Allow $ORIGIN to point to directory with the reference since this is as secure as using the object with the dependency. (_dl_dst_substitute): Likewise. * elf/dl-load.c (_dl_dst_count): Change strings in first two strncmp calls to allow reuse. (_dl_dst_substitute): Likewise. 1999-11-01 Arnold D. Robbins * posix/regex.c (init_syntax_once): move below definition of ISALNUM etc., then use ISALNUM to init the table, so that the word ops will work if i18n'ed. (SYNTAX): And subscript with 0xFF for 8bit character sets. 1999-11-09 Andreas Jaeger * sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin implementation for ttyname_r call; fix inverted condition; return ut_user. Closes PR libc/1438. 1999-11-09 Ulrich Drepper * timezone/checktab.awk: Update from tzcode1999h. * timezone/africa: Update from tzdata1999i. * timezone/asia: Likewise. * timezone/australasia: Likewise. * timezone/backward: Likewise. * timezone/europe: Likewise. * timezone/northamerica: Likewise. * timezone/southamerica: Likewise. * timezone/iso3166.tab: Likewise. * timezone/zone.tab: Likewise. * sysdeps/unix/sysv/linux/bits/resource.h: Define values also as macros. Patch by brg@csua.berkeley.edu [PR libc/1439]. 1999-11-09 Andreas Jaeger * posix/Makefile (tests): Added tst-getlogin. * posix/tst-getlogin.c: New file, contains simple tests for getlogin and getlogin_r. 1999-11-09 Andreas Schwab * misc/syslog.c: For LOG_PERROR only append a newline if necessary. --- sysdeps/unix/getlogin_r.c | 32 ++++++++++++++++---------------- sysdeps/unix/sysv/linux/bits/resource.h | 3 +++ 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c index cb0545e08a..04b99056b0 100644 --- a/sysdeps/unix/getlogin_r.c +++ b/sysdeps/unix/getlogin_r.c @@ -40,20 +40,20 @@ getlogin_r (name, name_len) int result = 0; struct utmp *ut, line, buffer; - { - int d = __open ("/dev/tty", 0); - if (d < 0) - return errno; + /* Get name of tty connected to fd 0. Return if not a tty or + if fd 0 isn't open. Note that a lot of documentation says that + getlogin() is based on the controlling terminal---what they + really mean is "the terminal connected to standard input". The + getlogin() implementation of DEC Unix, SunOS, Solaris, HP-UX all + return NULL if fd 0 has been closed, so this is the compatible + thing to do. Note that ttyname(open("/dev/tty")) on those + systems returns /dev/tty, so that is not a possible solution for + getlogin(). */ - result = __ttyname_r (d, real_tty_path, sizeof (tty_pathname)); - (void) __close (d); - - if (result != 0) - { - __set_errno (result); - return result; - } - } + result = __ttyname_r (0, real_tty_path, sizeof (tty_pathname)); + + if (result != 0) + return result; real_tty_path += 5; /* Remove "/dev/". */ @@ -69,16 +69,16 @@ getlogin_r (name, name_len) } else { - size_t needed = strlen (ut->ut_line) + 1; + size_t needed = strlen (ut->ut_user) + 1; - if (needed < name_len) + if (needed > name_len) { __set_errno (ERANGE); result = ERANGE; } else { - memcpy (name, ut->ut_line, needed); + memcpy (name, ut->ut_user, needed); result = 0; } } diff --git a/sysdeps/unix/sysv/linux/bits/resource.h b/sysdeps/unix/sysv/linux/bits/resource.h index 42e0d36f19..fcff605892 100644 --- a/sysdeps/unix/sysv/linux/bits/resource.h +++ b/sysdeps/unix/sysv/linux/bits/resource.h @@ -219,6 +219,9 @@ struct rusage enum __priority_which { PRIO_PROCESS = 0, /* WHO is a process ID. */ +#define PRIO_PROCESS PRIO_PROCESS PRIO_PGRP = 1, /* WHO is a process group ID. */ +#define PRIO_PGRP PRIO_PGRP PRIO_USER = 2 /* WHO is a user ID. */ +#define PRIO_USER PRIO_USER }; -- cgit v1.2.3