From patchwork Sun Jun 4 20:42:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 70573 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBF503857707 for ; Sun, 4 Jun 2023 20:43:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBF503857707 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685911405; bh=OOjTlmMDra6Vug4BsR/fyicDyoHtBJqtWn+qXyzW5Fg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=fGWevPCfFMKBGq5moQHpbJVgGbox+DpxL7uqk5WrzYt65SPIf4Yum4DTiKsFLr9Rv pZ9sZZvtvpYHNyvNSMNo+YDcd9zSTSdyK41rv1odJsxxuJcKy6tY9N1gb06eTtBV7A kYYKS/KEm66BNs6f75ID/4d3HjRwgxiNbvpnv5js= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 573723858D39 for ; Sun, 4 Jun 2023 20:43:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 573723858D39 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b1b66a8fd5so24463631fa.0 for ; Sun, 04 Jun 2023 13:43:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685911381; x=1688503381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OOjTlmMDra6Vug4BsR/fyicDyoHtBJqtWn+qXyzW5Fg=; b=ENfRUphHFrEIgC4/mRhAn27UfgjwCuwNMe4soP+mfeuTrkWbrqAdaJ8jZBpeF4ds0d JGwFCce/i2jZ1QKhIdGfvSPQGI2oZnGh3aaqailLoBaaVO6CsQCapNoaQ9KhLXUm40IS hs/5wDOnFrsYQpoUQNKSeaH3oUeXVTekc5X2Mhl9BKDZlS3ykq2IEemCCxcQASpVIuKh NxGr5q1FHEGfYg5zjvLws/26Uj32Z5Uw/+cJrqkKJTwafHnpfVD14pihSiQ39Lf2jsHA cFzMGlTZKt8MF188rFtkYC/sjfDQoGNo57mIE33hWYnV8tKuVLv1lW1+xpvWmd35PDhs IjjQ== X-Gm-Message-State: AC+VfDxg0bC+nR4zu2WdoPe4TOkP9PbdNoCe6w6rtfFjHkWW+U6AULR7 047yt5Wjglv7hoFIhxCfeef+Q1RNWgI= X-Google-Smtp-Source: ACHHUZ7tID5WpuybTLNN9CA8D++6X5Rc47pN73Ydd+PYAGODIA6FwqU0lNCked0QmE79R/oSD9/Vfg== X-Received: by 2002:a2e:3318:0:b0:2b1:b68d:b10c with SMTP id d24-20020a2e3318000000b002b1b68db10cmr2878736ljc.32.1685911381367; Sun, 04 Jun 2023 13:43:01 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:be3:dad4:cf62:50cd]) by smtp.gmail.com with ESMTPSA id h1-20020a2e9001000000b002a929484fa0sm1114587ljg.68.2023.06.04.13.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jun 2023 13:43:01 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault Subject: [PATCH v3 1/2] include/fcntl.h: Define O_IGNORE_CTTY Date: Sun, 4 Jun 2023 23:42:57 +0300 Message-Id: <20230604204258.2026816-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230604204258.2026816-1-bugaevc@gmail.com> References: <20230604204258.2026816-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This internal definition makes it possible to use O_IGNORE_CTTY in the glibc codebase unconditionally, no matter whether the current port provides it or not (i.e. both on Hurd and on Linux). Along with the definition, this adds a small guide on when O_IGNORE_CTTY is to be used. The following commit will actually make use of O_IGNORE_CTTY throughout the glibc codebase. Signed-off-by: Sergey Bugaev --- include/fcntl.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/fcntl.h b/include/fcntl.h index be435047..d788db2e 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -33,6 +33,21 @@ extern int __openat_2 (int __fd, const char *__path, int __oflag); extern int __openat64_2 (int __fd, const char *__path, int __oflag); +/* Makes open () & friends faster on the Hurd, but can only be used (without + altering user-visible behavior) when we're sure that the file we're opening + is not (at the moment) our controlling terminal. Use this when: + - opening well-known files internally (utmp, nss db); + - opening files with user-specified names that can not reasonably be ttys + (sem_open, shm_open); + - opening new (previously unused) ttys (openpty). + Don't use this when: + - doing a general-purpose open () with a user-controlled path that could + well be "/dev/tty" (fopen). */ +#ifndef O_IGNORE_CTTY +# define O_IGNORE_CTTY 0 +#endif + + #if IS_IN (rtld) # include #endif From patchwork Sun Jun 4 20:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 70574 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C20E385842E for ; Sun, 4 Jun 2023 20:44:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C20E385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685911448; bh=YD4jkrl66rlJ1wwrVYQHPakl6q84c7ys91n62KwaIOQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=PznXgJWLPaxhmmfWgYSOWNDH+4YPY5i8Q7Ldy+WH8L9Dwr9olGTEZxPBEr9aQ1aKv guGH1EJEhnOuwcWGr58ZoFhUbnK7uT+1FXTRTBoUdwWHH44uFvEJ+5sOwwDoCaFl46 0kMg9qtDMt610Yr9vOFoNfgvyCD9zEM2ortL/VFQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 3D8CB3858C2B for ; Sun, 4 Jun 2023 20:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D8CB3858C2B Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b1b1635661so29205151fa.0 for ; Sun, 04 Jun 2023 13:43:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685911382; x=1688503382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YD4jkrl66rlJ1wwrVYQHPakl6q84c7ys91n62KwaIOQ=; b=l98WKbs3qUcnOHMDJ0EeVcDzXUl5CPMRpiNmjgas08sMhfQp4n5w74cL6M8+ba9H/Y o7LvLobkEkn7Oyac05prHVKXHE8NldGe98n6hQj3SCirakTZ0Y1y4q6kpeacakQFhUoa 01uR5Cx5PAvXbg7tDiyRXH7YvtEMDEJEjG2tZKNrepHQwri3RVaChWVK5nP1MKxV0KBG 4LhTB53M94F3MPN2IDBzj7OHNARZGIvgXMhySKfcsROX0xkKFWfztKdWVW3nhjOAxuGV /PA7DwMIslDnDNfTYPwrunTrjG1zF8IJ6TDDArIckgAfIN0wGJcfzy62ojn2vXgf00xO kUrA== X-Gm-Message-State: AC+VfDwkxWBA+ckiLlyIz79IcRSZegtbJ79i80TbVK+ch90TIQsdqCNy le8uUv5iAAQ44GbPBFBx2a75I/tojo8= X-Google-Smtp-Source: ACHHUZ79xOz/gxSHU2+vtjyCr5w9dZQSVGnArZRSItfNcfjWQapHG7a0P/dSI3gDrqZn2e5uVIm0sQ== X-Received: by 2002:a2e:934f:0:b0:2a9:9e99:a508 with SMTP id m15-20020a2e934f000000b002a99e99a508mr2823062ljh.53.1685911382304; Sun, 04 Jun 2023 13:43:02 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:be3:dad4:cf62:50cd]) by smtp.gmail.com with ESMTPSA id h1-20020a2e9001000000b002a929484fa0sm1114587ljg.68.2023.06.04.13.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jun 2023 13:43:01 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault Subject: [PATCH v3 2/2] Use O_IGNORE_CTTY where appropriate Date: Sun, 4 Jun 2023 23:42:58 +0300 Message-Id: <20230604204258.2026816-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230604204258.2026816-1-bugaevc@gmail.com> References: <20230604204258.2026816-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" * 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 --- catgets/open_catalog.c | 4 ++-- 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 ++-- 17 files changed, 30 insertions(+), 26 deletions(-) diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index 46c444d2..129f4662 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -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; } diff --git a/elf/dl-load.c b/elf/dl-load.c index 9a87fda9..f58fa95e 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1620,7 +1620,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) { diff --git a/elf/dl-misc.c b/elf/dl-misc.c index 5b84adc2..85931c7c 100644 --- a/elf/dl-misc.c +++ b/elf/dl-misc.c @@ -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) diff --git a/elf/dl-profile.c b/elf/dl-profile.c index 8be0065f..040734d1 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -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]; diff --git a/gmon/gmon.c b/gmon/gmon.c index 6439ed1c..ed13b3ce 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -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]; diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c index 87136e24..c8d972c8 100644 --- a/iconv/gconv_cache.c +++ b/iconv/gconv_cache.c @@ -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; diff --git a/locale/loadarchive.c b/locale/loadarchive.c index 5b857d5d..f88ff8b8 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -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; diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 671e71cf..582144ed 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -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; diff --git a/login/openpty.c b/login/openpty.c index 1e44852a..a89555b2 100644 --- a/login/openpty.c +++ b/login/openpty.c @@ -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; } diff --git a/login/utmp_file.c b/login/utmp_file.c index 7055041d..bdf88b51 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -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; diff --git a/misc/daemon.c b/misc/daemon.c index 14577e40..2f653ec7 100644 --- a/misc/daemon.c +++ b/misc/daemon.c @@ -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 diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c index a5279dc0..2a996a6e 100644 --- a/nss/nss_db/db-open.c +++ b/nss/nss_db/db-open.c @@ -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; diff --git a/rt/shm_open.c b/rt/shm_open.c index fc1dc96b..7fd62cf3 100644 --- a/rt/shm_open.c +++ b/rt/shm_open.c @@ -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; diff --git a/shadow/lckpwdf.c b/shadow/lckpwdf.c index 3b36b2eb..4a623c41 100644 --- a/shadow/lckpwdf.c +++ b/shadow/lckpwdf.c @@ -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. */ diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c index 39c805bc..07260d22 100644 --- a/sysdeps/mach/hurd/opendir.c +++ b/sysdeps/mach/hurd/opendir.c @@ -73,7 +73,7 @@ __opendirat (int dfd, const char *name) but `open' might like it fine. */ return __hurd_fail (ENOENT), 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); diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c index e5db929d..5a248ebb 100644 --- a/sysdeps/pthread/sem_open.c +++ b/sysdeps/pthread/sem_open.c @@ -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) { diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c index 8369f958..48f3d07a 100644 --- a/sysdeps/unix/bsd/getpt.c +++ b/sysdeps/unix/bsd/getpt.c @@ -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)