@@ -49,7 +49,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
char *buf = NULL;
if (strchr (cat_name, '/') != NULL || nlspath == NULL)
- fd = __open_nocancel (cat_name, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (cat_name, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +177,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open_nocancel (buf, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (buf, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
if (fd >= 0)
break;
}
@@ -90,7 +90,7 @@ __libc_check_standard_fds (void)
is really paranoid but some people actually are. If /dev/null
should happen to be a symlink to somewhere else and not the
device commonly known as "/dev/null" we bail out. */
- check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW);
- check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW);
- check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW);
+ check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW | O_IGNORE_CTTY);
+ check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW | O_IGNORE_CTTY);
+ check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW | O_IGNORE_CTTY);
}
@@ -1616,7 +1616,7 @@ open_verify (const char *name, int fd,
if (fd == -1)
/* Open the file. We always open files read-only. */
- fd = __open64_nocancel (name, O_RDONLY | O_CLOEXEC);
+ fd = __open64_nocancel (name, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
if (fd != -1)
{
@@ -36,7 +36,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
{
void *result = MAP_FAILED;
struct __stat64_t64 st;
- int fd = __open64_nocancel (file, O_RDONLY | O_CLOEXEC);
+ int fd = __open64_nocancel (file, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
if (fd >= 0)
{
if (__fstat64_time64 (fd, &st) >= 0)
@@ -325,7 +325,7 @@ _dl_start_profile (void)
__stpcpy (__stpcpy (cp, GLRO(dl_profile)), ".profile");
fd = __open64_nocancel (filename, O_RDWR | O_CREAT | O_NOFOLLOW
- | O_CLOEXEC, DEFFILEMODE);
+ | O_CLOEXEC | O_IGNORE_CTTY, DEFFILEMODE);
if (fd == -1)
{
char buf[400];
@@ -385,13 +385,13 @@ write_gmon (void)
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
fd = __open_nocancel (buf, O_CREAT | O_TRUNC | O_WRONLY | O_NOFOLLOW
- | O_CLOEXEC, 0666);
+ | O_CLOEXEC | O_IGNORE_CTTY, 0666);
}
if (fd == -1)
{
fd = __open_nocancel ("gmon.out", O_CREAT | O_TRUNC | O_WRONLY
- | O_NOFOLLOW | O_CLOEXEC, 0666);
+ | O_NOFOLLOW | O_CLOEXEC | O_IGNORE_CTTY, 0666);
if (fd < 0)
{
char buf[300];
@@ -58,7 +58,8 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY | O_CLOEXEC, 0);
+ fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY
+ | O_CLOEXEC | O_IGNORE_CTTY, 0);
if (__builtin_expect (fd, 0) == -1)
/* Not available. */
return -1;
@@ -202,7 +202,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open_nocancel (archfname, O_RDONLY | O_LARGEFILE
+ | O_CLOEXEC | O_IGNORE_CTTY);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -397,8 +398,8 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct __stat64_t64 st;
- fd = __open_nocancel (archfname,
- O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open_nocancel (archfname, O_RDONLY | O_LARGEFILE
+ | O_CLOEXEC | O_IGNORE_CTTY);
if (fd == -1)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -240,7 +240,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
if (__builtin_expect (fd, 0) < 0)
/* Cannot open the file. */
return;
@@ -267,7 +267,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
"/SYS_", 5), _nl_category_names_get (category),
_nl_category_name_sizes[category] + 1);
- fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC | O_IGNORE_CTTY);
if (__builtin_expect (fd, 0) < 0)
return;
@@ -117,7 +117,7 @@ __openpty (int *pptmx, int *pterminal, char *name,
if (pts_name (ptmx, &buf, sizeof (_buf)))
goto on_error;
- terminal = __open64 (buf, O_RDWR | O_NOCTTY);
+ terminal = __open64 (buf, O_RDWR | O_NOCTTY | O_IGNORE_CTTY);
if (terminal == -1)
goto on_error;
}
@@ -142,7 +142,7 @@ __libc_setutent (void)
file_writable = false;
file_fd = __open_nocancel
- (file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ (file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC | O_IGNORE_CTTY);
if (file_fd == -1)
return 0;
}
@@ -354,7 +354,7 @@ __libc_pututline (const struct utmp *data)
const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
int new_fd = __open_nocancel
- (file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
+ (file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC | O_IGNORE_CTTY);
if (new_fd == -1)
return NULL;
@@ -463,7 +463,8 @@ __libc_updwtmp (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE | O_CLOEXEC);
+ fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE
+ | O_CLOEXEC | O_IGNORE_CTTY);
if (fd < 0)
return -1;
@@ -67,7 +67,7 @@ daemon (int nochdir, int noclose)
{
struct __stat64_t64 st;
- fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0);
+ fd = __open_nocancel(_PATH_DEVNULL, O_RDWR | O_IGNORE_CTTY, 0);
if (fd != -1 && __glibc_likely (__fstat64_time64 (fd, &st) == 0))
{
if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0
@@ -36,7 +36,8 @@ internal_setent (const char *file, struct nss_db_map *mapping)
{
enum nss_status status = NSS_STATUS_UNAVAIL;
- int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE
+ | O_CLOEXEC | O_IGNORE_CTTY);
if (fd != -1)
{
struct nss_db_header header;
@@ -37,7 +37,7 @@ __shm_open (const char *name, int oflag, mode_t mode)
return -1;
}
- oflag |= O_NOFOLLOW | O_CLOEXEC;
+ oflag |= O_NOFOLLOW | O_CLOEXEC | O_IGNORE_CTTY;
#if defined (SHM_ANON) && defined (O_TMPFILE)
if (name == SHM_ANON)
oflag |= O_TMPFILE;
@@ -96,7 +96,7 @@ __lckpwdf (void)
/* Prevent problems caused by multiple threads. */
__libc_lock_lock (lock);
- int oflags = O_WRONLY | O_CREAT | O_CLOEXEC;
+ int oflags = O_WRONLY | O_CREAT | O_CLOEXEC | O_IGNORE_CTTY;
lock_fd = __open (PWD_LOCKFILE, oflags, 0600);
if (lock_fd == -1)
/* Cannot create lock file. */
@@ -79,7 +79,7 @@ __opendirat (int dfd, const char *name)
return NULL;
}
- int flags = O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC;
+ int flags = O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_IGNORE_CTTY;
int fd;
#if IS_IN (rtld)
assert (dfd == AT_FDCWD);
@@ -65,7 +65,7 @@ __sem_open (const char *name, int oflag, ...)
/* If the semaphore object has to exist simply open it. */
if ((oflag & O_CREAT) == 0 || (oflag & O_EXCL) == 0)
{
- open_flags = O_RDWR | O_NOFOLLOW | O_CLOEXEC;
+ open_flags = O_RDWR | O_NOFOLLOW | O_CLOEXEC | O_IGNORE_CTTY;
open_flags |= (oflag & ~(O_CREAT|O_ACCMODE));
try_again:
fd = __open (dirname.name, open_flags);
@@ -135,7 +135,7 @@ __sem_open (const char *name, int oflag, ...)
}
/* Open the file. Make sure we do not overwrite anything. */
- open_flags = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC;
+ open_flags = O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC | O_IGNORE_CTTY;
fd = __open (tmpfname, open_flags, mode);
if (fd == -1)
{
@@ -76,7 +76,7 @@ __bsd_openpt (int oflag)
int
__getpt (void)
{
- return __bsd_openpt (O_RDWR);
+ return __bsd_openpt (O_RDWR | O_IGNORE_CTTY);
}
libc_hidden_def (__getpt)
weak_alias (__getpt, getpt)
@@ -84,6 +84,6 @@ weak_alias (__getpt, getpt)
int
__posix_openpt (int oflag)
{
- return __bsd_openpt (oflag);
+ return __bsd_openpt (oflag | O_IGNORE_CTTY);
}
weak_alias (__posix_openpt, posix_openpt)
* getpt, openpty: Opening an unused pty, which can't be our ctty * shm_open, sem_open: These don't work with ttys * opendir: Directories are unlikely to be ttys Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> --- catgets/open_catalog.c | 4 ++-- csu/check_fds.c | 6 +++--- elf/dl-load.c | 2 +- elf/dl-misc.c | 2 +- elf/dl-profile.c | 2 +- gmon/gmon.c | 4 ++-- iconv/gconv_cache.c | 3 ++- locale/loadarchive.c | 7 ++++--- locale/loadlocale.c | 4 ++-- login/openpty.c | 2 +- login/utmp_file.c | 7 ++++--- misc/daemon.c | 2 +- nss/nss_db/db-open.c | 3 ++- rt/shm_open.c | 2 +- shadow/lckpwdf.c | 2 +- sysdeps/mach/hurd/opendir.c | 2 +- sysdeps/pthread/sem_open.c | 4 ++-- sysdeps/unix/bsd/getpt.c | 4 ++-- 18 files changed, 33 insertions(+), 29 deletions(-)