Util-Linux package development
 help / color / mirror / Atom feed
From: Ruediger Meier <sweet_f_a@gmx.de>
To: Karel Zak <kzak@redhat.com>
Cc: Sami Kerola <kerolasa@iki.fi>, util-linux@vger.kernel.org
Subject: Re: [PATCH] script: close file descriptors on exec
Date: Fri, 15 Apr 2016 10:42:08 +0200	[thread overview]
Message-ID: <201604151042.08728.sweet_f_a@gmx.de> (raw)
In-Reply-To: <20160415083046.gaeryvxivffxrbal@ws.net.home>

On Friday 15 April 2016, Karel Zak wrote:
> On Fri, Apr 15, 2016 at 09:22:14AM +0200, Ruediger Meier wrote:
> > On Thursday 14 April 2016, Sami Kerola wrote:
> > > The commands spawned from script(1) will never need access
> > > various file descriptors the script(1) is using.
> > >
> > > Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> > > ---
> > >  term-utils/script.c | 12 ++++++------
> > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/term-utils/script.c b/term-utils/script.c
> > > index 1199742..88b522a 100644
> > > --- a/term-utils/script.c
> > > +++ b/term-utils/script.c
> > > @@ -419,15 +419,15 @@ static void do_io(struct script_control
> > > *ctl) };
> > >
> > >
> > > -	if ((ctl->typescriptfp = fopen(ctl->fname, ctl->append ? "a" :
> > > "w")) == NULL) { +	if ((ctl->typescriptfp = fopen(ctl->fname,
> > > ctl->append ? "ae" : "we")) == NULL) { warn(_("cannot open %s"),
> > > ctl->fname);
> > >  		fail(ctl);
> > >  	}
> > >  	if (ctl->timing) {
> > >  		if (!ctl->tname) {
> > > -			if (!(ctl->timingfp = fopen("/dev/stderr", "w")))
> > > +			if (!(ctl->timingfp = fopen("/dev/stderr", "we")))
> > >  				err(EXIT_FAILURE, _("cannot open %s"), "/dev/stderr");
> > > -		} else if (!(ctl->timingfp = fopen(ctl->tname, "w")))
> > > +		} else if (!(ctl->timingfp = fopen(ctl->tname, "we")))
> >
> > "e" works for glibc only.
>
> Yep, see c.h, should be
>
>     else if (!(ctl->timingfp = fopen(ctl->tname, "w" UL_CLOEXECSTR)))

Could be also fixed here:
login-utils/sulogin-consoles.c:163:  if (!(fp = fopen(file, "re")))
login-utils/sulogin-consoles.c:364:  fc = fopen("/proc/consoles", "re");


>     Karel

  reply	other threads:[~2016-04-15  8:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 20:22 [PATCH] script: close file descriptors on exec Sami Kerola
2016-04-15  7:22 ` Ruediger Meier
2016-04-15  8:30   ` Karel Zak
2016-04-15  8:42     ` Ruediger Meier [this message]
2016-04-16 15:26       ` Sami Kerola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201604151042.08728.sweet_f_a@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=kerolasa@iki.fi \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox