diff options
author | David E. O'Brien <obrien@FreeBSD.org> | 2000-10-31 09:37:58 +0000 |
---|---|---|
committer | David E. O'Brien <obrien@FreeBSD.org> | 2000-10-31 09:37:58 +0000 |
commit | 14ffe3e0e85c428c54f4e1726fb8400c182f5a01 (patch) | |
tree | 82fa13de34057da0ab2ff78186e9b2e43fa75548 /contrib/cvs/src/login.c | |
parent | ac8bbc33dbc27f7302f23aad975cd3bec25e511e (diff) | |
download | src-14ffe3e0e85c428c54f4e1726fb8400c182f5a01.tar.gz src-14ffe3e0e85c428c54f4e1726fb8400c182f5a01.zip |
MFC: update to `cvs' version 1.11.
Approved by: peter
Notes
Notes:
svn path=/stable/4/; revision=68058
Diffstat (limited to 'contrib/cvs/src/login.c')
-rw-r--r-- | contrib/cvs/src/login.c | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/contrib/cvs/src/login.c b/contrib/cvs/src/login.c index 708dfc8d15d5..cc564c066837 100644 --- a/contrib/cvs/src/login.c +++ b/contrib/cvs/src/login.c @@ -14,6 +14,12 @@ #ifdef AUTH_CLIENT_SUPPORT /* This covers the rest of the file. */ +#ifdef HAVE_GETPASSPHRASE +#define GETPASS getpassphrase +#else +#define GETPASS getpass +#endif + /* There seems to be very little agreement on which system header getpass is declared in. With a lot of fancy autoconfiscation, we could perhaps detect this, but for now we'll just rely on @@ -22,7 +28,7 @@ varadic, believe it or not). On Cray, getpass will be declared in either stdlib.h or unistd.h. */ #ifndef _CRAY -extern char *getpass (); +extern char *GETPASS (); #endif #ifndef CVS_PASSWORD_FILE @@ -144,7 +150,7 @@ login (argc, argv) fflush (stdout); passfile = construct_cvspass_filename (); - typed_password = getpass ("CVS password: "); + typed_password = GETPASS ("CVS password: "); typed_password = scramble (typed_password); /* Force get_cvs_password() to use this one (when the client @@ -291,21 +297,19 @@ login (argc, argv) } /* Returns the _scrambled_ password. The server must descramble - before hashing and comparing. */ + before hashing and comparing. If password file not found, or + password not found in the file, just return NULL. */ char * get_cvs_password () { int found_it = 0; int root_len; - char *password; - char *linebuf = (char *) NULL; + char *password = NULL; + char *linebuf = NULL; size_t linebuf_len; FILE *fp; char *passfile; int line_length; - int anoncvs; - - anoncvs = (strcmp(CVSroot_username, "anoncvs") == 0); /* If someone (i.e., login()) is calling connect_to_pserver() out of context, then assume they have supplied the correct, scrambled @@ -344,15 +348,10 @@ get_cvs_password () passfile = construct_cvspass_filename (); fp = CVS_FOPEN (passfile, "r"); - if (fp == NULL) + if (fp == NULL) { - if (anoncvs) { - free (passfile); - return strdup("Ay=0=h<Z"); /* scrambled "anoncvs" */ - } - error (0, errno, "could not open %s", passfile); free (passfile); - error (1, 0, "use \"cvs login\" to log in first"); + return NULL; } root_len = strlen (CVSroot_original); @@ -371,7 +370,6 @@ get_cvs_password () error (0, errno, "cannot read %s", passfile); if (fclose (fp) < 0) error (0, errno, "cannot close %s", passfile); - free (passfile); if (found_it) { @@ -379,25 +377,19 @@ get_cvs_password () char *tmp; strtok (linebuf, " "); - password = strtok (NULL, "\n"); + tmp = strtok (NULL, "\n"); + if (tmp == NULL) + error (1, 0, "bad entry in %s for %s", passfile, CVSroot_original); /* Give it permanent storage. */ - tmp = xstrdup (password); - memset (password, 0, strlen (password)); - free (linebuf); - return tmp; + password = xstrdup (tmp); + memset (tmp, 0, strlen (password)); } - else - { - if (linebuf) - free (linebuf); - if (anoncvs) - return strdup("Ay=0=h<Z"); /* scrambled "anoncvs" */ - error (0, 0, "cannot find password"); - error (1, 0, "use \"cvs login\" to log in first"); - } - /* NOTREACHED */ - return NULL; + + if (linebuf) + free (linebuf); + free (passfile); + return password; } static const char *const logout_usage[] = @@ -407,7 +399,7 @@ static const char *const logout_usage[] = NULL }; -/* Remove any entry for the CVSRoot repository found in "CVS/.cvspass". */ +/* Remove any entry for the CVSRoot repository found in .cvspass. */ int logout (argc, argv) int argc; @@ -415,7 +407,7 @@ logout (argc, argv) { char *passfile; FILE *fp; - char *tmp_name; + char *tmp_name = NULL; FILE *tmp_fp; char *linebuf = (char *) NULL; size_t linebuf_len; @@ -510,6 +502,10 @@ logout (argc, argv) error (0, errno, "cannot remove %s", tmp_name); chmod (passfile, 0600); } + + if (tmp_name) + free (tmp_name); + return 0; } |