util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] vipw: do not let editor to inherit open file descriptors
@ 2017-12-03 12:51 Sami Kerola
  2017-12-03 12:51 ` [PATCH 2/4] rename: use access(3) to check if a file exists Sami Kerola
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Sami Kerola @ 2017-12-03 12:51 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 login-utils/vipw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/login-utils/vipw.c b/login-utils/vipw.c
index b7650de8b..9b7696942 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -257,7 +257,7 @@ static void edit_file(int is_shadow)
 	if (lckpwdf() < 0)
 		err(EXIT_FAILURE, _("cannot get lock"));
 
-	passwd_file = open(orig_file, O_RDONLY, 0);
+	passwd_file = open(orig_file, O_RDONLY | O_CLOEXEC, 0);
 	if (passwd_file < 0)
 		err(EXIT_FAILURE, _("cannot open %s"), orig_file);
 	tmp_fd = pw_tmpfile(passwd_file);
@@ -275,7 +275,7 @@ static void edit_file(int is_shadow)
 	if (end.st_nlink == 0) {
 		if (close_stream(tmp_fd) != 0)
 			err(EXIT_FAILURE, _("write error"));
-		tmp_fd = fopen(tmp_file, "r");
+		tmp_fd = fopen(tmp_file, "r" UL_CLOEXECSTR);
 		if (!tmp_fd)
 			err(EXIT_FAILURE, _("cannot open %s"), tmp_file);
 		if (fstat(fileno(tmp_fd), &end))
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-12-11 15:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-03 12:51 [PATCH 1/4] vipw: do not let editor to inherit open file descriptors Sami Kerola
2017-12-03 12:51 ` [PATCH 2/4] rename: use access(3) to check if a file exists Sami Kerola
2017-12-04 12:05   ` Karel Zak
2017-12-03 12:51 ` [PATCH 3/4] docs: improve setarch(8) manual page Sami Kerola
2017-12-03 13:29   ` Dmitry V. Levin
2017-12-04 12:04   ` Karel Zak
2017-12-04 13:20     ` Sami Kerola
2017-12-09  1:29       ` Dmitry V. Levin
2017-12-10 10:54         ` Sami Kerola
2017-12-11 15:06           ` Karel Zak
2017-12-11 13:46         ` Karel Zak
2017-12-03 12:51 ` [PATCH 4/4] setarch: minor code clean up Sami Kerola
2017-12-04 12:06   ` Karel Zak
2017-12-04 12:05 ` [PATCH 1/4] vipw: do not let editor to inherit open file descriptors Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).