diff options
Diffstat (limited to 'login')
42 files changed, 110 insertions, 139 deletions
diff --git a/login/Makefile b/login/Makefile index 9ff36d623e..8b31991be8 100644 --- a/login/Makefile +++ b/login/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1996-2016 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 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 := getlogin getlogin_r setlogin getlogin_r_chk \ utmp_file utmpname updwtmp getpt grantpt unlockpt ptsname \ ptsname_r_chk -CFLAGS-grantpt.c = -DLIBEXECDIR='"$(libexecdir)"' +CFLAGS-grantpt.c += -DLIBEXECDIR='"$(libexecdir)"' others = utmpdump @@ -53,16 +53,15 @@ libutil-routines:= login login_tty logout logwtmp openpty forkpty include ../Rules -CFLAGS-getpt.c = -fexceptions +CFLAGS-getpt.c += -fexceptions ifeq (yesyes,$(have-fpie)$(build-shared)) pt_chown-cflags += $(pie-ccflag) endif -pt_chown-cflags += $(stack-protector) ifeq (yes,$(have-libcap)) libcap = -lcap endif -CFLAGS-pt_chown.c = $(pt_chown-cflags) +CFLAGS-pt_chown.c += $(pt_chown-cflags) LDLIBS-pt_chown = $(libcap) ifeq (yesyes,$(have-fpie)$(build-shared)) LDFLAGS-pt_chown = -Wl,-z,now diff --git a/login/endutxent.c b/login/endutxent.c index c6cdf4dacf..5e2ddb20d0 100644 --- a/login/endutxent.c +++ b/login/endutxent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/forkpty.c b/login/forkpty.c index c29cf7137e..93b99eae6c 100644 --- a/login/forkpty.c +++ b/login/forkpty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. diff --git a/login/getlogin.c b/login/getlogin.c index d8078c8347..47faf3dcbc 100644 --- a/login/getlogin.c +++ b/login/getlogin.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/login/getlogin_r.c b/login/getlogin_r.c index 1de668ee8e..ce596762ad 100644 --- a/login/getlogin_r.c +++ b/login/getlogin_r.c @@ -1,5 +1,5 @@ /* Reentrant function to return the current login name. Stub version. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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 diff --git a/login/getlogin_r_chk.c b/login/getlogin_r_chk.c index e62ca4e14b..ad82b9a19e 100644 --- a/login/getlogin_r_chk.c +++ b/login/getlogin_r_chk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2016 Free Software Foundation, Inc. +/* Copyright (C) 2005-2018 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 diff --git a/login/getpt.c b/login/getpt.c index d72d5924e2..b0e93719d7 100644 --- a/login/getpt.c +++ b/login/getpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. diff --git a/login/getutent.c b/login/getutent.c index c2d479722e..4b7d6f863c 100644 --- a/login/getutent.c +++ b/login/getutent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -41,4 +41,5 @@ __getutent (void) return result; } +libc_hidden_def (__getutent) weak_alias (__getutent, getutent) diff --git a/login/getutent_r.c b/login/getutent_r.c index 94143fd676..6a244ba6e0 100644 --- a/login/getutent_r.c +++ b/login/getutent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com> and Paul Janzen <pcj@primenet.com>, 1996. @@ -151,6 +151,7 @@ __getutent_r (struct utmp *buffer, struct utmp **result) return retval; } +libc_hidden_def (__getutent_r) weak_alias (__getutent_r, getutent_r) @@ -167,6 +168,7 @@ __pututline (const struct utmp *data) return buffer; } +libc_hidden_def (__pututline) weak_alias (__pututline, pututline) diff --git a/login/getutid.c b/login/getutid.c index 3c9844697f..9ef234327d 100644 --- a/login/getutid.c +++ b/login/getutid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -39,4 +39,5 @@ __getutid (const struct utmp *id) return result; } +libc_hidden_def (__getutid) weak_alias (__getutid, getutid) diff --git a/login/getutid_r.c b/login/getutid_r.c index 1d86d65129..b7d3dbac75 100644 --- a/login/getutid_r.c +++ b/login/getutid_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com> and Paul Janzen <pcj@primenet.com>, 1996. @@ -59,4 +59,5 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) return -1; #endif } +libc_hidden_def (__getutid_r) weak_alias (__getutid_r, getutid_r) diff --git a/login/getutline.c b/login/getutline.c index a9d1c1f4ae..cc1a8615e7 100644 --- a/login/getutline.c +++ b/login/getutline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -40,4 +40,5 @@ __getutline (const struct utmp *line) return result; } +libc_hidden_def (__getutline) weak_alias (__getutline, getutline) diff --git a/login/getutline_r.c b/login/getutline_r.c index 0ddd0cd8b7..6996887f76 100644 --- a/login/getutline_r.c +++ b/login/getutline_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com> and Paul Janzen <pcj@primenet.com>, 1996. @@ -42,4 +42,5 @@ __getutline_r (const struct utmp *line, struct utmp *buffer, return retval; } +libc_hidden_def (__getutline_r) weak_alias (__getutline_r, getutline_r) diff --git a/login/getutmp.c b/login/getutmp.c index 3bcb1a5444..481150d5ef 100644 --- a/login/getutmp.c +++ b/login/getutmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2016 Free Software Foundation, Inc. +/* Copyright (C) 1999-2018 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 diff --git a/login/getutmpx.c b/login/getutmpx.c index 154cf5cff1..34145fe8db 100644 --- a/login/getutmpx.c +++ b/login/getutmpx.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2016 Free Software Foundation, Inc. +/* Copyright (C) 1999-2018 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 diff --git a/login/getutxent.c b/login/getutxent.c index 2bd4fd5a06..aa6fd7beee 100644 --- a/login/getutxent.c +++ b/login/getutxent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/getutxid.c b/login/getutxid.c index de49d17579..d64f60be96 100644 --- a/login/getutxid.c +++ b/login/getutxid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/getutxline.c b/login/getutxline.c index 2de8469839..3169c05a68 100644 --- a/login/getutxline.c +++ b/login/getutxline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/grantpt.c b/login/grantpt.c index cba481bb6a..af42acacfb 100644 --- a/login/grantpt.c +++ b/login/grantpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. diff --git a/login/login.c b/login/login.c index 4c6b6bba6f..5d48cd487f 100644 --- a/login/login.c +++ b/login/login.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/login/logout.c b/login/logout.c index ea9c4e0585..d49bc4ecac 100644 --- a/login/logout.c +++ b/login/logout.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/login/logwtmp.c b/login/logwtmp.c index 41ec8c7ff7..a19da4ab5e 100644 --- a/login/logwtmp.c +++ b/login/logwtmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/login/openpty.c b/login/openpty.c index c8e4d102c9..941ba039e3 100644 --- a/login/openpty.c +++ b/login/openpty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. @@ -92,28 +92,35 @@ openpty (int *amaster, int *aslave, char *name, char _buf[512]; #endif char *buf = _buf; - int master, slave; + int master, ret = -1, slave = -1; + + *buf = '\0'; master = getpt (); if (master == -1) return -1; if (grantpt (master)) - goto fail; + goto on_error; if (unlockpt (master)) - goto fail; - - if (pts_name (master, &buf, sizeof (_buf))) - goto fail; + goto on_error; - slave = open (buf, O_RDWR | O_NOCTTY); +#ifdef TIOCGPTPEER + /* Try to allocate slave fd solely based on master fd first. */ + slave = ioctl (master, TIOCGPTPEER, O_RDWR | O_NOCTTY); +#endif if (slave == -1) { - if (buf != _buf) - free (buf); - - goto fail; + /* Fallback to path-based slave fd allocation in case kernel doesn't + * support TIOCGPTPEER. + */ + if (pts_name (master, &buf, sizeof (_buf))) + goto on_error; + + slave = open (buf, O_RDWR | O_NOCTTY); + if (slave == -1) + goto on_error; } /* XXX Should we ignore errors here? */ @@ -127,14 +134,27 @@ openpty (int *amaster, int *aslave, char *name, *amaster = master; *aslave = slave; if (name != NULL) - strcpy (name, buf); + { + if (*buf == '\0') + if (pts_name (master, &buf, sizeof (_buf))) + goto on_error; + + strcpy (name, buf); + } + + ret = 0; + + on_error: + if (ret == -1) { + close (master); + + if (slave != -1) + close (slave); + } if (buf != _buf) free (buf); - return 0; - fail: - close (master); - return -1; + return ret; } libutil_hidden_def (openpty) diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c index 6d11d778fb..10fee0627b 100644 --- a/login/programs/pt_chown.c +++ b/login/programs/pt_chown.c @@ -1,5 +1,5 @@ /* pt_chmod - helper program for `grantpt'. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by C. Scott Ananian <cananian@alumni.princeton.edu>, 1998. @@ -64,7 +64,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2016"); +"), "2018"); } static char * diff --git a/login/programs/utmpdump.c b/login/programs/utmpdump.c index c0b4eefaf7..dccdb669f5 100644 --- a/login/programs/utmpdump.c +++ b/login/programs/utmpdump.c @@ -1,5 +1,5 @@ /* utmpdump - dump utmp-like files. - Copyright (C) 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. diff --git a/login/ptsname.c b/login/ptsname.c index dacc8a7c12..41c85419ba 100644 --- a/login/ptsname.c +++ b/login/ptsname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. diff --git a/login/ptsname_r_chk.c b/login/ptsname_r_chk.c index 5acb935473..554cf1b35d 100644 --- a/login/ptsname_r_chk.c +++ b/login/ptsname_r_chk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2016 Free Software Foundation, Inc. +/* Copyright (C) 2005-2018 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 diff --git a/login/pty.h b/login/pty.h index e466144218..3f7129ce70 100644 --- a/login/pty.h +++ b/login/pty.h @@ -1,5 +1,5 @@ /* Functions for pseudo TTY handling. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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 diff --git a/login/pututxline.c b/login/pututxline.c index 079317d457..a58fba887c 100644 --- a/login/pututxline.c +++ b/login/pututxline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/setlogin.c b/login/setlogin.c index 0924bb2b8e..e6e53f1369 100644 --- a/login/setlogin.c +++ b/login/setlogin.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/login/setutxent.c b/login/setutxent.c index 0b4db38130..f9a86a59e6 100644 --- a/login/setutxent.c +++ b/login/setutxent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/tst-getlogin.c b/login/tst-getlogin.c index 09d5b11380..880c837f74 100644 --- a/login/tst-getlogin.c +++ b/login/tst-getlogin.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2016 Free Software Foundation, Inc. +/* Copyright (C) 1999-2018 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 diff --git a/login/tst-ptsname.c b/login/tst-ptsname.c index 4187285032..dc34adda1e 100644 --- a/login/tst-ptsname.c +++ b/login/tst-ptsname.c @@ -1,5 +1,5 @@ /* Test for ptsname/ptsname_r. - Copyright (C) 2014-2016 Free Software Foundation, Inc. + Copyright (C) 2014-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Aurelien Jarno <aurelien@aurel32.net>, 2014. @@ -70,7 +70,6 @@ do_test (void) if (fd != -1) { result |= do_single_test (fd, buf, sizeof (buf), 0); - result |= do_single_test (fd, NULL, sizeof (buf), EINVAL); result |= do_single_test (fd, buf, 1, ERANGE); close (fd); } diff --git a/login/tst-utmp.c b/login/tst-utmp.c index 2fb20b64db..8cc7aafa89 100644 --- a/login/tst-utmp.c +++ b/login/tst-utmp.c @@ -1,5 +1,5 @@ /* Tests for UTMP functions. - Copyright (C) 1998-2016 Free Software Foundation, Inc. + Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. @@ -62,7 +62,7 @@ do_prepare (int argc, char *argv[]) size_t name_len; name_len = strlen (test_dir); - name = malloc (name_len + sizeof ("/utmpXXXXXX")); + name = xmalloc (name_len + sizeof ("/utmpXXXXXX")); mempcpy (mempcpy (name, test_dir, name_len), "/utmpXXXXXX", sizeof ("/utmpXXXXXX")); diff --git a/login/unlockpt.c b/login/unlockpt.c index 695cef913a..322f324f04 100644 --- a/login/unlockpt.c +++ b/login/unlockpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998. diff --git a/login/updwtmp.c b/login/updwtmp.c index dd0cb9c2c7..56fb41916a 100644 --- a/login/updwtmp.c +++ b/login/updwtmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. @@ -31,4 +31,5 @@ __updwtmp (const char *wtmp_file, const struct utmp *utmp) (*__libc_utmp_file_functions.updwtmp) (file_name, utmp); } +libc_hidden_def (__updwtmp) weak_alias (__updwtmp, updwtmp) diff --git a/login/updwtmpx.c b/login/updwtmpx.c index 4f8e290c22..04c7bab49c 100644 --- a/login/updwtmpx.c +++ b/login/updwtmpx.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. diff --git a/login/utmp-private.h b/login/utmp-private.h index 88b5eebd4b..bd8773984c 100644 --- a/login/utmp-private.h +++ b/login/utmp-private.h @@ -1,5 +1,5 @@ /* Internal definitions and declarations for UTMP functions. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com> and Paul Janzen <pcj@primenet.com>, 1996. diff --git a/login/utmp.h b/login/utmp.h index 83e892d038..c6a55e375c 100644 --- a/login/utmp.h +++ b/login/utmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2016 Free Software Foundation, Inc. +/* Copyright (C) 1993-2018 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 diff --git a/login/utmp_file.c b/login/utmp_file.c index f1e23a3f0d..040a505711 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com> and Paul Janzen <pcj@primenet.com>, 1996. @@ -28,6 +28,8 @@ #include <utmp.h> #include <not-cancel.h> #include <kernel-features.h> +#include <sigsetops.h> +#include <not-cancel.h> #include "utmp-private.h" #include "utmp-equal.h" @@ -80,7 +82,7 @@ static void timeout_handler (int signum) {}; memset (&fl, '\0', sizeof (struct flock)); \ fl.l_type = (type); \ fl.l_whence = SEEK_SET; \ - if (fcntl_not_cancel ((fd), F_SETLKW, &fl) < 0) + if (__fcntl64_nocancel ((fd), F_SETLKW, &fl) < 0) #define LOCKING_FAILED() \ goto unalarm_return @@ -88,7 +90,7 @@ static void timeout_handler (int signum) {}; #define UNLOCK_FILE(fd) \ /* Unlock the file. */ \ fl.l_type = F_UNLCK; \ - fcntl_not_cancel ((fd), F_SETLKW, &fl); \ + __fcntl64_nocancel ((fd), F_SETLKW, &fl); \ \ unalarm_return: \ /* Reset the signal handler and alarm. We must reset the alarm \ @@ -141,42 +143,11 @@ setutent_file (void) file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name); -#ifdef O_CLOEXEC -# define O_flags O_LARGEFILE | O_CLOEXEC -#else -# define O_flags O_LARGEFILE -#endif file_writable = false; - file_fd = open_not_cancel_2 (file_name, O_RDONLY | O_flags); + file_fd = __open_nocancel + (file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC); if (file_fd == -1) return 0; - -#ifndef __ASSUME_O_CLOEXEC -# ifdef O_CLOEXEC - if (__have_o_cloexec <= 0) -# endif - { - /* We have to make sure the file is `closed on exec'. */ - int 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; - - if (__have_o_cloexec < 0) -# 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); @@ -217,7 +188,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result) } /* Read the next entry. */ - nbytes = read_not_cancel (file_fd, &last_entry, sizeof (struct utmp)); + nbytes = __read_nocancel (file_fd, &last_entry, sizeof (struct utmp)); UNLOCK_FILE (file_fd); @@ -261,7 +232,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, buffer, sizeof (struct utmp)) + if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); @@ -283,7 +254,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, buffer, sizeof (struct utmp)) + if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); @@ -359,7 +330,7 @@ getutline_r_file (const struct utmp *line, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, &last_entry, sizeof (struct utmp)) + if (__read_nocancel (file_fd, &last_entry, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); @@ -404,44 +375,18 @@ pututline_file (const struct utmp *data) /* We must make the file descriptor writable before going on. */ const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name); - int new_fd = open_not_cancel_2 (file_name, O_RDWR | O_flags); + int new_fd = __open_nocancel + (file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC); if (new_fd == -1) return NULL; -#ifndef __ASSUME_O_CLOEXEC -# ifdef O_CLOEXEC - if (__have_o_cloexec <= 0) -# endif - { - /* We have to make sure the file is `closed on exec'. */ - int 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; - - if (__have_o_cloexec < 0) -# endif - result = fcntl_not_cancel (file_fd, F_SETFD, - result | FD_CLOEXEC); - } - - if (result == -1) - { - close_not_cancel_no_status (file_fd); - return NULL; - } - } -#endif - if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1 || __dup2 (new_fd, file_fd) < 0) { - close_not_cancel_no_status (new_fd); + __close_nocancel_nostatus (new_fd); return NULL; } - close_not_cancel_no_status (new_fd); + __close_nocancel_nostatus (new_fd); file_writable = true; } @@ -500,7 +445,7 @@ pututline_file (const struct utmp *data) } /* Write the new data. */ - if (write_not_cancel (file_fd, data, sizeof (struct utmp)) + if (__write_nocancel (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp)) { /* If we appended a new record this is only partially written. @@ -527,7 +472,7 @@ endutent_file (void) { assert (file_fd >= 0); - close_not_cancel_no_status (file_fd); + __close_nocancel_nostatus (file_fd); file_fd = -1; } @@ -540,7 +485,7 @@ updwtmp_file (const char *file, const struct utmp *utmp) int fd; /* Open WTMP file. */ - fd = open_not_cancel_2 (file, O_WRONLY | O_LARGEFILE); + fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE); if (fd < 0) return -1; @@ -561,7 +506,7 @@ updwtmp_file (const char *file, const struct utmp *utmp) /* Write the entry. If we can't write all the bytes, reset the file size back to the original size. That way, no partial entries will remain. */ - if (write_not_cancel (fd, utmp, sizeof (struct utmp)) + if (__write_nocancel (fd, utmp, sizeof (struct utmp)) != sizeof (struct utmp)) { __ftruncate64 (fd, offset); @@ -574,7 +519,7 @@ unlock_return: UNLOCK_FILE (fd); /* Close WTMP file. */ - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); return result; } diff --git a/login/utmpname.c b/login/utmpname.c index 96e65902a4..21cb890a1a 100644 --- a/login/utmpname.c +++ b/login/utmpname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. diff --git a/login/utmpxname.c b/login/utmpxname.c index 0d44260849..a79f3306ea 100644 --- a/login/utmpxname.c +++ b/login/utmpxname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998. |