[augeas-devel] [Augeas] #241: --interactive mode fails to reopen stdout as another user (not root)
Augeas
trac at fedorahosted.org
Mon Dec 19 12:32:27 UTC 2011
#241: --interactive mode fails to reopen stdout as another user (not root)
----------------------+---------------------
Reporter: raphink | Owner: lutter
Type: defect | Status: new
Priority: minor | Milestone: next
Component: Augeas | Version: devel
Resolution: | Keywords:
Blocking: | Blocked By:
----------------------+---------------------
Comment (by mchapman):
The problem here is that `augtool` tries to open `/dev/stdout`. This can
be a symlink (via `/proc/self/fd/1`) to a device to which the user does
not have access.
The straight-forward fix is:
{{{
diff --git a/src/augtool.c b/src/augtool.c
index e9c1422..4f4be1d 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -462,7 +462,7 @@ static int main_loop(void) {
fclose(rl_outstream);
rl_outstream = NULL;
}
- if ((rl_outstream = fopen("/dev/stdout", "w")) == NULL) {
+ if ((rl_outstream = fdopen(STDOUT_FILENO, "w")) == NULL) {
perror("Failed to reopen stdout");
return -1;
}
}}}
However I'm wondering whether `rl_outstream` should also be connected to
`/dev/tty`, as `rl_instream` is a few lines above this. What is the
intended behaviour when standard output is redirected?
{{{
echo "ls /" | augtool -i >outfile
}}}
--
Ticket URL: <https://fedorahosted.org/augeas/ticket/241#comment:2>
Augeas <http://augeas.net/>
a configuration API
More information about the augeas-devel
mailing list