static void update_passwd (struct passwd *pwd, const char *passwd)
{
- void *arg = NULL;
+ void *crypt_arg = NULL;
if (crypt_method != NULL) {
if (sflg)
- arg = &sha_rounds;
+ crypt_arg = &sha_rounds;
}
if (crypt_method != NULL && 0 == strcmp(crypt_method, "NONE")) {
} else {
pwd->pw_passwd = pw_encrypt (passwd,
crypt_make_salt (crypt_method,
- arg));
+ crypt_arg));
}
}
{
const struct spwd *sp;
struct spwd spent;
+ void *crypt_arg = NULL;
+ if (crypt_method != NULL) {
+ if (sflg)
+ crypt_arg = &sha_rounds;
+ }
/*
* In the case of regular password files, this is real easy - pwd
if ((sp = spw_locate (pwd->pw_name))) {
spent = *sp;
spent.sp_pwdp = pw_encrypt (passwd,
- crypt_make_salt (NULL, NULL));
+ crypt_make_salt (crypt_method,
+ crypt_arg));
return !spw_update (&spent);
}
* shadow password file entry.
*/
spent.sp_namp = pwd->pw_name;
- spent.sp_pwdp = pw_encrypt (passwd, crypt_make_salt (NULL, NULL));
+ spent.sp_pwdp = pw_encrypt (passwd,
+ crypt_make_salt (crypt_method, crypt_arg));
spent.sp_lstchg = time ((time_t *) 0) / SCALE;
spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
/* 10000 is infinity this week */
static struct option long_options[] = {
{"crypt-method", required_argument, NULL, 'c'},
{"help", no_argument, NULL, 'h'},
+#ifdef ENCRYPTMETHOD_SELECT
{"sha-rounds", required_argument, NULL, 's'},
+#endif
{NULL, 0, NULL, '\0'}
};
while ((c =
- getopt_long (argc, argv, "c:hs:", long_options,
+ getopt_long (argc, argv,
+#ifdef ENCRYPTMETHOD_SELECT
+ "c:hs:",
+#else
+ "c:h",
+#endif
+ long_options,
&option_index)) != -1) {
switch (c) {
case 'c':
case 'h':
usage ();
break;
+#ifdef ENCRYPTMETHOD_SELECT
case 's':
sflg = 1;
if (!getlong(optarg, &sha_rounds)) {
usage ();
}
break;
+#endif
case 0:
/* long option */
break;