From d3790feac0b47bb817c572ac57e6bd4fc7f84b4a Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Sat, 24 Mar 2018 20:29:48 -0500 Subject: [PATCH] pwck.c: do not pass O_CREAT It causes a crash later when we try to close files. Closes #96 Signed-off-by: Serge Hallyn --- src/pwck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pwck.c b/src/pwck.c index 523135f6..05df68ec 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -281,7 +281,7 @@ static void open_files (void) * Open the files. Use O_RDONLY if we are in read_only mode, O_RDWR * otherwise. */ - if (pw_open (read_only ? O_RDONLY : O_CREAT | O_RDWR) == 0) { + if (pw_open (read_only ? O_RDONLY : O_RDWR) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ()); if (use_system_pw_file) { @@ -290,7 +290,7 @@ static void open_files (void) fail_exit (E_CANTOPEN); } if (is_shadow && !use_tcb) { - if (spw_open (read_only ? O_RDONLY : O_CREAT | O_RDWR) == 0) { + if (spw_open (read_only ? O_RDONLY : O_RDWR) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { @@ -566,7 +566,7 @@ static void check_pw_file (int *errors, bool *changed) continue; } spw_locked = true; - if (spw_open (read_only ? O_RDONLY : O_CREAT | O_RDWR) == 0) { + if (spw_open (read_only ? O_RDONLY : O_RDWR) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());