[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: failure to append to .cvspass should always be fatal
From: |
Mark D. Baushke |
Subject: |
Re: failure to append to .cvspass should always be fatal |
Date: |
Sun, 27 Feb 2005 18:52:06 -0800 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Jim,
Your patch looks good to me. Go ahead and commit it.
-- Mark
Jim Meyering <list+cvs@meyering.net> writes:
> When a `login' commands leads to appending to .cvspass, that file is
> copied to a stream opened on a temporary file, and the new entry is
> appended. While failing to open or fwrite the temporary file evokes an
> `error (1, ...', a failed fclose gets only a warning:
>
> if ((fp = CVS_FOPEN (passfile, "a")) == NULL)
> error (1, errno, "could not open %s for writing", passfile);
>
> if (fprintf (fp, "/1 %s %s\n", cvsroot_canonical, newpassword) == EOF)
> error (1, errno, "cannot write %s", passfile);
> if (fclose (fp) < 0)
> error (0, errno, "cannot close %s", passfile);
>
> Admittedly, it's pretty unlikely that an append would fail in the first
> place. But if cvs fails for an even less likely fprintf write failure,
> then it should also fail for an fclose-induced write failure. Since there
> is no comment explaining the discrepancy, I assume it was an oversight.
>
> Here's the fix:
>
> 2005-02-27 Jim Meyering <jim@meyering.net>
>
> * login.c (password_entry_operation): Exit nonzero when failing
> to close a just-appended-to .cvspass file.
>
> Index: src/login.c
> ===================================================================
> RCS file: /cvs/ccvs/src/login.c,v
> retrieving revision 1.82
> diff -u -p -r1.82 login.c
> --- src/login.c 1 Feb 2005 22:20:06 -0000 1.82
> +++ src/login.c 27 Feb 2005 10:47:58 -0000
> @@ -456,7 +456,7 @@ process:
> if (fprintf (fp, "/1 %s %s\n", cvsroot_canonical, newpassword) == EOF)
> error (1, errno, "cannot write %s", passfile);
> if (fclose (fp) < 0)
> - error (0, errno, "cannot close %s", passfile);
> + error (1, errno, "cannot close %s", passfile);
> }
>
> /* Utter, total, raving paranoia, I know. */
>
>
> _______________________________________________
> Bug-cvs mailing list
> Bug-cvs@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-cvs
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)
iD8DBQFCIodW3x41pRYZE/gRAp9+AJwPls35bJCTbdHVcaNLQI20Vc/PqACgtIF1
KgPMdo3rO+ZWAHwxz4Bp9oM=
=XMzH
-----END PGP SIGNATURE-----