]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: make fopen O_CLOEXEC specifier usage portable
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Apr 2016 14:43:17 +0000 (15:43 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 16 Apr 2016 22:09:26 +0000 (23:09 +0100)
The close at exit specifier "e" is glibc extension, so use it only if when
the extension is available.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/sulogin-consoles.c

index fe8eab15d76e78a7528bf4cd6fbf1ef5cfbf4572..4dcc77c43b7306287e0a35311a2d311b0cf79eae 100644 (file)
@@ -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;