vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jakub Jelen 134139
diff -up openssh-7.4p1/session.c.update-pw openssh-7.4p1/session.c
Jakub Jelen 134139
--- openssh-7.4p1/session.c.update-pw	2019-03-04 14:10:57.287054645 +0100
Jakub Jelen 134139
+++ openssh-7.4p1/session.c	2019-03-04 14:12:39.259997218 +0100
Jakub Jelen 134139
@@ -1522,9 +1522,18 @@ do_child(Session *s, const char *command
Jakub Jelen def1de
 	extern char **environ;
Jakub Jelen def1de
 	char **env, *argv[ARGV_MAX], remote_id[512];
Jakub Jelen 134139
 	const char *shell, *shell0;
Jakub Jelen 134139
-	struct passwd *pw = s->pw;
Jakub Jelen 134139
+	struct passwd *pw = NULL;
Jakub Jelen 134139
 	int r = 0;
Jakub Jelen 134139
 
Jakub Jelen 134139
+	/* Update the users passwd structure after successful login */
Jakub Jelen 134139
+	pw = getpwuid(s->pw->pw_uid);
Jakub Jelen 134139
+	if (pw != NULL) {
Jakub Jelen 134139
+		free(s->pw);
Jakub Jelen 134139
+		s->pw = pw;
Jakub Jelen 134139
+	} else {
Jakub Jelen 134139
+		pw = s->pw;
Jakub Jelen 134139
+	}
Jakub Jelen 134139
+
Jakub Jelen def1de
 	sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
Jakub Jelen def1de
 
Jakub Jelen 134139
 	/* remove hostkey from the child's memory */