2011/1/28 Eric Blake <eblake@xxxxxxxxxx>: > * src/fdstream.c (virFDStreamOpenFile, virFDStreamCreateFile): > Use VIR_FORCE_CLOSE instead of close. > * tests/commandtest.c (mymain): Likewise. > * tools/virsh.c (editFile): Use virCommand instead of system. > --- > Âsrc/fdstream.c   Â|  Â6 ++-- > Âtests/commandtest.c |  12 +++++++--- > Âtools/virsh.c    |  59 +++++++++++++++++++++++--------------------------- > Â3 files changed, 38 insertions(+), 39 deletions(-) > diff --git a/tools/virsh.c b/tools/virsh.c > index cd54174..cf482e3 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c >   editor = getenv ("VISUAL"); > -  Âif (!editor) editor = getenv ("EDITOR"); > -  Âif (!editor) editor = "vi"; /* could be cruel & default to ed(1) here */ > +  Âif (!editor) > +    Âeditor = getenv ("EDITOR"); > +  Âif (!editor) > +    Âeditor = "vi"; /* could be cruel & default to ed(1) here */ When VISUAL and EDITOR isn't set we fallback to vi here, but ... >   /* Check that filename doesn't contain shell meta-characters, and >   Â* if it does, refuse to run. ÂFollow the Unix conventions for >   Â* EDITOR: the user can intentionally specify command options, so >   Â* we don't protect any shell metacharacters there. ÂLots more >   Â* than virsh will misbehave if EDITOR has bogus contents (which > -   * is why sudo scrubs it by default). > +   * is why sudo scrubs it by default). ÂConversely, if the editor > +   * is safe, we can run it directly rather than wasting a shell. >   Â*/ > -  Âif (strspn (filename, ACCEPTED_CHARS) != strlen (filename)) { > -    ÂvshError(ctl, > -         _("%s: temporary filename contains shell meta or other " > -          "unacceptable characters (is $TMPDIR wrong?)"), > -         filename); > -    Âreturn -1; > +  Âif (strspn (editor, ACCEPTED_CHARS) != strlen (editor)) { > +    Âif (strspn (filename, ACCEPTED_CHARS) != strlen (filename)) { > +      ÂvshError(ctl, > +           _("%s: temporary filename contains shell meta or other " > +            "unacceptable characters (is $TMPDIR wrong?)"), > +           filename); > +      Âreturn -1; > +    Â} > +    Âcmd = virCommandNewArgList("sh", "-c", NULL); > +    ÂvirCommandAddArgFormat(cmd, "%s %s", editor, filename); > +  Â} else { > +    Âcmd = virCommandNewArgList("editor", filename, NULL); >   } ... here you made it fallback to editor instead. Shouldn't this be consistent and fallback to the same in both cases? Anyway, that's minor and doesn't affect my ACK. Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list