* src/pwck.c, man/pwck.8.xml: Add support for long options.
* src/pwck.c, man/pwck.8.xml: Add -h/--help option * src/grpck.c, man/grpck.8.xml: Add support for long options. * src/grpck.c, man/grpck.8.xml: Add -h/--help option
This commit is contained in:
parent
b9163f6348
commit
900943192f
@ -1,3 +1,10 @@
|
|||||||
|
2011-10-31 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/pwck.c, man/pwck.8.xml: Add support for long options.
|
||||||
|
* src/pwck.c, man/pwck.8.xml: Add -h/--help option
|
||||||
|
* src/grpck.c, man/grpck.8.xml: Add support for long options.
|
||||||
|
* src/grpck.c, man/grpck.8.xml: Add -h/--help option
|
||||||
|
|
||||||
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
|
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/expiry.c, man/expiry.1.xml: Add support for long options.
|
* src/expiry.c, man/expiry.1.xml: Add support for long options.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 1992 - 1993, Julianne Frances Haugh
|
Copyright (c) 1992 - 1993, Julianne Frances Haugh
|
||||||
Copyright (c) 2007 - 2009, Nicolas François
|
Copyright (c) 2007 - 2011, Nicolas François
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@ -49,16 +49,8 @@
|
|||||||
|
|
||||||
<refsynopsisdiv id='synopsis'>
|
<refsynopsisdiv id='synopsis'>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>grpck</command> <arg choice='opt'>-r </arg>
|
<command>grpck</command>
|
||||||
<arg choice='opt'>
|
<arg choice='opt'>options</arg>
|
||||||
<arg choice='plain'><replaceable>group</replaceable></arg>
|
|
||||||
<arg choice='opt' condition="gshadow">
|
|
||||||
<arg choice='plain'><replaceable>shadow</replaceable></arg>
|
|
||||||
</arg>
|
|
||||||
</arg>
|
|
||||||
</cmdsynopsis>
|
|
||||||
<cmdsynopsis>
|
|
||||||
<command>grpck</command> <arg choice='opt'>-s </arg>
|
|
||||||
<arg choice='opt'>
|
<arg choice='opt'>
|
||||||
<arg choice='plain'><replaceable>group</replaceable></arg>
|
<arg choice='plain'><replaceable>group</replaceable></arg>
|
||||||
<arg choice='opt' condition="gshadow">
|
<arg choice='opt' condition="gshadow">
|
||||||
@ -134,12 +126,22 @@
|
|||||||
|
|
||||||
<refsect1 id='options'>
|
<refsect1 id='options'>
|
||||||
<title>OPTIONS</title>
|
<title>OPTIONS</title>
|
||||||
|
<para>
|
||||||
|
The <option>-r</option> and <option>-s</option> options cannot be
|
||||||
|
combined.
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The options which apply to the <command>grpck</command> command are:
|
The options which apply to the <command>grpck</command> command are:
|
||||||
</para>
|
</para>
|
||||||
<variablelist remap='IP'>
|
<variablelist remap='IP'>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-r</option></term>
|
<term><option>-h</option>, <option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Display help message and exit.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-r</option>, <option>--read-only</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Execute the <command>grpck</command> command in read-only mode.
|
Execute the <command>grpck</command> command in read-only mode.
|
||||||
@ -149,7 +151,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-s</option></term>
|
<term><option>-s</option>, <option>--sort</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Sort entries in <filename>/etc/group</filename>
|
Sort entries in <filename>/etc/group</filename>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 1992 , Julianne Frances Haugh
|
Copyright (c) 1992 , Julianne Frances Haugh
|
||||||
Copyright (c) 2007 - 2009, Nicolas François
|
Copyright (c) 2007 - 2011, Nicolas François
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@ -55,8 +55,7 @@
|
|||||||
<refsynopsisdiv id='synopsis'>
|
<refsynopsisdiv id='synopsis'>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>pwck</command>
|
<command>pwck</command>
|
||||||
<arg choice='opt'>-q </arg>
|
<arg choice='opt'>options</arg>
|
||||||
<arg choice='opt'>-s </arg>
|
|
||||||
<arg choice='opt'>
|
<arg choice='opt'>
|
||||||
<arg choice='plain'>
|
<arg choice='plain'>
|
||||||
<replaceable>passwd</replaceable>
|
<replaceable>passwd</replaceable>
|
||||||
@ -68,21 +67,6 @@
|
|||||||
</arg>
|
</arg>
|
||||||
</arg>
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
|
||||||
<command>pwck</command>
|
|
||||||
<arg choice='opt'>-q </arg>
|
|
||||||
<arg choice='opt'>-r </arg>
|
|
||||||
<arg choice='opt'>
|
|
||||||
<arg choice='plain'>
|
|
||||||
<replaceable>passwd</replaceable>
|
|
||||||
</arg>
|
|
||||||
<arg choice='opt'>
|
|
||||||
<arg choice='plain'>
|
|
||||||
<replaceable>shadow</replaceable>
|
|
||||||
</arg>
|
|
||||||
</arg>
|
|
||||||
</arg>
|
|
||||||
</cmdsynopsis>
|
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
<refsect1 id='description'>
|
<refsect1 id='description'>
|
||||||
@ -171,14 +155,22 @@
|
|||||||
|
|
||||||
<refsect1 id='options'>
|
<refsect1 id='options'>
|
||||||
<title>OPTIONS</title>
|
<title>OPTIONS</title>
|
||||||
|
<para>
|
||||||
|
The <option>-r</option> and <option>-s</option> options cannot be
|
||||||
|
combined.
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The options which apply to the <command>pwck</command> command are:
|
The options which apply to the <command>pwck</command> command are:
|
||||||
</para>
|
</para>
|
||||||
<variablelist remap='IP'>
|
<variablelist remap='IP'>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term><option>-h</option>, <option>--help</option></term>
|
||||||
<option>-q</option>
|
<listitem>
|
||||||
</term>
|
<para>Display help message and exit.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-q</option>, <option>--quiet</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Report errors only. The warnings which do not require any
|
Report errors only. The warnings which do not require any
|
||||||
@ -187,9 +179,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term><option>-r</option>, <option>--read-only</option></term>
|
||||||
<option>-r</option>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Execute the <command>pwck</command> command in read-only mode.
|
Execute the <command>pwck</command> command in read-only mode.
|
||||||
@ -197,9 +187,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term><option>-s</option>, <option>--sort</option></term>
|
||||||
<option>-s</option>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Sort entries in <filename>/etc/passwd</filename> and
|
Sort entries in <filename>/etc/passwd</filename> and
|
||||||
|
53
src/grpck.c
53
src/grpck.c
@ -39,6 +39,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "chkname.h"
|
#include "chkname.h"
|
||||||
#include "commonio.h"
|
#include "commonio.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@ -55,6 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
/*@-exitarg@*/
|
/*@-exitarg@*/
|
||||||
#define E_OKAY 0
|
#define E_OKAY 0
|
||||||
|
#define E_SUCCESS 0
|
||||||
#define E_USAGE 1
|
#define E_USAGE 1
|
||||||
#define E_BAD_ENTRY 2
|
#define E_BAD_ENTRY 2
|
||||||
#define E_CANT_OPEN 3
|
#define E_CANT_OPEN 3
|
||||||
@ -82,7 +84,7 @@ static bool sort_mode = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int status);
|
static void fail_exit (int status);
|
||||||
static void usage (void);
|
static /*@noreturn@*/void usage (int status);
|
||||||
static void delete_member (char **, const char *);
|
static void delete_member (char **, const char *);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
static void open_files (void);
|
static void open_files (void);
|
||||||
@ -134,14 +136,28 @@ static void fail_exit (int status)
|
|||||||
/*
|
/*
|
||||||
* usage - print syntax message and exit
|
* usage - print syntax message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static /*@noreturn@*/void usage (int status)
|
||||||
{
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
fprintf (stderr, _("Usage: %s [-r] [-s] [group [gshadow]]\n"), Prog);
|
(void) fprintf (usageout,
|
||||||
#else
|
_("Usage: %s [options] [group [gshadow]]\n"
|
||||||
fprintf (stderr, _("Usage: %s [-r] [-s] [group]\n"), Prog);
|
"\n"
|
||||||
#endif
|
"Options:\n"),
|
||||||
exit (E_USAGE);
|
Prog);
|
||||||
|
#else /* !SHADOWGRP */
|
||||||
|
(void) fprintf (usageout,
|
||||||
|
_("Usage: %s [options] [group]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
|
#endif /* !SHADOWGRP */
|
||||||
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -r, --read-only display errors and warnings\n"
|
||||||
|
" but do not change files\n"), usageout);
|
||||||
|
(void) fputs (_(" -s, --sort sort entries by UID\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -173,13 +189,24 @@ static void delete_member (char **list, const char *member)
|
|||||||
*/
|
*/
|
||||||
static void process_flags (int argc, char **argv)
|
static void process_flags (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int arg;
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
|
{"read-only", no_argument, NULL, 'r'},
|
||||||
|
{"sort", no_argument, NULL, 's'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the command line arguments
|
* Parse the command line arguments
|
||||||
*/
|
*/
|
||||||
while ((arg = getopt (argc, argv, "qrs")) != EOF) {
|
while ((c = getopt_long (argc, argv, "hqrs",
|
||||||
switch (arg) {
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
case 'q':
|
case 'q':
|
||||||
/* quiet - ignored for now */
|
/* quiet - ignored for now */
|
||||||
break;
|
break;
|
||||||
@ -190,12 +217,12 @@ static void process_flags (int argc, char **argv)
|
|||||||
sort_mode = true;
|
sort_mode = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort_mode && read_only) {
|
if (sort_mode && read_only) {
|
||||||
fprintf (stderr, _("%s: -s and -r are incompatibile\n"), Prog);
|
fprintf (stderr, _("%s: -s and -r are incompatible\n"), Prog);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +235,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
if (argc > (optind + 1))
|
if (argc > (optind + 1))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
60
src/pwck.c
60
src/pwck.c
@ -3,7 +3,7 @@
|
|||||||
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
||||||
* Copyright (c) 2001 , Michał Moskal
|
* Copyright (c) 2001 , Michał Moskal
|
||||||
* Copyright (c) 2001 - 2006, Tomasz Kłoczko
|
* Copyright (c) 2001 - 2006, Tomasz Kłoczko
|
||||||
* Copyright (c) 2007 - 2010, Nicolas François
|
* Copyright (c) 2007 - 2011, Nicolas François
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -39,6 +39,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "chkname.h"
|
#include "chkname.h"
|
||||||
#include "commonio.h"
|
#include "commonio.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@ -56,6 +57,7 @@
|
|||||||
*/
|
*/
|
||||||
/*@-exitarg@*/
|
/*@-exitarg@*/
|
||||||
#define E_OKAY 0
|
#define E_OKAY 0
|
||||||
|
#define E_SUCCESS 0
|
||||||
#define E_USAGE 1
|
#define E_USAGE 1
|
||||||
#define E_BADENTRY 2
|
#define E_BADENTRY 2
|
||||||
#define E_CANTOPEN 3
|
#define E_CANTOPEN 3
|
||||||
@ -86,7 +88,7 @@ static bool quiet = false; /* don't report warnings, only errors */
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int code);
|
static void fail_exit (int code);
|
||||||
static void usage (void);
|
static /*@noreturn@*/void usage (int status);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
static void open_files (void);
|
static void open_files (void);
|
||||||
static void close_files (bool changed);
|
static void close_files (bool changed);
|
||||||
@ -127,20 +129,37 @@ static void fail_exit (int code)
|
|||||||
/*
|
/*
|
||||||
* usage - print syntax message and exit
|
* usage - print syntax message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static /*@noreturn@*/void usage (int status)
|
||||||
{
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
#ifdef WITH_TCB
|
#ifdef WITH_TCB
|
||||||
if (getdef_bool ("USE_TCB")) {
|
if (getdef_bool ("USE_TCB")) {
|
||||||
fprintf (stderr, _("Usage: %s [-q] [-r] [passwd]\n"),
|
(void) fprintf (usageout,
|
||||||
Prog);
|
_("Usage: %s [options] [passwd]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
} else
|
} else
|
||||||
#endif /* WITH_TCB */
|
#endif /* WITH_TCB */
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
(void) fprintf (usageout,
|
||||||
_("Usage: %s [-q] [-r] [-s] [passwd [shadow]]\n"),
|
_("Usage: %s [options] [passwd [shadow]]\n"
|
||||||
Prog);
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
}
|
}
|
||||||
exit (E_USAGE);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -q, --quiet report errors only\n"), usageout);
|
||||||
|
(void) fputs (_(" -r, --read-only display errors and warnings\n"
|
||||||
|
" but do not change files\n"), usageout);
|
||||||
|
#ifdef WITH_TCB
|
||||||
|
if (!getdef_bool ("USE_TCB")) {
|
||||||
|
#endif /* !WITH_TCB */
|
||||||
|
{
|
||||||
|
(void) fputs (_(" -s, --sort sort entries by UID\n"), usageout);
|
||||||
|
}
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -150,13 +169,24 @@ static void usage (void)
|
|||||||
*/
|
*/
|
||||||
static void process_flags (int argc, char **argv)
|
static void process_flags (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int arg;
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
|
{"read-only", no_argument, NULL, 'r'},
|
||||||
|
{"sort", no_argument, NULL, 's'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the command line arguments
|
* Parse the command line arguments
|
||||||
*/
|
*/
|
||||||
while ((arg = getopt (argc, argv, "eqrs")) != EOF) {
|
while ((c = getopt_long (argc, argv, "ehqrs",
|
||||||
switch (arg) {
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
case 'e': /* added for Debian shadow-961025-2 compatibility */
|
case 'e': /* added for Debian shadow-961025-2 compatibility */
|
||||||
case 'q':
|
case 'q':
|
||||||
quiet = true;
|
quiet = true;
|
||||||
@ -168,7 +198,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
sort_mode = true;
|
sort_mode = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +211,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
* Make certain we have the right number of arguments
|
* Make certain we have the right number of arguments
|
||||||
*/
|
*/
|
||||||
if ((argc < optind) || (argc > (optind + 2))) {
|
if ((argc < optind) || (argc > (optind + 2))) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -198,7 +228,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: no alternative shadow file allowed when USE_TCB is enabled.\n"),
|
_("%s: no alternative shadow file allowed when USE_TCB is enabled.\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
#endif /* WITH_TCB */
|
#endif /* WITH_TCB */
|
||||||
spw_setdbname (argv[optind + 1]);
|
spw_setdbname (argv[optind + 1]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user