* NEWS, src/pwconv.c, src/pwunconv.c, src/grpconv.c,
src/grpunconv.c, man/pwconv.8.xml: Add --root option. * src/pwconv.c, src/pwunconv.c, src/grpconv.c, src/grpunconv.c: Add --help option. * src/pwconv.c, src/pwunconv.c, src/grpconv.c, src/grpunconv.c: Add process_flags() and usage().
This commit is contained in:
@@ -23,6 +23,12 @@
|
|||||||
* NEWS, src/groupdel.c, man/groupdel.8.xml: Add --root option. Open
|
* NEWS, src/groupdel.c, man/groupdel.8.xml: Add --root option. Open
|
||||||
audit and syslog after the potential chroot.
|
audit and syslog after the potential chroot.
|
||||||
* src/groupdel.c: Check atexit failures.
|
* src/groupdel.c: Check atexit failures.
|
||||||
|
* NEWS, src/pwconv.c, src/pwunconv.c, src/grpconv.c,
|
||||||
|
src/grpunconv.c, man/pwconv.8.xml: Add --root option.
|
||||||
|
* src/pwconv.c, src/pwunconv.c, src/grpconv.c, src/grpunconv.c:
|
||||||
|
Add --help option.
|
||||||
|
* src/pwconv.c, src/pwunconv.c, src/grpconv.c, src/grpunconv.c:
|
||||||
|
Add process_flags() and usage().
|
||||||
|
|
||||||
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
8
NEWS
8
NEWS
@@ -43,6 +43,10 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
* Add --root option.
|
* Add --root option.
|
||||||
- grpck
|
- grpck
|
||||||
* NIS entries were dropped by -s (sort).
|
* NIS entries were dropped by -s (sort).
|
||||||
|
- grpconv
|
||||||
|
* Add --root option.
|
||||||
|
- grpunconv
|
||||||
|
* Add --root option.
|
||||||
-login
|
-login
|
||||||
* Fixed limits support (non PAM enabled versions only)
|
* Fixed limits support (non PAM enabled versions only)
|
||||||
* Added support for infinite limits and group based limits (non PAM
|
* Added support for infinite limits and group based limits (non PAM
|
||||||
@@ -73,6 +77,10 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
* Fix parsing of gshadow entries.
|
* Fix parsing of gshadow entries.
|
||||||
- pwpck
|
- pwpck
|
||||||
* NIS entries were dropped by -s (sort).
|
* NIS entries were dropped by -s (sort).
|
||||||
|
- pwconv
|
||||||
|
* Add --root option.
|
||||||
|
- pwunconv
|
||||||
|
* Add --root option.
|
||||||
- useradd
|
- useradd
|
||||||
* If the skeleton directory contained hardlinked files, copies of the
|
* If the skeleton directory contained hardlinked files, copies of the
|
||||||
hardlink were removed from the skeleton directory.
|
hardlink were removed from the skeleton directory.
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 1996 - 1998, Marek Michałkiewicz
|
Copyright (c) 1996 - 1998, Marek Michałkiewicz
|
||||||
Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
||||||
Copyright (c) 2007 - 2008, 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
|
||||||
@@ -58,15 +58,27 @@
|
|||||||
<refsynopsisdiv id='synopsis'>
|
<refsynopsisdiv id='synopsis'>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>pwconv</command>
|
<command>pwconv</command>
|
||||||
|
<arg choice='opt'>
|
||||||
|
<replaceable>options</replaceable>
|
||||||
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>pwunconv</command>
|
<command>pwunconv</command>
|
||||||
|
<arg choice='opt'>
|
||||||
|
<replaceable>options</replaceable>
|
||||||
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>grpconv</command>
|
<command>grpconv</command>
|
||||||
|
<arg choice='opt'>
|
||||||
|
<replaceable>options</replaceable>
|
||||||
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>grpunconv</command>
|
<command>grpunconv</command>
|
||||||
|
<arg choice='opt'>
|
||||||
|
<replaceable>options</replaceable>
|
||||||
|
</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
@@ -152,6 +164,36 @@
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id='options'>
|
||||||
|
<title>OPTIONS</title>
|
||||||
|
<para>
|
||||||
|
The options which apply to the <command>pwconv</command>,
|
||||||
|
<command>pwunconv</command>, <command>grpconv</command>, and
|
||||||
|
<command>grpunconv</command> commands are:
|
||||||
|
</para>
|
||||||
|
<variablelist remap='IP'>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-h</option>, <option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Display help message and exit.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>-R</option>, <option>--root</option>
|
||||||
|
<replaceable>CHROOT_DIR</replaceable>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Apply changes in the <replaceable>CHROOT_DIR</replaceable>
|
||||||
|
directory and use the configuration files from the
|
||||||
|
<replaceable>CHROOT_DIR</replaceable> directory.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id='bugs'>
|
<refsect1 id='bugs'>
|
||||||
<title>BUGS</title>
|
<title>BUGS</title>
|
||||||
<para>
|
<para>
|
||||||
|
@@ -46,8 +46,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
/*@-exitarg@*/
|
||||||
|
#include "exitcodes.h"
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
#include "groupio.h"
|
#include "groupio.h"
|
||||||
#include "sgroupio.h"
|
#include "sgroupio.h"
|
||||||
@@ -61,6 +64,8 @@ static bool sgr_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int status);
|
static void fail_exit (int status);
|
||||||
|
static void usage (int status);
|
||||||
|
static void process_flags (int argc, char **argv);
|
||||||
|
|
||||||
static void fail_exit (int status)
|
static void fail_exit (int status)
|
||||||
{
|
{
|
||||||
@@ -83,6 +88,55 @@ static void fail_exit (int status)
|
|||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usage (int status)
|
||||||
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
|
(void) fprintf (usageout,
|
||||||
|
_("Usage: %s [options]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* process_flags - parse the command line options
|
||||||
|
*
|
||||||
|
* It will not return if an error is encountered.
|
||||||
|
*/
|
||||||
|
static void process_flags (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Parse the command line options.
|
||||||
|
*/
|
||||||
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
|
while ((c = getopt_long (argc, argv, "hR:",
|
||||||
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const struct group *gr;
|
const struct group *gr;
|
||||||
@@ -90,18 +144,18 @@ int main (int argc, char **argv)
|
|||||||
const struct sgrp *sg;
|
const struct sgrp *sg;
|
||||||
struct sgrp sgent;
|
struct sgrp sgent;
|
||||||
|
|
||||||
if (1 != argc) {
|
|
||||||
(void) fputs (_("Usage: grpconv\n"), stderr);
|
|
||||||
fail_exit (2);
|
|
||||||
}
|
|
||||||
Prog = Basename (argv[0]);
|
Prog = Basename (argv[0]);
|
||||||
|
|
||||||
(void) setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
OPENLOG ("grpconv");
|
OPENLOG ("grpconv");
|
||||||
|
|
||||||
|
process_flags (argc, argv);
|
||||||
|
|
||||||
if (gr_lock () == 0) {
|
if (gr_lock () == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: cannot lock %s; try again later.\n"),
|
_("%s: cannot lock %s; try again later.\n"),
|
||||||
|
@@ -46,8 +46,11 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
/*@-exitarg@*/
|
||||||
|
#include "exitcodes.h"
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
#include "groupio.h"
|
#include "groupio.h"
|
||||||
#include "sgroupio.h"
|
#include "sgroupio.h"
|
||||||
@@ -61,6 +64,8 @@ static bool sgr_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int status);
|
static void fail_exit (int status);
|
||||||
|
static void usage (int status);
|
||||||
|
static void process_flags (int argc, char **argv);
|
||||||
|
|
||||||
static void fail_exit (int status)
|
static void fail_exit (int status)
|
||||||
{
|
{
|
||||||
@@ -83,24 +88,73 @@ static void fail_exit (int status)
|
|||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usage (int status)
|
||||||
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
|
(void) fprintf (usageout,
|
||||||
|
_("Usage: %s [options]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* process_flags - parse the command line options
|
||||||
|
*
|
||||||
|
* It will not return if an error is encountered.
|
||||||
|
*/
|
||||||
|
static void process_flags (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Parse the command line options.
|
||||||
|
*/
|
||||||
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
|
while ((c = getopt_long (argc, argv, "hR:",
|
||||||
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const struct group *gr;
|
const struct group *gr;
|
||||||
struct group grent;
|
struct group grent;
|
||||||
const struct sgrp *sg;
|
const struct sgrp *sg;
|
||||||
|
|
||||||
if (1 != argc) {
|
|
||||||
(void) fputs (_("Usage: grpunconv\n"), stderr);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
Prog = Basename (argv[0]);
|
Prog = Basename (argv[0]);
|
||||||
|
|
||||||
(void) setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
OPENLOG ("grpunconv");
|
OPENLOG ("grpunconv");
|
||||||
|
|
||||||
|
process_flags (argc, argv);
|
||||||
|
|
||||||
if (sgr_file_present () == 0) {
|
if (sgr_file_present () == 0) {
|
||||||
exit (0); /* no /etc/gshadow, nothing to do */
|
exit (0); /* no /etc/gshadow, nothing to do */
|
||||||
}
|
}
|
||||||
|
64
src/pwconv.c
64
src/pwconv.c
@@ -65,6 +65,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "getdef.h"
|
#include "getdef.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
@@ -93,6 +94,8 @@ static bool pw_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int status);
|
static void fail_exit (int status);
|
||||||
|
static void usage (int status);
|
||||||
|
static void process_flags (int argc, char **argv);
|
||||||
|
|
||||||
static void fail_exit (int status)
|
static void fail_exit (int status)
|
||||||
{
|
{
|
||||||
@@ -115,6 +118,55 @@ static void fail_exit (int status)
|
|||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usage (int status)
|
||||||
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
|
(void) fprintf (usageout,
|
||||||
|
_("Usage: %s [options]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* process_flags - parse the command line options
|
||||||
|
*
|
||||||
|
* It will not return if an error is encountered.
|
||||||
|
*/
|
||||||
|
static void process_flags (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Parse the command line options.
|
||||||
|
*/
|
||||||
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
|
while ((c = getopt_long (argc, argv, "hR:",
|
||||||
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const struct passwd *pw;
|
const struct passwd *pw;
|
||||||
@@ -122,22 +174,22 @@ int main (int argc, char **argv)
|
|||||||
const struct spwd *sp;
|
const struct spwd *sp;
|
||||||
struct spwd spent;
|
struct spwd spent;
|
||||||
|
|
||||||
if (1 != argc) {
|
|
||||||
(void) fputs (_("Usage: pwconv\n"), stderr);
|
|
||||||
fail_exit (E_USAGE);
|
|
||||||
}
|
|
||||||
Prog = Basename (argv[0]);
|
Prog = Basename (argv[0]);
|
||||||
|
|
||||||
(void) setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
OPENLOG ("pwconv");
|
OPENLOG ("pwconv");
|
||||||
|
|
||||||
|
process_flags (argc, argv);
|
||||||
|
|
||||||
#ifdef WITH_TCB
|
#ifdef WITH_TCB
|
||||||
if (getdef_bool("USE_TCB")) {
|
if (getdef_bool("USE_TCB")) {
|
||||||
fprintf(stderr, _("%s: can't work with tcb enabled\n"), Prog);
|
fprintf (stderr, _("%s: can't work with tcb enabled\n"), Prog);
|
||||||
fail_exit(E_FAILURE);
|
exit (E_FAILURE);
|
||||||
}
|
}
|
||||||
#endif /* WITH_TCB */
|
#endif /* WITH_TCB */
|
||||||
|
|
||||||
|
@@ -39,11 +39,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "pwio.h"
|
#include "pwio.h"
|
||||||
#include "shadowio.h"
|
#include "shadowio.h"
|
||||||
|
/*@-exitarg@*/
|
||||||
|
#include "exitcodes.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
@@ -55,6 +58,8 @@ static bool pw_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int status);
|
static void fail_exit (int status);
|
||||||
|
static void usage (int status);
|
||||||
|
static void process_flags (int argc, char **argv);
|
||||||
|
|
||||||
static void fail_exit (int status)
|
static void fail_exit (int status)
|
||||||
{
|
{
|
||||||
@@ -75,6 +80,54 @@ static void fail_exit (int status)
|
|||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usage (int status)
|
||||||
|
{
|
||||||
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
|
(void) fprintf (usageout,
|
||||||
|
_("Usage: %s [options]\n"
|
||||||
|
"\n"
|
||||||
|
"Options:\n"),
|
||||||
|
Prog);
|
||||||
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* process_flags - parse the command line options
|
||||||
|
*
|
||||||
|
* It will not return if an error is encountered.
|
||||||
|
*/
|
||||||
|
static void process_flags (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Parse the command line options.
|
||||||
|
*/
|
||||||
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
|
{NULL, 0, NULL, '\0'}
|
||||||
|
};
|
||||||
|
|
||||||
|
while ((c = getopt_long (argc, argv, "hR:",
|
||||||
|
long_options, NULL)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
|
/*@notreached@*/break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
usage (E_USAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -82,18 +135,18 @@ int main (int argc, char **argv)
|
|||||||
struct passwd pwent;
|
struct passwd pwent;
|
||||||
const struct spwd *spwd;
|
const struct spwd *spwd;
|
||||||
|
|
||||||
if (1 != argc) {
|
|
||||||
(void) fputs (_("Usage: pwunconv\n"), stderr);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
Prog = Basename (argv[0]);
|
Prog = Basename (argv[0]);
|
||||||
|
|
||||||
(void) setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
OPENLOG ("pwunconv");
|
OPENLOG ("pwunconv");
|
||||||
|
|
||||||
|
process_flags (argc, argv);
|
||||||
|
|
||||||
#ifdef WITH_TCB
|
#ifdef WITH_TCB
|
||||||
if (getdef_bool("USE_TCB")) {
|
if (getdef_bool("USE_TCB")) {
|
||||||
fprintf (stderr, _("%s: can't work with tcb enabled\n"), Prog);
|
fprintf (stderr, _("%s: can't work with tcb enabled\n"), Prog);
|
||||||
|
Reference in New Issue
Block a user