Skip to content

Conversation

@alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Jul 13, 2025

This allows compacting a lot of code. It also makes it easier to discern lines that print to actual files, from those that print to stderr/stdout.

Queued after:


Revisions:

v2
$ git range-diff f6e676334455^..gh/eprintf shadow/master..eprintf 
1:  f6e67633 ! 1:  302aae32 lib/io/fprintf/: eprintf(): Add function to print to stderr
    @@ lib/io/fprintf/eprintf.c (new)
     +// SPDX-License-Identifier: BSD-3-Clause
     +
     +
    -+#include <config.h>
    ++#include "config.h"
     +
     +#include "io/fprintf/eprintf.h"
     +
    @@ lib/io/fprintf/eprintf.h (new)
     +#define SHADOW_INCLUDE_LIB_IO_FPRINTF_EPRINTF_H_
     +
     +
    -+#include <config.h>
    ++#include "config.h"
     +
     +#include <stdarg.h>
     +#include <stdio.h>
2:  1c1568e1 = 2:  a3ed1da0 lib/, src/: Use eprintf() instead of its pattern
3:  be83d1b4 < -:  -------- src/vipw.c: usage(): Print everything to the same stream
4:  c3af808a < -:  -------- lib/, src/: Use printf(3) instead of its pattern
v2b
  • Rebase
