diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-11-27 01:37:10 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-11-27 03:16:32 +0100 |
commit | b2bcec13f17ce9174238a704e91d52203e916432 (patch) | |
tree | 5abac7c69acd610df2442284effc4131fbfe26d7 /monitor.c | |
parent | upstream: when loading PKCS#11 keys, include the key fingerprints (diff) | |
download | openssh-b2bcec13f17ce9174238a704e91d52203e916432.tar.xz openssh-b2bcec13f17ce9174238a704e91d52203e916432.zip |
upstream: clean up passing of struct passwd from monitor to preauth
privsep process. No longer copy entire struct w/ pointer addresses, but pass
remaining scalar fields explicitly,
Prompted by Yuichiro NAITO, feedback Thorsten Glaser; ok dtucker@
OpenBSD-Commit-ID: 9925df75a56732c43f3663e70dd15ff413ab3e53
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.217 2020/10/18 11:32:01 djm Exp $ */ +/* $OpenBSD: monitor.c,v 1.218 2020/11/27 00:37:10 djm Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2002 Markus Friedl <markus@openbsd.org> @@ -705,8 +705,14 @@ mm_answer_sign(struct ssh *ssh, int sock, struct sshbuf *m) return (0); } -/* Retrieves the password entry and also checks if the user is permitted */ +#define PUTPW(b, id) \ + do { \ + if ((r = sshbuf_put_string(b, \ + &pwent->id, sizeof(pwent->id))) != 0) \ + fatal_fr(r, "assemble %s", #id); \ + } while (0) +/* Retrieves the password entry and also checks if the user is permitted */ int mm_answer_pwnamallow(struct ssh *ssh, int sock, struct sshbuf *m) { @@ -742,10 +748,18 @@ mm_answer_pwnamallow(struct ssh *ssh, int sock, struct sshbuf *m) authctxt->pw = pwent; authctxt->valid = 1; - /* XXX don't sent pwent to unpriv; send fake class/dir/shell too */ - if ((r = sshbuf_put_u8(m, 1)) != 0 || - (r = sshbuf_put_string(m, pwent, sizeof(*pwent))) != 0 || - (r = sshbuf_put_cstring(m, pwent->pw_name)) != 0 || + /* XXX send fake class/dir/shell, etc. */ + if ((r = sshbuf_put_u8(m, 1)) != 0) + fatal_fr(r, "assemble ok"); + PUTPW(m, pw_uid); + PUTPW(m, pw_gid); +#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE + PUTPW(m, pw_change); +#endif +#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE + PUTPW(m, pw_expire); +#endif + if ((r = sshbuf_put_cstring(m, pwent->pw_name)) != 0 || (r = sshbuf_put_cstring(m, "*")) != 0 || #ifdef HAVE_STRUCT_PASSWD_PW_GECOS (r = sshbuf_put_cstring(m, pwent->pw_gecos)) != 0 || |