From fa849886fc343068ff294304ff991a7a755c4576 Mon Sep 17 00:00:00 2001 From: "chaoming.meng" Date: Thu, 7 Nov 2024 11:13:36 +0800 Subject: [PATCH] Fix regular users expired password reset issue --- session.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/session.c b/session.c index 41fdcf7a95d5..a341821abdf2 100644 --- a/session.c +++ b/session.c @@ -1438,8 +1438,11 @@ do_pwchange(Session *s) setexeccon(NULL); #endif #ifdef PASSWD_NEEDS_USERNAME - execl(_PATH_PASSWD_PROG, "passwd", s->pw->pw_name, - (char *)NULL); + if (getuid() != 0) { + execl(_PATH_PASSWD_PROG, "passwd", (char *)NULL); + } else { + execl(_PATH_PASSWD_PROG, "passwd", s->pw->pw_name, (char *)NULL); + } #else execl(_PATH_PASSWD_PROG, "passwd", (char *)NULL); #endif