From ef34619dbd59da6485c17838c174b91c7938c05a Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 20 Nov 2012 10:59:41 +0000 Subject: Correctly set the password file mode after renaming in NIS mode --- pw/pw_nis.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pw') diff --git a/pw/pw_nis.c b/pw/pw_nis.c index af5901a..7af2bef 100644 --- a/pw/pw_nis.c +++ b/pw/pw_nis.c @@ -68,6 +68,8 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user) } if (rename(pw_tempname(), path) == -1) err(1, "rename()"); + if (chmod(path, 0644) == -1) + err(1, "chmod()"); free(pw); pw_fini(); -- cgit v1.2.3-56-ge451 From f1c19efaaef09572d044b5d2656c4ee623dea092 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 20 Nov 2012 14:05:46 +0000 Subject: In NIS mode first chmod(2) the temporary file and is succeed then rename(2) --- pw/pw_nis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pw') diff --git a/pw/pw_nis.c b/pw/pw_nis.c index 7af2bef..918fc30 100644 --- a/pw/pw_nis.c +++ b/pw/pw_nis.c @@ -66,10 +66,10 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user) pw_fini(); err(1, "pw_copy()"); } + if (chmod(pw_tempname(), 0644) == -1) + err(1, "chmod()"); if (rename(pw_tempname(), path) == -1) err(1, "rename()"); - if (chmod(path, 0644) == -1) - err(1, "chmod()"); free(pw); pw_fini(); -- cgit v1.2.3-56-ge451