Merge pull request #263 from edneville/261_grpck_questionable_warning

Option to suppress group/gshadow inconsistencies
This commit is contained in:
Serge Hallyn 2020-08-11 13:58:22 -05:00 committed by GitHub
commit a271076041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View File

@ -34,7 +34,6 @@
<!-- SHADOW-CONFIG-HERE --> <!-- SHADOW-CONFIG-HERE -->
]> ]>
<refentry id='grpck.8'> <refentry id='grpck.8'>
<!-- $Id$ -->
<refentryinfo> <refentryinfo>
<author> <author>
<firstname>Julianne Frances</firstname> <firstname>Julianne Frances</firstname>
@ -192,6 +191,17 @@
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-S</option>, <option>--silence-warnings</option></term>
<listitem>
<para>
Suppress more controversial warnings, in particular warnings about
inconsistency between group members listed in
<filename>/etc/group</filename> and
<filename>/etc/ghadow</filename>.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
<para> <para>
By default, <command>grpck</command> operates on By default, <command>grpck</command> operates on

View File

@ -33,8 +33,6 @@
#include <config.h> #include <config.h>
#ident "$Id$"
#include <fcntl.h> #include <fcntl.h>
#include <grp.h> #include <grp.h>
#include <pwd.h> #include <pwd.h>
@ -82,6 +80,7 @@ static bool gr_locked = false;
/* Options */ /* Options */
static bool read_only = false; static bool read_only = false;
static bool sort_mode = false; static bool sort_mode = false;
static bool silence_warnings = false;
/* local function prototypes */ /* local function prototypes */
static void fail_exit (int status); static void fail_exit (int status);
@ -158,6 +157,7 @@ static /*@noreturn@*/void usage (int status)
" but do not change files\n"), usageout); " but do not change files\n"), usageout);
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
(void) fputs (_(" -s, --sort sort entries by UID\n"), usageout); (void) fputs (_(" -s, --sort sort entries by UID\n"), usageout);
(void) fputs (_(" -S, --silence-warnings silence controversial/paranoid warnings\nn"), usageout);
(void) fputs ("\n", usageout); (void) fputs ("\n", usageout);
exit (status); exit (status);
} }
@ -197,6 +197,7 @@ static void process_flags (int argc, char **argv)
{"quiet", no_argument, NULL, 'q'}, {"quiet", no_argument, NULL, 'q'},
{"read-only", no_argument, NULL, 'r'}, {"read-only", no_argument, NULL, 'r'},
{"root", required_argument, NULL, 'R'}, {"root", required_argument, NULL, 'R'},
{"silence-warnings", no_argument, NULL, 'S'},
{"sort", no_argument, NULL, 's'}, {"sort", no_argument, NULL, 's'},
{NULL, 0, NULL, '\0'} {NULL, 0, NULL, '\0'}
}; };
@ -204,7 +205,7 @@ static void process_flags (int argc, char **argv)
/* /*
* Parse the command line arguments * Parse the command line arguments
*/ */
while ((c = getopt_long (argc, argv, "hqrR:s", while ((c = getopt_long (argc, argv, "hqrR:sS",
long_options, NULL)) != -1) { long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
@ -221,6 +222,9 @@ static void process_flags (int argc, char **argv)
case 's': case 's':
sort_mode = true; sort_mode = true;
break; break;
case 'S':
silence_warnings = true;
break;
default: default:
usage (E_USAGE); usage (E_USAGE);
} }
@ -456,7 +460,7 @@ static void compare_members_lists (const char *groupname,
break; break;
} }
} }
if (*other_pmem == NULL) { if (!silence_warnings && *other_pmem == NULL) {
printf printf
("'%s' is a member of the '%s' group in %s but not in %s\n", ("'%s' is a member of the '%s' group in %s but not in %s\n",
*pmem, groupname, file, other_file); *pmem, groupname, file, other_file);