From 155b485ba7d659b3c6992b9bdf8c067369990677 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Wed, 30 Mar 2016 08:59:06 +0200 Subject: [PATCH] copy ownership and modes of old challenge file when creating a new one fixes #92 --- pam_yubico.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pam_yubico.c b/pam_yubico.c index b1934361..b49d5c26 100644 --- a/pam_yubico.c +++ b/pam_yubico.c @@ -616,10 +616,14 @@ do_challenge_response(pam_handle_t *pamh, struct cfg *cfg, const char *username) goto restpriv_out; } - if (fchmod (fd, S_IRUSR | S_IWUSR) != 0) { + if (fchmod (fd, st.st_mode) != 0) { DBG (("could not set correct file permissions")); goto restpriv_out; } + if (fchown (fd, st.st_uid, st.st_gid) != 0) { + DBG (("could not set correct file ownership")); + goto restpriv_out; + } f = fdopen(fd, "w"); if (! f) {