ypserv/ypserv-2.27-crypt.patch

53 lines
1.8 KiB
Diff

diff -up ypserv-2.27/rpc.yppasswdd/update.c.crypt ypserv-2.27/rpc.yppasswdd/update.c
--- ypserv-2.27/rpc.yppasswdd/update.c.crypt 2012-04-23 13:43:11.180743268 +0200
+++ ypserv-2.27/rpc.yppasswdd/update.c 2012-04-23 13:43:15.747726695 +0200
@@ -216,14 +216,27 @@ putspent_adjunct (const struct spwd *p,
/* Check if the password the user supplied matches the old one */
static int
-password_ok (char *plain, char *crypted, char *root)
+password_ok (char *plain, char *crypted, char *root, char *logbuf)
{
+ char *crypted_new;
if (crypted[0] == '\0')
return 1;
- if (strcmp (crypt (plain, crypted), crypted) == 0)
+ crypted_new = crypt (plain, crypted);
+ if (crypted_new == NULL)
+ {
+ log_msg ("crypt() call failed.", logbuf);
+ return 0;
+ }
+ if (strcmp (crypted_new, crypted) == 0)
return 1;
#if CHECKROOT
- if (strcmp (crypt (plain, root), root) == 0)
+ crypted_new = crypt (plain, root);
+ if (crypted_new == NULL)
+ {
+ log_msg ("crypt() call failed.", logbuf);
+ return 0;
+ }
+ if (strcmp (crypted_new, root) == 0)
return 1;
#endif
@@ -557,7 +570,7 @@ update_files (yppasswd *yppw, char *logb
{
if (strcmp (yppw->newpw.pw_name, spw->sp_namp) == 0)
{
- if (!password_ok (yppw->oldpass, spw->sp_pwdp, rootpass))
+ if (!password_ok (yppw->oldpass, spw->sp_pwdp, rootpass, logbuf))
{
log_msg ("%s rejected", logbuf);
log_msg ("Invalid password.");
@@ -579,7 +592,7 @@ update_files (yppasswd *yppw, char *logb
/* We don't have a shadow password file or we don't find the
user in it. */
if (spw == NULL &&
- !password_ok (yppw->oldpass, pw->pw_passwd, rootpass))
+ !password_ok (yppw->oldpass, pw->pw_passwd, rootpass, logbuf))
{
log_msg ("%s rejected", logbuf);
log_msg ("Invalid password.");