Same changes as for chpasswd:
* src/chpasswd.c: main() split in process_flags(), check_flags(), check_perms(), open_files(), and close_files().
This commit is contained in:
parent
28cd038c35
commit
9fe450e216
@ -76,24 +76,24 @@ static void close_files (void);
|
|||||||
static void usage (void)
|
static void usage (void)
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Usage: %s [options]\n"
|
fprintf (stderr, _("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -c, --crypt-method the crypt method (one of %s)\n"
|
" -c, --crypt-method the crypt method (one of %s)\n"
|
||||||
" -e, --encrypted supplied passwords are encrypted\n"
|
" -e, --encrypted supplied passwords are encrypted\n"
|
||||||
" -h, --help display this help message and exit\n"
|
" -h, --help display this help message and exit\n"
|
||||||
" -m, --md5 encrypt the clear text password using\n"
|
" -m, --md5 encrypt the clear text password using\n"
|
||||||
" the MD5 algorithm\n"
|
" the MD5 algorithm\n"
|
||||||
"%s"
|
"%s"
|
||||||
"\n"),
|
"\n"),
|
||||||
Prog,
|
Prog,
|
||||||
#ifndef USE_SHA_CRYPT
|
#ifndef USE_SHA_CRYPT
|
||||||
"NONE DES MD5", ""
|
"NONE DES MD5", ""
|
||||||
#else
|
#else
|
||||||
"NONE DES MD5 SHA256 SHA512",
|
"NONE DES MD5 SHA256 SHA512",
|
||||||
_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
||||||
" crypt algorithms\n")
|
" crypt algorithms\n")
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,16 +171,16 @@ static void check_flags (void)
|
|||||||
{
|
{
|
||||||
if (sflg && !cflg) {
|
if (sflg && !cflg) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is ONLY allowed with the %s flag\n"),
|
_("%s: %s flag is ONLY allowed with the %s flag\n"),
|
||||||
Prog, "-s", "-c");
|
Prog, "-s", "-c");
|
||||||
usage ();
|
usage ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((eflg && (md5flg || cflg)) ||
|
if ((eflg && (md5flg || cflg)) ||
|
||||||
(md5flg && cflg)) {
|
(md5flg && cflg)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,13 +272,13 @@ static void open_files (void)
|
|||||||
if (is_shadow_grp) {
|
if (is_shadow_grp) {
|
||||||
if (!sgr_lock ()) {
|
if (!sgr_lock ()) {
|
||||||
fprintf (stderr, _("%s: can't lock gshadow file\n"),
|
fprintf (stderr, _("%s: can't lock gshadow file\n"),
|
||||||
Prog);
|
Prog);
|
||||||
gr_unlock ();
|
gr_unlock ();
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
if (!sgr_open (O_RDWR)) {
|
if (!sgr_open (O_RDWR)) {
|
||||||
fprintf (stderr, _("%s: can't open shadow file\n"),
|
fprintf (stderr, _("%s: can't open shadow file\n"),
|
||||||
Prog);
|
Prog);
|
||||||
gr_unlock ();
|
gr_unlock ();
|
||||||
sgr_unlock ();
|
sgr_unlock ();
|
||||||
exit (1);
|
exit (1);
|
||||||
@ -296,7 +296,7 @@ static void close_files (void)
|
|||||||
if (is_shadow_grp) {
|
if (is_shadow_grp) {
|
||||||
if (!sgr_close ()) {
|
if (!sgr_close ()) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: error updating shadow file\n"), Prog);
|
_("%s: error updating shadow file\n"), Prog);
|
||||||
gr_unlock ();
|
gr_unlock ();
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ int main (int argc, char **argv)
|
|||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr, _("%s: line %d: line too long\n"),
|
fprintf (stderr, _("%s: line %d: line too long\n"),
|
||||||
Prog, line);
|
Prog, line);
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -373,8 +373,8 @@ int main (int argc, char **argv)
|
|||||||
*cp++ = '\0';
|
*cp++ = '\0';
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: line %d: missing new password\n"),
|
_("%s: line %d: missing new password\n"),
|
||||||
Prog, line);
|
Prog, line);
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -401,8 +401,8 @@ int main (int argc, char **argv)
|
|||||||
gr = gr_locate (name);
|
gr = gr_locate (name);
|
||||||
if (!gr) {
|
if (!gr) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: line %d: unknown group %s\n"), Prog,
|
_("%s: line %d: unknown group %s\n"), Prog,
|
||||||
line, name);
|
line, name);
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -443,9 +443,9 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_
|
||||||
("%s: line %d: cannot update password entry\n"),
|
("%s: line %d: cannot update password entry\n"),
|
||||||
Prog, line);
|
Prog, line);
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ int main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (errors) {
|
if (errors) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: error detected, changes ignored\n"), Prog);
|
_("%s: error detected, changes ignored\n"), Prog);
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
if (is_shadow_grp)
|
if (is_shadow_grp)
|
||||||
sgr_unlock ();
|
sgr_unlock ();
|
||||||
@ -479,3 +479,4 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user