This diff allows CVS login to get the password from an environment variable;
it's very useful when using automatic update scripts (e.g., run out of
cron). Perhaps CVSPASSFILE is a better way to go, but I didn't want to deal
with the the (de)scrambling. And this avoids any issues if/when someone adds
real encryption to the passfile.
A couple of improvements do come to mind:
(1) Warn if CVSPASSWORD is set and isatty(fileno(stdin))
i.e., warn if being used interactively. I didn't do this because
I didn't want to address the portability of that test.
(2) Allow the other commands to transparently login and logout.
So that something like this would work (/bin/sh syntax)
CVSROOT="...." CVSPASSWORD="guest" cvs update </dev/null
In addition to (2), it would be nice if setting CVSPASSFILE to /dev/null (or
NUL: on other systems :) meant do not read or write passwords.
If there's interest, I'll work on doing the above items as well.
Comments?
/r$
Index: login.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/login.c,v
retrieving revision 1.56
diff -r1.56 login.c
120a121
> char *passenv;
145,146c146,154
< typed_password = getpass ("CVS password: ");
< typed_password = scramble (typed_password);
---
> passenv = getenv ("CVSPASSWORD");
> if (passenv) {
> passenv = xstrdup (passenv);
> typed_password = scramble (passenv);
> }
> else {
> typed_password = getpass ("CVS password: ");
> typed_password = scramble (typed_password);
> }