Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16820

Re: How do we intercept file saving or output to stdout directly

From Robert Elz <kre@munnari.OZ.AU>
Newsgroups gnu.bash.bug
Subject Re: How do we intercept file saving or output to stdout directly
Date 2020-08-27 05:26 +0700
Message-ID <mailman.1396.1598480844.2469.bug-bash@gnu.org> (permalink)
References <20200826121352.GN931@eeg.ccf.org> <1598249852364-0.post@n7.nabble.com> <87a6yinjhl.fsf@hobgoblin.ariadne.com> <6237.1598480806@jinx.noi.kre.to>

Show all headers | View raw


    Date:        Wed, 26 Aug 2020 08:13:52 -0400
    From:        Greg Wooledge <wooledg@eeg.ccf.org>
    Message-ID:  <20200826121352.GN931@eeg.ccf.org>

  | The obvious guess is that it's to "prevent you from accidentally
  | overwriting a file".

That would be what one would normally assume, but Dale didn't
show what comes just before the open (this sys call trace is
from a different OS, so the format is different)

 28469  28469 xkbcomp  CALL  unlink(0x7f7fffffec7b)
 28469  28469 xkbcomp  NAMI  "/dev/stdout"
 28469  28469 xkbcomp  RET   unlink -1 errno 13 Permission denied
 28469  28469 xkbcomp  CALL  open(0x7f7fffffec7b,0xa01,0x1b6)
 28469  28469 xkbcomp  NAMI  "/dev/stdout"
 28469  28469 xkbcomp  RET   open -1 errno 17 File exists

If it was attempting to "prevent you from accidentally overwriting a file"
it is unlikely it would be unlinking it (or attempting to) first.

(0xa01 == O_EXCL|O_CREAT|O_WRONLY   0x1b6 == 0666).

If one were to execute xkbcomp as root (people, please don't)
then all of this would probably succeed, and replace /dev/stdout
with a regular file containing the xkbcomp output.

kre

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: How do we intercept file saving or output to stdout directly Robert Elz <kre@munnari.OZ.AU> - 2020-08-27 05:26 +0700

csiph-web