[Pkg-shadow-devel] Bug#688260: vipw: Erroneous "No such file or directory" error when editor fails

Ben Harris bjh21 at cam.ac.uk
Thu Sep 20 19:12:46 UTC 2012


Package: passwd
Version: 1:4.1.5.1-1
Severity: minor

If the editor invoked by vipw(8) exits with a non-zero exit status, vipw 
reports two spurious "No such file or directory" errors:

wraith:~# EDITOR=false vipw
vipw: false: No such file or directory
vipw: false: No such file or directory
vipw: /etc/passwd is unchanged

Looking at the source code, I think the first message comes from this bit 
of code in vipwedit():

                 if (system (buf) != 0) {
                         fprintf (stderr, "%s: %s: %s\n", Prog, editor,
                                  strerror (errno));
                         exit (1);
                 } else {
                         exit (0);
                 }

This is wrong, because system() only sets errno when it returns -1 (to 
indicate a failure to fork), and not when it returns the child process's 
exit status.

The second message comes from this code a little later:

         if (   (-1 == pid)
             || (WIFEXITED (status) == 0)
             || (WEXITSTATUS (status) != 0)) {
                 vipwexit (editor, 1, 1);

While a return value of -1 from waitpid() will set errno, a successful 
return of a non-zero exit status will not.

-- 
Ben Harris, University of Cambridge Computing Service.



More information about the Pkg-shadow-devel mailing list