summaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
commit8833066b122427710a9e14a888ce6cfa862332d3 (patch)
tree29591019d695919417b3698618d6a342e97381d6 /login
parentfedca46896bdb702cb988837a0c2c5447e72ba2b (diff)
Updated to fedora-glibc-20070731T1624cvs/fedora-glibc-2_6_90-1
Diffstat (limited to 'login')
-rw-r--r--login/Makefile4
-rw-r--r--login/forkpty.c4
-rw-r--r--login/logout.c7
-rw-r--r--login/logwtmp.c13
-rw-r--r--login/utmp_file.c42
5 files changed, 43 insertions, 27 deletions
diff --git a/login/Makefile b/login/Makefile
index 2e414a3ee7..b02d385b66 100644
--- a/login/Makefile
+++ b/login/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1996-1998,2000-2002,2003 Free Software Foundation, Inc.
+# Copyright (C) 1996-1998,2000-2002,2003,2007 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
@@ -30,7 +30,7 @@ routines := getutent getutent_r getutid getutline getutid_r getutline_r \
CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"'
others = utmpdump pt_chown
-install-others = $(inst_libexecdir)/pt_chown
+install-others-programs = $(inst_libexecdir)/pt_chown
distribute := utmp-private.h utmp-equal.h pty-private.h
diff --git a/login/forkpty.c b/login/forkpty.c
index ff87fd031d..ccd5dbfe0e 100644
--- a/login/forkpty.c
+++ b/login/forkpty.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
@@ -38,6 +38,8 @@ forkpty (amaster, name, termp, winp)
switch (pid = fork ())
{
case -1:
+ close (master);
+ close (slave);
return -1;
case 0:
/* Child. */
diff --git a/login/logout.c b/login/logout.c
index 020ff6189a..8902036c5e 100644
--- a/login/logout.c
+++ b/login/logout.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -51,15 +51,10 @@ logout (const char *line)
bzero (ut->ut_host, sizeof ut->ut_host);
#endif
#if _HAVE_UT_TV - 0
- if (sizeof (ut->ut_tv) == sizeof (struct timeval))
- __gettimeofday ((struct timeval *) &ut->ut_tv, NULL);
- else
- {
struct timeval tv;
__gettimeofday (&tv, NULL);
ut->ut_tv.tv_sec = tv.tv_sec;
ut->ut_tv.tv_usec = tv.tv_usec;
- }
#else
ut->ut_time = time (NULL);
#endif
diff --git a/login/logwtmp.c b/login/logwtmp.c
index 96ef05d795..ff2e7f9887 100644
--- a/login/logwtmp.c
+++ b/login/logwtmp.c
@@ -44,15 +44,10 @@ logwtmp (const char *line, const char *name, const char *host)
#endif
#if _HAVE_UT_TV - 0
- if (sizeof (ut.ut_tv) == sizeof (struct timeval))
- __gettimeofday ((struct timeval *) &ut.ut_tv, NULL);
- else
- {
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- ut.ut_tv.tv_sec = tv.tv_sec;
- ut.ut_tv.tv_usec = tv.tv_usec;
- }
+ struct timeval tv;
+ __gettimeofday (&tv, NULL);
+ ut.ut_tv.tv_sec = tv.tv_sec;
+ ut.ut_tv.tv_usec = tv.tv_usec;
#else
ut.ut_time = time (NULL);
#endif
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 871c856071..4a9e409454 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <utmp.h>
#include <not-cancel.h>
+#include <kernel-features.h>
#include "utmp-private.h"
#include "utmp-equal.h"
@@ -140,24 +141,47 @@ setutent_file (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
- file_fd = open_not_cancel_2 (file_name, O_RDWR | O_LARGEFILE);
+#ifdef O_CLOEXEC
+# define O_flags O_LARGEFILE | O_CLOEXEC
+#else
+# define O_flags O_LARGEFILE
+#endif
+ file_fd = open_not_cancel_2 (file_name, O_RDWR | O_flags);
if (file_fd == -1)
{
/* Hhm, read-write access did not work. Try read-only. */
- file_fd = open_not_cancel_2 (file_name, O_RDONLY | O_LARGEFILE);
+ file_fd = open_not_cancel_2 (file_name, O_RDONLY | O_flags);
if (file_fd == -1)
return 0;
}
- /* We have to make sure the file is `closed on exec'. */
- result = fcntl_not_cancel (file_fd, F_GETFD, 0);
- if (result >= 0)
- result = fcntl_not_cancel (file_fd, F_SETFD, result | FD_CLOEXEC);
- if (result == -1)
+#ifndef __ASSUME_O_CLOEXEC
+# ifdef O_CLOEXEC
+ static int have_o_cloexec;
+
+ if (have_o_cloexec <= 0)
+# endif
{
- close_not_cancel_no_status (file_fd);
- return 0;
+ /* We have to make sure the file is `closed on exec'. */
+ result = fcntl_not_cancel (file_fd, F_GETFD, 0);
+ if (result >= 0)
+ {
+# ifdef O_CLOEXEC
+ if (have_o_cloexec == 0)
+ have_o_cloexec = (result & FD_CLOEXEC) ? 1 : -1;
+# endif
+
+ result = fcntl_not_cancel (file_fd, F_SETFD,
+ result | FD_CLOEXEC);
+ }
+
+ if (result == -1)
+ {
+ close_not_cancel_no_status (file_fd);
+ return 0;
+ }
}
+#endif
}
__lseek64 (file_fd, 0, SEEK_SET);