$ git rd 
1:  302aae32 = 1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
2:  a3ed1da0 ! 2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
    @@ src/login.c: int main (int argc, char **argv)
                exit (0);
        } else if (child != 0) {
     @@ src/login.c: int main (int argc, char **argv)
    -   if (getppid() == 1) {
    +   if (1 == initial_pid) {
                setsid();
                if (ioctl(0, TIOCSCTTY, 1) != 0) {
     -                  fprintf (stderr, _("TIOCSCTTY failed on %s"), tty);
v3
  • Add and use strerrno(). This compacts some lines further.
$ git rd
1:  da4c7959 = 1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
2:  13a80305 = 2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
-:  -------- > 3:  e1cddf24 lib/string/: strerrno(): Add function
-:  -------- > 4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
v4
  • Fix definition of SYSLOG() to remove the weird double parentheses.
  • Fix non-matching parentheses in SYSLOG() call.
$ git rd 
1:  da4c7959 = 1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
2:  13a80305 = 2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
3:  e1cddf24 = 3:  e1cddf24 lib/string/: strerrno(): Add function
4:  767c2377 = 4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
-:  -------- > 5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
-:  -------- > 6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
v5
  • Add moar wrappers, fix moar bugs, make code moar readable.
$ git rd 
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 -:  -------- >  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 -:  -------- >  8:  eb3b2517 lib/io/: syslog_c(): Implement SYSLOG() with a helper function
 -:  -------- >  9:  82cf1bd0 lib/io/syslog.h: Call setlocale(3) and free(3) unconditionally
 -:  -------- > 10:  67826ff5 lib/io/fprintf/: [v]fprinte(): Add function
 -:  -------- > 11:  53eaccf5 lib/io/fprintf/: [v]eprinte(): Add function
 -:  -------- > 12:  a7e0a585 lib/, src/: Use eprinte() instead of its pattern
 -:  -------- > 13:  ec4bcad1 lib/: Use [v]fprinte() instead of its pattern
 -:  -------- > 14:  15c8269f lib/io/syslog.h: SYSLOGE(): Add macro
 -:  -------- > 15:  73f63bd4 src/userdel.c: Fix error message
 -:  -------- > 16:  2c45897a lib/, src/: Use SYSLOGE() instead of its pattern
v5b
  • tfix
$ git rd 
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  eb3b2517 =  8:  eb3b2517 lib/io/: syslog_c(): Implement SYSLOG() with a helper function
 9:  82cf1bd0 =  9:  82cf1bd0 lib/io/syslog.h: Call setlocale(3) and free(3) unconditionally
10:  67826ff5 ! 10:  9ad98eef lib/io/fprintf/: [v]fprinte(): Add function
    @@ lib/io/fprintf/fprinte.h (new)
     +#include "attr.h"
     +
     +
    -+format_attr(printf, 2, 2)
    ++format_attr(printf, 2, 3)
     +inline int fprinte(FILE *restrict stream, const char *restrict fmt, ...);
     +format_attr(printf, 2, 0)
     +inline int vfprinte(FILE *restrict stream, const char *restrict fmt, va_list ap);
11:  53eaccf5 = 11:  ff79b1d7 lib/io/fprintf/: [v]eprinte(): Add function
12:  a7e0a585 = 12:  79ce27b7 lib/, src/: Use eprinte() instead of its pattern
13:  ec4bcad1 = 13:  adf040bd lib/: Use [v]fprinte() instead of its pattern
14:  15c8269f = 14:  3c56b00e lib/io/syslog.h: SYSLOGE(): Add macro
15:  73f63bd4 = 15:  215bfe62 src/userdel.c: Fix error message
16:  2c45897a = 16:  2e8be431 lib/, src/: Use SYSLOGE() instead of its pattern
v6
  • SYSLOG_C() must be a macro. It does some interesting magic!
$ git rd 
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  eb3b2517 !  8:  d9cb90ca lib/io/: syslog_c(): Implement SYSLOG() with a helper function
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    lib/io/: syslog_c(): Implement SYSLOG() with a helper function
    +    lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
    +
    +    The name of this macro makes it more evident what it does.  It's a
    +    C-locale version of syslog(3).  We need to implement it as a macro
    +    so that arguments such as strerror(3) are evaluated after setting
    +    the C locale.  This would be impossible with a function.
     
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
    - ## lib/io/syslog.c ##
    -@@
    - #include "config.h"
    - 
    - #include "io/syslog.h"
    -+
    -+#include <stdarg.h>
    -+
    -+
    -+extern inline void syslog_c(int priority, const char *restrict fmt, ...);
    -+extern inline void vsyslog_c(int priority, const char *restrict fmt, va_list ap);
    -
      ## lib/io/syslog.h ##
    -@@
    - #include "config.h"
    - 
    - #include <locale.h>
    -+#include <stdarg.h>
    - #include <stddef.h>
    - #include <stdlib.h>
    - #include <string.h>
     @@
      #define LOG_AUTHPRIV LOG_AUTH
      #endif
    @@ lib/io/syslog.h
     -          }                                                       \
     -  } while (false)
     -#else                             /* !ENABLE_NLS */
    -+#define SYSLOG(...)  syslog_c(__VA_ARGS__)
    ++#define SYSLOG(...)  SYSLOG_C(__VA_ARGS__)
     +#else
      #define SYSLOG(...)  syslog(__VA_ARGS__)
     -#endif                            /* !ENABLE_NLS */
    @@ lib/io/syslog.h
      #define OPENLOG(progname) openlog(progname, SYSLOG_OPTIONS, SYSLOG_FACILITY)
      
      
    -+inline void syslog_c(int priority, const char *restrict fmt, ...);
    -+inline void vsyslog_c(int priority, const char *restrict fmt, va_list ap);
    -+
    -+
     +// system log C-locale
    -+inline void
    -+syslog_c(int priority, const char *restrict fmt, ...)
    -+{
    -+  va_list  ap;
    -+
    -+  va_start(ap, fmt);
    -+  vsyslog_c(priority, fmt, ap);
    -+  va_end(ap);
    -+}
    -+
    -+
    -+// va_list system log C-locale
    -+inline void
    -+vsyslog_c(int priority, const char *restrict fmt, va_list ap)
    -+{
    -+  char *old_locale;
    -+  char *saved_locale;
    -+
    -+  old_locale = setlocale(LC_ALL, NULL);
    -+  saved_locale = NULL;
    -+
    -+  if (NULL != old_locale)
    -+          saved_locale = strdup(old_locale);
    -+
    -+  if (NULL != saved_locale)
    -+          setlocale(LC_ALL, "C");
    -+
    -+  vsyslog(priority, fmt, ap);
    -+
    -+  if (NULL != saved_locale) {
    -+          setlocale(LC_ALL, saved_locale);
    -+          free(saved_locale);
    -+  }
    -+}
    ++#define SYSLOG_C(...)  do                                             \
    ++{                                                                     \
    ++  char  *old_locale;                                            \
    ++  char  *saved_locale;                                          \
    ++                                                                      \
    ++  old_locale = setlocale(LC_ALL, NULL);                         \
    ++  saved_locale = NULL;                                          \
    ++                                                                      \
    ++  if (NULL != old_locale)                                       \
    ++          saved_locale = strdup(old_locale);                    \
    ++                                                                      \
    ++  if (NULL != saved_locale) {                                   \
    ++          setlocale(LC_ALL, "C");                               \
    ++                                                                      \
    ++  syslog(__VA_ARGS__);                                          \
    ++  if (NULL != saved_locale) {                                   \
    ++          setlocale(LC_ALL, saved_locale);                      \
    ++          free(saved_locale);                                   \
    ++  }                                                             \
    ++} while (0)
     +
     +
      #endif  // include guard
 9:  82cf1bd0 <  -:  -------- lib/io/syslog.h: Call setlocale(3) and free(3) unconditionally
 -:  -------- >  9:  1f0531b1 lib/io/syslog.h: Rename local variable
 -:  -------- > 10:  41bd7c81 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 -:  -------- > 11:  163ebeea lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
10:  9ad98eef = 12:  95463ee9 lib/io/fprintf/: [v]fprinte(): Add function
11:  ff79b1d7 = 13:  1c37648a lib/io/fprintf/: [v]eprinte(): Add function
12:  79ce27b7 = 14:  d45e1fee lib/, src/: Use eprinte() instead of its pattern
13:  adf040bd = 15:  cfecd5ca lib/: Use [v]fprinte() instead of its pattern
14:  3c56b00e ! 16:  3caa45d7 lib/io/syslog.h: SYSLOGE(): Add macro
    @@ lib/io/syslog.h
     +)
     +
     +
    - inline void syslog_c(int priority, const char *restrict fmt, ...);
    - inline void vsyslog_c(int priority, const char *restrict fmt, va_list ap);
    - 
    + // system log C-locale
    + #define SYSLOG_C(...)  do                                             \
    + {                                                                     \
15:  215bfe62 = 17:  eaed086d src/userdel.c: Fix error message
16:  2e8be431 = 18:  5b44ec25 lib/, src/: Use SYSLOGE() instead of its pattern
v6b
  • fix braces
$ git rd 
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  d9cb90ca !  8:  73336b3f lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
    @@ lib/io/syslog.h
     +  if (NULL != old_locale)                                       \
     +          saved_locale = strdup(old_locale);                    \
     +                                                                      \
    -+  if (NULL != saved_locale) {                                   \
    ++  if (NULL != saved_locale)                                     \
     +          setlocale(LC_ALL, "C");                               \
     +                                                                      \
     +  syslog(__VA_ARGS__);                                          \
 9:  1f0531b1 !  9:  063966cc lib/io/syslog.h: Rename local variable
    @@ lib/io/syslog.h
     +  if (NULL != l_)                                               \
     +          saved_locale = strdup(l_);                            \
                                                                            \
    -   if (NULL != saved_locale) {                                   \
    +   if (NULL != saved_locale)                                     \
                setlocale(LC_ALL, "C");                               \
10:  41bd7c81 ! 10:  ab24ab95 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
    @@ lib/io/syslog.h
     -          saved_locale = strdup(l_);                            \
     +          l_ = strdup(l_);                                      \
                                                                            \
    --  if (NULL != saved_locale) {                                   \
    -+  if (NULL != l_) {                                             \
    +-  if (NULL != saved_locale)                                     \
    ++  if (NULL != l_)                                               \
                setlocale(LC_ALL, "C");                               \
                                                                            \
        syslog(__VA_ARGS__);                                          \
11:  163ebeea = 11:  07f77ecf lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  95463ee9 = 12:  4d3b887d lib/io/fprintf/: [v]fprinte(): Add function
13:  1c37648a = 13:  e2e2c4fd lib/io/fprintf/: [v]eprinte(): Add function
14:  d45e1fee = 14:  058f311a lib/, src/: Use eprinte() instead of its pattern
15:  cfecd5ca = 15:  3b1c3231 lib/: Use [v]fprinte() instead of its pattern
16:  3caa45d7 = 16:  955ab8bf lib/io/syslog.h: SYSLOGE(): Add macro
17:  eaed086d = 17:  7be1c698 src/userdel.c: Fix error message
18:  5b44ec25 = 18:  2e1ee543 lib/, src/: Use SYSLOGE() instead of its pattern
v6c
  • Use do-while(0) to implement SYSLOGE()
$ git rd 
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  73336b3f =  8:  73336b3f lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  063966cc =  9:  063966cc lib/io/syslog.h: Rename local variable
10:  ab24ab95 = 10:  ab24ab95 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  07f77ecf = 11:  07f77ecf lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  4d3b887d = 12:  4d3b887d lib/io/fprintf/: [v]fprinte(): Add function
13:  e2e2c4fd = 13:  e2e2c4fd lib/io/fprintf/: [v]eprinte(): Add function
14:  058f311a = 14:  058f311a lib/, src/: Use eprinte() instead of its pattern
15:  3b1c3231 = 15:  3b1c3231 lib/: Use [v]fprinte() instead of its pattern
16:  955ab8bf ! 16:  47cf544a lib/io/syslog.h: SYSLOGE(): Add macro
    @@ lib/io/syslog.h
      
      
     +// system log errno
    -+#define SYSLOGE(prio, fmt, ...)                                       \
    -+(                                                                     \
    ++#define SYSLOGE(prio, fmt, ...)  do                                   \
    ++{                                                                     \
     +  SYSLOG(prio, "" fmt ": %s" __VA_OPT__(,) __VA_ARGS__, strerrno()) \
    -+)
    ++} while (0)
     +
     +
      // system log C-locale
17:  7be1c698 = 17:  9faad6e1 src/userdel.c: Fix error message
18:  2e1ee543 = 18:  e0290fcb lib/, src/: Use SYSLOGE() instead of its pattern
v6d
  • Fix semicolons.
$ git rd
 1:  da4c7959 =  1:  da4c7959 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  2:  13a80305 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  3:  e1cddf24 lib/string/: strerrno(): Add function
 4:  767c2377 =  4:  767c2377 lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  5:  7e6bef2e src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  6:  a9900489 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  7:  ca6382ba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  73336b3f =  8:  73336b3f lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  063966cc =  9:  063966cc lib/io/syslog.h: Rename local variable
10:  ab24ab95 = 10:  ab24ab95 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  07f77ecf = 11:  07f77ecf lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  4d3b887d = 12:  4d3b887d lib/io/fprintf/: [v]fprinte(): Add function
13:  e2e2c4fd = 13:  e2e2c4fd lib/io/fprintf/: [v]eprinte(): Add function
14:  058f311a = 14:  058f311a lib/, src/: Use eprinte() instead of its pattern
15:  3b1c3231 = 15:  3b1c3231 lib/: Use [v]fprinte() instead of its pattern
16:  47cf544a ! 16:  d94ded03 lib/io/syslog.h: SYSLOGE(): Add macro
    @@ lib/io/syslog.h
     +// system log errno
     +#define SYSLOGE(prio, fmt, ...)  do                                   \
     +{                                                                     \
    -+  SYSLOG(prio, "" fmt ": %s" __VA_OPT__(,) __VA_ARGS__, strerrno()) \
    ++  SYSLOG(prio, "" fmt ": %s" __VA_OPT__(,) __VA_ARGS__, strerrno()); \
     +} while (0)
     +
     +
17:  9faad6e1 = 17:  a16468a1 src/userdel.c: Fix error message
18:  e0290fcb = 18:  97d74781 lib/, src/: Use SYSLOGE() instead of its pattern
v6e
  • Add missing includes
$ git rd 
 -:  -------- >  1:  453bb132 lib/getdef.h: Add missing includes
 1:  da4c7959 =  2:  1aa42283 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  13a80305 =  3:  e0f12df3 lib/, src/: Use eprintf() instead of its pattern
 3:  e1cddf24 =  4:  9478a434 lib/string/: strerrno(): Add function
 4:  767c2377 =  5:  7d03b42e lib/, src/: Use strerrno() instead of its pattern
 5:  7e6bef2e =  6:  869d2b44 src/su.c: Fix incorrect (non-matching) parentheses
 6:  a9900489 =  7:  96049602 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  ca6382ba =  8:  e542800a lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  73336b3f =  9:  59a7bd7a lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  063966cc = 10:  df5826c0 lib/io/syslog.h: Rename local variable
10:  ab24ab95 = 11:  7508615d lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  07f77ecf = 12:  20a4f244 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  4d3b887d = 13:  7b2ce1f1 lib/io/fprintf/: [v]fprinte(): Add function
13:  e2e2c4fd = 14:  5b13bfba lib/io/fprintf/: [v]eprinte(): Add function
14:  058f311a = 15:  da1c2aac lib/, src/: Use eprinte() instead of its pattern
15:  3b1c3231 = 16:  1004d7e8 lib/: Use [v]fprinte() instead of its pattern
16:  d94ded03 = 17:  fa4d663d lib/io/syslog.h: SYSLOGE(): Add macro
17:  a16468a1 = 18:  42ff49da src/userdel.c: Fix error message
18:  97d74781 = 19:  68dfb3ae lib/, src/: Use SYSLOGE() instead of its pattern
v6f
  • Rebase
$ git rd 
 1:  453bb132 =  1:  0ac2e68c lib/getdef.h: Add missing includes
 2:  1aa42283 =  2:  acc8238c lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  e0f12df3 !  3:  4ebb63c2 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chfn.c: int main (int argc, char **argv)
                        SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
                                 (unsigned long) getuid ()));
     @@ src/chfn.c: int main (int argc, char **argv)
    -    */
    -   if ((strlen (fullnm) + strlen (roomno) + strlen (workph) +
    -        strlen (homeph) + strlen (slop)) > (unsigned int) 80) {
    +           p = stpeprintf(p, e, ",%s", slop);
    + 
    +   if (p == e || p == NULL) {
     -          fprintf (stderr, _("%s: fields too long\n"), Prog);
     +          eprintf(_("%s: fields too long\n"), Prog);
                fail_exit (E_NOPERM);
        }
    -   SNPRINTF(new_gecos, "%s,%s,%s,%s%s%s",
    + 
     
      ## src/chgpasswd.c ##
     @@
 4:  9478a434 =  4:  2a615806 lib/string/: strerrno(): Add function
 5:  7d03b42e =  5:  fae8b792 lib/, src/: Use strerrno() instead of its pattern
 6:  869d2b44 =  6:  bdbe3523 src/su.c: Fix incorrect (non-matching) parentheses
 7:  96049602 =  7:  b170a21d lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 8:  e542800a =  8:  abdabe26 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 9:  59a7bd7a =  9:  feda6e03 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
10:  df5826c0 = 10:  75cd1347 lib/io/syslog.h: Rename local variable
11:  7508615d = 11:  71818a6f lib/io/syslog.h: SYSLOG_C(): Use a single local variable
12:  20a4f244 = 12:  02ce55c6 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
13:  7b2ce1f1 = 13:  c77c1be8 lib/io/fprintf/: [v]fprinte(): Add function
14:  5b13bfba = 14:  3a5f8825 lib/io/fprintf/: [v]eprinte(): Add function
15:  da1c2aac = 15:  a1a173d4 lib/, src/: Use eprinte() instead of its pattern
16:  1004d7e8 = 16:  17c5083e lib/: Use [v]fprinte() instead of its pattern
17:  fa4d663d = 17:  51640f21 lib/io/syslog.h: SYSLOGE(): Add macro
18:  42ff49da = 18:  3fb3b4c8 src/userdel.c: Fix error message
19:  68dfb3ae = 19:  55cd6cbc lib/, src/: Use SYSLOGE() instead of its pattern
v6g
  • Rebase
$ git rd 
 1:  0ac2e68c =  1:  6bc39aba lib/getdef.h: Add missing includes
 2:  acc8238c =  2:  4a57daa1 lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  4ebb63c2 =  3:  e75c9ff3 lib/, src/: Use eprintf() instead of its pattern
 4:  2a615806 =  4:  a46a8a0e lib/string/: strerrno(): Add function
 5:  fae8b792 =  5:  98555258 lib/, src/: Use strerrno() instead of its pattern
 6:  bdbe3523 =  6:  ad63c9e1 src/su.c: Fix incorrect (non-matching) parentheses
 7:  b170a21d =  7:  f56b7440 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 8:  abdabe26 =  8:  d688bdb1 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 9:  feda6e03 =  9:  4b42ef08 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
10:  75cd1347 = 10:  31706a0b lib/io/syslog.h: Rename local variable
11:  71818a6f = 11:  bd960db3 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
12:  02ce55c6 = 12:  5164c736 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
13:  c77c1be8 = 13:  c3e54019 lib/io/fprintf/: [v]fprinte(): Add function
14:  3a5f8825 = 14:  854399af lib/io/fprintf/: [v]eprinte(): Add function
15:  a1a173d4 = 15:  9d17e83b lib/, src/: Use eprinte() instead of its pattern
16:  17c5083e = 16:  f773e997 lib/: Use [v]fprinte() instead of its pattern
17:  51640f21 = 17:  93b6a5fc lib/io/syslog.h: SYSLOGE(): Add macro
18:  3fb3b4c8 = 18:  dc366523 src/userdel.c: Fix error message
19:  55cd6cbc = 19:  0a20d7bf lib/, src/: Use SYSLOGE() instead of its pattern
v7
  • Rebase
$ git rd 
 1:  6bc39aba =  1:  4c7cdd81 lib/getdef.h: Add missing includes
 2:  4a57daa1 =  2:  c5f7d1ba lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  e75c9ff3 !  3:  e9de5767 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chpasswd.c: static void close_files (void)
                /* continue */
        }
     @@ src/chpasswd.c: int main (int argc, char **argv)
    -                                   }
    +                                           break;
                                }
      
     -                          fprintf (stderr,
    @@ src/lastlog.c: int main (int argc, char **argv)
     -          fprintf (stderr,
     -                   _("%s: Cannot get the size of %s: %s\n"),
     +          eprintf(_("%s: Cannot get the size of %s: %s\n"),
    -                    Prog, LASTLOG_FILE, strerror (errno));
    +                    Prog, _PATH_LASTLOG, strerror(errno));
                exit (EXIT_FAILURE);
        }
     
    @@ src/newgidmap.c: int main(int argc, char **argv)
     @@ src/newgidmap.c: int main(int argc, char **argv)
        }
      
    -   if (!sub_gid_open(O_RDONLY)) {
    +   if (want_subgid_file() && !sub_gid_open(O_RDONLY)) {
     -          fprintf (stderr,
     -                   _("%s: cannot open %s: %s\n"),
     +          eprintf(_("%s: cannot open %s: %s\n"),
    @@ src/newuidmap.c: int main(int argc, char **argv)
     @@ src/newuidmap.c: int main(int argc, char **argv)
        }
      
    -   if (!sub_uid_open(O_RDONLY)) {
    +   if (want_subuid_file() && !sub_uid_open(O_RDONLY)) {
     -          fprintf (stderr,
     -                   _("%s: cannot open %s: %s\n"),
     +          eprintf(_("%s: cannot open %s: %s\n"),
    @@ src/su.c: save_caller_context(void)
     @@ src/su.c: int main (int argc, char **argv)
        ret = pam_start (Prog, name, &conv, &pamh);
        if (PAM_SUCCESS != ret) {
    -           SYSLOG ((LOG_ERR, "pam_start: error %d", ret);
    --          fprintf (stderr,
    --                   _("%s: pam_start: error %d\n"),
    --                   Prog, ret));
    -+          eprintf(_("%s: pam_start: error %d\n"), Prog, ret));
    +           SYSLOG((LOG_ERR, "pam_start: error %d", ret));
    +-          fprintf(stderr, _("%s: pam_start: error %d\n"), Prog, ret);
    ++          eprintf(_("%s: pam_start: error %d\n"), Prog, ret);
                exit (1);
        }
      
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
        }
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
      
    -   fd = open (LASTLOG_FILE, O_RDWR);
    +   fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
     -          fprintf (stderr,
     -                   _("%s: failed to open the lastlog file for UID %lu: %s\n"),
    @@ src/usermod.c: static void move_home (void)
        }
      }
     @@ src/usermod.c: static void update_lastlog (void)
    -   fd = open (LASTLOG_FILE, O_RDWR);
    +   fd = open(_PATH_LASTLOG, O_RDWR);
      
        if (-1 == fd) {
     -          fprintf (stderr,
 4:  a46a8a0e =  4:  c303977c lib/string/: strerrno(): Add function
 5:  98555258 !  5:  05f95c6f lib/, src/: Use strerrno() instead of its pattern
    @@ lib/tcbfuncs.c: static shadowtcb_status mkdir_leading (const char *name, uid_t u
     +                   shadow_progname, TCB_DIR, strerrno());
                goto out_free_path;
        }
    -   while ((ind = strchr (ptr, '/'))) {
    +   while (NULL != (ind = strchr(ptr, '/'))) {
     @@ lib/tcbfuncs.c: static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
                if ((mkdir (dir, 0700) != 0) && (errno != EEXIST)) {
                        fprintf (shadow_logfd,
    @@ src/lastlog.c: int main (int argc, char **argv)
        /* Get the lastlog size */
        if (fstat (fileno (lastlogfile), &statbuf) != 0) {
                eprintf(_("%s: Cannot get the size of %s: %s\n"),
    --                   Prog, LASTLOG_FILE, strerror (errno));
    -+                  Prog, LASTLOG_FILE, strerrno());
    +-                   Prog, _PATH_LASTLOG, strerror(errno));
    ++                  Prog, _PATH_LASTLOG, strerrno());
                exit (EXIT_FAILURE);
        }
      
    @@ src/newgidmap.c: int main(int argc, char **argv)
     @@ src/newgidmap.c: int main(int argc, char **argv)
        }
      
    -   if (!sub_gid_open(O_RDONLY)) {
    +   if (want_subgid_file() && !sub_gid_open(O_RDONLY)) {
     -          eprintf(_("%s: cannot open %s: %s\n"),
     -                   Prog, sub_gid_dbname (), strerror (errno));
     +          eprintf(_("%s: cannot open %s: %s\n"), Prog, sub_gid_dbname(), strerrno());
    @@ src/newuidmap.c: int main(int argc, char **argv)
      
     @@ src/newuidmap.c: int main(int argc, char **argv)
      
    -   if (!sub_uid_open(O_RDONLY)) {
    +   if (want_subuid_file() && !sub_uid_open(O_RDONLY)) {
                eprintf(_("%s: cannot open %s: %s\n"),
     -                   Prog, sub_uid_dbname (), strerror (errno));
     +                  Prog, sub_uid_dbname(), strerrno());
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
        }
      }
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
    -   fd = open (LASTLOG_FILE, O_RDWR);
    +   fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
                eprintf(_("%s: failed to open the lastlog file for UID %lu: %s\n"),
     -                   Prog, (unsigned long) uid, strerror (errno));
 6:  ad63c9e1 <  -:  -------- src/su.c: Fix incorrect (non-matching) parentheses
 7:  f56b7440 !  6:  5a448c24 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
    @@ lib/log.c: void dolastlog (
        if (lseek (fd, offset, SEEK_SET) != offset) {
     -          SYSLOG ((LOG_WARN,
     -                   "Can't read last lastlog entry for UID %lu in %s. Entry not updated.",
    --                   (unsigned long) pw->pw_uid, LASTLOG_FILE));
    +-                   (unsigned long) pw->pw_uid, _PATH_LASTLOG));
     +          SYSLOG(LOG_WARN,
     +                 "Can't read last lastlog entry for UID %lu in %s. Entry not updated.",
    -+                 (unsigned long) pw->pw_uid, LASTLOG_FILE);
    ++                 (unsigned long) pw->pw_uid, _PATH_LASTLOG);
                (void) close (fd);
                return;
        }
    @@ lib/log.c: err_write:
      err_close:
     -  SYSLOG ((LOG_WARN,
     -           "Can't write lastlog entry for UID %lu in %s: %m",
    --           (unsigned long) pw->pw_uid, LASTLOG_FILE));
    +-           (unsigned long) pw->pw_uid, _PATH_LASTLOG));
     +  SYSLOG(LOG_WARN,
     +         "Can't write lastlog entry for UID %lu in %s: %m",
    -+         (unsigned long) pw->pw_uid, LASTLOG_FILE);
    ++         (unsigned long) pw->pw_uid, _PATH_LASTLOG);
      }
     
      ## lib/pwdcheck.c ##
 8:  d688bdb1 =  7:  89a68bba lib/: Move <syslog.h> wrappers to "io/syslog.h"
 9:  4b42ef08 =  8:  de8b9cd4 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
10:  31706a0b =  9:  5cbca3af lib/io/syslog.h: Rename local variable
11:  bd960db3 = 10:  91bbde22 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
12:  5164c736 = 11:  e32447c6 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
13:  c3e54019 = 12:  fa2d4762 lib/io/fprintf/: [v]fprinte(): Add function
14:  854399af = 13:  d36ed519 lib/io/fprintf/: [v]eprinte(): Add function
15:  9d17e83b ! 14:  0a0f2c23 lib/, src/: Use eprinte() instead of its pattern
    @@ src/lastlog.c: int main (int argc, char **argv)
        /* Get the lastlog size */
        if (fstat (fileno (lastlogfile), &statbuf) != 0) {
     -          eprintf(_("%s: Cannot get the size of %s: %s\n"),
    --                  Prog, LASTLOG_FILE, strerrno());
    -+          eprinte(_("%s: Cannot get the size of %s"), Prog, LASTLOG_FILE);
    +-                  Prog, _PATH_LASTLOG, strerrno());
    ++          eprinte(_("%s: Cannot get the size of %s"), Prog, _PATH_LASTLOG);
                exit (EXIT_FAILURE);
        }
      
    @@ src/newgidmap.c: int main(int argc, char **argv)
     @@ src/newgidmap.c: int main(int argc, char **argv)
        }
      
    -   if (!sub_gid_open(O_RDONLY)) {
    +   if (want_subgid_file() && !sub_gid_open(O_RDONLY)) {
     -          eprintf(_("%s: cannot open %s: %s\n"), Prog, sub_gid_dbname(), strerrno());
     +          eprinte(_("%s: cannot open %s"), Prog, sub_gid_dbname());
                return EXIT_FAILURE;
    @@ src/newuidmap.c: int main(int argc, char **argv)
     @@ src/newuidmap.c: int main(int argc, char **argv)
        }
      
    -   if (!sub_uid_open(O_RDONLY)) {
    +   if (want_subuid_file() && !sub_uid_open(O_RDONLY)) {
     -          eprintf(_("%s: cannot open %s: %s\n"),
     -                  Prog, sub_uid_dbname(), strerrno());
     +          eprinte(_("%s: cannot open %s"), Prog, sub_uid_dbname());
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
      }
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
      
    -   fd = open (LASTLOG_FILE, O_RDWR);
    +   fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
     -          eprintf(_("%s: failed to open the lastlog file for UID %lu: %s\n"),
     -                  Prog, (unsigned long) uid, strerrno());
    @@ src/usermod.c: prepend_range(const char *str, struct id_range_list_entry **head)
        }
        entry->next = *head;
     @@ src/usermod.c: static void update_lastlog (void)
    -   fd = open (LASTLOG_FILE, O_RDWR);
    +   fd = open(_PATH_LASTLOG, O_RDWR);
      
        if (-1 == fd) {
     -          eprintf(_("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
16:  f773e997 ! 15:  350da966 lib/: Use [v]fprinte() instead of its pattern
    @@ lib/tcbfuncs.c: static shadowtcb_status mkdir_leading (const char *name, uid_t u
     +                  shadow_progname, TCB_DIR);
                goto out_free_path;
        }
    -   while ((ind = strchr (ptr, '/'))) {
    +   while (NULL != (ind = strchr(ptr, '/'))) {
     @@ lib/tcbfuncs.c: static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
                        return SHADOWTCB_FAILURE;
                }
17:  93b6a5fc = 16:  64d4993c lib/io/syslog.h: SYSLOGE(): Add macro
18:  dc366523 = 17:  dfb25c6c src/userdel.c: Fix error message
19:  0a20d7bf = 18:  3b1b87e4 lib/, src/: Use SYSLOGE() instead of its pattern

v8: #1289 (comment)

v8b
  • Fix previous rebase (v8).
$ git range-diff shadow/master gh/eprintf eprintf 
 1:  093ab3f0 =  1:  093ab3f0 lib/getdef.h: Add missing includes
 2:  5f2879a5 =  2:  5f2879a5 lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  224ebc52 =  3:  224ebc52 lib/, src/: Use eprintf() instead of its pattern
 4:  86d632c8 =  4:  86d632c8 lib/string/: strerrno(): Add function
 5:  931f9e4b =  5:  931f9e4b lib/, src/: Use strerrno() instead of its pattern
 6:  2e5885c8 !  6:  89e91e48 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
    @@ src/grpunconv.c: int main (int argc, char **argv)
        if (unlink(_PATH_GSHADOW) != 0) {
                eprintf(_("%s: cannot delete %s\n"), Prog, _PATH_GSHADOW);
     -          SYSLOG((LOG_ERR, "cannot delete %s", _PATH_GSHADOW));
    -+          SYSLOG(LOG_ERR, "cannot delete %s", SGROUP_FILE);
    ++          SYSLOG(LOG_ERR, "cannot delete %s", _PATH_GSHADOW);
                fail_exit (3, process_selinux);
        }
      
 7:  0d4af870 =  7:  6b17f1be lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  d22e486c =  8:  0807708a lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  aace99d5 =  9:  92d14578 lib/io/syslog.h: Rename local variable
10:  0d718f3b = 10:  928b2285 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  2d142ecf = 11:  78571ba2 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  17a5a34a = 12:  8df579dd lib/io/fprintf/: [v]fprinte(): Add function
13:  af7f8cb6 = 13:  7bf404c5 lib/io/fprintf/: [v]eprinte(): Add function
14:  9ae067f8 = 14:  d9fc1d94 lib/, src/: Use eprinte() instead of its pattern
15:  85698a10 = 15:  78cccbd7 lib/: Use [v]fprinte() instead of its pattern
16:  69dbc822 = 16:  171454ec lib/io/syslog.h: SYSLOGE(): Add macro
17:  300e074d = 17:  db55a04a src/userdel.c: Fix error message
18:  65c2e9cc = 18:  86ca0d69 lib/, src/: Use SYSLOGE() instead of its pattern
v9
$ git range-diff shadow/master..gh/eprintf gh/strerrno..eprintf 
 1:  093ab3f0 <  -:  -------- lib/getdef.h: Add missing includes
 2:  5f2879a5 =  1:  f311d59c lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  224ebc52 !  2:  e3a68500 lib/, src/: Use eprintf() instead of its pattern
    @@ lib/get_pid.c
     +#include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "string/sprintf/snprintf.h"
    - 
    + #include "string/strerrno.h"
     @@ lib/get_pid.c: int open_pidfd(const char *pidstr)
                return -ENOENT;
      
        if (SNPRINTF(proc_dir_name, "/proc/%d/", target) == -1) {
     -          fprintf(stderr, "snprintf of proc path failed for %d: %s\n",
     +          eprintf("snprintf of proc path failed for %d: %s\n",
    -                   target, strerror(errno));
    +                   target, strerrno());
                return -EINVAL;
        }
      
    @@ lib/get_pid.c: int open_pidfd(const char *pidstr)
        if (proc_dir_fd < 0) {
     -          fprintf(stderr, _("Could not open proc directory for target %d: %s\n"),
     +          eprintf(_("Could not open proc directory for target %d: %s\n"),
    -                   target, strerror(errno));
    +                   target, strerrno());
                return -EINVAL;
        }
     
    @@ src/chage.c: int main (int argc, char **argv)
                     || (setreuid (ruid, ruid) != 0))) {
     -          fprintf (stderr, _("%s: failed to drop privileges (%s)\n"),
     +          eprintf(_("%s: failed to drop privileges (%s)\n"),
    -                    Prog, strerror (errno));
    +                    Prog, strerrno());
                fail_exit (E_NOPERM, process_selinux);
        }
      
    @@ src/chgpasswd.c: int main (int argc, char **argv)
     -                          fprintf (stderr,
     -                                   _("%s: failed to crypt password with salt '%s': %s\n"),
     +                          eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                                    Prog, salt, strerror (errno));
    +                                   Prog, salt, strerrno());
                                fail_exit (1, process_selinux);
                        }
     @@ src/chgpasswd.c: int main (int argc, char **argv)
    @@ src/chpasswd.c: int main (int argc, char **argv)
     -                          fprintf (stderr,
     -                                   _("%s: failed to crypt password with salt '%s': %s\n"),
     +                          eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                                    Prog, salt, strerror (errno));
    +                                   Prog, salt, strerrno());
                                fail_exit (1, process_selinux);
                        }
     @@ src/chpasswd.c: int main (int argc, char **argv)
    @@ src/faillog.c: int main (int argc, char **argv)
     -          fprintf (stderr,
     -                   _("%s: Cannot open %s: %s\n"),
     +          eprintf(_("%s: Cannot open %s: %s\n"),
    -                    Prog, FAILLOG_FILE, strerror (errno));
    +                   Prog, FAILLOG_FILE, strerrno());
                exit (E_NOPERM);
        }
      
    @@ src/faillog.c: int main (int argc, char **argv)
     -          fprintf (stderr,
     -                   _("%s: Cannot get the size of %s: %s\n"),
     +          eprintf(_("%s: Cannot get the size of %s: %s\n"),
    -                    Prog, FAILLOG_FILE, strerror (errno));
    +                   Prog, FAILLOG_FILE, strerrno());
                exit (E_NOPERM);
        }
     @@ src/faillog.c: int main (int argc, char **argv)
    @@ src/faillog.c: int main (int argc, char **argv)
     -                  fprintf (stderr,
     -                           _("%s: Failed to write %s: %s\n"),
     +                  eprintf(_("%s: Failed to write %s: %s\n"),
    -                            Prog, FAILLOG_FILE, strerror (errno));
    +                           Prog, FAILLOG_FILE, strerrno());
                        (void) fclose (fail);
                        errors = true;
     
    @@ src/gpasswd.c: static void change_passwd (struct group *gr)
     -          fprintf (stderr,
     -                   _("%s: failed to crypt password with salt '%s': %s\n"),
     +          eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                    Prog, salt, strerror (errno));
    +                   Prog, salt, strerrno());
                exit (1);
        }
     @@ src/gpasswd.c: int main (int argc, char **argv)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
      
        /* And now open the databases */
        if (gr_open (O_CREAT | O_RDWR) == 0) {
    --          fprintf (stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname (), strerror(errno));
    -+          eprintf(_("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerror(errno));
    -           SYSLOG ((LOG_WARN, "cannot open %s: %s", gr_dbname (), strerror(errno)));
    +-          fprintf(stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
    ++          eprintf(_("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
    +           SYSLOG((LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno()));
                fail_exit (E_GRP_UPDATE);
        }
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
                if (sgr_open (O_CREAT | O_RDWR) == 0) {
     -                  fprintf (stderr,
     -                           _("%s: cannot open %s: %s\n"),
    -+                  eprintf(_("%s: cannot open %s: %s\n"),
    -                            Prog, sgr_dbname (), strerror(errno));
    -                   SYSLOG ((LOG_WARN, "cannot open %s: %s", sgr_dbname (), strerror(errno)));
    +-                           Prog, sgr_dbname(), strerrno());
    ++                  eprintf(_("%s: cannot open %s: %s\n"), Prog, sgr_dbname(), strerrno());
    +                   SYSLOG((LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno()));
                        fail_exit (E_GRP_UPDATE);
    +           }
     @@ src/groupadd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
                        gflg = true;
                        if (   (get_gid(optarg, &group_id) == -1)
    @@ src/lastlog.c: int main (int argc, char **argv)
     -          fprintf (stderr,
     -                   _("%s: Cannot get the size of %s: %s\n"),
     +          eprintf(_("%s: Cannot get the size of %s: %s\n"),
    -                    Prog, _PATH_LASTLOG, strerror(errno));
    +                   Prog, _PATH_LASTLOG, strerrno());
                exit (EXIT_FAILURE);
        }
     
    @@ src/login.c: int main (int argc, char **argv)
        child = fork ();
        if (child < 0) {
                /* error in fork() */
    --          fprintf (stderr, _("%s: failure forking: %s"),
    --                   Prog, strerror (errno));
    -+          eprintf(_("%s: failure forking: %s"), Prog, strerror(errno));
    +-          fprintf(stderr, _("%s: failure forking: %s"), Prog, strerrno());
    ++          eprintf(_("%s: failure forking: %s"), Prog, strerrno());
                PAM_END;
                exit (0);
        } else if (child != 0) {
    @@ src/newgidmap.c: static void write_setgroups(int proc_dir_fd, bool allow_setgrou
                        goto out;
                }
     -          fprintf(stderr, _("%s: couldn't open process setgroups: %s\n"),
    -+          eprintf(_("%s: couldn't open process setgroups: %s\n"),
    -                   Prog,
    -                   strerror(errno));
    +-                  Prog, strerrno());
    ++          eprintf(_("%s: couldn't open process setgroups: %s\n"), Prog, strerrno());
                exit(EXIT_FAILURE);
    +   }
    + 
     @@ src/newgidmap.c: static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
         * fail.
         */
        if (read(setgroups_fd, policy_buffer, sizeof(policy_buffer)) < 0) {
     -          fprintf(stderr, _("%s: failed to read setgroups: %s\n"),
    -+          eprintf(_("%s: failed to read setgroups: %s\n"),
    -                   Prog,
    -                   strerror(errno));
    +-                  Prog, strerrno());
    ++          eprintf(_("%s: failed to read setgroups: %s\n"), Prog, strerrno());
                exit(EXIT_FAILURE);
    +   }
    +   if (strprefix(policy_buffer, policy))
     @@ src/newgidmap.c: static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
      
        /* Write the policy. */
        if (lseek(setgroups_fd, 0, SEEK_SET) < 0) {
     -          fprintf(stderr, _("%s: failed to seek setgroups: %s\n"),
    -+          eprintf(_("%s: failed to seek setgroups: %s\n"),
    -                   Prog,
    -                   strerror(errno));
    +-                  Prog, strerrno());
    ++          eprintf(_("%s: failed to seek setgroups: %s\n"), Prog, strerrno());
                exit(EXIT_FAILURE);
        }
        if (dprintf(setgroups_fd, "%s", policy) < 0) {
     -          fprintf(stderr, _("%s: failed to setgroups %s policy: %s\n"),
     +          eprintf(_("%s: failed to setgroups %s policy: %s\n"),
    -                   Prog,
    -                   policy,
    -                   strerror(errno));
    +                   Prog, policy, strerrno());
    +           exit(EXIT_FAILURE);
    +   }
     @@ src/newgidmap.c: int main(int argc, char **argv)
        /* Who am I? */
        pw = get_my_pwent ();
    @@ src/newgidmap.c: int main(int argc, char **argv)
     -          fprintf(stderr,
     -                  _("%s: Could not stat directory for target process: %s\n"),
     +          eprintf(_("%s: Could not stat directory for target process: %s\n"),
    -                   Prog, strerror (errno));
    +                   Prog, strerrno());
                return EXIT_FAILURE;
        }
     @@ src/newgidmap.c: int main(int argc, char **argv)
    @@ src/newgidmap.c: int main(int argc, char **argv)
        if (want_subgid_file() && !sub_gid_open(O_RDONLY)) {
     -          fprintf (stderr,
     -                   _("%s: cannot open %s: %s\n"),
    -+          eprintf(_("%s: cannot open %s: %s\n"),
    -                    Prog, sub_gid_dbname (), strerror (errno));
    +-                   Prog, sub_gid_dbname(), strerrno());
    ++          eprintf(_("%s: cannot open %s: %s\n"), Prog, sub_gid_dbname(), strerrno());
                return EXIT_FAILURE;
        }
    + 
     
      ## src/newgrp.c ##
     @@
    @@ src/newgrp.c: static void check_perms (const struct group *grp,
     -                  fprintf (stderr,
     -                           _("%s: failed to crypt password with previous salt: %s\n"),
     +                  eprintf(_("%s: failed to crypt password with previous salt: %s\n"),
    -                            Prog, strerror (errno));
    +                           Prog, strerrno());
                        SYSLOG ((LOG_INFO,
                                 "Failed to crypt password with previous salt of group '%s'",
     @@ src/newgrp.c: static void syslog_sg (const char *name, const char *group)
    @@ src/newgrp.c: static void syslog_sg (const char *name, const char *group)
                        /* error in fork() */
     -                  fprintf (stderr, _("%s: failure forking: %s\n"),
     +                  eprintf(_("%s: failure forking: %s\n"),
    -                            is_newgrp ? "newgrp" : "sg", strerror (errno));
    +                           is_newgrp ? "newgrp" : "sg", strerrno());
      #ifdef WITH_AUDIT
                        if (group) {
     @@ src/newgrp.c: int main (int argc, char **argv)
    @@ src/newuidmap.c: int main(int argc, char **argv)
     -          fprintf(stderr,
     -                  _("%s: Could not stat directory for target process: %s\n"),
     +          eprintf(_("%s: Could not stat directory for target process: %s\n"),
    -                   Prog, strerror (errno));
    +                   Prog, strerrno());
                return EXIT_FAILURE;
        }
     @@ src/newuidmap.c: int main(int argc, char **argv)
    @@ src/newuidmap.c: int main(int argc, char **argv)
     -          fprintf (stderr,
     -                   _("%s: cannot open %s: %s\n"),
     +          eprintf(_("%s: cannot open %s: %s\n"),
    -                    Prog, sub_uid_dbname (), strerror (errno));
    +                   Prog, sub_uid_dbname(), strerrno());
                return EXIT_FAILURE;
        }
     
    @@ src/newusers.c: static int update_passwd (struct passwd *pwd, const char *passwo
     -                  fprintf (stderr,
     -                           _("%s: failed to crypt password with salt '%s': %s\n"),
     +                  eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                            Prog, salt, strerror (errno));
    +                           Prog, salt, strerrno());
                        return 1;
                }
     @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
     -                          fprintf (stderr,
     -                                   _("%s: failed to crypt password with salt '%s': %s\n"),
     +                          eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                                    Prog, salt, strerror (errno));
    +                                   Prog, salt, strerrno());
                                return 1;
                        }
     @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
     -                  fprintf (stderr,
     -                           _("%s: failed to crypt password with salt '%s': %s\n"),
     +                  eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                            Prog, salt, strerror (errno));
    +                           Prog, salt, strerrno());
                        return 1;
                }
     @@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/newusers.c: int main (int argc, char **argv)
                usernames = REALLOCF(usernames, nusers, char *);
                passwords = REALLOCF(passwords, nusers, char *);
                if (lines == NULL || usernames == NULL || passwords == NULL) {
    --                  fprintf (stderr,
    --                           _("%s: line %jd: %s\n"),
    --                           Prog, line, strerror(errno));
    -+                  eprintf(_("%s: line %jd: %s\n"), Prog, line, strerror(errno));
    +-                  fprintf(stderr, _("%s: line %jd: %s\n"), Prog, line, strerrno());
    ++                  eprintf(_("%s: line %jd: %s\n"), Prog, line, strerrno());
                        fail_exit (EXIT_FAILURE, process_selinux);
                }
                lines[nusers-1]     = line;
    @@ src/newusers.c: int main (int argc, char **argv)
     -                          fprintf (stderr,
     -                                   _("%s: line %jd: mkdir %s failed: %s\n"),
     +                          eprintf(_("%s: line %jd: mkdir %s failed: %s\n"),
    -                                    Prog, line, newpw.pw_dir,
    -                                    strerror (errno));
    +                                   Prog, line, newpw.pw_dir, strerrno());
                                if (errno != EEXIST) {
    +                                   fail_exit (EXIT_FAILURE, process_selinux);
     @@ src/newusers.c: int main (int argc, char **argv)
                        }
                        if (chown(newpw.pw_dir, newpw.pw_uid, newpw.pw_gid) != 0)
    @@ src/newusers.c: int main (int argc, char **argv)
     -                          fprintf (stderr,
     -                                   _("%s: line %jd: chown %s failed: %s\n"),
     +                          eprintf(_("%s: line %jd: chown %s failed: %s\n"),
    -                                    Prog, line, newpw.pw_dir,
    -                                    strerror (errno));
    +                                   Prog, line, newpw.pw_dir, strerrno());
                                fail_exit (EXIT_FAILURE, process_selinux);
    +                   }
     @@ src/newusers.c: int main (int argc, char **argv)
                 * Update the password entry with the new changes made.
                 */
    @@ src/passwd.c: static int new_password (const struct passwd *pw)
     -                  fprintf (stderr,
     -                           _("%s: failed to crypt password with previous salt: %s\n"),
     +                  eprintf(_("%s: failed to crypt password with previous salt: %s\n"),
    -                            Prog, strerror (errno));
    +                            Prog, strerrno());
                        SYSLOG ((LOG_INFO,
                                 "Failed to crypt password with previous salt of user '%s'",
     @@ src/passwd.c: static int new_password (const struct passwd *pw)
    @@ src/passwd.c: static int new_password (const struct passwd *pw)
     -          fprintf (stderr,
     -                   _("%s: failed to crypt password with salt '%s': %s\n"),
     +          eprintf(_("%s: failed to crypt password with salt '%s': %s\n"),
    -                    Prog, salt, strerror (errno));
    +                    Prog, salt, strerrno());
                return -1;
        }
     @@ src/passwd.c: static void check_password (const struct passwd *pw, const struct spwd *sp)
    @@ src/useradd.c: set_defaults(void)
        if (new_file == NULL) {
     -          fprintf(stderr, _("%s: cannot create new defaults file: %s\n"),
     +          eprintf(_("%s: cannot create new defaults file: %s\n"),
    -                   Prog, strerror(errno));
    +                   Prog, strerrno());
                return -1;
              }
     @@ src/useradd.c: set_defaults(void)
    @@ src/useradd.c: set_defaults(void)
     -                  fprintf(stderr,
     -                          _("%s: cannot create new defaults file: %s\n"),
     +                  eprintf(_("%s: cannot create new defaults file: %s\n"),
    -                           Prog, strerror(errno));
    +                           Prog, strerrno());
                        goto err_free_new;
                }
     @@ src/useradd.c: set_defaults(void)
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
     -          fprintf (stderr,
     -                   _("%s: failed to open the faillog file for UID %lu: %s\n"),
     +          eprintf(_("%s: failed to open the faillog file for UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to open the faillog file for UID %lu", (unsigned long) uid));
                return;
     @@ src/useradd.c: static void faillog_reset (uid_t uid)
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
     -          fprintf (stderr,
     -                   _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
     +          eprintf(_("%s: failed to reset the faillog entry of UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to reset the faillog entry of UID %lu", (unsigned long) uid));
        }
        if (close (fd) != 0 && errno != EINTR) {
     -          fprintf (stderr,
     -                   _("%s: failed to close the faillog file for UID %lu: %s\n"),
     +          eprintf(_("%s: failed to close the faillog file for UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to close the faillog file for UID %lu", (unsigned long) uid));
        }
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
    @@ src/useradd.c: static void lastlog_reset (uid_t uid)
     -          fprintf (stderr,
     -                   _("%s: failed to open the lastlog file for UID %lu: %s\n"),
     +          eprintf(_("%s: failed to open the lastlog file for UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to open the lastlog file for UID %lu", (unsigned long) uid));
                return;
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
    @@ src/useradd.c: static void lastlog_reset (uid_t uid)
     -          fprintf (stderr,
     -                   _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
     +          eprintf(_("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to reset the lastlog entry of UID %lu", (unsigned long) uid));
                /* continue */
        }
    @@ src/useradd.c: static void lastlog_reset (uid_t uid)
     -          fprintf (stderr,
     -                   _("%s: failed to close the lastlog file for UID %lu: %s\n"),
     +          eprintf(_("%s: failed to close the lastlog file for UID %lu: %s\n"),
    -                    Prog, (unsigned long) uid, strerror (errno));
    +                   Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to close the lastlog file for UID %lu", (unsigned long) uid));
                /* continue */
     @@ src/useradd.c: static void tallylog_reset (const char *user_name)
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                  fprintf (stderr,
     -                           _("%s: warning: can't remove %s: %s\n"),
     +                  eprintf(_("%s: warning: can't remove %s: %s\n"),
    -                            Prog, mailfile, strerror (errno));
    -                   SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
    +                           Prog, mailfile, strerrno());
    +                   SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
      #ifdef WITH_AUDIT
     @@ src/userdel.c: static bool remove_mailbox (void)
      
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                  fprintf (stderr,
     -                           _("%s: warning: can't remove %s: %s\n"),
     +                  eprintf(_("%s: warning: can't remove %s: %s\n"),
    -                            Prog, mailfile, strerror (errno));
    -                   SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
    +                           Prog, mailfile, strerrno());
    +                   SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
      #ifdef WITH_AUDIT
     @@ src/userdel.c: static bool remove_mailbox (void)
        }
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                   _("%s: %s not owned by %s, not removing\n"),
     +          eprintf(_("%s: %s not owned by %s, not removing\n"),
                         Prog, mailfile, user_name);
    -           SYSLOG ((LOG_ERR,
    -                    "%s not owned by %s, not removed",
    +           SYSLOG((LOG_ERR, "%s not owned by %s, not removed", mailfile, strerrno()));
    + #ifdef WITH_AUDIT
     @@ src/userdel.c: static bool remove_mailbox (void)
                return 0;               /* mailbox doesn't exist */
        }
        if (unlink (mailfile) != 0) {
     -          fprintf (stderr,
     -                   _("%s: warning: can't remove %s: %s\n"),
    -+          eprintf(_("%s: warning: can't remove %s: %s\n"),
    -                    Prog, mailfile, strerror (errno));
    -           SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
    +-                   Prog, mailfile, strerrno());
    ++          eprintf(_("%s: warning: can't remove %s: %s\n"), Prog, mailfile, strerrno());
    +           SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
      #ifdef WITH_AUDIT
    +           audit_logger (AUDIT_DEL_USER, Prog,
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
      
        buf = aprintf(TCB_DIR "/%s", user_name);
    @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
        }
        if (shadowtcb_drop_priv () == SHADOWTCB_FAILURE) {
     -          fprintf (stderr, _("%s: Cannot drop privileges: %s\n"),
    -+          eprintf(_("%s: Cannot drop privileges: %s\n"),
    -                    Prog, strerror (errno));
    +-                   Prog, strerrno());
    ++          eprintf(_("%s: Cannot drop privileges: %s\n"), Prog, strerrno());
                shadowtcb_gain_priv ();
                free (buf);
    +           return 1;
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
         * We will regain them and remove the user's tcb directory afterwards.
         */
        if (remove_tree (buf, false) != 0) {
     -          fprintf (stderr, _("%s: Cannot remove the content of %s: %s\n"),
     +          eprintf(_("%s: Cannot remove the content of %s: %s\n"),
    -                    Prog, buf, strerror (errno));
    +                   Prog, buf, strerrno());
                shadowtcb_gain_priv ();
                free (buf);
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
    @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
        if (shadowtcb_remove (user_name) == SHADOWTCB_FAILURE) {
     -          fprintf (stderr, _("%s: Cannot remove tcb files for %s: %s\n"),
     +          eprintf(_("%s: Cannot remove tcb files for %s: %s\n"),
    -                    Prog, user_name, strerror (errno));
    +                   Prog, user_name, strerrno());
                ret = 1;
        }
     @@ src/userdel.c: int main (int argc, char **argv)
    @@ src/usermod.c: prepend_range(const char *str, struct id_range_list_entry **head)
        if (!entry) {
     -          fprintf (stderr,
     -                  _("%s: failed to allocate memory: %s\n"),
    -+          eprintf(_("%s: failed to allocate memory: %s\n"),
    -                   Prog, strerror (errno));
    +-                  Prog, strerrno());
    ++          eprintf(_("%s: failed to allocate memory: %s\n"), Prog, strerrno());
                return 0;
        }
    +   entry->next = *head;
     @@ src/usermod.c: static char *new_pw_passwd (char *pw_pass)
                pw_pass = xaprintf("!%s", pw_pass);
        } else if (Uflg && strprefix(pw_pass, "!")) {
    @@ src/usermod.c: static void update_lastlog (void)
     -          fprintf (stderr,
     -                   _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
     +          eprintf(_("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
    -                    Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                   Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                return;
        }
     @@ src/usermod.c: static void update_lastlog (void)
    @@ src/usermod.c: static void update_lastlog (void)
     -                  fprintf (stderr,
     -                           _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
     +                  eprintf(_("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
    -                            Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                           Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                }
        } else {
     @@ src/usermod.c: static void update_lastlog (void)
    @@ src/usermod.c: static void update_lastlog (void)
     -                          fprintf (stderr,
     -                                   _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
     +                          eprintf(_("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
    -                                    Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                                   Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                        }
                }
        }
    @@ src/usermod.c: static void update_lastlog (void)
     -          fprintf (stderr,
     -                   _("%s: failed to copy the lastlog entry of user %ju to user %ju: %s\n"),
     +          eprintf(_("%s: failed to copy the lastlog entry of user %ju to user %ju: %s\n"),
    -                    Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerror (errno));
    +                   Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerrno());
        }
      }
     @@ src/usermod.c: static void update_faillog (void)
    @@ src/usermod.c: static void update_faillog (void)
     -          fprintf (stderr,
     -                   _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
     +          eprintf(_("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
    -                    Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                   Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                return;
        }
     @@ src/usermod.c: static void update_faillog (void)
    @@ src/usermod.c: static void update_faillog (void)
     -                  fprintf (stderr,
     -                           _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
     +                  eprintf(_("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
    -                            Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                           Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                }
        } else {
     @@ src/usermod.c: static void update_faillog (void)
    @@ src/usermod.c: static void update_faillog (void)
     -                          fprintf (stderr,
     -                                   _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
     +                          eprintf(_("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
    -                                    Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
    +                                   Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                        }
                }
        }
    @@ src/usermod.c: static void update_faillog (void)
     -          fprintf (stderr,
     -                   _("%s: failed to copy the faillog entry of user %ju to user %ju: %s\n"),
     +          eprintf(_("%s: failed to copy the faillog entry of user %ju to user %ju: %s\n"),
    -                    Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerror (errno));
    +                   Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerrno());
        }
      }
     @@ src/usermod.c: static void move_mailbox (void)
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
      
                status = system (buf);
                if (-1 == status) {
    --                  fprintf (stderr, _("%s: %s: %s\n"), Prog, editor,
    -+                  eprintf(_("%s: %s: %s\n"), Prog, editor,
    -                            strerror (errno));
    +-                  fprintf(stderr, _("%s: %s: %s\n"), Prog, editor, strerrno());
    ++                  eprintf(_("%s: %s: %s\n"), Prog, editor, strerrno());
                        exit (1);
                } else if (   WIFEXITED (status)
                           && (WEXITSTATUS (status) != 0)) {
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
                                if (editor_pgrp == -1) {
     -                                  fprintf (stderr, "%s: %s: %s", Prog,
     +                                  eprintf("%s: %s: %s", Prog,
    -                                            "tcgetpgrp", strerror (errno));
    +                                           "tcgetpgrp", strerrno());
                                }
                                if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
     -                                  fprintf (stderr, "%s: %s: %s", Prog,
     +                                  eprintf("%s: %s: %s", Prog,
    -                                            "tcsetpgrp", strerror (errno));
    +                                           "tcsetpgrp", strerrno());
                                }
                        }
     @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
                                if (tcsetpgrp(STDIN_FILENO, editor_pgrp) == -1) {
     -                                  fprintf (stderr, "%s: %s: %s", Prog,
     +                                  eprintf("%s: %s: %s", Prog,
    -                                            "tcsetpgrp", strerror (errno));
    +                                           "tcsetpgrp", strerrno());
                                }
                        }
     @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
        if (orig_pgrp != -1) {
                 /* Restore terminal pgrp after editing. */
                if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
    --                  fprintf(stderr, "%s: %s: %s", Prog,
    -+                  eprintf("%s: %s: %s", Prog,
    -                           "tcsetpgrp", strerror(errno));
    +-                  fprintf(stderr, "%s: %s: %s", Prog, "tcsetpgrp", strerrno());
    ++                  eprintf("%s: %s: %s", Prog, "tcsetpgrp", strerrno());
                }
                sigprocmask(SIG_SETMASK, &omask, NULL);
    +   }
     @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
                   && (WEXITSTATUS (status) != 0)) {
                vipwexit (NULL, 0, WEXITSTATUS (status));
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
     -          fprintf (stderr,
     -                   _("%s: can't restore %s: %s (your changes are in %s)\n"),
     +          eprintf(_("%s: can't restore %s: %s (your changes are in %s)\n"),
    -                    Prog, file, strerror (errno), to_rename);
    +                   Prog, file, strerrno(), to_rename);
      #ifdef WITH_TCB
                if (tcb_mode) {
     @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
 4:  86d632c8 <  -:  -------- lib/string/: strerrno(): Add function
 5:  931f9e4b <  -:  -------- lib/, src/: Use strerrno() instead of its pattern
 6:  89e91e48 =  3:  e2e8c983 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 7:  6b17f1be =  4:  b182024c lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  0807708a =  5:  03a3d05c lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  92d14578 =  6:  c9e628dd lib/io/syslog.h: Rename local variable
10:  928b2285 =  7:  447e46ee lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  78571ba2 =  8:  d9e9dffb lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  8df579dd =  9:  511051c3 lib/io/fprintf/: [v]fprinte(): Add function
13:  7bf404c5 = 10:  b89bee67 lib/io/fprintf/: [v]eprinte(): Add function
14:  d9fc1d94 = 11:  c8d5afba lib/, src/: Use eprinte() instead of its pattern
15:  78cccbd7 = 12:  e212bedc lib/: Use [v]fprinte() instead of its pattern
16:  171454ec = 13:  74a354bb lib/io/syslog.h: SYSLOGE(): Add macro
17:  db55a04a = 14:  a2dcdc97 src/userdel.c: Fix error message
18:  86ca0d69 = 15:  b3f573b1 lib/, src/: Use SYSLOGE() instead of its pattern
v9b
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  f311d59c =  1:  32d6cd8d lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  e3a68500 !  2:  12360771 lib/, src/: Use eprintf() instead of its pattern
    @@ src/groupdel.c: int main (int argc, char **argv)
     
      ## src/groupmems.c ##
     @@
    - #include "alloc/x/xmalloc.h"
    + #include "alloc/malloc.h"
      #include "defines.h"
      #include "groupio.h"
     +#include "io/fprintf/eprintf.h"
 3:  e2e8c983 =  3:  54a071ad lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  b182024c =  4:  058dddb6 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  03a3d05c =  5:  3e3f1c12 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  c9e628dd =  6:  c9001a70 lib/io/syslog.h: Rename local variable
 7:  447e46ee =  7:  56aade53 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  d9e9dffb =  8:  5b720d6d lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  511051c3 =  9:  e9fc6219 lib/io/fprintf/: [v]fprinte(): Add function
10:  b89bee67 = 10:  745e0633 lib/io/fprintf/: [v]eprinte(): Add function
11:  c8d5afba ! 11:  7ad63296 lib/, src/: Use eprinte() instead of its pattern
    @@ src/chage.c
      #include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "pwio.h"
    -@@
    - #include "string/strcmp/streq.h"
    - #include "string/strcpy/strtcpy.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "string/strftime.h"
    - #include "time/day_to_str.h"
    - /*@-exitarg@*/
     @@ src/chage.c: int main (int argc, char **argv)
        /* Drop privileges */
        if (lflg && (   (setregid (rgid, rgid) != 0)
    @@ src/gpasswd.c
      #include "io/fprintf/eprintf.h"
      #include "nscd.h"
      #include "prototypes.h"
    -@@
    - #include "string/strcmp/streq.h"
    - #include "string/strcpy/strtcpy.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - 
    - struct option_flags {
    -   bool chroot;
     @@ src/gpasswd.c: static void change_passwd (struct group *gr)
        cp = pw_encrypt (pass, salt);
        MEMZERO(pass);
    @@ src/login.c
      #include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "pwauth.h"
    -@@
    - #include "string/strcmp/strprefix.h"
    - #include "string/strcpy/strtcpy.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "string/strftime.h"
    - 
    - 
     @@ src/login.c: int main (int argc, char **argv)
        child = fork ();
        if (child < 0) {
    @@ src/newgrp.c
      #include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "search/l/lfind.h"
    -@@
    - #include "string/strcmp/streq.h"
    - #include "string/strcmp/strprefix.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - 
    - #include <assert.h>
    - 
     @@ src/newgrp.c: static void check_perms (const struct group *grp,
                erase_pass (cp);
      
    @@ src/newusers.c
      #include "io/fprintf/eprintf.h"
      #include "nscd.h"
      #include "prototypes.h"
    -@@
    - #include "string/sprintf/snprintf.h"
    - #include "string/strcmp/streq.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "string/strtok/stpsep.h"
    - #include "string/strtok/strsep2arr.h"
    - 
     @@ src/newusers.c: static int update_passwd (struct passwd *pwd, const char *password)
                const char *salt = crypt_make_salt (crypt_method, crypt_arg);
                cp = pw_encrypt (password, salt);
    @@ src/passwd.c
      #include "io/fprintf/eprintf.h"
      #include "nscd.h"
      #include "prototypes.h"
    -@@
    - #include "string/strcmp/strprefix.h"
    - #include "string/strcpy/strtcpy.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "time/day_to_str.h"
    - 
    - 
     @@ src/passwd.c: static int new_password (const struct passwd *pw)
      
                if (NULL == cipher) {
    @@ src/useradd.c
      #include "io/fprintf/eprintf.h"
      #include "nscd.h"
      #include "prototypes.h"
    -@@
    - #include "string/strcmp/streq.h"
    - #include "string/strcmp/strprefix.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "string/strtok/stpsep.h"
    - 
    - 
     @@ src/useradd.c: set_defaults(void)
      
        new_file = aprintf("%s%s%s", prefix, prefix[0]?"/":"", NEW_USER_FILE);
    @@ src/usermod.c
      #include "io/fprintf/eprintf.h"
      #include "nscd.h"
      #include "prototypes.h"
    -@@
    - #include "string/strcmp/streq.h"
    - #include "string/strcmp/strprefix.h"
    - #include "string/strdup/xstrdup.h"
    --#include "string/strerrno.h"
    - #include "time/day_to_str.h"
    - #include "typetraits.h"
    - 
     @@ src/usermod.c: prepend_range(const char *str, struct id_range_list_entry **head)
      
        entry = MALLOC(1, struct id_range_list_entry);
    @@ src/vipw.c
      #include "nscd.h"
      #include "prototypes.h"
     @@
    + #include "string/sprintf/aprintf.h"
      #include "string/sprintf/snprintf.h"
    - #include "string/sprintf/xaprintf.h"
      #include "string/strcmp/streq.h"
     -#include "string/strerrno.h"
      
12:  e212bedc ! 12:  96a193a7 lib/: Use [v]fprinte() instead of its pattern
    @@ lib/addgrps.c: add_groups(const char *list)
        }
      
     
    - ## lib/alloc/x/xcalloc.c ##
    -@@
    - #include <string.h>
    - 
    - #include "defines.h"
    -+#include "io/fprintf/fprinte.h"
    - #include "shadowlog.h"
    --#include "string/strerrno.h"
    - 
    - 
    - void *
    -@@ lib/alloc/x/xcalloc.c: xcalloc(size_t nmemb, size_t size)
    -   return p;
    - 
    - x:
    --  fprintf(log_get_logfd(), _("%s: %s\n"), log_get_progname(), strerrno());
    -+  fprinte(log_get_logfd(), "%s", log_get_progname());
    -   exit(13);
    - }
    -
    - ## lib/alloc/x/xrealloc.c ##
    -@@
    - 
    - #include "alloc/reallocf.h"
    - #include "defines.h"
    -+#include "io/fprintf/fprinte.h"
    - #include "shadowlog.h"
    --#include "string/strerrno.h"
    - 
    - 
    - void *
    -@@ lib/alloc/x/xrealloc.c: xreallocarray(void *p, size_t nmemb, size_t size)
    -   return p;
    - 
    - x:
    --  fprintf(log_get_logfd(), _("%s: %s\n"), log_get_progname(), strerrno());
    -+  fprinte(log_get_logfd(), "%s", log_get_progname());
    -   exit(13);
    - }
    -
      ## lib/chowntty.c ##
     @@
      #include <stdio.h>
    @@ lib/commonio.c: static int do_lock_file (const char *file, const char *lock, boo
     
      ## lib/copydir.c ##
     @@
    - #include "alloc/x/xmalloc.h"
    + #include "alloc/malloc.h"
      #include "attr.h"
      #include "fs/readlink/areadlink.h"
     +#include "io/fprintf/fprinte.h"
    @@ lib/copydir.c
      #include "defines.h"
      #ifdef WITH_SELINUX
     @@
    - #include "string/sprintf/xaprintf.h"
    + #include "string/sprintf/aprintf.h"
      #include "string/strcmp/streq.h"
      #include "string/strcmp/strprefix.h"
     -#include "string/strerrno.h"
    @@ lib/copydir.c: static void error_acl (MAYBE_UNUSED struct error_context *ctx, co
      }
      
     
    + ## lib/exit_if_null.h ##
    +@@
    + #include <stdio.h>
    + #include <stdlib.h>
    + 
    ++#include "io/fprintf/fprinte.h"
    + #include "shadowlog.h"
    +-#include "string/strerrno.h"
    + 
    + 
    + /*
    +@@ lib/exit_if_null.h: inline void
    + exit_if_null_(void *p)
    + {
    +   if (p == NULL) {
    +-          fprintf(log_get_logfd(), "%s: %s\n", log_get_progname(), strerrno());
    ++          fprinte(log_get_logfd(), "%s", log_get_progname());
    +           exit(13);
    +   }
    + }
    +
      ## lib/find_new_gid.c ##
     @@
      #include <errno.h>
    @@ lib/gettime.c: gettime(void)
     
      ## lib/idmapping.c ##
     @@
    - #include "alloc/x/xmalloc.h"
    + #include "alloc/malloc.h"
      #include "atoi/a2i/a2u.h"
      #include "idmapping.h"
     +#include "io/fprintf/fprinte.h"
    @@ lib/prefix_flag.c
      #ifdef    SHADOWGRP
      #include "sgroupio.h"
     @@
    - #include "string/sprintf/xaprintf.h"
    + #include "string/sprintf/aprintf.h"
      #include "string/strcmp/streq.h"
      #include "string/strcmp/strprefix.h"
     -#include "string/strerrno.h"
    @@ lib/spawn.c: run_command(const char *cmd, const char *argv[],
        }
      
     
    - ## lib/string/strtok/xastrsep2ls.h ##
    -@@
    - #include <string.h>
    - 
    - #include "attr.h"
    -+#include "io/fprintf/fprinte.h"
    - #include "shadowlog.h"
    - #include "string/strtok/astrsep2ls.h"
    --#include "string/strerrno.h"
    - 
    - 
    - ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 3)
    -@@ lib/string/strtok/xastrsep2ls.h: xastrsep2ls(char *s, const char *restrict delim, size_t *restrict np)
    - 
    -   return ls;
    - x:
    --  fprintf(log_get_logfd(), "%s: %s\n", log_get_progname(), strerrno());
    -+  fprinte(log_get_logfd(), "%s", log_get_progname());
    -   exit(13);
    - }
    - 
    -
      ## lib/tcbfuncs.c ##
     @@
      #include "defines.h"
13:  74a354bb = 13:  b0555c70 lib/io/syslog.h: SYSLOGE(): Add macro
14:  a2dcdc97 = 14:  9ea01862 src/userdel.c: Fix error message
15:  b3f573b1 = 15:  b70f3d85 lib/, src/: Use SYSLOGE() instead of its pattern
v9c
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  32d6cd8da =  1:  02d908010 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  123607716 =  2:  e12c346ac lib/, src/: Use eprintf() instead of its pattern
 3:  54a071ada =  3:  4aa7af55d lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  058dddb6c =  4:  2c1ddba14 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  3e3f1c121 =  5:  05a2edec1 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  c9001a701 =  6:  46c76c318 lib/io/syslog.h: Rename local variable
 7:  56aade53d =  7:  a575498c1 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  5b720d6d7 =  8:  82c19e705 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  e9fc62191 =  9:  ecc37d893 lib/io/fprintf/: [v]fprinte(): Add function
10:  745e0633c = 10:  c863844f9 lib/io/fprintf/: [v]eprinte(): Add function
11:  7ad632968 = 11:  1e9a50f84 lib/, src/: Use eprinte() instead of its pattern
12:  96a193a78 = 12:  55430e2a4 lib/: Use [v]fprinte() instead of its pattern
13:  b0555c707 = 13:  3ae20d047 lib/io/syslog.h: SYSLOGE(): Add macro
14:  9ea018620 = 14:  68d8690f6 src/userdel.c: Fix error message
15:  b70f3d857 = 15:  5f726c811 lib/, src/: Use SYSLOGE() instead of its pattern
v9d
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  02d908010 =  1:  cbafb3c7a lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  e12c346ac =  2:  74020b9af lib/, src/: Use eprintf() instead of its pattern
 3:  4aa7af55d =  3:  cf954ecaa lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  2c1ddba14 =  4:  837b982ed lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  05a2edec1 =  5:  455888065 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  46c76c318 =  6:  b68d049f8 lib/io/syslog.h: Rename local variable
 7:  a575498c1 =  7:  960680cb7 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  82c19e705 =  8:  e9b79a845 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  ecc37d893 =  9:  936cc98ea lib/io/fprintf/: [v]fprinte(): Add function
10:  c863844f9 = 10:  390ba8cd0 lib/io/fprintf/: [v]eprinte(): Add function
11:  1e9a50f84 = 11:  391403416 lib/, src/: Use eprinte() instead of its pattern
12:  55430e2a4 = 12:  d0bbfdb43 lib/: Use [v]fprinte() instead of its pattern
13:  3ae20d047 = 13:  e3bd861f6 lib/io/syslog.h: SYSLOGE(): Add macro
14:  68d8690f6 = 14:  850e7c0dd src/userdel.c: Fix error message
15:  5f726c811 = 15:  9c8c33d07 lib/, src/: Use SYSLOGE() instead of its pattern
v9e
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  cbafb3c7a =  1:  0b062b7ab lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  74020b9af =  2:  fc83647ee lib/, src/: Use eprintf() instead of its pattern
 3:  cf954ecaa =  3:  2fa5ec3af lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  837b982ed =  4:  bef3c7b3e lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  455888065 =  5:  589ecf478 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  b68d049f8 =  6:  2582d6fd5 lib/io/syslog.h: Rename local variable
 7:  960680cb7 =  7:  fc508610d lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  e9b79a845 =  8:  99033cfa3 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  936cc98ea =  9:  7fc6f4f8d lib/io/fprintf/: [v]fprinte(): Add function
10:  390ba8cd0 = 10:  137e9e6b5 lib/io/fprintf/: [v]eprinte(): Add function
11:  391403416 = 11:  abf5cf226 lib/, src/: Use eprinte() instead of its pattern
12:  d0bbfdb43 = 12:  d6fc5087f lib/: Use [v]fprinte() instead of its pattern
13:  e3bd861f6 = 13:  9e78e35a3 lib/io/syslog.h: SYSLOGE(): Add macro
14:  850e7c0dd = 14:  b64a7c895 src/userdel.c: Fix error message
15:  9c8c33d07 = 15:  42e67581b lib/, src/: Use SYSLOGE() instead of its pattern
v9f
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  0b062b7ab =  1:  9f8e483ca lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  fc83647ee =  2:  700943415 lib/, src/: Use eprintf() instead of its pattern
 3:  2fa5ec3af =  3:  2233e855c lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  bef3c7b3e =  4:  b60d327c0 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  589ecf478 =  5:  96cbea968 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  2582d6fd5 =  6:  14d733842 lib/io/syslog.h: Rename local variable
 7:  fc508610d =  7:  421ede5c2 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  99033cfa3 =  8:  e163f529c lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  7fc6f4f8d =  9:  3e61317ec lib/io/fprintf/: [v]fprinte(): Add function
10:  137e9e6b5 = 10:  94bcd9cf8 lib/io/fprintf/: [v]eprinte(): Add function
11:  abf5cf226 = 11:  48efa1f24 lib/, src/: Use eprinte() instead of its pattern
12:  d6fc5087f = 12:  c868ea466 lib/: Use [v]fprinte() instead of its pattern
13:  9e78e35a3 = 13:  dfc65a8c0 lib/io/syslog.h: SYSLOGE(): Add macro
14:  b64a7c895 = 14:  ed7db160a src/userdel.c: Fix error message
15:  42e67581b = 15:  da27e3c62 lib/, src/: Use SYSLOGE() instead of its pattern
v9g
  • Rebase
$ git range-diff gh/strerrno..gh/eprintf strerrno..eprintf 
 1:  9f8e483ca =  1:  f56341565 lib/io/fprintf/: eprintf(): Add function to print to stderr
 2:  700943415 =  2:  aec585294 lib/, src/: Use eprintf() instead of its pattern
 3:  2233e855c =  3:  7dddf5f6a lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  b60d327c0 =  4:  153e846e5 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 5:  96cbea968 =  5:  9540ad6b0 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  14d733842 =  6:  1098d5a3e lib/io/syslog.h: Rename local variable
 7:  421ede5c2 =  7:  43211534d lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  e163f529c =  8:  be07d8008 lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  3e61317ec =  9:  7ee12ae26 lib/io/fprintf/: [v]fprinte(): Add function
10:  94bcd9cf8 = 10:  597c3a530 lib/io/fprintf/: [v]eprinte(): Add function
11:  48efa1f24 = 11:  97463e4c1 lib/, src/: Use eprinte() instead of its pattern
12:  c868ea466 = 12:  f52b801f6 lib/: Use [v]fprinte() instead of its pattern
13:  dfc65a8c0 = 13:  1aa7d44ee lib/io/syslog.h: SYSLOGE(): Add macro
14:  ed7db160a = 14:  54d5bb3b0 src/userdel.c: Fix error message
15:  da27e3c62 = 15:  ed333898f lib/, src/: Use SYSLOGE() instead of its pattern

v10: #1289 (comment)

v10b
  • Reorder commits, to allow splitting some to a separate PR.
$ git range-diff gh/strerrno gh/eprintf eprintf 
 1:  98037675f =  1:  98037675f lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 4:  195845666 !  2:  165b4829c lib/: Move <syslog.h> wrappers to "io/syslog.h"
    @@ Commit message
     
      ## lib/Makefile.am ##
     @@ lib/Makefile.am: libshadow_la_SOURCES = \
    +   hushed.c \
    +   idmapping.h \
        idmapping.c \
    -   io/fprintf/eprintf.c \
    -   io/fprintf/eprintf.h \
     +  io/syslog.c \
     +  io/syslog.h \
        isexpired.c \
 5:  a01badd0c =  3:  da9c94103 lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 6:  eebd42541 =  4:  85f5dc585 lib/io/syslog.h: Rename local variable
 7:  fbfc7f153 =  5:  76c47f951 lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 8:  0d5c45361 =  6:  a81bb672d lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 2:  e1bcd94ab !  7:  c52eb077a lib/io/fprintf/: eprintf(): Add function to print to stderr
    @@ lib/Makefile.am: libshadow_la_SOURCES = \
        idmapping.c \
     +  io/fprintf/eprintf.c \
     +  io/fprintf/eprintf.h \
    +   io/syslog.c \
    +   io/syslog.h \
        isexpired.c \
    -   limits.c \
    -   list.c \
     
      ## lib/io/fprintf/eprintf.c (new) ##
     @@
 3:  11e991ed7 =  8:  96059fad4 lib/, src/: Use eprintf() instead of its pattern
 9:  f9da6bae3 =  9:  167e37962 lib/io/fprintf/: [v]fprinte(): Add function
10:  f7ae0caaa = 10:  822fd0b48 lib/io/fprintf/: [v]eprinte(): Add function
11:  bc9967364 = 11:  d0d4efc55 lib/, src/: Use eprinte() instead of its pattern
12:  add0f7870 = 12:  631c5be81 lib/: Use [v]fprinte() instead of its pattern
13:  7a4d5bed0 = 13:  2030ded26 lib/io/syslog.h: SYSLOGE(): Add macro
14:  957e9ab3e = 14:  413c1dfc0 src/userdel.c: Fix error message
15:  6a4975da0 = 15:  870c5c7cb lib/, src/: Use SYSLOGE() instead of its pattern
v11
$ git diff gh/eprintf..eprintf
$
$ git range-diff gh/strerrno..gh/eprintf gh/syslog_c..eprintf 
 1:  98037675f <  -:  --------- lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
 2:  165b4829c <  -:  --------- lib/: Move <syslog.h> wrappers to "io/syslog.h"
 3:  da9c94103 <  -:  --------- lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 4:  85f5dc585 <  -:  --------- lib/io/syslog.h: Rename local variable
 5:  76c47f951 <  -:  --------- lib/io/syslog.h: SYSLOG_C(): Use a single local variable
 6:  a81bb672d <  -:  --------- lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
 9:  167e37962 !  1:  f9a2c5170 lib/io/fprintf/: [v]fprinte(): Add function
    @@ Commit message
     
      ## lib/Makefile.am ##
     @@ lib/Makefile.am: libshadow_la_SOURCES = \
    +   hushed.c \
    +   idmapping.h \
        idmapping.c \
    -   io/fprintf/eprintf.c \
    -   io/fprintf/eprintf.h \
     +  io/fprintf/fprinte.c \
     +  io/fprintf/fprinte.h \
        io/syslog.c \
12:  631c5be81 =  2:  cd56367d3 lib/: Use [v]fprinte() instead of its pattern
13:  2030ded26 =  3:  3bf242849 lib/io/syslog.h: SYSLOGE(): Add macro
15:  870c5c7cb !  4:  ae21a2a32 lib/, src/: Use SYSLOGE() instead of its pattern
    @@ lib/setugid.c: int change_uid (const struct passwd *info)
     
      ## src/groupadd.c ##
     @@
    + #include "defines.h"
    + #include "getdef.h"
      #include "groupio.h"
    - #include "io/fprintf/eprinte.h"
    - #include "io/fprintf/eprintf.h"
     +#include "io/syslog.h"
      #include "nscd.h"
      #include "sssd.h"
    @@ src/groupadd.c
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
        /* And now open the databases */
        if (gr_open (O_CREAT | O_RDWR) == 0) {
    -           eprinte(_("%s: cannot open %s"), Prog, gr_dbname());
    +           fprintf(stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
     -          SYSLOG(LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno());
     +          SYSLOGE(LOG_WARN, "cannot open %s", gr_dbname());
                fail_exit (E_GRP_UPDATE);
        }
      
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    -   if (is_shadow_grp) {
    -           if (sgr_open (O_CREAT | O_RDWR) == 0) {
    -                   eprinte(_("%s: cannot open %s"), Prog, sgr_dbname());
    +                   fprintf (stderr,
    +                            _("%s: cannot open %s: %s\n"),
    +                            Prog, sgr_dbname(), strerrno());
     -                  SYSLOG(LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno());
     +                  SYSLOGE(LOG_WARN, "cannot open %s", sgr_dbname());
                        fail_exit (E_GRP_UPDATE);
    @@ src/suauth.c: check_su_auth(const char *actual_id, const char *wanted_id, bool s
     
      ## src/userdel.c ##
     @@
    + #include "defines.h"
    + #include "getdef.h"
      #include "groupio.h"
    - #include "io/fprintf/eprinte.h"
    - #include "io/fprintf/eprintf.h"
     +#include "io/syslog.h"
      #include "nscd.h"
      #include "sssd.h"
      #include "prototypes.h"
     @@ src/userdel.c: static bool remove_mailbox (void)
    -                   return 0;
    -           } else {
    -                   eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    +                   fprintf (stderr,
    +                            _("%s: warning: can't remove %s: %s\n"),
    +                           Prog, mailfile, strerrno());
     -                  SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
     +                  SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
                                      "delete-mail-file",
     @@ src/userdel.c: static bool remove_mailbox (void)
    -   if (fflg) {
    -           if (unlink (mailfile) != 0) {
    -                   eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    +                   fprintf (stderr,
    +                            _("%s: warning: can't remove %s: %s\n"),
    +                           Prog, mailfile, strerrno());
     -                  SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
     +                  SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
                                      "delete-mail-file",
     @@ src/userdel.c: static bool remove_mailbox (void)
    -   }
    -   if (unlink (mailfile) != 0) {
    -           eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    +           fprintf (stderr,
    +                    _("%s: warning: can't remove %s: %s\n"),
    +                    Prog, mailfile, strerrno());
     -          SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
     +          SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
 7:  c52eb077a !  5:  5380dd557 lib/io/fprintf/: eprintf(): Add function to print to stderr
    @@ lib/Makefile.am: libshadow_la_SOURCES = \
        idmapping.c \
     +  io/fprintf/eprintf.c \
     +  io/fprintf/eprintf.h \
    +   io/fprintf/fprinte.c \
    +   io/fprintf/fprinte.h \
        io/syslog.c \
    -   io/syslog.h \
    -   isexpired.c \
     
      ## lib/io/fprintf/eprintf.c (new) ##
     @@
 8:  96059fad4 !  6:  57af7fdc3 lib/, src/: Use eprintf() instead of its pattern
    @@ src/groupadd.c
      #include "getdef.h"
      #include "groupio.h"
     +#include "io/fprintf/eprintf.h"
    + #include "io/syslog.h"
      #include "nscd.h"
      #include "sssd.h"
    - #include "prototypes.h"
     @@ src/groupadd.c: grp_update(void)
                ul = user_list;
                while (NULL != (u = strsep(&ul, ","))) {
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
        if (gr_open (O_CREAT | O_RDWR) == 0) {
     -          fprintf(stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
     +          eprintf(_("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
    -           SYSLOG(LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno());
    +           SYSLOGE(LOG_WARN, "cannot open %s", gr_dbname());
                fail_exit (E_GRP_UPDATE);
        }
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
     -                           _("%s: cannot open %s: %s\n"),
     -                           Prog, sgr_dbname(), strerrno());
     +                  eprintf(_("%s: cannot open %s: %s\n"), Prog, sgr_dbname(), strerrno());
    -                   SYSLOG(LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno());
    +                   SYSLOGE(LOG_WARN, "cannot open %s", sgr_dbname());
                        fail_exit (E_GRP_UPDATE);
                }
     @@ src/groupadd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/userdel.c
      #include "getdef.h"
      #include "groupio.h"
     +#include "io/fprintf/eprintf.h"
    + #include "io/syslog.h"
      #include "nscd.h"
      #include "sssd.h"
    - #include "prototypes.h"
     @@ src/userdel.c: static void update_groups (bool process_selinux)
                 */
                ngrp = __gr_dup (grp);
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                           _("%s: warning: can't remove %s: %s\n"),
     +                  eprintf(_("%s: warning: can't remove %s: %s\n"),
                                Prog, mailfile, strerrno());
    -                   SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +                   SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
     @@ src/userdel.c: static bool remove_mailbox (void)
      
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                           _("%s: warning: can't remove %s: %s\n"),
     +                  eprintf(_("%s: warning: can't remove %s: %s\n"),
                                Prog, mailfile, strerrno());
    -                   SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +                   SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
     @@ src/userdel.c: static bool remove_mailbox (void)
        }
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                   _("%s: warning: can't remove %s: %s\n"),
     -                   Prog, mailfile, strerrno());
     +          eprintf(_("%s: warning: can't remove %s: %s\n"), Prog, mailfile, strerrno());
    -           SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +           SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                audit_logger (AUDIT_DEL_USER, Prog,
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
10:  822fd0b48 =  7:  591a84760 lib/io/fprintf/: [v]eprinte(): Add function
11:  d0d4efc55 !  8:  0c9e404a3 lib/, src/: Use eprinte() instead of its pattern
    @@ src/groupadd.c
      #include "groupio.h"
     +#include "io/fprintf/eprinte.h"
      #include "io/fprintf/eprintf.h"
    + #include "io/syslog.h"
      #include "nscd.h"
    - #include "sssd.h"
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
      
        /* And now open the databases */
        if (gr_open (O_CREAT | O_RDWR) == 0) {
     -          eprintf(_("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
     +          eprinte(_("%s: cannot open %s"), Prog, gr_dbname());
    -           SYSLOG(LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno());
    +           SYSLOGE(LOG_WARN, "cannot open %s", gr_dbname());
                fail_exit (E_GRP_UPDATE);
        }
     @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
                if (sgr_open (O_CREAT | O_RDWR) == 0) {
     -                  eprintf(_("%s: cannot open %s: %s\n"), Prog, sgr_dbname(), strerrno());
     +                  eprinte(_("%s: cannot open %s"), Prog, sgr_dbname());
    -                   SYSLOG(LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno());
    +                   SYSLOGE(LOG_WARN, "cannot open %s", sgr_dbname());
                        fail_exit (E_GRP_UPDATE);
                }
     
    @@ src/userdel.c
      #include "groupio.h"
     +#include "io/fprintf/eprinte.h"
      #include "io/fprintf/eprintf.h"
    + #include "io/syslog.h"
      #include "nscd.h"
    - #include "sssd.h"
     @@ src/userdel.c: static bool remove_mailbox (void)
                        free(mailfile);
                        return 0;
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                  eprintf(_("%s: warning: can't remove %s: %s\n"),
     -                          Prog, mailfile, strerrno());
     +                  eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    -                   SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +                   SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
     @@ src/userdel.c: static bool remove_mailbox (void)
    @@ src/userdel.c: static bool remove_mailbox (void)
     -                  eprintf(_("%s: warning: can't remove %s: %s\n"),
     -                          Prog, mailfile, strerrno());
     +                  eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    -                   SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +                   SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
     @@ src/userdel.c: static bool remove_mailbox (void)
    @@ src/userdel.c: static bool remove_mailbox (void)
        if (unlink (mailfile) != 0) {
     -          eprintf(_("%s: warning: can't remove %s: %s\n"), Prog, mailfile, strerrno());
     +          eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
    -           SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
    +           SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
                audit_logger (AUDIT_DEL_USER, Prog,
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
14:  413c1dfc0 =  9:  4ae6b0399 src/userdel.c: Fix error message

v12: #1289 (comment)

v12b
  • Rebase.
$ git range-diff f9a2c5170^..59c9d208b se2..c0483feb0
 1:  f9a2c5170 =  1:  c9324c952 lib/io/fprintf/: [v]fprinte(): Add function
 2:  22d737344 =  2:  e1cb59b9e lib/: Use [v]fprinte() instead of its pattern
 3:  a79ac3072 =  3:  14f2b7c9f lib/io/syslog.h: SYSLOGE(): Add macro
 4:  9f5390550 =  4:  0bf285d61 lib/, src/: Use SYSLOGE() instead of its pattern
 5:  5013dd39b =  5:  f12cfbb6b lib/io/fprintf/: eprintf(): Add function to print to stderr
 6:  682f10445 =  6:  82135db03 lib/, src/: Use eprintf() instead of its pattern
 7:  71e868fd2 =  7:  2562ce8de lib/io/fprintf/: eprinte(): Add macro
 8:  c1249764e =  8:  ad4b855dd lib/, src/: Use eprinte() instead of its pattern
 9:  59c9d208b =  9:  c0483feb0 src/userdel.c: Fix error message
v12c
$ git range-diff se2..gh/eprintf  e..eprintf 
 1:  c9324c952 <  -:  --------- lib/io/fprintf/: [v]fprinte(): Add function
 2:  e1cb59b9e <  -:  --------- lib/: Use [v]fprinte() instead of its pattern
 3:  14f2b7c9f <  -:  --------- lib/io/syslog.h: SYSLOGE(): Add macro
 4:  0bf285d61 <  -:  --------- lib/, src/: Use SYSLOGE() instead of its pattern
 5:  f12cfbb6b =  1:  f12cfbb6b lib/io/fprintf/: eprintf(): Add function to print to stderr
 6:  82135db03 =  2:  82135db03 lib/, src/: Use eprintf() instead of its pattern
 7:  2562ce8de =  3:  2562ce8de lib/io/fprintf/: eprinte(): Add macro
 8:  ad4b855dd =  4:  ad4b855dd lib/, src/: Use eprinte() instead of its pattern
 9:  c0483feb0 =  5:  c0483feb0 src/userdel.c: Fix error message
v12d
  • Rebase
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  f12cfbb6b = 1:  af91e3e35 lib/io/fprintf/: eprintf(): Add function to print to stderr
2:  82135db03 = 2:  f2ed153b7 lib/, src/: Use eprintf() instead of its pattern
3:  2562ce8de = 3:  017690e14 lib/io/fprintf/: eprinte(): Add macro
4:  ad4b855dd = 4:  2bb6eb674 lib/, src/: Use eprinte() instead of its pattern
5:  c0483feb0 = 5:  99c0a3a6a src/userdel.c: Fix error message
v13
  • Rebase
  • Implement APIs as macros.
  • Reduce header fields.
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  af91e3e35 < -:  --------- lib/io/fprintf/: eprintf(): Add function to print to stderr
-:  --------- > 1:  d23dfbd64 lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  f2ed153b7 ! 2:  60238f9c0 lib/, src/: Use eprintf() instead of its pattern
    @@ Commit message
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/chage.c ##
    -@@
    - #include "atoi/a2i/a2s.h"
    - #include "defines.h"
    - #include "fields.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "pwio.h"
     @@ src/chage.c: fail_exit (int code, bool process_selinux)
      {
        if (spw_locked) {
    @@ src/chfn.c: int main (int argc, char **argv)
      
     
      ## src/chgpasswd.c ##
    -@@
    - #include "atoi/str2i.h"
    - #include "defines.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "sssd.h"
     @@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
      {
        if (gr_locked) {
    @@ src/chgpasswd.c: int main (int argc, char **argv)
      
     
      ## src/chpasswd.c ##
    -@@
    - #include "chkhash.h"
    - #include "defines.h"
    - #include "getdef.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "sssd.h"
     @@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
      {
        if (pw_locked) {
    @@ src/expiry.c: int main (int argc, char **argv)
                exit (10);
     
      ## src/faillog.c ##
    -@@
    - /*@-exitarg@*/
    - #include "exitcodes.h"
    - #include "faillog.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "shadowlog.h"
     @@ src/faillog.c: static off_t lookup_faillog(struct faillog *fl, uid_t uid)
      
        /* Ensure multiplication does not overflow and retrieving a wrong entry */
    @@ src/getsubids.c: int main(int argc, char *argv[])
        for (i = 0; i < count; i++) {
     
      ## src/gpasswd.c ##
    -@@
    - /*@-exitarg@*/
    - #include "exitcodes.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/gpasswd.c: static bool is_valid_user_list (const char *users)
      
                /* local, no need for xgetpwnam */
    @@ src/gpasswd.c: int main (int argc, char **argv)
      
     
      ## src/groupadd.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "io/syslog.h"
    - #include "nscd.h"
     @@ src/groupadd.c: grp_update(void)
                ul = user_list;
                while (NULL != (u = strsep(&ul, ","))) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
      #endif                            /* !SHADOWGRP */
     
      ## src/lastlog.c ##
    -@@
    - /*@-exitarg@*/
    - #include "exitcodes.h"
    - #include "getdef.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "shadowlog.h"
     @@ src/lastlog.c: static void print_one (/*@null@*/const struct passwd *pw)
                 * empty entry in this case.
                 */
    @@ src/lastlog.c: int main (int argc, char **argv)
                }
     
      ## src/login.c ##
    -@@
    - #include "faillog.h"
    - #include "failure.h"
    - #include "getdef.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "pwauth.h"
     @@
      static pam_handle_t *pamh = NULL;
      
    @@ src/new_subid_range.c: int main(int argc, char *argv[])
        printf("Subuid range %lu:%lu\n", range.start, range.count);
     
      ## src/newgidmap.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "idmapping.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "shadowlog.h"
     @@ src/newgidmap.c: static void verify_ranges(struct passwd *pw, int ranges,
        mapping = mappings;
        for (idx = 0; idx < ranges; idx++, mapping++) {
    @@ src/newgidmap.c: int main(int argc, char **argv)
                        (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid);
     
      ## src/newgrp.c ##
    -@@
    - /*@-exitarg@*/
    - #include "exitcodes.h"
    - #include "getdef.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "search/l/lfind.h"
     @@ src/newgrp.c: int main (int argc, char **argv)
      
        pwd = get_my_pwent ();
    @@ src/newgrp.c: int main (int argc, char **argv)
      
     
      ## src/newuidmap.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "idmapping.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "prototypes.h"
    - #include "shadowlog.h"
     @@ src/newuidmap.c: static void verify_ranges(struct passwd *pw, int ranges,
        mapping = mappings;
        for (idx = 0; idx < ranges; idx++, mapping++) {
    @@ src/newuidmap.c: int main(int argc, char **argv)
                        (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid);
     
      ## src/newusers.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
      {
        if (spw_locked) {
    @@ src/newusers.c: int main (int argc, char **argv)
                }
     
      ## src/passwd.c ##
    -@@
    - #include "chkname.h"
    - #include "defines.h"
    - #include "getdef.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/passwd.c: static int new_password (const struct passwd *pw)
                        strzero (cipher);
                        SYSLOG(LOG_WARN, "incorrect password for %s", pw->pw_name);
    @@ src/su.c: int main (int argc, char **argv)
                (void) shell (shellstr, cp, environ);
     
      ## src/useradd.c ##
    -@@
    - #include "fs/mkstemp/fmkomstemp.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/useradd.c: static void fail_exit (int code, bool process_selinux)
      #endif
      
    @@ src/useradd.c: int main (int argc, char **argv)
      
     
      ## src/userdel.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "io/syslog.h"
    - #include "nscd.h"
     @@ src/userdel.c: static void update_groups (bool process_selinux)
                 */
                ngrp = __gr_dup (grp);
    @@ src/userdel.c: int main (int argc, char **argv)
                        audit_logger (AUDIT_ROLE_REMOVE, Prog,
     
      ## src/usermod.c ##
    -@@
    - #include "faillog.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/usermod.c: static int get_groups (char *list)
                 * string name.
                 */
    @@ src/usermod.c: int main (int argc, char **argv)
                        }
     
      ## src/vipw.c ##
    -@@
    - #include "defines.h"
    - #include "getdef.h"
    - #include "groupio.h"
    -+#include "io/fprintf/eprintf.h"
    - #include "io/fprintf/fprinte.h"
    - #include "nscd.h"
    - #include "prototypes.h"
     @@ src/vipw.c: static void vipwexit (const char *msg, int syserr, int ret)
      
        if (createedit) {
3:  017690e14 ! 3:  b3aba13f2 lib/io/fprintf/: eprinte(): Add macro
    @@ Commit message
     
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
    - ## lib/io/fprintf/fprinte.h ##
    + ## lib/io/fprintf.h ##
     @@
    - #include "attr.h"
    + // eprintf - stderr print formatted
    + #define eprintf(...)  fprintf(stderr, __VA_ARGS__)
      
    - 
    -+// eprinte - stderr print error
    ++// eprinte - stderr print errno
     +#define eprinte(...)  fprinte(stderr, __VA_ARGS__)
     +
    -+
    - format_attr(printf, 2, 3)
    - inline int fprinte(FILE *restrict stream, const char *restrict fmt, ...);
    - format_attr(printf, 2, 0)
    + // fprinte - FILE print errno
    + #define fprinte(stream, ...)       fprintec(stream, errno, __VA_ARGS__)
    + // vfprinte - va_list FILE print errno
4:  2bb6eb674 = 4:  bfac0a7f9 lib/, src/: Use eprinte() instead of its pattern
5:  99c0a3a6a = 5:  16cc12078 src/userdel.c: Fix error message
v13b
  • Rebase
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  d23dfbd64 = 1:  4fb6a85fe lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  60238f9c0 = 2:  a2bfb923f lib/, src/: Use eprintf() instead of its pattern
3:  b3aba13f2 = 3:  1ca3010ac lib/io/fprintf/: eprinte(): Add macro
4:  bfac0a7f9 = 4:  321f3110d lib/, src/: Use eprinte() instead of its pattern
5:  16cc12078 = 5:  85e28e216 src/userdel.c: Fix error message
v14
  • Rebase
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  4fb6a85fe = 1:  f2da3fd7a lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  a2bfb923f ! 2:  51fdf6f9c lib/, src/: Use eprintf() instead of its pattern
    @@ src/newgrp.c: int main (int argc, char **argv)
     -                   Prog);
     +          eprintf(_("%s: Cannot determine your user name.\n"), Prog);
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_CHGRP_ID, Prog,
    +           audit_logger (AUDIT_CHGRP_ID,
                              "changing", NULL, getuid (), SHADOW_AUDIT_FAILURE);
     @@ src/newgrp.c: int main (int argc, char **argv)
                 */
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
     +                  eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
                        SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname());
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ADD_USER, Prog,
    +                   audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void close_files (struct option_flags *flags)
                spw_locked = false;
        }
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
     +          eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
                SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_ADD_USER, Prog,
    +           audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void close_files (struct option_flags *flags)
      #ifdef ENABLE_SUBIDS
        if (is_sub_uid) {
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
     +                  eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname());
                        SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname());
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ADD_USER, Prog,
    +                   audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void close_files (struct option_flags *flags)
        }
        if (is_sub_gid) {
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
     +                  eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname());
                        SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname());
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ADD_USER, Prog,
    +                   audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void close_group_files (bool process_selinux)
                return;
      
    @@ src/useradd.c: static void close_group_files (bool process_selinux)
     +          eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname());
                SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname());
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_ADD_USER, Prog,
    +           audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void unlock_group_files (bool process_selinux)
      #ifdef    SHADOWGRP
        if (is_shadow_grp) {
    @@ src/useradd.c: static void unlock_group_files (bool process_selinux)
     +                  eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname());
                        SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname());
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ADD_USER, Prog,
    +                   audit_logger (AUDIT_ADD_USER,
     @@ src/useradd.c: static void unlock_group_files (bool process_selinux)
      static void open_files (bool process_selinux)
      {
    @@ src/useradd.c: static void grp_add (bool process_selinux)
     +          eprintf(_("%s: failed to prepare the new %s entry '%s'\n"),
                         Prog, gr_dbname (), grp.gr_name);
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_ADD_GROUP, Prog,
    +           audit_logger (AUDIT_ADD_GROUP,
     @@ src/useradd.c: static void grp_add (bool process_selinux)
         * Write out the new shadow group entries as well.
         */
    @@ src/useradd.c: static void grp_add (bool process_selinux)
     +          eprintf(_("%s: failed to prepare the new %s entry '%s'\n"),
                         Prog, sgr_dbname (), sgrp.sg_namp);
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_ADD_GROUP, Prog,
    +           audit_logger (AUDIT_ADD_GROUP,
     @@ src/useradd.c: static void tallylog_reset (const char *user_name)
      
        if (failed)
    @@ src/useradd.c: int main (int argc, char **argv)
     +                  eprintf(_("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),
                                 Prog, user_name, user_selinux);
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ROLE_ASSIGN, Prog,
    +                   audit_logger (AUDIT_ROLE_ASSIGN,
     @@ src/useradd.c: int main (int argc, char **argv)
                        copy_tree (def_usrtemplate, prefix_user_home, false, true,
                                   (uid_t)-1, user_id, (gid_t)-1, user_gid);
    @@ src/userdel.c: int main (int argc, char **argv)
     +                  eprintf(_("%s: user '%s' does not exist\n"),
                                 Prog, user_name);
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_DEL_USER, Prog,
    +                   audit_logger (AUDIT_DEL_USER,
     @@ src/userdel.c: int main (int argc, char **argv)
        if (rflg) {
                int home_owned = is_owner (user_id, user_home);
    @@ src/userdel.c: int main (int argc, char **argv)
     +                  eprintf(_("%s: warning: the user name %s to SELinux user mapping removal failed.\n"),
                                 Prog, user_name);
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_ROLE_REMOVE, Prog,
    +                   audit_logger (AUDIT_ROLE_REMOVE,
     
      ## src/usermod.c ##
     @@ src/usermod.c: static int get_groups (char *list)
    @@ src/usermod.c: int main (int argc, char **argv)
     +                          eprintf(_("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),
                                         Prog, user_name, user_selinux);
      #ifdef WITH_AUDIT
    -                           audit_logger (AUDIT_ROLE_ASSIGN, Prog,
    +                           audit_logger (AUDIT_ROLE_ASSIGN,
     @@ src/usermod.c: int main (int argc, char **argv)
                        }
                } else {
    @@ src/usermod.c: int main (int argc, char **argv)
     +                          eprintf(_("%s: warning: the user name %s to SELinux user mapping removal failed.\n"),
                                         Prog, user_name);
      #ifdef WITH_AUDIT
    -                           audit_logger (AUDIT_ROLE_REMOVE, Prog,
    +                           audit_logger (AUDIT_ROLE_REMOVE,
     @@ src/usermod.c: int main (int argc, char **argv)
                                        uflg ? user_newid  : (uid_t)-1,
                                        user_gid,
3:  1ca3010ac = 3:  d2d388352 lib/io/fprintf/: eprinte(): Add macro
4:  321f3110d ! 4:  366e77d48 lib/, src/: Use eprinte() instead of its pattern
    @@ src/userdel.c: static bool remove_mailbox (void)
     +                  eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
                        SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_DEL_USER, Prog,
    +                   audit_logger (AUDIT_DEL_USER,
     @@ src/userdel.c: static bool remove_mailbox (void)
      
        if (fflg) {
    @@ src/userdel.c: static bool remove_mailbox (void)
     +                  eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
                        SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
    -                   audit_logger (AUDIT_DEL_USER, Prog,
    +                   audit_logger (AUDIT_DEL_USER,
     @@ src/userdel.c: static bool remove_mailbox (void)
                return 0;               /* mailbox doesn't exist */
        }
    @@ src/userdel.c: static bool remove_mailbox (void)
     +          eprinte(_("%s: warning: can't remove %s"), Prog, mailfile);
                SYSLOGE(LOG_ERR, "Cannot remove %s", mailfile);
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_DEL_USER, Prog,
    +           audit_logger (AUDIT_DEL_USER,
     @@ src/userdel.c: static int remove_tcbdir (const char *user_name, uid_t user_id)
                return 1;
        }
5:  85e28e216 ! 5:  3214071d8 src/userdel.c: Fix error message
    @@ src/userdel.c: static bool remove_mailbox (void)
     -          SYSLOG(LOG_ERR, "%s not owned by %s, not removed", mailfile, strerrno());
     +          SYSLOG(LOG_ERR, "%s not owned by %s, not removed", mailfile, user_name);
      #ifdef WITH_AUDIT
    -           audit_logger (AUDIT_DEL_USER, Prog,
    +           audit_logger (AUDIT_DEL_USER,
                              "delete-mail-file",

v15: #1289 (comment)

v15b
  • Rebase
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  937a956ee = 1:  dae375ee4 lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  771951419 = 2:  32262f123 lib/, src/: Use eprintf() instead of its pattern
3:  b5075839d = 3:  d32a24767 lib/io/fprintf/: eprinte(): Add macro
4:  734ef3b7a = 4:  d18c50838 lib/, src/: Use eprinte() instead of its pattern
5:  06ffd61b0 = 5:  185fd3505 src/userdel.c: Fix error message
v15c
  • Rebase
$ git range-diff -U0 gh/e..gh/eprintf e..eprintf 
1:  dae375ee4 = 1:  6bad4e73d lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  32262f123 ! 2:  d4b5c7577 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chage.c: static void check_flags (int argc, int opt_index)
    -@@ src/chage.c: static void check_perms (struct option_flags *flags)
    +@@ src/chage.c: static void check_perms(const struct option_flags *flags)
    @@ src/chage.c: static void check_perms (struct option_flags *flags)
    -@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    +@@ src/chage.c: static void open_files(bool readonly, const struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    -@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    +@@ src/chage.c: static void open_files(bool readonly, const struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    -@@ src/chage.c: static void close_files (struct option_flags *flags)
    +@@ src/chage.c: static void close_files(const struct option_flags *flags)
    @@ src/chage.c: static void close_files (struct option_flags *flags)
    -@@ src/chage.c: static void close_files (struct option_flags *flags)
    +@@ src/chage.c: static void close_files(const struct option_flags *flags)
    @@ src/chfn.c: static void check_perms (const struct passwd *pw)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    +@@ src/chfn.c: static void update_gecos(const char *user, char *gecos, const struct option_flag
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct opti
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    +@@ src/chfn.c: static void update_gecos(const char *user, char *gecos, const struct option_flag
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct opti
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    +@@ src/chfn.c: static void update_gecos(const char *user, char *gecos, const struct option_flag
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct opti
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    +@@ src/chfn.c: static void update_gecos(const char *user, char *gecos, const struct option_flag
    @@ src/chgpasswd.c: static void open_files (bool process_selinux)
    -@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/chgpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    -@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/chgpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/chpasswd.c: static void check_perms (void)
    -@@ src/chpasswd.c: static void open_files (struct option_flags *flags)
    +@@ src/chpasswd.c: static void open_files(const struct option_flags *flags)
    @@ src/chpasswd.c: static void open_files (struct option_flags *flags)
    -@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/chpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    -@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/chpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/chsh.c: static bool shell_is_listed (const char *sh)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    +@@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
    @@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flag
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    +@@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
    @@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flag
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    +@@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
    @@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flag
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    +@@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
    @@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flag
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    +@@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
    @@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flag
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, const struct option_
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct o
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, const struct option_
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct o
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, const struct option_
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct o
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, const struct option_
    @@ src/gpasswd.c: static void open_files (void)
    -@@ src/gpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/gpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/gpasswd.c: static void close_files (struct option_flags *flags)
    -@@ src/gpasswd.c: static void close_files (struct option_flags *flags)
    +@@ src/gpasswd.c: static void close_files(const struct option_flags *flags)
    @@ src/gpasswd.c: static void update_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    +@@ src/gpasswd.c: static void get_group(struct group *gr, const struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *fla
    -@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    +@@ src/gpasswd.c: static void get_group(struct group *gr, const struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *fla
    -@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    +@@ src/gpasswd.c: static void get_group(struct group *gr, const struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *fla
    -@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    +@@ src/gpasswd.c: static void get_group(struct group *gr, const struct option_flags *flags)
    @@ src/groupadd.c: static void
    -@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void close_files(const struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (struct option_flags *flags)
    -@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void close_files(const struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (struct option_flags *flags)
    -@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void open_files(const struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    -@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void open_files(const struct option_flags *flags)
    @@ src/groupdel.c: static void grp_update (void)
    -@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    +@@ src/groupdel.c: static void close_files(const struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (struct option_flags *flags)
    -@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    +@@ src/groupdel.c: static void close_files(const struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (struct option_flags *flags)
    -@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    +@@ src/groupdel.c: static void open_files(const struct option_flags *flags)
    @@ src/groupdel.c: static void open_files (struct option_flags *flags)
    -@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    +@@ src/groupdel.c: static void open_files(const struct option_flags *flags)
    @@ src/groupdel.c: static void open_files (struct option_flags *flags)
    -@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    +@@ src/groupdel.c: static void open_files(const struct option_flags *flags)
    @@ src/groupmems.c
    - #include "alloc/malloc.h"
    + #include "attr.h"
    @@ src/groupmems.c: static void process_flags (int argc, char **argv, struct option
    -@@ src/groupmems.c: static void check_perms (bool process_selinux)
    +@@ src/groupmems.c: check_perms(MAYBE_UNUSED bool process_selinux)
    @@ src/groupmems.c: static void check_perms (bool process_selinux)
    -@@ src/groupmems.c: static void check_perms (bool process_selinux)
    +@@ src/groupmems.c: check_perms(MAYBE_UNUSED bool process_selinux)
    @@ src/groupmems.c: static void open_files (bool process_selinux)
    -@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    +@@ src/groupmems.c: static void close_files(const struct option_flags *flags)
    @@ src/groupmems.c: static void close_files (struct option_flags *flags)
    -@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    +@@ src/groupmems.c: static void close_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void process_flags (int argc, char **argv, struct option_
    -@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void close_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void close_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void close_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void lock_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void lock_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void lock_files(const struct option_flags *flags)
    @@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    -@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    +@@ src/groupmod.c: static void lock_files(const struct option_flags *flags)
    @@ src/grpck.c: static void open_files (bool process_selinux)
    -@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/grpck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/grpck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/grpck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    +@@ src/grpck.c: static void check_grp_file(bool *errors, bool *changed, const struct option_flag
    @@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct opt
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    +@@ src/grpck.c: static void check_grp_file(bool *errors, bool *changed, const struct option_flag
    @@ src/grpconv.c: int main (int argc, char **argv)
    - #else                             /* !SHADOWGRP */
    - int main (MAYBE_UNUSED int argc, char **argv)
    + int
    + main(int, char **argv)
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - #else                             /* !SHADOWGRP */
    - int main (MAYBE_UNUSED int argc, char **argv)
    + int
    + main(int, char **argv)
    @@ src/newusers.c: static void check_flags (void)
    -@@ src/newusers.c: static void check_perms (struct option_flags *flags)
    +@@ src/newusers.c: check_perms(MAYBE_UNUSED const struct option_flags *flags)
    @@ src/newusers.c: static void check_perms (struct option_flags *flags)
    -@@ src/newusers.c: static void check_perms (struct option_flags *flags)
    +@@ src/newusers.c: check_perms(MAYBE_UNUSED const struct option_flags *flags)
    @@ src/newusers.c: static void open_files (bool process_selinux)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
    -@@ src/newusers.c: static void close_files (struct option_flags *flags)
    +@@ src/newusers.c: static void close_files(const struct option_flags *flags)
    @@ src/newusers.c: int main (int argc, char **argv)
    -           if (add_passwd (&newpw, fields[1]) != 0) {
    +           if (!streq(fields[1], "") && add_passwd(&newpw, fields[1]) != 0) {
    @@ src/newusers.c: int main (int argc, char **argv)
    -   /* Now update the passwords using PAM */
    -   for (size_t i = 0; i < nusers; i++) {
    +           if (streq(passwords[i], ""))
    +                   continue;
    @@ src/passwd.c: static char *update_crypt_pw (char *cp, bool process_selinux)
    -@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    +@@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
    @@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    -@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    +@@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
    @@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    -@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    +@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    @@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    -@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    +@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    @@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    -@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    +@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    @@ src/pwck.c: static void process_flags (int argc, char **argv, struct option_flag
    -@@ src/pwck.c: static void open_files (struct option_flags *flags)
    +@@ src/pwck.c: static void open_files(const struct option_flags *flags)
    @@ src/pwck.c: static void open_files (struct option_flags *flags)
    -@@ src/pwck.c: static void open_files (struct option_flags *flags)
    +@@ src/pwck.c: static void open_files(const struct option_flags *flags)
    @@ src/pwck.c: static void open_files (struct option_flags *flags)
    -@@ src/pwck.c: static void open_files (struct option_flags *flags)
    +@@ src/pwck.c: static void open_files(const struct option_flags *flags)
    @@ src/pwck.c: static void open_files (struct option_flags *flags)
    -@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/pwck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/pwck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/pwck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    +@@ src/pwck.c: static void close_files(bool changed, const struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    +@@ src/pwck.c: static void check_pw_file(bool *errors, bool *changed, const struct option_flags
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct optio
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    +@@ src/pwck.c: static void check_pw_file(bool *errors, bool *changed, const struct option_flags
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct optio
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    +@@ src/pwck.c: static void check_pw_file(bool *errors, bool *changed, const struct option_flags
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct optio
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    +@@ src/pwck.c: static void check_pw_file(bool *errors, bool *changed, const struct option_flags
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct optio
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    +@@ src/pwck.c: static void check_pw_file(bool *errors, bool *changed, const struct option_flags
    @@ src/useradd.c: static void fail_exit (int code, bool process_selinux)
    -@@ src/useradd.c: get_defaults(struct option_flags *flags)
    +@@ src/useradd.c: get_defaults(const struct option_flags *flags)
    @@ src/useradd.c: get_defaults(struct option_flags *flags)
    -@@ src/useradd.c: get_defaults(struct option_flags *flags)
    +@@ src/useradd.c: get_defaults(const struct option_flags *flags)
    @@ src/useradd.c: get_defaults(struct option_flags *flags)
    -@@ src/useradd.c: get_defaults(struct option_flags *flags)
    +@@ src/useradd.c: get_defaults(const struct option_flags *flags)
    @@ src/useradd.c: set_defaults(void)
    -@@ src/useradd.c: static int get_groups (char *list, struct option_flags *flags)
    +@@ src/useradd.c: static int get_groups(char *list, const struct option_flags *flags)
    @@ src/useradd.c: static int get_groups (char *list, struct option_flags *flags)
    -@@ src/useradd.c: static int get_groups (char *list, struct option_flags *flags)
    +@@ src/useradd.c: static int get_groups(char *list, const struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_f
    -@@ src/useradd.c: static void close_files (struct option_flags *flags)
    +@@ src/useradd.c: static void close_files(const struct option_flags *flags)
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
    -@@ src/useradd.c: static void close_files (struct option_flags *flags)
    +@@ src/useradd.c: static void close_files(const struct option_flags *flags)
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
    -@@ src/useradd.c: static void close_files (struct option_flags *flags)
    +@@ src/useradd.c: static void close_files(const struct option_flags *flags)
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
    -@@ src/useradd.c: static void close_files (struct option_flags *flags)
    +@@ src/useradd.c: static void close_files(const struct option_flags *flags)
    @@ src/useradd.c: static void close_files (struct option_flags *flags)
    -@@ src/useradd.c: static void close_files (struct option_flags *flags)
    +@@ src/useradd.c: static void close_files(const struct option_flags *flags)
    @@ src/useradd.c: usr_update (unsigned long subuid_count, unsigned long subgid_coun
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_home (struct option_flags *flags)
    +@@ src/useradd.c: static void create_home(const struct option_flags *flags)
    @@ src/useradd.c: static void create_home (struct option_flags *flags)
    -@@ src/useradd.c: static void create_mail (struct option_flags *flags)
    +@@ src/useradd.c: static void create_mail(const struct option_flags *flags)
    @@ src/useradd.c: static void create_mail (struct option_flags *flags)
    -@@ src/useradd.c: static void create_mail (struct option_flags *flags)
    +@@ src/useradd.c: static void create_mail(const struct option_flags *flags)
    @@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/userdel.c: static void close_files (struct option_flags *flags)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/userdel.c: static void close_files (struct option_flags *flags)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/userdel.c: static void close_files (struct option_flags *flags)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/userdel.c: static void close_files (struct option_flags *flags)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/userdel.c: static void close_files (struct option_flags *flags)
    -@@ src/userdel.c: static void close_files (struct option_flags *flags)
    +@@ src/userdel.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void close_files (struct option_flags *flags)
    -@@ src/usermod.c: static void close_files (struct option_flags *flags)
    +@@ src/usermod.c: static void close_files(const struct option_flags *flags)
    @@ src/usermod.c: static void open_files (bool process_selinux)
    -@@ src/usermod.c: static void usr_update (struct option_flags *flags)
    +@@ src/usermod.c: static void usr_update(const struct option_flags *flags)
    @@ src/usermod.c: static void usr_update (struct option_flags *flags)
    -@@ src/usermod.c: static void usr_update (struct option_flags *flags)
    +@@ src/usermod.c: static void usr_update(const struct option_flags *flags)
3:  d32a24767 = 3:  1732745e1 lib/io/fprintf/: eprinte(): Add macro
4:  d18c50838 ! 4:  8e5dbae99 lib/, src/: Use eprinte() instead of its pattern
    @@ src/groupadd.c
    -@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void open_files(const struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (struct option_flags *flags)
    -@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    +@@ src/groupadd.c: static void open_files(const struct option_flags *flags)
    @@ src/newusers.c: static int update_passwd (struct passwd *pwd, const char *passwo
    -@@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    +@@ src/newusers.c: add_passwd(struct passwd *pwd, MAYBE_UNUSED const char *password)
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    -@@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    +@@ src/newusers.c: add_passwd(struct passwd *pwd, MAYBE_UNUSED const char *password)
    @@ src/newusers.c: int main (int argc, char **argv)
    -           usernames = REALLOCF(usernames, nusers, char *);
    -           passwords = REALLOCF(passwords, nusers, char *);
    +           usernames = reallocf_T(usernames, nusers, char *);
    +           passwords = reallocf_T(passwords, nusers, char *);
    @@ src/usermod.c: prepend_range(const char *str, struct id_range_list_entry **head)
    -   entry = MALLOC(1, struct id_range_list_entry);
    +   entry = malloc_T(1, struct id_range_list_entry);
5:  185fd3505 = 5:  c1b93d2ec src/userdel.c: Fix error message

v16: #1289 (comment)

v16b
  • Rebase
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  4353e9a7e ! 1:  5c89f0981 lib/io/fprintf/: eprintf(): Add macro to print to stderr
    @@ lib/io/fprintf.h
     +// eprintf - stderr print formatted
     +#define eprintf(...)  fprintf(stderr, __VA_ARGS__)
     +
    - // fprinte - FILE print errno
    - #define fprinte(stream, ...)       fprintec(stream, errno, __VA_ARGS__)
    - // vfprinte - va_list FILE print errno
    ++
    + // fprinte - FILE* print errno
    + #define fprinte(stream, ...)  do                                      \
    + {                                                                     \
2:  69edc43e8 = 2:  40a82ced1 lib/, src/: Use eprintf() instead of its pattern
3:  0938f9c97 ! 3:  593001d46 lib/io/fprintf/: eprinte(): Add macro
    @@ lib/io/fprintf.h
     +// eprinte - stderr print errno
     +#define eprinte(...)  fprinte(stderr, __VA_ARGS__)
     +
    - // fprinte - FILE print errno
    - #define fprinte(stream, ...)       fprintec(stream, errno, __VA_ARGS__)
    - // vfprinte - va_list FILE print errno
    + 
    + // fprinte - FILE* print errno
    + #define fprinte(stream, ...)  do                                      \
4:  57e0eafd6 = 4:  6e71c7410 lib/, src/: Use eprinte() instead of its pattern
5:  60a5920fd = 5:  08d4abe32 src/userdel.c: Fix error message

@alejandro-colomar
Copy link
Collaborator Author

I recommend reviewing the second commit with

$ git show HEAD^ --color-words=.

@alejandro-colomar alejandro-colomar linked an issue Jul 13, 2025 that may be closed by this pull request
@alejandro-colomar alejandro-colomar force-pushed the eprintf branch 3 times, most recently from 5fa8f9a to c3af808 Compare July 13, 2025 20:44
@ikerexxe
Copy link
Collaborator

I have some reservations about commits 1 and 2. Specifically, the new interface introduced isn't something I've commonly seen in other projects, even though I'm aware of its mention in the GCC documentation. From my perspective, it doesn't appear to offer a significant benefit here.

Furthermore, I'm concerned that commit 2 introduces changes across many files, which could make it quite challenging for distribution maintainers to backport future changes to their distributions. This could lead to a lot of friction and messy patch applications down the line.

On the other hand, I'm fine with the changes in commits 3 and 4. They look good to me.

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Jul 17, 2025

I have some reservations about commits 1 and 2. Specifically, the new interface introduced isn't something I've commonly seen in other projects, even though I'm aware of its mention in the GCC documentation. From my perspective, it doesn't appear to offer a significant benefit here.

Furthermore, I'm concerned that commit 2 introduces changes across many files, which could make it quite challenging for distribution maintainers to backport future changes to their distributions. This could lead to a lot of friction and messy patch applications down the line.

Yeah, I guess this would be a lot of work for distros. I'm fine not applying it for now; we can come back to it in the future.

On the other hand, I'm fine with the changes in commits 3 and 4. They look good to me.

I will split patches 3 and 4 to allow applying them separately.

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Jul 17, 2025

On the other hand, I plan to do a lot of work on error messages after this eprintf() patch, trying to unify them and use strerror(errno) more, which would significantly reduce translation work. This would similarly force distros to rebase their patches, so I don't see eprintf() as a huge added problem here.

But yeah, we have lower hanging fruits for now.

@alejandro-colomar alejandro-colomar marked this pull request as draft July 20, 2025 13:40
@alejandro-colomar alejandro-colomar marked this pull request as ready for review July 22, 2025 23:25
@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Jul 22, 2025

@ikerexxe

I think we now have strong reasons to merge this. See the bug fixed in a call to SYSLOG() (and fprintf()).

Edit: I've found more bugs after spending more time looking at these calls.

@alejandro-colomar alejandro-colomar linked an issue Jul 22, 2025 that may be closed by this pull request
@alejandro-colomar alejandro-colomar changed the title Add and use eprintf() Add and use eprintf(), and de-weirdify SYSLOG(()) Jul 22, 2025
@alejandro-colomar alejandro-colomar changed the title Add and use eprintf(), and de-weirdify SYSLOG(()) Add and use eprintf() and strerrno(), and de-weirdify SYSLOG(()) Jul 22, 2025
@alejandro-colomar alejandro-colomar force-pushed the eprintf branch 6 times, most recently from 97d7478 to 68dfb3a Compare July 23, 2025 20:51
@alejandro-colomar alejandro-colomar force-pushed the eprintf branch 2 times, most recently from 55cd6cb to 0a20d7b Compare August 16, 2025 20:32
@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Oct 19, 2025

v8
  • Rebase
$ git rd -U0 | tee /dev/tty | xclip -selection clipboard
 1:  4c7cdd81 =  1:  093ab3f0 lib/getdef.h: Add missing includes
 2:  c5f7d1ba =  2:  5f2879a5 lib/io/fprintf/: eprintf(): Add function to print to stderr
 3:  e9de5767 !  3:  224ebc52 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chage.c
    -@@ src/chage.c: fail_exit (int code)
    +@@ src/chage.c: fail_exit (int code, bool process_selinux)
    @@ src/chage.c: fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chage.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chage.c: fail_exit (int code)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void process_flags (int argc, char **argv)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void process_flags (int argc, char **argv)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void process_flags (int argc, char **argv)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void process_flags (int argc, char **argv)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void process_flags (int argc, char **argv)
    -@@ src/chage.c: static void process_flags (int argc, char **argv)
    +@@ src/chage.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chage.c: static void check_flags (int argc, int opt_index)
    -@@ src/chage.c: static void check_perms (void)
    +@@ src/chage.c: static void check_perms (struct option_flags *flags)
    @@ src/chage.c: static void check_perms (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void check_perms (void)
    -@@ src/chage.c: static void open_files (bool readonly)
    +@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    -@@ src/chage.c: static void open_files (bool readonly)
    +@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    -@@ src/chage.c: static void close_files (void)
    +@@ src/chage.c: static void close_files (struct option_flags *flags)
    @@ src/chage.c: static void close_files (void)
    - 	if (spw_close () == 0) {
    + 	if (spw_close (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void close_files (void)
    -@@ src/chage.c: static void close_files (void)
    +@@ src/chage.c: static void close_files (struct option_flags *flags)
    @@ src/chage.c: static void close_files (void)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void close_files (void)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chage.c: static void update_age (/*@null@*/const struct spwd *sp,
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void update_age (/*@null@*/const struct spwd *sp,
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: int main (int argc, char **argv)
    - 	check_perms ();
    + 	check_perms (&flags);
    @@ src/chage.c: int main (int argc, char **argv)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: int main (int argc, char **argv)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: int main (int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: int main (int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c
    -@@ src/chfn.c: static void fail_exit (int code)
    +@@ src/chfn.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chfn.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chfn.c: static void fail_exit (int code)
    -@@ src/chfn.c: static void process_flags (int argc, char **argv)
    +@@ src/chfn.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chfn.c: static void process_flags (int argc, char **argv)
    -@@ src/chfn.c: static void process_flags (int argc, char **argv)
    +@@ src/chfn.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chfn.c: static void process_flags (int argc, char **argv)
    -@@ src/chfn.c: static void process_flags (int argc, char **argv)
    +@@ src/chfn.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chfn.c: static void process_flags (int argc, char **argv)
    -@@ src/chfn.c: static void process_flags (int argc, char **argv)
    +@@ src/chfn.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chfn.c: static void check_perms (const struct passwd *pw)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    -@@ src/chfn.c: static void check_fields (void)
    +@@ src/chfn.c: static void check_fields (bool process_selinux)
    @@ src/chfn.c: static void check_fields (void)
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void check_fields (void)
    - 		fail_exit (E_NOPERM);
    @@ src/chfn.c: static void check_fields (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void check_fields (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void check_fields (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void check_fields (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: int main (int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: int main (int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: int main (int argc, char **argv)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chgpasswd.c
    -@@ src/chgpasswd.c: static void fail_exit (int code)
    +@@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chgpasswd.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void fail_exit (int code)
    -@@ src/chgpasswd.c: static void fail_exit (int code)
    +@@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chgpasswd.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void fail_exit (int code)
    -@@ src/chgpasswd.c: static void process_flags (int argc, char **argv)
    +@@ src/chgpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chgpasswd.c: static void process_flags (int argc, char **argv)
    -@@ src/chgpasswd.c: static void process_flags (int argc, char **argv)
    +@@ src/chgpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chgpasswd.c: static void check_perms (void)
    -@@ src/chgpasswd.c: static void open_files (void)
    +@@ src/chgpasswd.c: static void open_files (bool process_selinux)
    @@ src/chgpasswd.c: static void open_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void open_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void open_files (void)
    -@@ src/chgpasswd.c: static void open_files (void)
    +@@ src/chgpasswd.c: static void open_files (bool process_selinux)
    @@ src/chgpasswd.c: static void open_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void open_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void open_files (void)
    -@@ src/chgpasswd.c: static void close_files (void)
    +@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    @@ src/chgpasswd.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    -@@ src/chgpasswd.c: static void close_files (void)
    +@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    @@ src/chgpasswd.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chpasswd.c
    -@@ src/chpasswd.c: static void fail_exit (int code)
    +@@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chpasswd.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void fail_exit (int code)
    -@@ src/chpasswd.c: static void fail_exit (int code)
    +@@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chpasswd.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void fail_exit (int code)
    -@@ src/chpasswd.c: static void process_flags (int argc, char **argv)
    +@@ src/chpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/chpasswd.c: static void check_perms (void)
    -@@ src/chpasswd.c: static void open_files (void)
    +@@ src/chpasswd.c: static void open_files (struct option_flags *flags)
    @@ src/chpasswd.c: static void open_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void open_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void open_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void open_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void open_files (void)
    -@@ src/chpasswd.c: static void close_files (void)
    - {
    +@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    + 
    @@ src/chpasswd.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    -@@ src/chpasswd.c: static void close_files (void)
    +@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    @@ src/chpasswd.c: static void close_files (void)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/chpasswd.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c
    -@@ src/chsh.c: fail_exit (int code)
    +@@ src/chsh.c: fail_exit (int code, bool process_selinux)
    @@ src/chsh.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chsh.c: static bool shell_is_listed (const char *sh)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chsh.c: int main (int argc, char **argv)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chsh.c: int main (int argc, char **argv)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chsh.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: int main (int argc, char **argv)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/gpasswd.c: static bool is_valid_user_list (const char *users)
    -@@ src/gpasswd.c: static void process_flags (int argc, char **argv)
    +@@ src/gpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/gpasswd.c: static void process_flags (int argc, char **argv)
    -@@ src/gpasswd.c: static void process_flags (int argc, char **argv)
    +@@ src/gpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/gpasswd.c: static void open_files (void)
    -@@ src/gpasswd.c: static void log_gpasswd_success_group (MAYBE_UNUSED void *arg)
    - static void close_files (void)
    - {
    - 	if (gr_close () == 0) {
    +@@ src/gpasswd.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot;
    + 
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/gpasswd.c: static void log_gpasswd_success_group (MAYBE_UNUSED void *arg)
    -@@ src/gpasswd.c: static void close_files (void)
    +@@ src/gpasswd.c: static void close_files (struct option_flags *flags)
    @@ src/gpasswd.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/gpasswd.c: static void update_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    - #endif
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    + 	process_selinux = !flags->chroot;
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/groupadd.c: static void
    -@@ src/groupadd.c: static void close_files (void)
    - {
    +@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    + 
    @@ src/groupadd.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/groupadd.c: static void close_files (void)
    -@@ src/groupadd.c: static void close_files (void)
    +@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/groupadd.c: static void close_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    - {
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    + 
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void process_flags (int argc, char **argv)
    +@@ src/groupadd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/groupadd.c: static void process_flags (int argc, char **argv)
    -@@ src/groupadd.c: static void process_flags (int argc, char **argv)
    +@@ src/groupadd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/groupdel.c: static void grp_update (void)
    -@@ src/groupdel.c: static void close_files (void)
    - {
    +@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    + 
    @@ src/groupdel.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/groupdel.c: static void close_files (void)
    -@@ src/groupdel.c: static void close_files (void)
    +@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/groupdel.c: static void close_files (void)
    -@@ src/groupdel.c: static void open_files (void)
    - {
    +@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    + 
    @@ src/groupdel.c: static void open_files (void)
    -@@ src/groupdel.c: static void open_files (void)
    +@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    @@ src/groupdel.c: static void open_files (void)
    -@@ src/groupdel.c: static void open_files (void)
    +@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    @@ src/groupmems.c: static void add_user (const char *user,
    - 		fail_exit (EXIT_MEMBER_EXISTS);
    + 		fail_exit (EXIT_MEMBER_EXISTS, process_selinux);
    @@ src/groupmems.c: static void add_user (const char *user,
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void add_user (const char *user,
    - 				fail_exit (13);
    + 				fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void add_user (const char *user,
    - 			fail_exit (13);
    + 			fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void add_user (const char *user,
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    - 		fail_exit (EXIT_NOT_MEMBER);
    + 		fail_exit (EXIT_NOT_MEMBER, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    - 				fail_exit (13);
    + 				fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    - 			fail_exit (13);
    + 			fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void remove_user (const char *user,
    -@@ src/groupmems.c: static void purge_members (const struct group *grp)
    +@@ src/groupmems.c: static void purge_members (const struct group *grp, bool process_selinux)
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    -@@ src/groupmems.c: static void purge_members (const struct group *grp)
    +@@ src/groupmems.c: static void purge_members (const struct group *grp, bool process_selinux)
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    - 				fail_exit (13);
    + 				fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    -@@ src/groupmems.c: static void purge_members (const struct group *grp)
    +@@ src/groupmems.c: static void purge_members (const struct group *grp, bool process_selinux)
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    - 			fail_exit (13);
    + 			fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    -@@ src/groupmems.c: static void purge_members (const struct group *grp)
    +@@ src/groupmems.c: static void purge_members (const struct group *grp, bool process_selinux)
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    - 		fail_exit (13);
    + 		fail_exit (13, process_selinux);
    @@ src/groupmems.c: static void purge_members (const struct group *grp)
    -@@ src/groupmems.c: static void process_flags (int argc, char **argv)
    +@@ src/groupmems.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/groupmems.c: static void process_flags (int argc, char **argv)
    - 		fail_exit (EXIT_INVALID_USER);
    + 		fail_exit (EXIT_INVALID_USER, !flags->chroot);
    @@ src/groupmems.c: static void process_flags (int argc, char **argv)
    -@@ src/groupmems.c: static void check_perms (void)
    +@@ src/groupmems.c: static void check_perms (bool process_selinux)
    @@ src/groupmems.c: static void check_perms (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/groupmems.c: static void check_perms (void)
    -@@ src/groupmems.c: static void check_perms (void)
    +@@ src/groupmems.c: static void check_perms (bool process_selinux)
    @@ src/groupmems.c: static void check_perms (void)
    -@@ src/groupmems.c: static void fail_exit (int code)
    +@@ src/groupmems.c: static void fail_exit (int code, bool process_selinux)
    @@ src/groupmems.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void fail_exit (int code)
    -@@ src/groupmems.c: static void fail_exit (int code)
    +@@ src/groupmems.c: static void fail_exit (int code, bool process_selinux)
    @@ src/groupmems.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void fail_exit (int code)
    -@@ src/groupmems.c: static void open_files (void)
    +@@ src/groupmems.c: static void open_files (bool process_selinux)
    @@ src/groupmems.c: static void open_files (void)
    - 			fail_exit (EXIT_GROUP_FILE);
    + 			fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void open_files (void)
    -@@ src/groupmems.c: static void open_files (void)
    +@@ src/groupmems.c: static void open_files (bool process_selinux)
    @@ src/groupmems.c: static void open_files (void)
    - 				fail_exit (EXIT_GROUP_FILE);
    + 				fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void open_files (void)
    -@@ src/groupmems.c: static void open_files (void)
    +@@ src/groupmems.c: static void open_files (bool process_selinux)
    @@ src/groupmems.c: static void open_files (void)
    - 		fail_exit (EXIT_GROUP_FILE);
    + 		fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void open_files (void)
    - 			fail_exit (EXIT_GROUP_FILE);
    + 			fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void open_files (void)
    -@@ src/groupmems.c: static void open_files (void)
    - static void close_files (void)
    - {
    - 	if ((gr_close () == 0) && !list) {
    +@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot;
    + 
    + 	if ((gr_close (process_selinux) == 0) && !list) {
    @@ src/groupmems.c: static void open_files (void)
    - 		fail_exit (EXIT_GROUP_FILE);
    + 		fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void open_files (void)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void open_files (void)
    -@@ src/groupmems.c: static void close_files (void)
    +@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    @@ src/groupmems.c: static void close_files (void)
    - 		if ((sgr_close () == 0) && !list) {
    + 		if ((sgr_close (process_selinux) == 0) && !list) {
    @@ src/groupmems.c: static void close_files (void)
    - 			fail_exit (EXIT_GROUP_FILE);
    + 			fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void close_files (void)
    - 			if (sgr_unlock () == 0) {
    + 			if (sgr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_NOT_PRIMARY);
    + 			fail_exit (EXIT_NOT_PRIMARY, process_selinux);
    @@ src/groupmems.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_NOT_ROOT);
    + 			fail_exit (EXIT_NOT_ROOT, process_selinux);
    @@ src/groupmems.c: int main (int argc, char **argv)
    - 		fail_exit (EXIT_INVALID_GROUP);
    + 		fail_exit (EXIT_INVALID_GROUP, process_selinux);
    @@ src/groupmod.c: check_new_name(void)
    -@@ src/groupmod.c: static void process_flags (int argc, char **argv)
    +@@ src/groupmod.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/groupmod.c: static void process_flags (int argc, char **argv)
    -@@ src/groupmod.c: static void process_flags (int argc, char **argv)
    - static void close_files (void)
    - {
    - 	if (gr_close () == 0) {
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    + 
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/groupmod.c: static void process_flags (int argc, char **argv)
    -@@ src/groupmod.c: static void close_files (void)
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/groupmod.c: static void close_files (void)
    -@@ src/groupmod.c: static void close_files (void)
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (void)
    - 		if (pw_close () == 0) {
    + 		if (pw_close (process_selinux) == 0) {
    @@ src/groupmod.c: static void close_files (void)
    -@@ src/groupmod.c: static void prepare_failure_reports (void)
    - static void lock_files (void)
    - {
    +@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    + 
    @@ src/groupmod.c: static void prepare_failure_reports (void)
    -@@ src/groupmod.c: static void lock_files (void)
    +@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    @@ src/groupmod.c: static void lock_files (void)
    -@@ src/groupmod.c: static void lock_files (void)
    +@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    @@ src/groupmod.c: static void lock_files (void)
    -@@ src/groupmod.c: static void lock_files (void)
    +@@ src/groupmod.c: static void lock_files (struct option_flags *flags)
    @@ src/grpck.c
    - #include "shadowlog.h"
    -@@ src/grpck.c: static void fail_exit (int status)
    + #include "shadow/gshadow/gshadow.h"
    +@@ src/grpck.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpck.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void fail_exit (int status)
    -@@ src/grpck.c: static void fail_exit (int status)
    +@@ src/grpck.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpck.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void fail_exit (int status)
    -@@ src/grpck.c: static void process_flags (int argc, char **argv)
    +@@ src/grpck.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/grpck.c: static void process_flags (int argc, char **argv)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    - 			fail_exit (E_CANT_LOCK);
    + 			fail_exit (E_CANT_LOCK, process_selinux);
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    - 				fail_exit (E_CANT_LOCK);
    + 				fail_exit (E_CANT_LOCK, process_selinux);
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void close_files (bool changed)
    +@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (gr_close () == 0) {
    + 		if (gr_close (process_selinux) == 0) {
    @@ src/grpck.c: static void close_files (bool changed)
    - 			fail_exit (E_CANT_UPDATE);
    + 			fail_exit (E_CANT_UPDATE, process_selinux);
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (is_shadow && (sgr_close () == 0)) {
    + 		if (is_shadow && (sgr_close (process_selinux) == 0)) {
    @@ src/grpck.c: static void close_files (bool changed)
    - 			fail_exit (E_CANT_UPDATE);
    + 			fail_exit (E_CANT_UPDATE, process_selinux);
    @@ src/grpck.c: static void close_files (bool changed)
    -@@ src/grpck.c: static void close_files (bool changed)
    +@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void close_files (bool changed)
    -@@ src/grpck.c: static void close_files (bool changed)
    +@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void close_files (bool changed)
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    +@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    @@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    - 						fail_exit (E_CANT_UPDATE);
    + 						fail_exit (E_CANT_UPDATE, process_selinux);
    @@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    +@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    @@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    - 						fail_exit (E_CANT_UPDATE);
    + 						fail_exit (E_CANT_UPDATE, process_selinux);
    @@ src/grpconv.c
    -@@ src/grpconv.c: static void fail_exit (int status)
    +@@ src/grpconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpconv.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: static void fail_exit (int status)
    -@@ src/grpconv.c: static void fail_exit (int status)
    +@@ src/grpconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpconv.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	process_flags (argc, argv);
    + 	process_selinux = !flags.chroot;
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 			fail_exit (3);
    + 			fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 			fail_exit (3);
    + 			fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 			fail_exit (3);
    + 			fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (sgr_close () == 0) {
    + 	if (sgr_close (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (sgr_unlock () == 0) {
    + 	if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c
    -@@ src/grpunconv.c: static void fail_exit (int status)
    +@@ src/grpunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpunconv.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: static void fail_exit (int status)
    -@@ src/grpunconv.c: static void fail_exit (int status)
    +@@ src/grpunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpunconv.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 				fail_exit (3);
    + 				fail_exit (3, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	(void) sgr_close (); /* was only open O_RDONLY */
    + 	(void) sgr_close (process_selinux); /* was only open O_RDONLY */
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (unlink (SGROUP_FILE) != 0) {
    + 	if (unlink(_PATH_GSHADOW) != 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    --		         Prog, SGROUP_FILE);
    -+		eprintf(_("%s: cannot delete %s\n"), Prog, SGROUP_FILE);
    - 		SYSLOG ((LOG_ERR, "cannot delete %s", SGROUP_FILE));
    - 		fail_exit (3);
    +-		         Prog, _PATH_GSHADOW);
    ++		eprintf(_("%s: cannot delete %s\n"), Prog, _PATH_GSHADOW);
    + 		SYSLOG((LOG_ERR, "cannot delete %s", _PATH_GSHADOW));
    + 		fail_exit (3, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (sgr_unlock () == 0) {
    + 	if (sgr_unlock (process_selinux) == 0) {
    @@ src/login.c
    - #include "shadowlog.h"
    + #include "shadow/gshadow/endsgent.h"
    @@ src/newusers.c
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
    -@@ src/newusers.c: static void process_flags (int argc, char **argv)
    +@@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/newusers.c: static void process_flags (int argc, char **argv)
    -@@ src/newusers.c: static void process_flags (int argc, char **argv)
    +@@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/newusers.c: static void check_flags (void)
    -@@ src/newusers.c: static void check_perms (void)
    +@@ src/newusers.c: static void check_perms (struct option_flags *flags)
    @@ src/newusers.c: static void check_perms (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void check_perms (void)
    -@@ src/newusers.c: static void check_perms (void)
    +@@ src/newusers.c: static void check_perms (struct option_flags *flags)
    @@ src/newusers.c: static void check_perms (void)
    -@@ src/newusers.c: static void open_files (void)
    +@@ src/newusers.c: static void open_files (bool process_selinux)
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void open_files (void)
    +@@ src/newusers.c: static void open_files (bool process_selinux)
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void open_files (void)
    +@@ src/newusers.c: static void open_files (bool process_selinux)
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void open_files (void)
    +@@ src/newusers.c: static void open_files (bool process_selinux)
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void open_files (void)
    +@@ src/newusers.c: static void open_files (bool process_selinux)
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void open_files (void)
    - static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot;
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/newusers.c: static void open_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void open_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void open_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (is_sub_uid  && (sub_uid_close () == 0)) {
    + 	if (is_sub_uid  && (sub_uid_close (process_selinux) == 0)) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (is_sub_gid  && (sub_gid_close () == 0)) {
    + 	if (is_sub_gid  && (sub_gid_close (process_selinux) == 0)) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/passwd.c: static void print_status (const struct passwd *pw)
    -@@ src/passwd.c: fail_exit (int status)
    +@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    @@ src/passwd.c: fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/passwd.c: fail_exit (int status)
    -+			(void) eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    ++			eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    @@ src/passwd.c: fail_exit (int status)
    -@@ src/passwd.c: fail_exit (int status)
    +@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    @@ src/passwd.c: fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/passwd.c: fail_exit (int status)
    -+			(void) eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    ++			eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    @@ src/passwd.c: NORETURN
    - oom (void)
    + oom (bool process_selinux)
    @@ src/passwd.c: NORETURN
    -+	(void) eprintf(_("%s: out of memory\n"), Prog);
    - 	fail_exit (E_FAILURE);
    ++	eprintf(_("%s: out of memory\n"), Prog);
    + 	fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: NORETURN
    -@@ src/passwd.c: static char *update_crypt_pw (char *cp)
    +@@ src/passwd.c: static char *update_crypt_pw (char *cp, bool process_selinux)
    @@ src/passwd.c: static char *update_crypt_pw (char *cp)
    - 			fail_exit (E_FAILURE);
    + 			fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static char *update_crypt_pw (char *cp)
    -@@ src/passwd.c: static void update_noshadow (void)
    - 	struct passwd *npw;
    +@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_MISSING);
    + 		fail_exit (E_MISSING, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    -@@ src/passwd.c: static void update_noshadow (void)
    +@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    @@ src/passwd.c: static void update_noshadow (void)
    - 	npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
    + 	npw->pw_passwd = update_crypt_pw (npw->pw_passwd, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/passwd.c: static void update_noshadow (void)
    -+		(void) eprintf(_("%s: failure while writing changes to %s\n"),
    ++		eprintf(_("%s: failure while writing changes to %s\n"),
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/passwd.c: static void update_noshadow (void)
    -+		(void) eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    ++		eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    @@ src/passwd.c: static void update_noshadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    - 	struct spwd *nsp;
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    @@ src/passwd.c: static void update_shadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_shadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    - 		(void) spw_close ();
    - 		update_noshadow ();
    - 		if (spw_unlock () == 0) {
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    + 		(void) spw_close (process_selinux);
    + 		update_noshadow (flags);
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/passwd.c: static void update_shadow (void)
    -+			(void) eprintf(_("%s: failed to unlock %s\n"),
    ++			eprintf(_("%s: failed to unlock %s\n"),
    @@ src/passwd.c: static void update_shadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    @@ src/passwd.c: static void update_shadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_shadow (void)
    - 	if (spw_close () == 0) {
    + 	if (spw_close (process_selinux) == 0) {
    @@ src/passwd.c: static void update_shadow (void)
    -+		(void) eprintf(_("%s: failure while writing changes to %s\n"),
    ++		eprintf(_("%s: failure while writing changes to %s\n"),
    @@ src/passwd.c: static void update_shadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_shadow (void)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/passwd.c: static void update_shadow (void)
    -+		(void) eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    ++		eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    @@ src/passwd.c: main(int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/pwck.c
    -@@ src/pwck.c: static void fail_exit (int code)
    +@@ src/pwck.c: static void fail_exit (int code, bool process_selinux)
    @@ src/pwck.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void fail_exit (int code)
    -@@ src/pwck.c: static void fail_exit (int code)
    +@@ src/pwck.c: static void fail_exit (int code, bool process_selinux)
    @@ src/pwck.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void fail_exit (int code)
    -@@ src/pwck.c: static void process_flags (int argc, char **argv)
    +@@ src/pwck.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/pwck.c: static void process_flags (int argc, char **argv)
    -@@ src/pwck.c: static void process_flags (int argc, char **argv)
    +@@ src/pwck.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/pwck.c: static void process_flags (int argc, char **argv)
    -@@ src/pwck.c: static void open_files (void)
    +@@ src/pwck.c: static void open_files (struct option_flags *flags)
    @@ src/pwck.c: static void open_files (void)
    - 			fail_exit (E_CANTLOCK);
    + 			fail_exit (E_CANTLOCK, process_selinux);
    @@ src/pwck.c: static void open_files (void)
    - 				fail_exit (E_CANTLOCK);
    + 				fail_exit (E_CANTLOCK, process_selinux);
    @@ src/pwck.c: static void open_files (void)
    -@@ src/pwck.c: static void open_files (void)
    +@@ src/pwck.c: static void open_files (struct option_flags *flags)
    @@ src/pwck.c: static void open_files (void)
    -@@ src/pwck.c: static void open_files (void)
    +@@ src/pwck.c: static void open_files (struct option_flags *flags)
    @@ src/pwck.c: static void open_files (void)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    - 		if (pw_close () == 0) {
    + 		if (pw_close (process_selinux) == 0) {
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    - 			fail_exit (E_CANTUPDATE);
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    + 			fail_exit (E_CANTUPDATE, process_selinux);
    @@ src/pwck.c: static void close_files (bool changed)
    - 		if (spw_opened && (spw_close () == 0)) {
    + 		if (spw_opened && (spw_close (process_selinux) == 0)) {
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    - 					if (spw_unlock () == 0) {
    + 					if (spw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    - 						fail_exit (E_CANTUPDATE);
    + 						fail_exit (E_CANTUPDATE, process_selinux);
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    - 						fail_exit (E_CANTUPDATE);
    + 						fail_exit (E_CANTUPDATE, process_selinux);
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    - 			if (spw_opened && (spw_close () == 0)) {
    + 			if (spw_opened && (spw_close (process_selinux) == 0)) {
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    - 			if (spw_unlock () == 0) {
    + 			if (spw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: int main (int argc, char **argv)
    - 			fail_exit (E_CANTSORT);
    + 			fail_exit (E_CANTSORT, process_selinux);
    @@ src/pwck.c: int main (int argc, char **argv)
    - 				fail_exit (E_CANTSORT);
    + 				fail_exit (E_CANTSORT, process_selinux);
    @@ src/pwconv.c
    -@@ src/pwconv.c: static void fail_exit (int status)
    +@@ src/pwconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwconv.c: static void fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: static void fail_exit (int status)
    -@@ src/pwconv.c: static void fail_exit (int status)
    +@@ src/pwconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwconv.c: static void fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_PWDBUSY);
    + 		fail_exit (E_PWDBUSY, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_MISSING);
    + 		fail_exit (E_MISSING, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_PWDBUSY);
    + 		fail_exit (E_PWDBUSY, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 			fail_exit (E_FAILURE);
    + 			fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 			fail_exit (E_FAILURE);
    + 			fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 			fail_exit (E_FAILURE);
    + 			fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (spw_close () == 0) {
    + 	if (spw_close (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c
    -@@ src/pwunconv.c: static void fail_exit (int status)
    +@@ src/pwunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwunconv.c: static void fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: static void fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (5);
    + 		fail_exit (5, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 			fail_exit (3);
    + 			fail_exit (3, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	(void) spw_close (); /* was only open O_RDONLY */
    + 	(void) spw_close (process_selinux); /* was only open O_RDONLY */
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/useradd.c
    -@@ src/useradd.c: static void fail_exit (int code)
    +@@ src/useradd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (spw_locked && spw_unlock() == 0) {
    + 	if (spw_locked && spw_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (pw_locked && pw_unlock() == 0) {
    + 	if (pw_locked && pw_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (gr_locked && gr_unlock() == 0) {
    + 	if (gr_locked && gr_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sgr_locked && sgr_unlock() == 0) {
    + 	if (sgr_locked && sgr_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sub_uid_locked && sub_uid_unlock() == 0) {
    + 	if (sub_uid_locked && sub_uid_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sub_gid_locked && sub_gid_unlock() == 0) {
    + 	if (sub_gid_locked && sub_gid_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    -@@ src/useradd.c: get_defaults(void)
    +@@ src/useradd.c: get_defaults(struct option_flags *flags)
    @@ src/useradd.c: get_defaults(void)
    -@@ src/useradd.c: get_defaults(void)
    +@@ src/useradd.c: get_defaults(struct option_flags *flags)
    @@ src/useradd.c: get_defaults(void)
    - 			if (get_groups (cp) != 0) {
    + 			if (get_groups (cp, flags) != 0) {
    @@ src/useradd.c: get_defaults(void)
    -@@ src/useradd.c: get_defaults(void)
    +@@ src/useradd.c: get_defaults(struct option_flags *flags)
    @@ src/useradd.c: set_defaults(void)
    -@@ src/useradd.c: static int get_groups (char *list)
    +@@ src/useradd.c: static int get_groups (char *list, struct option_flags *flags)
    @@ src/useradd.c: static int get_groups (char *list)
    -@@ src/useradd.c: static int get_groups (char *list)
    +@@ src/useradd.c: static int get_groups (char *list, struct option_flags *flags)
    @@ src/useradd.c: static int get_groups (char *list)
    -@@ src/useradd.c: static struct group * get_local_group(char * grp_name)
    +@@ src/useradd.c: static struct group * get_local_group(char * grp_name, bool process_selinux)
    @@ src/useradd.c: static struct group * get_local_group(char * grp_name)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static struct group * get_local_group(char * grp_name)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);	/* XXX */
    -@@ src/useradd.c: static void grp_update (void)
    + 			fail_exit (E_GRP_UPDATE, process_selinux);	/* XXX */
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);
    -@@ src/useradd.c: static void grp_update (void)
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);	/* XXX */
    -@@ src/useradd.c: static void grp_update (void)
    + 			fail_exit (E_GRP_UPDATE, process_selinux);	/* XXX */
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    +@@ src/useradd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void process_flags (int argc, char **argv)
    - static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    - 	if (is_shadow_pwd && (spw_close () == 0)) {
    + 	if (is_shadow_pwd && (spw_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void process_flags (int argc, char **argv)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 	if (is_sub_uid  && (sub_uid_close () == 0)) {
    + 	if (is_sub_uid  && (sub_uid_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_SUB_UID_UPDATE);
    + 		fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    - 	if (is_sub_gid  && (sub_gid_close () == 0)) {
    + 	if (is_sub_gid  && (sub_gid_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_SUB_GID_UPDATE);
    + 		fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_group_files (void)
    +@@ src/useradd.c: static void close_group_files (bool process_selinux)
    @@ src/useradd.c: static void close_group_files (void)
    - 	if (gr_close() == 0) {
    + 	if (gr_close(process_selinux) == 0) {
    @@ src/useradd.c: static void close_group_files (void)
    - 		fail_exit(E_GRP_UPDATE);
    + 		fail_exit(E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_group_files (void)
    - 	if (is_shadow_grp && sgr_close() == 0) {
    + 	if (is_shadow_grp && sgr_close(process_selinux) == 0) {
    @@ src/useradd.c: static void close_group_files (void)
    - 		fail_exit(E_GRP_UPDATE);
    -@@ src/useradd.c: static void close_group_files (void)
    - static void unlock_group_files (void)
    + 		fail_exit(E_GRP_UPDATE, process_selinux);
    +@@ src/useradd.c: static void close_group_files (bool process_selinux)
    + static void unlock_group_files (bool process_selinux)
    @@ src/useradd.c: static void close_group_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_group_files (void)
    -@@ src/useradd.c: static void unlock_group_files (void)
    +@@ src/useradd.c: static void unlock_group_files (bool process_selinux)
    @@ src/useradd.c: static void unlock_group_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void unlock_group_files (void)
    -@@ src/useradd.c: static void unlock_group_files (void)
    - static void open_files (void)
    +@@ src/useradd.c: static void unlock_group_files (bool process_selinux)
    + static void open_files (bool process_selinux)
    @@ src/useradd.c: static void unlock_group_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void unlock_group_files (void)
    -@@ src/useradd.c: static void open_files (void)
    +@@ src/useradd.c: static void open_files (bool process_selinux)
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    -@@ src/useradd.c: static void open_files (void)
    - static void open_group_files (void)
    +@@ src/useradd.c: static void open_files (bool process_selinux)
    + static void open_group_files (bool process_selinux)
    @@ src/useradd.c: static void open_files (void)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_files (void)
    -@@ src/useradd.c: static void open_shadow (void)
    +@@ src/useradd.c: static void open_shadow (bool process_selinux)
    @@ src/useradd.c: static void open_shadow (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_shadow (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void open_shadow (void)
    -@@ src/useradd.c: static void grp_add (void)
    +@@ src/useradd.c: static void grp_add (bool process_selinux)
    @@ src/useradd.c: static void grp_add (void)
    -@@ src/useradd.c: static void grp_add (void)
    +@@ src/useradd.c: static void grp_add (bool process_selinux)
    @@ src/useradd.c: static void tallylog_reset (const char *user_name)
    -@@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
    +@@ src/useradd.c: usr_update (unsigned long subuid_count, unsigned long subgid_count,
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    -@@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
    +@@ src/useradd.c: usr_update (unsigned long subuid_count, unsigned long subgid_count,
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    - 		fail_exit (E_SUB_UID_UPDATE);
    + 		fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    - 		fail_exit (E_SUB_GID_UPDATE);
    + 		fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long
    -@@ src/useradd.c: static void create_home (void)
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    - 		fail_exit(E_HOMEDIR);
    + 		fail_exit(E_HOMEDIR, process_selinux);
    @@ src/useradd.c: static void create_home (void)
    - 
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    - 	if (set_selinux_file_context(prefix_user_home, S_IFDIR) != 0) {
    --		fprintf(stderr,
    --			_("%s: cannot set SELinux context for home directory %s\n"),
    -+		eprintf(_("%s: cannot set SELinux context for home directory %s\n"),
    - 			Prog, user_home);
    - 		fail_exit(E_HOMEDIR);
    - 	}
    -@@ src/useradd.c: static void create_home (void)
    + 	if (process_selinux) {
    + 		if (set_selinux_file_context(prefix_user_home, S_IFDIR) != 0) {
    +-			fprintf(stderr,
    +-				_("%s: cannot set SELinux context for home directory %s\n"),
    ++			eprintf(_("%s: cannot set SELinux context for home directory %s\n"),
    + 				Prog, user_home);
    + 			fail_exit(E_HOMEDIR, process_selinux);
    + 		}
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    - 				fail_exit(E_HOMEDIR);
    + 				fail_exit(E_HOMEDIR, process_selinux);
    @@ src/useradd.c: static void create_home (void)
    - 				fail_exit(E_HOMEDIR);
    + 				fail_exit(E_HOMEDIR, process_selinux);
    @@ src/useradd.c: static void create_home (void)
    - 				fail_exit(E_HOMEDIR);
    + 				fail_exit(E_HOMEDIR, process_selinux);
    @@ src/useradd.c: static void create_home (void)
    -@@ src/useradd.c: static void create_home (void)
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    - 			fail_exit(E_HOMEDIR);
    + 			fail_exit(E_HOMEDIR, process_selinux);
    @@ src/useradd.c: static void create_home (void)
    -@@ src/useradd.c: static void create_home (void)
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    -@@ src/useradd.c: static void create_home (void)
    +@@ src/useradd.c: static void create_home (struct option_flags *flags)
    + 	if (process_selinux) {
    + 		/* Reset SELinux to create files with default contexts */
    + 		if (reset_selinux_file_context() != 0) {
    +-			fprintf(stderr,
    +-				_("%s: cannot reset SELinux file creation context\n"),
    ++			eprintf(_("%s: cannot reset SELinux file creation context\n"),
    + 				Prog);
    + 			fail_exit(E_HOMEDIR, process_selinux);
    + 		}
    +@@ src/useradd.c: static void create_mail (struct option_flags *flags)
    @@ src/useradd.c: static void create_home (void)
    - 	/* Reset SELinux to create files with default contexts */
    - 	if (reset_selinux_file_context() != 0) {
    --		fprintf(stderr,
    --			_("%s: cannot reset SELinux file creation context\n"),
    -+		eprintf(_("%s: cannot reset SELinux file creation context\n"),
    - 			Prog);
    - 		fail_exit(E_HOMEDIR);
    + 	if (process_selinux) {
    + 		if (set_selinux_file_context(file, S_IFREG) != 0) {
    +-			fprintf(stderr,
    +-					_("%s: cannot set SELinux context for mailbox file %s\n"),
    +-					Prog, file);
    ++			eprintf(_("%s: cannot set SELinux context for mailbox file %s\n"),
    ++				Prog, file);
    + 			fail_exit(E_MAILBOXFILE, process_selinux);
    + 		}
    @@ src/useradd.c: static void create_home (void)
    -@@ src/useradd.c: static void create_mail (void)
    - 
    - #ifdef WITH_SELINUX
    - 	if (set_selinux_file_context(file, S_IFREG) != 0) {
    --		fprintf(stderr,
    --		        _("%s: cannot set SELinux context for mailbox file %s\n"),
    -+		eprintf(_("%s: cannot set SELinux context for mailbox file %s\n"),
    - 		        Prog, file);
    - 		fail_exit(E_MAILBOXFILE);
    - 	}
    -@@ src/useradd.c: static void create_mail (void)
    - #ifdef WITH_SELINUX
    - 	/* Reset SELinux to create files with default contexts */
    - 	if (reset_selinux_file_context() != 0) {
    --		fprintf(stderr,
    --		        _("%s: cannot reset SELinux file creation context\n"),
    -+		eprintf(_("%s: cannot reset SELinux file creation context\n"),
    - 		        Prog);
    - 		fail_exit(E_MAILBOXFILE);
    +@@ src/useradd.c: static void create_mail (struct option_flags *flags)
    + 	if (process_selinux) {
    + 		/* Reset SELinux to create files with default contexts */
    + 		if (reset_selinux_file_context() != 0) {
    +-			fprintf(stderr,
    +-					_("%s: cannot reset SELinux file creation context\n"),
    +-					Prog);
    ++			eprintf(_("%s: cannot reset SELinux file creation context\n"),
    ++				Prog);
    + 			fail_exit(E_MAILBOXFILE, process_selinux);
    + 		}
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 		fail_exit (E_NAME_IN_USE);
    + 		fail_exit (E_NAME_IN_USE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit (E_NAME_IN_USE);
    + 			fail_exit (E_NAME_IN_USE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 				fail_exit (E_UID_IN_USE);
    + 				fail_exit (E_UID_IN_USE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 				fail_exit (E_UID_IN_USE);
    + 				fail_exit (E_UID_IN_USE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit (E_UID_IN_USE);
    + 			fail_exit (E_UID_IN_USE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit (4);
    + 			fail_exit (4, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 		grp_add ();
    + 		grp_add (process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit(E_SUB_UID_UPDATE);
    + 			fail_exit(E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: int main (int argc, char **argv)
    - 			fail_exit(E_SUB_GID_UPDATE);
    + 			fail_exit(E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c
    -@@ src/userdel.c: static void update_groups (void)
    +@@ src/userdel.c: static void update_groups (bool process_selinux)
    @@ src/userdel.c: static void update_groups (void)
    -@@ src/userdel.c: static void update_groups (void)
    +@@ src/userdel.c: static void update_groups (bool process_selinux)
    @@ src/userdel.c: static void update_groups (void)
    -@@ src/userdel.c: static void update_groups (void)
    +@@ src/userdel.c: static void update_groups (bool process_selinux)
    @@ src/userdel.c: static void update_groups (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    - 				fail_exit (E_GRP_UPDATE);
    + 				fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    - static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/userdel.c: static void remove_usergroup (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void remove_usergroup (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_uid_close () == 0) {
    + 		if (sub_uid_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_gid_close () == 0) {
    + 		if (sub_gid_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void fail_exit (int code)
    - static void open_files (void)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    + static void open_files (bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void open_files (void)
    +@@ src/userdel.c: static void open_files (bool process_selinux)
    @@ src/userdel.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    -@@ src/userdel.c: static void open_files (void)
    - static void update_user (void)
    +@@ src/userdel.c: static void open_files (bool process_selinux)
    + static void update_user (bool process_selinux)
    @@ src/userdel.c: static void open_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 		fail_exit (E_SUB_UID_UPDATE);
    + 		fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/userdel.c: static void open_files (void)
    - 		fail_exit (E_SUB_GID_UPDATE);
    + 		fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c: int main (int argc, char **argv)
    - 			pw_close();
    + 			pw_close(process_selinux);
    @@ src/usermod.c: static char *new_pw_passwd (char *pw_pass)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    - 			fail_exit (E_NAME_IN_USE);
    + 			fail_exit (E_NAME_IN_USE, process_selinux);
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_spent (struct spwd *spent)
    +@@ src/usermod.c: static void new_spent (struct spwd *spent, bool process_selinux)
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
    - 			fail_exit (E_NAME_IN_USE);
    + 			fail_exit (E_NAME_IN_USE, process_selinux);
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: update_group(const struct group *grp)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    - 		fail_exit (E_GRP_UPDATE);
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    - 	}
    + #endif				/* WITH_SELINUX */
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    +@@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: process_flags(int argc, char **argv)
    - static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + 	process_selinux = !flags->chroot && !flags->prefix;
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/usermod.c: process_flags(int argc, char **argv)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: process_flags(int argc, char **argv)
    - 	if (is_shadow_pwd && (spw_close () == 0)) {
    + 	if (is_shadow_pwd && (spw_close (process_selinux) == 0)) {
    @@ src/usermod.c: process_flags(int argc, char **argv)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (gr_close () == 0) {
    + 		if (gr_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 			if (sgr_close () == 0) {
    + 			if (sgr_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 			if (sgr_unlock () == 0) {
    + 			if (sgr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_uid_close () == 0) {
    + 		if (sub_uid_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_gid_close () == 0) {
    + 		if (sub_gid_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    - static void open_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + static void open_files (bool process_selinux)
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void open_files (void)
    +@@ src/usermod.c: static void open_files (bool process_selinux)
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    -@@ src/usermod.c: static void open_files (void)
    +@@ src/usermod.c: static void open_files (bool process_selinux)
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/usermod.c: static void open_files (void)
    -@@ src/usermod.c: static void usr_update (void)
    +@@ src/usermod.c: static void usr_update (struct option_flags *flags)
    @@ src/usermod.c: static void usr_update (void)
    - 		fail_exit (E_NOTFOUND);
    + 		fail_exit (E_NOTFOUND, process_selinux);
    @@ src/usermod.c: static void usr_update (void)
    -@@ src/usermod.c: static void usr_update (void)
    +@@ src/usermod.c: static void usr_update (struct option_flags *flags)
    @@ src/usermod.c: static void usr_update (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void usr_update (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void usr_update (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void usr_update (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void usr_update (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    - 		fail_exit (E_HOMEDIR);
    + 		fail_exit (E_HOMEDIR, process_selinux);
    @@ src/usermod.c: static void move_home (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    - 			fail_exit (E_HOMEDIR);
    + 			fail_exit (E_HOMEDIR, process_selinux);
    @@ src/usermod.c: static void move_home (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    - 				fail_exit (E_HOMEDIR);
    + 				fail_exit (E_HOMEDIR, process_selinux);
    @@ src/usermod.c: static void move_home (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    - 					fail_exit (E_HOMEDIR);
    + 					fail_exit (E_HOMEDIR, process_selinux);
    @@ src/usermod.c: static void move_home (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    -@@ src/usermod.c: static void move_home (void)
    +@@ src/usermod.c: static void move_home (bool process_selinux)
    @@ src/usermod.c: static void move_home (void)
    - 			fail_exit (E_HOMEDIR);
    + 			fail_exit (E_HOMEDIR, process_selinux);
    @@ src/usermod.c: int main (int argc, char **argv)
    - 				fail_exit (E_HOMEDIR);
    + 				fail_exit (E_HOMEDIR, process_selinux);
    @@ src/vipw.c: static void vipwexit (const char *msg, int syserr, int ret)
    - 		if ((*unlock) () == 0) {
    + 		if ((*unlock) (true) == 0) {
    @@ src/vipw.c: static void vipwexit (const char *msg, int syserr, int ret)
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    - 	if ((*file_unlock) () == 0) {
    + 	if ((*file_unlock) (true) == 0) {
 4:  c303977c =  4:  86d632c8 lib/string/: strerrno(): Add function
 5:  05f95c6f !  5:  931f9e4b lib/, src/: Use strerrno() instead of its pattern
    @@ src/chage.c: int main (int argc, char **argv)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chgpasswd.c
    - #include "exitcodes.h"
    + #include "shadow/gshadow/sgrp.h"
    @@ src/chgpasswd.c
    - 
    + /*
    @@ src/chgpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/chpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/gpasswd.c
    - 
    - /*
    + struct option_flags {
    + 	bool chroot;
    @@ src/groupadd.c
    - #endif
    + #include "shadow/gshadow/sgrp.h"
    @@ src/groupadd.c
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 					fail_exit (EXIT_FAILURE);
    + 					fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/vipw.c
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
 6:  5a448c24 !  6:  2e5885c8 lib/defines.h, lib/, src/: Redefine SYSLOG() as a variadic macro
    @@ lib/cleanup_group.c: void cleanup_report_del_group_gshadow (void *group_name)
    -@@ lib/cleanup_group.c: void cleanup_unlock_group (MAYBE_UNUSED void *arg)
    +@@ lib/cleanup_group.c: void cleanup_unlock_group (void *process_selinux)
    @@ lib/cleanup_group.c: void cleanup_unlock_group (MAYBE_UNUSED void *arg)
    -@@ lib/cleanup_group.c: void cleanup_unlock_gshadow (MAYBE_UNUSED void *arg)
    +@@ lib/cleanup_group.c: void cleanup_unlock_gshadow (void *process_selinux)
    @@ lib/cleanup_user.c: void cleanup_report_add_user_shadow (void *user_name)
    -@@ lib/cleanup_user.c: void cleanup_unlock_passwd (MAYBE_UNUSED void *arg)
    +@@ lib/cleanup_user.c: void cleanup_unlock_passwd (void *process_selinux)
    @@ lib/cleanup_user.c: void cleanup_unlock_passwd (MAYBE_UNUSED void *arg)
    -@@ lib/cleanup_user.c: void cleanup_unlock_shadow (MAYBE_UNUSED void *arg)
    +@@ lib/cleanup_user.c: void cleanup_unlock_shadow (void *process_selinux)
    @@ src/chage.c
    -@@ src/chage.c: fail_exit (int code)
    +@@ src/chage.c: fail_exit (int code, bool process_selinux)
    @@ src/chage.c: fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chage.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chage.c: fail_exit (int code)
    -@@ src/chage.c: static void open_files (bool readonly)
    +@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    -@@ src/chage.c: static void open_files (bool readonly)
    +@@ src/chage.c: static void open_files (bool readonly, struct option_flags *flags)
    @@ src/chage.c: static void open_files (bool readonly)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void open_files (bool readonly)
    -@@ src/chage.c: static void close_files (void)
    +@@ src/chage.c: static void close_files (struct option_flags *flags)
    @@ src/chage.c: static void close_files (void)
    - 	if (spw_close () == 0) {
    + 	if (spw_close (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void close_files (void)
    -@@ src/chage.c: static void close_files (void)
    +@@ src/chage.c: static void close_files (struct option_flags *flags)
    @@ src/chage.c: static void close_files (void)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chage.c: static void close_files (void)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/chage.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chage.c: int main (int argc, char **argv)
    - 	close_files ();
    + 	close_files (&flags);
    @@ src/chfn.c
    -@@ src/chfn.c: static void fail_exit (int code)
    +@@ src/chfn.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chfn.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chfn.c: static void check_perms (const struct passwd *pw)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    -@@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    +@@ src/chfn.c: static void update_gecos (const char *user, char *gecos, struct option_flags *fl
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: static void update_gecos (const char *user, char *gecos)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chfn.c: int main (int argc, char **argv)
    - 			fail_exit (E_NOPERM);
    + 			fail_exit (E_NOPERM, process_selinux);
    @@ src/chfn.c: int main (int argc, char **argv)
    - 	update_gecos (user, new_gecos);
    + 	update_gecos (user, new_gecos, &flags);
    @@ src/chgpasswd.c
    -@@ src/chgpasswd.c: static void fail_exit (int code)
    +@@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chgpasswd.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void fail_exit (int code)
    -@@ src/chgpasswd.c: static void fail_exit (int code)
    +@@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chgpasswd.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void check_perms (void)
    -@@ src/chgpasswd.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    +@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    -@@ src/chgpasswd.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    +@@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/chgpasswd.c: static void close_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chgpasswd.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c
    -@@ src/chpasswd.c: static void fail_exit (int code)
    +@@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chpasswd.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void fail_exit (int code)
    -@@ src/chpasswd.c: static void fail_exit (int code)
    +@@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/chpasswd.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void check_perms (void)
    -@@ src/chpasswd.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    +@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    -@@ src/chpasswd.c: static void close_files (void)
    - 	if (pw_close () == 0) {
    +@@ src/chpasswd.c: static void close_files (struct option_flags *flags)
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chpasswd.c: static void close_files (void)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chpasswd.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chsh.c
    -@@ src/chsh.c: fail_exit (int code)
    +@@ src/chsh.c: fail_exit (int code, bool process_selinux)
    @@ src/chsh.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/chsh.c: fail_exit (int code)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void check_perms (const struct passwd *pw)
    +@@ src/chsh.c: static void check_perms (const struct passwd *pw, struct option_flags *flags)
    @@ src/chsh.c: static void check_perms (const struct passwd *pw)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    -@@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    +@@ src/chsh.c: static void update_shell (const char *user, char *newshell, struct option_flags
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 		fail_exit (1);
    + 		fail_exit (1, process_selinux);
    @@ src/chsh.c: static void update_shell (const char *user, char *newshell)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/chsh.c: int main (int argc, char **argv)
    - 			fail_exit (1);
    + 			fail_exit (1, process_selinux);
    @@ src/chsh.c: int main (int argc, char **argv)
    - 	update_shell (user, loginsh);
    + 	update_shell (user, loginsh, &flags);
    @@ src/gpasswd.c: static void log_gpasswd_success (const char *suffix)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    - 	if (gr_close () == 0) {
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    @@ src/gpasswd.c: static void get_group (struct group *gr)
    -@@ src/gpasswd.c: static void get_group (struct group *gr)
    - 		if (sgr_close () == 0) {
    +@@ src/gpasswd.c: static void get_group (struct group *gr, struct option_flags *flags)
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/groupadd.c
    -@@ src/groupadd.c: static void close_files (void)
    +@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (void)
    - 	cleanup_unlock_group (NULL);
    -@@ src/groupadd.c: static void close_files (void)
    + 	cleanup_unlock_group (&process_selinux);
    +@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (void)
    - 		cleanup_unlock_gshadow (NULL);
    -@@ src/groupadd.c: static void close_files (void)
    + 		cleanup_unlock_gshadow (&process_selinux);
    +@@ src/groupadd.c: static void close_files (struct option_flags *flags)
    @@ src/groupadd.c: static void close_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupdel.c
    -@@ src/groupdel.c: static void close_files (void)
    +@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (void)
    - 	cleanup_unlock_group (NULL);
    -@@ src/groupdel.c: static void close_files (void)
    + 	cleanup_unlock_group (&process_selinux);
    +@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (void)
    - 		cleanup_unlock_gshadow (NULL);
    -@@ src/groupdel.c: static void close_files (void)
    + 		cleanup_unlock_gshadow (&process_selinux);
    +@@ src/groupdel.c: static void close_files (struct option_flags *flags)
    @@ src/groupdel.c: static void close_files (void)
    -@@ src/groupdel.c: static void open_files (void)
    +@@ src/groupdel.c: static void open_files (struct option_flags *flags)
    @@ src/groupmems.c
    -@@ src/groupmems.c: static void check_perms (void)
    +@@ src/groupmems.c: static void check_perms (bool process_selinux)
    @@ src/groupmems.c: static void check_perms (void)
    -@@ src/groupmems.c: static void fail_exit (int code)
    +@@ src/groupmems.c: static void fail_exit (int code, bool process_selinux)
    @@ src/groupmems.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void fail_exit (int code)
    -@@ src/groupmems.c: static void fail_exit (int code)
    +@@ src/groupmems.c: static void fail_exit (int code, bool process_selinux)
    @@ src/groupmems.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void fail_exit (int code)
    -@@ src/groupmems.c: static void close_files (void)
    - {
    - 	if ((gr_close () == 0) && !list) {
    +@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    + 
    + 	if ((gr_close (process_selinux) == 0) && !list) {
    @@ src/groupmems.c: static void close_files (void)
    - 		fail_exit (EXIT_GROUP_FILE);
    + 		fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void close_files (void)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/groupmems.c: static void close_files (void)
    -@@ src/groupmems.c: static void close_files (void)
    +@@ src/groupmems.c: static void close_files (struct option_flags *flags)
    @@ src/groupmems.c: static void close_files (void)
    - 		if ((sgr_close () == 0) && !list) {
    + 		if ((sgr_close (process_selinux) == 0) && !list) {
    @@ src/groupmems.c: static void close_files (void)
    - 			fail_exit (EXIT_GROUP_FILE);
    + 			fail_exit (EXIT_GROUP_FILE, process_selinux);
    @@ src/groupmems.c: static void close_files (void)
    - 			if (sgr_unlock () == 0) {
    + 			if (sgr_unlock (process_selinux) == 0) {
    @@ src/groupmod.c
    -@@ src/groupmod.c: static void close_files (void)
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (void)
    - 	cleanup_unlock_group (NULL);
    -@@ src/groupmod.c: static void close_files (void)
    + 	cleanup_unlock_group (&process_selinux);
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (void)
    - 		cleanup_unlock_gshadow (NULL);
    -@@ src/groupmod.c: static void close_files (void)
    + 		cleanup_unlock_gshadow (&process_selinux);
    +@@ src/groupmod.c: static void close_files (struct option_flags *flags)
    @@ src/groupmod.c: static void close_files (void)
    - 		cleanup_unlock_passwd (NULL);
    + 		cleanup_unlock_passwd (&process_selinux);
    @@ src/grpck.c
    -@@ src/grpck.c: static void fail_exit (int status)
    +@@ src/grpck.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpck.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void fail_exit (int status)
    -@@ src/grpck.c: static void fail_exit (int status)
    +@@ src/grpck.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpck.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void fail_exit (int status)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    - 		fail_exit (E_CANT_OPEN);
    + 		fail_exit (E_CANT_OPEN, process_selinux);
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void open_files (void)
    +@@ src/grpck.c: static void open_files (bool process_selinux)
    @@ src/grpck.c: static void open_files (void)
    - 		fail_exit (E_CANT_OPEN);
    + 		fail_exit (E_CANT_OPEN, process_selinux);
    @@ src/grpck.c: static void open_files (void)
    -@@ src/grpck.c: static void close_files (bool changed)
    +@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static void close_files (bool changed)
    -@@ src/grpck.c: static void close_files (bool changed)
    +@@ src/grpck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/grpck.c: static void close_files (bool changed)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpck.c: static int check_members (const char *groupname,
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    +@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    @@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    -@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed)
    +@@ src/grpck.c: static void check_grp_file (bool *errors, bool *changed, struct option_flags *fl
    @@ src/grpconv.c
    -@@ src/grpconv.c: static void fail_exit (int status)
    +@@ src/grpconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpconv.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: static void fail_exit (int status)
    -@@ src/grpconv.c: static void fail_exit (int status)
    +@@ src/grpconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpconv.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (sgr_close () == 0) {
    + 	if (sgr_close (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (sgr_unlock () == 0) {
    + 	if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpconv.c: int main (int argc, char **argv)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c
    -@@ src/grpunconv.c: static void fail_exit (int status)
    +@@ src/grpunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpunconv.c: static void fail_exit (int status)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: static void fail_exit (int status)
    -@@ src/grpunconv.c: static void fail_exit (int status)
    +@@ src/grpunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/grpunconv.c: static void fail_exit (int status)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (unlink (SGROUP_FILE) != 0) {
    - 		eprintf(_("%s: cannot delete %s\n"), Prog, SGROUP_FILE);
    --		SYSLOG ((LOG_ERR, "cannot delete %s", SGROUP_FILE));
    + 	if (unlink(_PATH_GSHADOW) != 0) {
    + 		eprintf(_("%s: cannot delete %s\n"), Prog, _PATH_GSHADOW);
    +-		SYSLOG((LOG_ERR, "cannot delete %s", _PATH_GSHADOW));
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/grpunconv.c: int main (int argc, char **argv)
    - 	if (sgr_unlock () == 0) {
    + 	if (sgr_unlock (process_selinux) == 0) {
    @@ src/newusers.c
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    -@@ src/newusers.c: static void fail_exit (int code)
    +@@ src/newusers.c: static void fail_exit (int code, bool process_selinux)
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void fail_exit (int code)
    -@@ src/newusers.c: static void check_perms (void)
    +@@ src/newusers.c: static void check_perms (struct option_flags *flags)
    @@ src/newusers.c: static void check_perms (void)
    -@@ src/newusers.c: static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (is_sub_uid  && (sub_uid_close () == 0)) {
    + 	if (is_sub_uid  && (sub_uid_close (process_selinux) == 0)) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (is_sub_gid  && (sub_gid_close () == 0)) {
    + 	if (is_sub_gid  && (sub_gid_close (process_selinux) == 0)) {
    @@ src/newusers.c: static void close_files (void)
    - 		fail_exit (EXIT_FAILURE);
    + 		fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/newusers.c: static void close_files (void)
    -@@ src/newusers.c: static void close_files (void)
    +@@ src/newusers.c: static void close_files (struct option_flags *flags)
    @@ src/newusers.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/passwd.c: static void check_password (const struct passwd *pw, const struct
    -@@ src/passwd.c: fail_exit (int status)
    +@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    @@ src/passwd.c: fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    - 			(void) eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    + 		if (pw_unlock (process_selinux) == 0) {
    + 			eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    @@ src/passwd.c: fail_exit (int status)
    -@@ src/passwd.c: fail_exit (int status)
    +@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    @@ src/passwd.c: fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    - 			(void) eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    + 		if (spw_unlock (process_selinux) == 0) {
    + 			eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    @@ src/passwd.c: fail_exit (int status)
    -@@ src/passwd.c: static void update_noshadow (void)
    +@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_MISSING);
    + 		fail_exit (E_MISSING, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    -@@ src/passwd.c: static void update_noshadow (void)
    - 	if (pw_close () == 0) {
    - 		(void) eprintf(_("%s: failure while writing changes to %s\n"),
    +@@ src/passwd.c: static void update_noshadow (struct option_flags *flags)
    + 	if (pw_close (process_selinux) == 0) {
    + 		eprintf(_("%s: failure while writing changes to %s\n"),
    @@ src/passwd.c: static void update_noshadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_noshadow (void)
    - 	if (pw_unlock () == 0) {
    - 		(void) eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    + 	if (pw_unlock (process_selinux) == 0) {
    + 		eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    @@ src/passwd.c: static void update_noshadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    @@ src/passwd.c: static void update_shadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_shadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    - 		if (spw_unlock () == 0) {
    - 			(void) eprintf(_("%s: failed to unlock %s\n"),
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    + 		if (spw_unlock (process_selinux) == 0) {
    + 			eprintf(_("%s: failed to unlock %s\n"),
    @@ src/passwd.c: static void update_shadow (void)
    -@@ src/passwd.c: static void update_shadow (void)
    - 	if (spw_close () == 0) {
    - 		(void) eprintf(_("%s: failure while writing changes to %s\n"),
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
    + 	if (spw_close (process_selinux) == 0) {
    + 		eprintf(_("%s: failure while writing changes to %s\n"),
    @@ src/passwd.c: static void update_shadow (void)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/passwd.c: static void update_shadow (void)
    - 	if (spw_unlock () == 0) {
    - 		(void) eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    + 	if (spw_unlock (process_selinux) == 0) {
    + 		eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    @@ src/pwck.c
    -@@ src/pwck.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    +@@ src/pwck.c: static void fail_exit (int code, bool process_selinux)
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void fail_exit (int code)
    -@@ src/pwck.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    +@@ src/pwck.c: static void fail_exit (int code, bool process_selinux)
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwck.c: static void fail_exit (int code)
    -@@ src/pwck.c: static void open_files (void)
    +@@ src/pwck.c: static void open_files (struct option_flags *flags)
    @@ src/pwck.c: static void open_files (void)
    - 		fail_exit (E_CANTOPEN);
    + 		fail_exit (E_CANTOPEN, process_selinux);
    @@ src/pwck.c: static void open_files (void)
    -@@ src/pwck.c: static void open_files (void)
    +@@ src/pwck.c: static void open_files (struct option_flags *flags)
    @@ src/pwck.c: static void open_files (void)
    - 			fail_exit (E_CANTOPEN);
    + 			fail_exit (E_CANTOPEN, process_selinux);
    @@ src/pwck.c: static void open_files (void)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    - 			fail_exit (E_CANTUPDATE);
    + 			fail_exit (E_CANTUPDATE, process_selinux);
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    - 			fail_exit (E_CANTUPDATE);
    + 			fail_exit (E_CANTUPDATE, process_selinux);
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void close_files (bool changed)
    +@@ src/pwck.c: static void close_files (bool changed, struct option_flags *flags)
    @@ src/pwck.c: static void close_files (bool changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
    @@ src/pwconv.c
    -@@ src/pwconv.c: static void fail_exit (int status)
    +@@ src/pwconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwconv.c: static void fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: static void fail_exit (int status)
    -@@ src/pwconv.c: static void fail_exit (int status)
    +@@ src/pwconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwconv.c: static void fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (spw_close () == 0) {
    + 	if (spw_close (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 		fail_exit (E_FAILURE);
    + 		fail_exit (E_FAILURE, process_selinux);
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c
    -@@ src/pwunconv.c: static void fail_exit (int status)
    +@@ src/pwunconv.c: static void fail_exit (int status, bool process_selinux)
    @@ src/pwunconv.c: static void fail_exit (int status)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: static void fail_exit (int status)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (pw_close () == 0) {
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 		fail_exit (3);
    + 		fail_exit (3, process_selinux);
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (spw_unlock () == 0) {
    + 	if (spw_unlock (process_selinux) == 0) {
    @@ src/pwunconv.c: int main (int argc, char **argv)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/useradd.c
    -@@ src/useradd.c: static void fail_exit (int code)
    +@@ src/useradd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (spw_locked && spw_unlock() == 0) {
    + 	if (spw_locked && spw_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (pw_locked && pw_unlock() == 0) {
    + 	if (pw_locked && pw_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (gr_locked && gr_unlock() == 0) {
    + 	if (gr_locked && gr_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sgr_locked && sgr_unlock() == 0) {
    + 	if (sgr_locked && sgr_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sub_uid_locked && sub_uid_unlock() == 0) {
    + 	if (sub_uid_locked && sub_uid_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    - 	if (sub_gid_locked && sub_gid_unlock() == 0) {
    + 	if (sub_gid_locked && sub_gid_unlock(process_selinux) == 0) {
    @@ src/useradd.c: static void fail_exit (int code)
    -@@ src/useradd.c: static void fail_exit (int code)
    +@@ src/useradd.c: static void fail_exit (int code, bool process_selinux)
    @@ src/useradd.c: set_defaults(void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);	/* XXX */
    + 			fail_exit (E_GRP_UPDATE, process_selinux);	/* XXX */
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);	/* XXX */
    + 			fail_exit (E_GRP_UPDATE, process_selinux);	/* XXX */
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void grp_update (void)
    +@@ src/useradd.c: static void grp_update (bool process_selinux)
    @@ src/useradd.c: static void grp_update (void)
    -@@ src/useradd.c: static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    - 	if (is_shadow_pwd && (spw_close () == 0)) {
    + 	if (is_shadow_pwd && (spw_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 	if (is_sub_uid  && (sub_uid_close () == 0)) {
    + 	if (is_sub_uid  && (sub_uid_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_SUB_UID_UPDATE);
    + 		fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    - 	if (is_sub_gid  && (sub_gid_close () == 0)) {
    + 	if (is_sub_gid  && (sub_gid_close (process_selinux) == 0)) {
    @@ src/useradd.c: static void close_files (void)
    - 		fail_exit (E_SUB_GID_UPDATE);
    + 		fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_files (void)
    +@@ src/useradd.c: static void close_files (struct option_flags *flags)
    @@ src/useradd.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void close_files (void)
    -@@ src/useradd.c: static void close_group_files (void)
    - 	if (gr_close() == 0) {
    +@@ src/useradd.c: static void close_group_files (bool process_selinux)
    + 	if (gr_close(process_selinux) == 0) {
    @@ src/useradd.c: static void close_group_files (void)
    - 		fail_exit(E_GRP_UPDATE);
    + 		fail_exit(E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_group_files (void)
    - 	if (is_shadow_grp && sgr_close() == 0) {
    + 	if (is_shadow_grp && sgr_close(process_selinux) == 0) {
    @@ src/useradd.c: static void close_group_files (void)
    - 		fail_exit(E_GRP_UPDATE);
    + 		fail_exit(E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void close_group_files (void)
    -@@ src/useradd.c: static void unlock_group_files (void)
    +@@ src/useradd.c: static void unlock_group_files (bool process_selinux)
    @@ src/useradd.c: static void unlock_group_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void unlock_group_files (void)
    -@@ src/useradd.c: static void unlock_group_files (void)
    +@@ src/useradd.c: static void unlock_group_files (bool process_selinux)
    @@ src/useradd.c: static void unlock_group_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/useradd.c: static void unlock_group_files (void)
    -@@ src/useradd.c: static void grp_add (void)
    - 		fail_exit (E_GRP_UPDATE);
    +@@ src/useradd.c: static void grp_add (bool process_selinux)
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/useradd.c: static void tallylog_reset (const char *user_name)
    -@@ src/useradd.c: static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
    +@@ src/useradd.c: usr_update (unsigned long subuid_count, unsigned long subgid_count,
    @@ src/userdel.c
    -@@ src/userdel.c: static void update_groups (void)
    +@@ src/userdel.c: static void update_groups (bool process_selinux)
    @@ src/userdel.c: static void update_groups (void)
    -@@ src/userdel.c: static void update_groups (void)
    +@@ src/userdel.c: static void update_groups (bool process_selinux)
    @@ src/userdel.c: static void update_groups (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void remove_usergroup (void)
    +@@ src/userdel.c: static void remove_usergroup (bool process_selinux)
    @@ src/userdel.c: static void remove_usergroup (void)
    -@@ src/userdel.c: static void close_files (void)
    - {
    - 	if (pw_close () == 0) {
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    + 
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (spw_close () == 0) {
    + 		if (spw_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_PW_UPDATE);
    + 			fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 	if (gr_close () == 0) {
    + 	if (gr_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 	if (gr_unlock () == 0) {
    + 	if (gr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sgr_close () == 0) {
    + 		if (sgr_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_uid_close () == 0) {
    + 		if (sub_uid_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void close_files (void)
    +@@ src/userdel.c: static void close_files (struct option_flags *flags)
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_gid_close () == 0) {
    + 		if (sub_gid_close (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/userdel.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void close_files (void)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void fail_exit (int code)
    +@@ src/userdel.c: static void fail_exit (int code, bool process_selinux)
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/userdel.c: static void fail_exit (int code)
    -@@ src/userdel.c: static void update_user (void)
    +@@ src/userdel.c: static void update_user (bool process_selinux)
    @@ src/usermod.c: static char *new_pw_passwd (char *pw_pass)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    +@@ src/usermod.c: static void new_pwent (struct passwd *pwent, bool process_selinux)
    @@ src/usermod.c: static void new_pwent (struct passwd *pwent)
    -@@ src/usermod.c: static void new_spent (struct spwd *spent)
    +@@ src/usermod.c: static void new_spent (struct spwd *spent, bool process_selinux)
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
    -@@ src/usermod.c: static void new_spent (struct spwd *spent)
    +@@ src/usermod.c: static void new_spent (struct spwd *spent, bool process_selinux)
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sgr_unlock () == 0) {
    + 		if (sgr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    - 		if (pw_unlock () == 0) {
    + 		if (pw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: fail_exit (int code)
    +@@ src/usermod.c: fail_exit (int code, bool process_selinux)
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: fail_exit (int code)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    -@@ src/usermod.c: update_group(const struct group *grp)
    +@@ src/usermod.c: update_group(const struct group *grp, bool process_selinux)
    @@ src/usermod.c: update_group(const struct group *grp)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: update_group(const struct group *grp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    +@@ src/usermod.c: update_gshadow(const struct sgrp *sgrp, bool process_selinux)
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    - 		fail_exit (E_GRP_UPDATE);
    + 		fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: update_gshadow(const struct sgrp *sgrp)
    -@@ src/usermod.c: static void close_files (void)
    - 	if (pw_close () == 0) {
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + 	if (pw_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 	if (is_shadow_pwd && (spw_close () == 0)) {
    + 	if (is_shadow_pwd && (spw_close (process_selinux) == 0)) {
    @@ src/usermod.c: static void close_files (void)
    - 		fail_exit (E_PW_UPDATE);
    + 		fail_exit (E_PW_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    - 		if (gr_close () == 0) {
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + 		if (gr_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 			fail_exit (E_GRP_UPDATE);
    + 			fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    - 			if (sgr_close () == 0) {
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + 			if (sgr_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 				fail_exit (E_GRP_UPDATE);
    + 				fail_exit (E_GRP_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    - 			if (sgr_unlock () == 0) {
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    + 			if (sgr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 		if (gr_unlock () == 0) {
    + 		if (gr_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (spw_unlock () == 0) {
    + 		if (spw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 	if (pw_unlock () == 0) {
    + 	if (pw_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_uid_close () == 0) {
    + 		if (sub_uid_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 			fail_exit (E_SUB_UID_UPDATE);
    + 			fail_exit (E_SUB_UID_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_uid_unlock () == 0) {
    + 		if (sub_uid_unlock (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    -@@ src/usermod.c: static void close_files (void)
    +@@ src/usermod.c: static void close_files (struct option_flags *flags)
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_gid_close () == 0) {
    + 		if (sub_gid_close (process_selinux) == 0) {
    @@ src/usermod.c: static void close_files (void)
    - 			fail_exit (E_SUB_GID_UPDATE);
    + 			fail_exit (E_SUB_GID_UPDATE, process_selinux);
    @@ src/usermod.c: static void close_files (void)
    - 		if (sub_gid_unlock () == 0) {
    + 		if (sub_gid_unlock (process_selinux) == 0) {
    @@ src/vipw.c: static void vipwexit (const char *msg, int syserr, int ret)
    - 		if ((*unlock) () == 0) {
    + 		if ((*unlock) (true) == 0) {
    @@ src/vipw.c: static void vipwexit (const char *msg, int syserr, int ret)
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    - 	if ((*file_unlock) () == 0) {
    + 	if ((*file_unlock) (true) == 0) {
 7:  89a68bba =  7:  0d4af870 lib/: Move <syslog.h> wrappers to "io/syslog.h"
 8:  de8b9cd4 =  8:  d22e486c lib/io/syslog.h: SYSLOG_C(): Split code to helper macro
 9:  5cbca3af =  9:  aace99d5 lib/io/syslog.h: Rename local variable
10:  91bbde22 = 10:  0d718f3b lib/io/syslog.h: SYSLOG_C(): Use a single local variable
11:  e32447c6 = 11:  2d142ecf lib/io/syslog.h: SYSLOG_C(): Call setlocale(3) and free(3) unconditionally
12:  fa2d4762 = 12:  17a5a34a lib/io/fprintf/: [v]fprinte(): Add function
13:  d36ed519 = 13:  af7f8cb6 lib/io/fprintf/: [v]eprinte(): Add function
14:  0a0f2c23 ! 14:  9ae067f8 lib/, src/: Use eprinte() instead of its pattern
    @@ src/chage.c: int main (int argc, char **argv)
    - 		fail_exit (E_NOPERM);
    + 		fail_exit (E_NOPERM, process_selinux);
    @@ src/chgpasswd.c
    - #include "exitcodes.h"
    + #include "shadow/gshadow/sgrp.h"
    @@ src/chgpasswd.c
    - 
    + /*
    @@ src/chgpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/chpasswd.c: int main (int argc, char **argv)
    - 				fail_exit (1);
    + 				fail_exit (1, process_selinux);
    @@ src/gpasswd.c
    - 
    - /*
    + struct option_flags {
    + 	bool chroot;
    @@ src/groupadd.c
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/newusers.c: int main (int argc, char **argv)
    - 			fail_exit (EXIT_FAILURE);
    + 			fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 					fail_exit (EXIT_FAILURE);
    + 					fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/newusers.c: int main (int argc, char **argv)
    - 				fail_exit (EXIT_FAILURE);
    + 				fail_exit (EXIT_FAILURE, process_selinux);
    @@ src/vipw.c
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
    @@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlo
    -@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
    +@@ src/vipw.c: vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
15:  350da966 = 15:  85698a10 lib/: Use [v]fprinte() instead of its pattern
16:  64d4993c = 16:  69dbc822 lib/io/syslog.h: SYSLOGE(): Add macro
17:  dfb25c6c = 17:  300e074d src/userdel.c: Fix error message
18:  3b1b87e4 ! 18:  65c2e9cc lib/, src/: Use SYSLOGE() instead of its pattern
    @@ src/groupadd.c
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)
    @@ src/groupadd.c: static void open_files (void)
    -@@ src/groupadd.c: static void open_files (void)
    +@@ src/groupadd.c: static void open_files (struct option_flags *flags)

@alejandro-colomar
Copy link
Collaborator Author

alejandro-colomar commented Nov 28, 2025

v15

  • Rebase
range-diff
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  f2da3fd7a = 1:  937a956ee lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  51fdf6f9c ! 2:  771951419 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chfn.c: static void process_flags (int argc, char **argv, struct option_flag
     +                          eprintf(_("%s: fields too long\n"), Prog);
                                exit (E_NOPERM);
                        }
    -                   STRTCPY(slop, optarg);
    +                   strtcpy_a(slop, optarg);
                        break;
                case 'r':
                        if (!may_change_field ('r')) {
    @@ src/chgpasswd.c: static void close_files (struct option_flags *flags)
                /* continue */
        }
     @@ src/chgpasswd.c: int main (int argc, char **argv)
    -   while (fgets (buf, (int) sizeof buf, stdin) != NULL) {
    +   while (fgets(buf, sizeof(buf), stdin) != NULL) {
                line++;
                if (stpsep(buf, "\n") == NULL) {
     -                  fprintf (stderr, _("%s: line %jd: line too long\n"),
    @@ src/faillog.c: static void print_one (/*@null@*/const struct passwd *pw, bool fo
     +          eprintf("Cannot read time from faillog.\n");
                return;
        }
    -   STRFTIME(ptime, "%D %H:%M:%S %z", tm);
    +   strftime_a(ptime, "%D %H:%M:%S %z", tm);
     @@ src/faillog.c: static bool reset_one (uid_t uid)
                return false;
        }
    @@ src/free_subid_range.c
     @@
      #include <unistd.h>
      
    - #include "atoi/str2i.h"
    + #include "atoi/a2i.h"
     +#include "io/fprintf/eprintf.h"
      #include "subid.h"
      #include "stdlib.h"
    @@ src/free_subid_range.c: int main(int argc, char *argv[])
     
      ## src/get_subid_owners.c ##
     @@
    - #include <stdio.h>
      
      #include "atoi/getnum.h"
    + #include "attr.h"
     +#include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "shadowlog.h"
      #include "stdlib.h"
    -@@ src/get_subid_owners.c: static const char Prog[] = "get_subid_owners";
    - 
    - static void usage(void)
    - {
    --  fprintf(stderr, "Usage: [-g] %s subuid\n", Prog);
    --  fprintf(stderr, "    list uids who own the given subuid\n");
    --  fprintf(stderr, "    pass -g to query a subgid\n");
    -+  eprintf("Usage: [-g] %s subuid\n", Prog);
    -+  eprintf("    list uids who own the given subuid\n");
    -+  eprintf("    pass -g to query a subgid\n");
    -   exit(EXIT_FAILURE);
    - }
    - 
     @@ src/get_subid_owners.c: int main(int argc, char *argv[])
                n = subid_get_uid_owners(u, &uids);
        }
    @@ src/get_subid_owners.c: int main(int argc, char *argv[])
                exit(1);
        }
        for (i = 0; i < n; i++) {
    +@@ src/get_subid_owners.c: int main(int argc, char *argv[])
    + static void
    + usage(void)
    + {
    +-  fprintf(stderr, "Usage: [-g] %s subuid\n", Prog);
    +-  fprintf(stderr, "    list uids who own the given subuid\n");
    +-  fprintf(stderr, "    pass -g to query a subgid\n");
    ++  eprintf("Usage: [-g] %s subuid\n", Prog);
    ++  eprintf("    list uids who own the given subuid\n");
    ++  eprintf("    pass -g to query a subgid\n");
    +   exit(EXIT_FAILURE);
    + }
     
      ## src/getsubids.c ##
     @@
    - #include <stdlib.h>
      #include <string.h>
      
    + #include "attr.h"
     +#include "io/fprintf/eprintf.h"
      #include "prototypes.h"
      #include "shadowlog.h"
      #include "string/strcmp/streq.h"
    -@@ src/getsubids.c: static const char Prog[] = "getsubids";
    - 
    - static void usage(void)
    - {
    --  fprintf(stderr, "Usage: %s [-g] user\n", Prog);
    --  fprintf(stderr, "    list subuid ranges for user\n");
    --  fprintf(stderr, "    pass -g to list subgid ranges\n");
    -+  eprintf("Usage: %s [-g] user\n", Prog);
    -+  eprintf("    list subuid ranges for user\n");
    -+  eprintf("    pass -g to list subgid ranges\n");
    -   exit(EXIT_FAILURE);
    - }
    - 
     @@ src/getsubids.c: int main(int argc, char *argv[])
                count = subid_get_uid_ranges(owner, &ranges);
        }
    @@ src/getsubids.c: int main(int argc, char *argv[])
                exit(1);
        }
        for (i = 0; i < count; i++) {
    +@@ src/getsubids.c: int main(int argc, char *argv[])
    + static void
    + usage(void)
    + {
    +-  fprintf(stderr, "Usage: %s [-g] user\n", Prog);
    +-  fprintf(stderr, "    list subuid ranges for user\n");
    +-  fprintf(stderr, "    pass -g to list subgid ranges\n");
    ++  eprintf("Usage: %s [-g] user\n", Prog);
    ++  eprintf("    list subuid ranges for user\n");
    ++  eprintf("    pass -g to list subgid ranges\n");
    +   exit(EXIT_FAILURE);
    + }
     
      ## src/gpasswd.c ##
     @@ src/gpasswd.c: static bool is_valid_user_list (const char *users)
    @@ src/lastlog.c
     @@ src/lastlog.c: static void print_one (/*@null@*/const struct passwd *pw)
                 * empty entry in this case.
                 */
    -           if (fread (&ll, sizeof (ll), 1, lastlogfile) != 1) {
    +           if (fread(&ll, sizeof(ll), 1, lastlogfile) != 1) {
     -                  fprintf (stderr,
     -                           _("%s: Failed to get the entry for UID %lu\n"),
     +                  eprintf(_("%s: Failed to get the entry for UID %lu\n"),
    @@ src/lastlog.c: static void print (void)
     @@ src/lastlog.c: static void update_one (/*@null@*/const struct passwd *pw)
      #endif
      
    -   if (fwrite (&ll, sizeof(ll), 1, lastlogfile) != 1) {
    +   if (fwrite(&ll, sizeof(ll), 1, lastlogfile) != 1) {
     -                  fprintf (stderr,
     -                           _("%s: Failed to update the entry for UID %lu\n"),
     +                  eprintf(_("%s: Failed to update the entry for UID %lu\n"),
    @@ src/new_subid_range.c
     @@
      #include <unistd.h>
      
    - #include "atoi/str2i.h"
    + #include "atoi/a2i.h"
     +#include "io/fprintf/eprintf.h"
      #include "subid.h"
      #include "stdlib.h"
    @@ src/newusers.c: static void close_files (struct option_flags *flags)
                        /* continue */
                }
     @@ src/newusers.c: int main (int argc, char **argv)
    -   while (fgets (buf, sizeof buf, stdin) != NULL) {
    +   while (fgets(buf, sizeof(buf), stdin) != NULL) {
                line++;
                if (stpsep(buf, "\n") == NULL && feof(stdin) == 0) {
     -                  fprintf (stderr, _("%s: line %jd: line too long\n"),
    @@ src/newusers.c: int main (int argc, char **argv)
                        fail_exit (EXIT_FAILURE, process_selinux);
                }
      
    -           if (STRSEP2ARR(buf, ":", fields) == -1) {
    +           if (strsep2arr_a(buf, ":", fields) == -1) {
     -                  fprintf (stderr, _("%s: line %jd: invalid line\n"),
     -                           Prog, line);
     +                  eprintf(_("%s: line %jd: invalid line\n"), Prog, line);
    @@ src/su.c: static /*@only@*/struct passwd * do_check_perms (void)
     @@ src/su.c: static /*@only@*/struct passwd * do_check_perms (void)
                       "Change user from '%s' to '%s' as requested by PAM",
                       name, tmp_name);
    -           if (STRTCPY(name, tmp_name) == -1) {
    +           if (strtcpy_a(name, tmp_name) == -1) {
     -                  fprintf (stderr, _("Overlong user name '%s'\n"),
     -                           tmp_name);
     +                  eprintf(_("Overlong user name '%s'\n"), tmp_name);
3:  d2d388352 = 3:  b5075839d lib/io/fprintf/: eprinte(): Add macro
4:  366e77d48 ! 4:  734ef3b7a lib/, src/: Use eprinte() instead of its pattern
    @@ lib/get_pid.c
     @@ lib/get_pid.c: int open_pidfd(const char *pidstr)
                return -ENOENT;
      
    -   if (SNPRINTF(proc_dir_name, "/proc/%d/", target) == -1) {
    +   if (stprintf_a(proc_dir_name, "/proc/%d/", target) == -1) {
     -          fprinte(stderr, "snprintf of proc path failed for %d", target);
     +          eprinte("snprintf of proc path failed for %d", target);
                return -EINVAL;
    @@ src/faillog.c: int main (int argc, char **argv)
      ## src/gpasswd.c ##
     @@ src/gpasswd.c: static void change_passwd (struct group *gr)
        cp = pw_encrypt (pass, salt);
    -   MEMZERO(pass);
    +   memzero_a(pass);
        if (NULL == cp) {
     -          fprinte(stderr, _("%s: failed to crypt password with salt '%s'"), Prog, salt);
     +          eprinte(_("%s: failed to crypt password with salt '%s'"), Prog, salt);
    @@ src/passwd.c: static int new_password (const struct passwd *pw)
                        SYSLOG(LOG_INFO,
                               "Failed to crypt password with previous salt of user '%s'",
     @@ src/passwd.c: static int new_password (const struct passwd *pw)
    -   MEMZERO(pass);
    +   memzero_a(pass);
      
        if (NULL == cp) {
     -          fprinte(stderr, _("%s: failed to crypt password with salt '%s'"),
    @@ src/useradd.c: set_defaults(void)
                }
        }
     @@ src/useradd.c: set_defaults(void)
    -   assert(SNPRINTF(buf, "%s-", default_file) != -1);
    +   assert(stprintf_a(buf, "%s-", default_file) != -1);
        unlink (buf);
        if ((link (default_file, buf) != 0) && (ENOENT != errno)) {
     -          fprinte(stderr, _("%s: Cannot create backup file (%s)"), Prog, buf);
    @@ src/useradd.c: static void faillog_reset (uid_t uid)
                return;
     @@ src/useradd.c: static void faillog_reset (uid_t uid)
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
    -       || (write_full(fd, &fl, sizeof (fl)) == -1)
    +       || (write_full(fd, &fl, sizeof(fl)) == -1)
            || (fsync (fd) != 0)) {
     -          fprinte(stderr, _("%s: failed to reset the faillog entry of UID %lu"),
     +          eprinte(_("%s: failed to reset the faillog entry of UID %lu"),
    @@ src/useradd.c: static void lastlog_reset (uid_t uid)
                return;
     @@ src/useradd.c: static void lastlog_reset (uid_t uid)
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
    -       || (write_full (fd, &ll, sizeof (ll)) == -1)
    +       || (write_full(fd, &ll, sizeof(ll)) == -1)
            || (fsync (fd) != 0)) {
     -          fprinte(stderr, _("%s: failed to reset the lastlog entry of UID %lu"),
     +          eprinte(_("%s: failed to reset the lastlog entry of UID %lu"),
    @@ src/usermod.c: static void update_lastlog (void)
        }
     @@ src/usermod.c: static void update_lastlog (void)
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
    -               || (write_full(fd, &ll, sizeof ll) == -1)
    +               || (write_full(fd, &ll, sizeof(ll)) == -1)
                    || (fsync (fd) != 0)) {
     -                  fprinte(stderr, _("%s: failed to copy the lastlog entry of user %lu to user %lu"),
     +                  eprinte(_("%s: failed to copy the lastlog entry of user %lu to user %lu"),
    @@ src/usermod.c: static void update_lastlog (void)
        } else {
     @@ src/usermod.c: static void update_lastlog (void)
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
    -                       || (write_full(fd, &ll, sizeof ll) == -1)
    +                       || (write_full(fd, &ll, sizeof(ll)) == -1)
                            || (fsync (fd) != 0)) {
     -                          fprinte(stderr, _("%s: failed to copy the lastlog entry of user %lu to user %lu"),
     +                          eprinte(_("%s: failed to copy the lastlog entry of user %lu to user %lu"),
    @@ src/usermod.c: static void update_faillog (void)
        }
     @@ src/usermod.c: static void update_faillog (void)
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
    -               || (write_full(fd, &fl, sizeof fl) == -1)
    +               || (write_full(fd, &fl, sizeof(fl)) == -1)
                    || (fsync (fd) != 0)) {
     -                  fprinte(stderr, _("%s: failed to copy the faillog entry of user %lu to user %lu"),
     +                  eprinte(_("%s: failed to copy the faillog entry of user %lu to user %lu"),
    @@ src/usermod.c: static void update_faillog (void)
        } else {
     @@ src/usermod.c: static void update_faillog (void)
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
    -                       || (write_full(fd, &fl, sizeof fl) == -1))
    +                       || (write_full(fd, &fl, sizeof(fl)) == -1))
                        {
     -                          fprinte(stderr, _("%s: failed to copy the faillog entry of user %lu to user %lu"),
     +                          eprinte(_("%s: failed to copy the faillog entry of user %lu to user %lu"),
5:  3214071d8 = 5:  06ffd61b0 src/userdel.c: Fix error message

The double parentheses were used to fake a variadic macro with a
non-variadic one.  With a variadic macro, we remove the weird double
parentheses that were needed to call this macro, which BTW were
error-prone.  This would have prevented the bug fixed in 3f5ae5d
(2025-09-10; "src/su.c: Fix incorrect (non-matching) parentheses").

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
The name of this macro makes it more evident what it does.  It's a
C-locale version of syslog(3).  We need to implement it as a macro
so that arguments such as strerror(3) are evaluated after setting
the C locale.  This would be impossible with a function.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
There's no need for two variables, and this avoids one assignment.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
…nally

Both setlocale(3) and free(3) are okay to call with a null pointer.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
In some cases, we print strerrno() with this macro.  Because this is
a macro, and internal calls such as strdup(3) may set errno, that value
could be corrupted when we arrive at syslog(3).  While we could solve
this here, it's not robust.  Instead, we'll use a dedicated wrapper for
that, which will be added in the following commits: SYSLOGE().

What we'll do here is preserve errno when we exit from this macro, as we
often follow SYSLOG() calls with fprintf(stderr,) calls, which also use
the errno value, and we don't want to pollute that.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar
Copy link
Collaborator Author

v16

  • Rebase
range-diff
$ git range-diff gh/e..gh/eprintf e..eprintf 
1:  6bad4e73d = 1:  4353e9a7e lib/io/fprintf/: eprintf(): Add macro to print to stderr
2:  d4b5c7577 ! 2:  69edc43e8 lib/, src/: Use eprintf() instead of its pattern
    @@ src/chgpasswd.c: static void fail_exit (int code, bool process_selinux)
                        /* continue */
                }
     @@ src/chgpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    -                         bad_s = 0;
    +                   bad_s = 0;
      
                        if (!crypt_method) {
     -                          fprintf (stderr,
    @@ src/chgpasswd.c: static void process_flags (int argc, char **argv, struct option
                                usage (E_USAGE);
                        }
     @@ src/chgpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    -                         }
    +                   }
      #endif                            /* USE_YESCRYPT */
    -                         if (bad_s != 0) {
    +                   if (bad_s != 0) {
     -                          fprintf (stderr,
     -                                   _("%s: invalid numeric argument '%s'\n"),
     +                          eprintf(_("%s: invalid numeric argument '%s'\n"),
    @@ src/chpasswd.c: static void fail_exit (int code, bool process_selinux)
                        /* continue */
                }
     @@ src/chpasswd.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    -                         }
    +                   }
      #endif                            /* USE_YESCRYPT */
    -                         if (bad_s != 0) {
    +                   if (bad_s != 0) {
     -                          fprintf (stderr,
     -                                   _("%s: invalid numeric argument '%s'\n"),
     +                          eprintf(_("%s: invalid numeric argument '%s'\n"),
    @@ src/chsh.c: fail_exit (int code, bool process_selinux)
                        SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
                        /* continue */
                }
    -@@ src/chsh.c: static bool shell_is_listed (const char *sh)
    +@@ src/chsh.c: static bool shell_is_listed (const char *sh, bool process_selinux)
                               "", /* key only */
                               "#" /* comment */);
        if (error) {
    @@ src/chsh.c: static bool shell_is_listed (const char *sh)
     -                   _("Cannot parse shell files: %s"),
     +          eprintf(_("Cannot parse shell files: %s"),
                         econf_errString(error));
    -           fail_exit (1);
    +           fail_exit (1, process_selinux);
        }
      
        error = econf_getKeys(key_file, NULL, &size, &keys);
    @@ src/chsh.c: static bool shell_is_listed (const char *sh)
     +          eprintf(_("Cannot evaluate entries in shell files: %s"),
                         econf_errString(error));
                econf_free (key_file);
    -           fail_exit (1);
    +           fail_exit (1, process_selinux);
     @@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
         */
        if (!amroot && pw->pw_uid != getuid ()) {
    @@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option
      
     @@ src/chsh.c: static void check_perms(const struct passwd *pw, const struct option_flags *flag
         */
    -   if (!amroot && is_restricted_shell (pw->pw_shell)) {
    +   if (!amroot && is_restricted_shell (pw->pw_shell, process_selinux)) {
                SYSLOG(LOG_WARN, "can't change shell for '%s'", pw->pw_name);
     -          fprintf (stderr,
     -                   _("You may not change the shell for '%s'.\n"),
    @@ src/gpasswd.c: static void process_flags (int argc, char **argv, struct option_f
                                         Prog);
                                exit (E_GSHADOW_NOTFOUND);
                        }
    -@@ src/gpasswd.c: static void check_flags (int argc, int opt_index)
    - static void open_files (void)
    - {
    +@@ src/gpasswd.c: static void open_files(const struct option_flags *flags)
    +   process_selinux = !flags->chroot;
    + 
        if (gr_lock () == 0) {
     -          fprintf (stderr,
     -                   _("%s: cannot lock %s; try again later.\n"),
    @@ src/gpasswd.c: static void check_flags (int argc, int opt_index)
                         Prog, gr_dbname ());
                exit (E_NOPERM);
        }
    -@@ src/gpasswd.c: static void open_files (void)
    +@@ src/gpasswd.c: static void open_files(const struct option_flags *flags)
      #ifdef SHADOWGRP
        if (is_shadowgrp) {
                if (sgr_lock () == 0) {
    @@ src/gpasswd.c: static void open_files (void)
                                 Prog, sgr_dbname ());
                        exit (E_NOPERM);
                }
    -@@ src/gpasswd.c: static void open_files (void)
    +@@ src/gpasswd.c: static void open_files(const struct option_flags *flags)
        add_cleanup (log_gpasswd_failure_system, NULL);
      
        if (gr_open (O_CREAT | O_RDWR) == 0) {
    @@ src/gpasswd.c: static void open_files (void)
                SYSLOG(LOG_WARN, "cannot open %s", gr_dbname());
                exit (E_NOPERM);
        }
    -@@ src/gpasswd.c: static void open_files (void)
    +@@ src/gpasswd.c: static void open_files(const struct option_flags *flags)
      #ifdef SHADOWGRP
        if (is_shadowgrp) {
                if (sgr_open (O_CREAT | O_RDWR) == 0) {
    @@ src/newusers.c: static int add_user (const char *name, uid_t uid, gid_t gid)
                return -1;
        }
     @@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    -                         bad_s = 0;
    +                   bad_s = 0;
      
                        if (!crypt_method){
     -                          fprintf(stderr,
    @@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_
                                usage (EXIT_FAILURE);
                        }
     @@ src/newusers.c: static void process_flags (int argc, char **argv, struct option_flags *flags)
    -                         }
    +                   }
      #endif                            /* USE_YESCRYPT */
    -                         if (bad_s != 0) {
    +                   if (bad_s != 0) {
     -                          fprintf (stderr,
     -                                   _("%s: invalid numeric argument '%s'\n"),
     +                          eprintf(_("%s: invalid numeric argument '%s'\n"),
    @@ src/passwd.c: static int new_password (const struct passwd *pw)
                                        pw->pw_name);
                        return -1;
                }
    -@@ src/passwd.c: static void check_password (const struct passwd *pw, const struct spwd *sp)
    +@@ src/passwd.c: static void check_password (const struct passwd *pw, const struct spwd *sp, bool
            || (exp_status > 1)
            || (   (sp->sp_max >= 0)
                && (sp->sp_min > sp->sp_max))) {
    @@ src/passwd.c: static void check_password (const struct passwd *pw, const struct
                                sp->sp_namp);
                SYSLOG(LOG_WARN, "password locked for '%s'", sp->sp_namp);
                closelog ();
    -@@ src/passwd.c: static void check_password (const struct passwd *pw, const struct spwd *sp)
    +@@ src/passwd.c: static void check_password (const struct passwd *pw, const struct spwd *sp, bool
                }
      
                if (now < ok) {
     -                  (void) fprintf (stderr,
     -                                  _("The password for %s cannot be changed yet.\n"),
     +                  (void) eprintf(_("The password for %s cannot be changed yet.\n"),
    -                                   pw->pw_name);
    -                   SYSLOG(LOG_WARN, "now < minimum age for '%s'", pw->pw_name);
    +                                   sp->sp_namp);
    +                   SYSLOG(LOG_WARN, "now < minimum age for '%s'", sp->sp_namp);
                        closelog ();
     @@ src/passwd.c: static void print_status (const struct passwd *pw)
                (void) printf ("%s %s\n",
    @@ src/passwd.c: static void print_status (const struct passwd *pw)
      }
     @@ src/passwd.c: fail_exit (int status, bool process_selinux)
      {
    -   if (pw_locked) {
    -           if (pw_unlock (process_selinux) == 0) {
    --                  (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
    -+                  eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    -                   SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
    -                   /* continue */
    -           }
    -@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    - 
        if (spw_locked) {
                if (spw_unlock (process_selinux) == 0) {
     -                  (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
    @@ src/passwd.c: fail_exit (int status, bool process_selinux)
                        SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname());
                        /* continue */
                }
    +@@ src/passwd.c: fail_exit (int status, bool process_selinux)
    + 
    +   if (pw_locked) {
    +           if (pw_unlock (process_selinux) == 0) {
    +-                  (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
    ++                  eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    +                   SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
    +                   /* continue */
    +           }
     @@ src/passwd.c: NORETURN
      static void
      oom (bool process_selinux)
    @@ src/passwd.c: NORETURN
        fail_exit (E_FAILURE, process_selinux);
      }
      
    +@@ src/passwd.c: oom (bool process_selinux)
    + static void open_files(bool process_selinux)
    + {
    +   if (pw_lock () == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: cannot lock %s; try again later.\n"),
    +-                          Prog, pw_dbname ());
    ++          eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname());
    +           exit (E_PWDBUSY);
    +   }
    +   pw_locked = true;
    +   if (pw_open (O_CREAT | O_RDWR) == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: cannot open %s\n"),
    +-                          Prog, pw_dbname ());
    ++          eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname());
    +           SYSLOG(LOG_WARN, "cannot open %s", pw_dbname());
    +           fail_exit (E_MISSING, process_selinux);
    +   }
    +@@ src/passwd.c: static void open_files(bool process_selinux)
    +   if (!spw_file_present ())
    +           return;
    +   if (spw_lock () == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: cannot lock %s; try again later.\n"),
    +-                          Prog, spw_dbname ());
    ++          eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname());
    +           fail_exit (E_PWDBUSY, process_selinux);
    +   }
    +   spw_locked = true;
    +   if (spw_open (O_CREAT | O_RDWR) == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: cannot open %s\n"),
    +-                          Prog, spw_dbname ());
    ++          eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname());
    +           SYSLOG(LOG_WARN, "cannot open %s", spw_dbname());
    +           fail_exit (E_FAILURE, process_selinux);
    +   }
    +@@ src/passwd.c: static void close_files(bool process_selinux)
    + {
    +   if (spw_locked) {
    +           if (spw_close (process_selinux) == 0) {
    +-                  (void) fprintf (stderr,
    +-                                  _("%s: failure while writing changes to %s\n"),
    +-                                  Prog, spw_dbname ());
    ++                  eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname());
    +                   SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname());
    +                   fail_exit (E_FAILURE, process_selinux);
    +           }
    +           if (spw_unlock (process_selinux) == 0) {
    +-                  (void) fprintf (stderr,
    +-                                  _("%s: failed to unlock %s\n"),
    +-                                  Prog, spw_dbname ());
    ++                  eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    +                   SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname());
    +                   /* continue */
    +           }
    +           spw_locked = false;
    +   }
    +   if (pw_close (process_selinux) == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: failure while writing changes to %s\n"),
    +-                          Prog, pw_dbname ());
    ++          eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname());
    +           SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname());
    +           fail_exit (E_FAILURE, process_selinux);
    +   }
    +   if (pw_unlock (process_selinux) == 0) {
    +-          (void) fprintf (stderr,
    +-                          _("%s: failed to unlock %s\n"),
    +-                          Prog, pw_dbname ());
    ++          eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    +           SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
    +           /* continue */
    +   }
     @@ src/passwd.c: static char *update_crypt_pw (char *cp, bool process_selinux)
      
        if (uflg && strprefix(cp, "!")) {
    @@ src/passwd.c: static char *update_crypt_pw (char *cp, bool process_selinux)
                                        Prog);
                        fail_exit (E_FAILURE, process_selinux);
                } else {
    -@@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
    -   process_selinux = !flags->chroot && !flags->prefix;
    +@@ src/passwd.c: static void update_noshadow(bool process_selinux)
      
    -   if (pw_lock () == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: cannot lock %s; try again later.\n"),
    -+          (void) eprintf(_("%s: cannot lock %s; try again later.\n"),
    -                           Prog, pw_dbname ());
    -           exit (E_PWDBUSY);
    -   }
    -   pw_locked = true;
    -   if (pw_open (O_CREAT | O_RDWR) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: cannot open %s\n"),
    --                          Prog, pw_dbname ());
    -+          (void) eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname());
    -           SYSLOG(LOG_WARN, "cannot open %s", pw_dbname());
    -           fail_exit (E_MISSING, process_selinux);
    -   }
        pw = pw_locate (name);
        if (NULL == pw) {
     -          (void) fprintf (stderr,
    @@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
                                Prog, name, pw_dbname ());
                fail_exit (E_NOPERM, process_selinux);
        }
    -@@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
    +@@ src/passwd.c: static void update_noshadow(bool process_selinux)
        }
        npw->pw_passwd = update_crypt_pw (npw->pw_passwd, process_selinux);
        if (pw_update (npw) == 0) {
    @@ src/passwd.c: static void update_noshadow(const struct option_flags *flags)
                                Prog, pw_dbname (), npw->pw_name);
                fail_exit (E_FAILURE, process_selinux);
        }
    -   if (pw_close (process_selinux) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: failure while writing changes to %s\n"),
    -+          eprintf(_("%s: failure while writing changes to %s\n"),
    -                           Prog, pw_dbname ());
    -           SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname());
    -           fail_exit (E_FAILURE, process_selinux);
    -   }
    -   if (pw_unlock (process_selinux) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: failed to unlock %s\n"),
    --                          Prog, pw_dbname ());
    -+          eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname());
    -           SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname());
    -           /* continue */
    -   }
    -@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    -   process_selinux = !flags->chroot && !flags->prefix;
    - 
    -   if (spw_lock () == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: cannot lock %s; try again later.\n"),
    -+          (void) eprintf(_("%s: cannot lock %s; try again later.\n"),
    -                           Prog, spw_dbname ());
    -           exit (E_PWDBUSY);
    -   }
    -   spw_locked = true;
    -   if (spw_open (O_CREAT | O_RDWR) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: cannot open %s\n"),
    --                          Prog, spw_dbname ());
    -+          (void) eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname());
    -           SYSLOG(LOG_WARN, "cannot open %s", spw_dbname());
    -           fail_exit (E_FAILURE, process_selinux);
    -   }
    -@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    -           (void) spw_close (process_selinux);
    -           update_noshadow (flags);
    -           if (spw_unlock (process_selinux) == 0) {
    --                  (void) fprintf (stderr,
    --                                  _("%s: failed to unlock %s\n"),
    -+                  eprintf(_("%s: failed to unlock %s\n"),
    -                                   Prog, spw_dbname ());
    -                   SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname());
    -                   /* continue */
    -@@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
    +@@ src/passwd.c: static void update_shadow(bool process_selinux)
        }
      
        if (spw_update (nsp) == 0) {
    @@ src/passwd.c: static void update_shadow(const struct option_flags *flags)
                                Prog, spw_dbname (), nsp->sp_namp);
                fail_exit (E_FAILURE, process_selinux);
        }
    -   if (spw_close (process_selinux) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: failure while writing changes to %s\n"),
    -+          eprintf(_("%s: failure while writing changes to %s\n"),
    -                           Prog, spw_dbname ());
    -           SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname());
    -           fail_exit (E_FAILURE, process_selinux);
    -   }
    -   if (spw_unlock (process_selinux) == 0) {
    --          (void) fprintf (stderr,
    --                          _("%s: failed to unlock %s\n"),
    --                          Prog, spw_dbname ());
    -+          eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname());
    -           SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname());
    -           /* continue */
    -   }
     @@ src/passwd.c: main(int argc, char **argv)
                                if (a2sl(&inact, optarg, NULL, 0, -1, LONG_MAX)
                                    == -1)
    @@ src/pwunconv.c: int main (int argc, char **argv)
        }
      
     @@ src/pwunconv.c: int main (int argc, char **argv)
    -            * to weeks and so on.
    -            */
    +           }
    + 
                if (pw_update (&pwent) == 0) {
     -                  fprintf (stderr,
     -                           _("%s: failed to prepare the new %s entry '%s'\n"),
    @@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
                                        exit(E_BAD_ARG);
                                }
     @@ src/usermod.c: process_flags(int argc, char **argv, struct option_flags *flags)
    -                 break;
    +                           break;
                        case 'W':
                                if (prepend_range (optarg, &del_sub_gids) == 0) {
     -                                  fprintf (stderr,
3:  1732745e1 = 3:  0938f9c97 lib/io/fprintf/: eprinte(): Add macro
4:  8e5dbae99 ! 4:  57e0eafd6 lib/, src/: Use eprinte() instead of its pattern
    @@ src/useradd.c: set_defaults(void)
     -          fprinte(stderr, _("%s: cannot create new defaults file"), Prog);
     +          eprinte(_("%s: cannot create new defaults file"), Prog);
                return -1;
    -         }
    +   }
      
        if (prefix[0]) {
                default_file = aprintf("%s/%s", prefix, USER_DEFAULTS_FILE);
5:  c1b93d2ec = 5:  60a5920fd src/userdel.c: Fix error message

@alejandro-colomar
Copy link
Collaborator Author

I have some reservations about commits 1 and 2. Specifically, the new interface introduced isn't something I've commonly seen in other projects, even though I'm aware of its mention in the GCC documentation. From my perspective, it doesn't appear to offer a significant benefit here.

Furthermore, I'm concerned that commit 2 introduces changes across many files, which could make it quite challenging for distribution maintainers to backport future changes to their distributions. This could lead to a lot of friction and messy patch applications down the line.

@stoeckmann has provided a reproducer for a bug that we have as a plague: clobbering of errno. See:

We need to solve this by having APIs that preserve errno. And this needs global churn, because the bug is everywhere.

On the other hand, I'm fine with the changes in commits 3 and 4. They look good to me.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
These functions print a formatted string, followed by a colon and
a space, followed by an error string produced by strerror($2).  That is,
the output is as follows:

	fmt: error message string

For example,
	fprintec(stderr, ENOMEM, "foo(%d)", 42);
prints
	foo(42): Cannot allocate memory

These functions return the number of characters printed, or a negative
value on error, like fprintf(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
fprinte() is like fprintec(), but uses errno instead of an error code.

It is implemented as a macro so that it can read the value in errno
before evaluating any of its arguments, thus not corrupting it.

It also preserves errno so that the error can be printed more than once.
This is useful because we often print to stderr or log_get_logfd(), and
immediately after print to the system log with syslog(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
like the fprintf(3) wrappers, these print an error message.  SYSLOGE()
uses errno, and SYSLOGEC() uses an errno-like error code.

This time we need to be careful to name the local copy of errno
differently than within SYSLOG() --which we call--.  Let's use a double
underscore.  In the future, C might have function literals (similar to
lambdas), which will solve this issue.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Having such long and complex format strings and variadic arguments is
error-prone, as can be seen in the previous commit, which fixes a bug of
this kind.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This will allow having shorter lines for writing to stderr.

This name is commonly used in other projects, it seems (see link below).

Link: <https://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/Variadic-Macros.html>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing closing parenthesis in syslog(3) call Writing to wrong stream

2 participants