From: Sami Kerola Date: Sat, 16 Apr 2016 14:43:17 +0000 (+0100) Subject: sulogin: make fopen O_CLOEXEC specifier usage portable X-Git-Tag: v2.29-rc1~285^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=400423824a6810aa0ec09b0d1cae34e420cfa781;p=thirdparty%2Futil-linux.git sulogin: make fopen O_CLOEXEC specifier usage portable The close at exit specifier "e" is glibc extension, so use it only if when the extension is available. Proposed-by: Ruediger Meier Signed-off-by: Sami Kerola --- diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c index fe8eab15d7..4dcc77c43b 100644 --- a/login-utils/sulogin-consoles.c +++ b/login-utils/sulogin-consoles.c @@ -160,7 +160,7 @@ char *oneline(const char *file) DBG(dbgprint("reading %s", file)); - if (!(fp = fopen(file, "re"))) + if (!(fp = fopen(file, "r" UL_CLOEXECSTR))) return NULL; len = getline(&ret, &dummy, fp); if (len >= 0) { @@ -361,7 +361,7 @@ static int detect_consoles_from_proc(struct list_head *consoles) DBG(dbgprint("trying /proc")); - fc = fopen("/proc/consoles", "re"); + fc = fopen("/proc/consoles", "r" UL_CLOEXECSTR); if (!fc) { rc = 2; goto done;