diff options
author | obrien <obrien@FreeBSD.org> | 2008-03-19 15:11:46 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-03-19 15:11:46 +0000 |
commit | 4f8541364ad4cdfd6ed314f550276f5e431b97f5 (patch) | |
tree | 93923d8c7b4887c0ba4210a7ef5e0871c7b4f838 /contrib/cvs | |
parent | 134c02a9d43c4d7e3510328fadba2d7bcc7579a1 (diff) | |
download | FreeBSD-src-4f8541364ad4cdfd6ed314f550276f5e431b97f5.zip FreeBSD-src-4f8541364ad4cdfd6ed314f550276f5e431b97f5.tar.gz |
We use the stock versions of these files.
Diffstat (limited to 'contrib/cvs')
-rw-r--r-- | contrib/cvs/src/import.c | 25 | ||||
-rw-r--r-- | contrib/cvs/src/login.c | 53 | ||||
-rw-r--r-- | contrib/cvs/src/mkmodules.c | 57 | ||||
-rw-r--r-- | contrib/cvs/src/recurse.c | 5 |
4 files changed, 109 insertions, 31 deletions
diff --git a/contrib/cvs/src/import.c b/contrib/cvs/src/import.c index d4e2f24..0f82332 100644 --- a/contrib/cvs/src/import.c +++ b/contrib/cvs/src/import.c @@ -164,14 +164,21 @@ import (argc, argv) * Could abstract this to valid_module_path, but I don't think we'll need * to call it from anywhere else. */ - if ((cp = strstr(argv[0], "CVS")) && /* path contains "CVS" AND ... */ - ((cp == argv[0]) || ISDIRSEP(*(cp-1))) && /* /^CVS/ OR m#/CVS# AND ... */ - ((*(cp+3) == '\0') || ISDIRSEP(*(cp+3))) /* /CVS$/ OR m#CVS/# */ - ) + /* for each "CVS" in path... */ + cp = argv[0]; + while ((cp = strstr(cp, "CVS")) != NULL) { - error (0, 0, - "The word `CVS' is reserved by CVS and may not be used"); - error (1, 0, "as a directory in a path or as a file name."); + if ( /* /^CVS/ OR m#/CVS#... */ + (cp == argv[0] || ISDIRSEP(*(cp-1))) + /* ...AND /CVS$/ OR m#CVS/# */ + && (*(cp+3) == '\0' || ISDIRSEP(*(cp+3))) + ) + { + error (0, 0, + "The word `CVS' is reserved by CVS and may not be used"); + error (1, 0, "as a directory in a path or as a file name."); + } + cp += 3; } for (i = 1; i < argc; i++) /* check the tags for validity */ @@ -1603,8 +1610,8 @@ import_descend_dir (message, dir, vtag, targc, targv) if ( CVS_CHDIR (dir) < 0) { ierrno = errno; - fperrmsg (logfp, 0, ierrno, "ERROR: cannot chdir to %s", repository); - error (0, ierrno, "ERROR: cannot chdir to %s", repository); + fperrmsg (logfp, 0, ierrno, "ERROR: cannot chdir to %s", dir); + error (0, ierrno, "ERROR: cannot chdir to %s", dir); err = 1; goto out; } diff --git a/contrib/cvs/src/login.c b/contrib/cvs/src/login.c index 3222228..2ea0705 100644 --- a/contrib/cvs/src/login.c +++ b/contrib/cvs/src/login.c @@ -117,20 +117,20 @@ password_entry_parseline (cvsroot_canonical, warn, linenumber, linebuf) { /* Yes: slurp '^/\d+\D' and parse the rest of the line according to version number */ char *q; - unsigned long int entry_version; + unsigned long int entry_version = 0; if (isspace(*(linebuf + 1))) + { /* special case since strtoul ignores leading white space */ q = linebuf + 1; + } else + { entry_version = strtoul (linebuf + 1, &q, 10); - - if (q == linebuf + 1) - /* no valid digits found by strtoul */ - entry_version = 0; - else - /* assume a delimiting seperator */ - q++; + if (q != linebuf + 1) + /* assume a delimiting seperator */ + q++; + } switch (entry_version) { @@ -568,21 +568,40 @@ login (argc, argv) password_entry_operation (password_entry_add, current_parsed_root, typed_password); - memset (typed_password, 0, strlen (typed_password)); - free (typed_password); - - free (cvs_password); + free_cvs_password (typed_password); free (cvsroot_canonical); - cvs_password = NULL; return 0; } -/* Returns the _scrambled_ password. The server must descramble - before hashing and comparing. If password file not found, or - password not found in the file, just return NULL. */ +/* Free the password returned by get_cvs_password() and also free the + * saved cvs_password if they are different pointers. Be paranoid + * about the in-memory copy of the password and overwrite it with zero + * bytes before doing the free(). + */ +void +free_cvs_password (char *password) +{ + if (password && password != cvs_password) + { + memset (password, 0, strlen (password)); + free (password); + } + + if (cvs_password) + { + memset (cvs_password, 0, strlen (cvs_password)); + free (cvs_password); + cvs_password = NULL; + } +} + +/* Returns the _scrambled_ password in freshly allocated memory. The server + * must descramble before hashing and comparing. If password file not found, + * or password not found in the file, just return NULL. + */ char * get_cvs_password () { @@ -593,7 +612,7 @@ get_cvs_password () context, then assume they have supplied the correct, scrambled password. */ if (cvs_password) - return cvs_password; + return xstrdup (cvs_password); if (getenv ("CVS_PASSWORD") != NULL) { diff --git a/contrib/cvs/src/mkmodules.c b/contrib/cvs/src/mkmodules.c index cdd766e..fd21713 100644 --- a/contrib/cvs/src/mkmodules.c +++ b/contrib/cvs/src/mkmodules.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1986-2005 The Free Software Foundation, Inc. + * Copyright (C) 1986-2008 The Free Software Foundation, Inc. * * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, * and others. @@ -13,6 +13,7 @@ * $FreeBSD$ */ +#include <assert.h> #include "cvs.h" #include "getline.h" #include "history.h" @@ -264,7 +265,6 @@ static const char *const modules_contents[] = { "# key [options] directory files...\n", "#\n", "# Where \"options\" are composed of:\n", - "# -i prog Run \"prog\" on \"cvs commit\" from top-level of module.\n", "# -o prog Run \"prog\" on \"cvs checkout\" of module.\n", "# -e prog Run \"prog\" on \"cvs export\" of module.\n", "# -t prog Run \"prog\" on \"cvs rtag\" of module.\n", @@ -291,6 +291,13 @@ static const char *const config_contents[] = { "# Set this to \"no\" if pserver shouldn't check system users/passwords\n", "#SystemAuth=yes\n", "\n", + "# Set `IgnoreUnknownConfigKeys' to `yes' to ignore unknown config\n", + "# keys which are supported in a future version of CVS.\n", + "# This option is intended to be useful as a transition for read-only\n", + "# mirror sites when sites may need to be updated later than the\n", + "# primary CVS repository.\n", + "#IgnoreUnknownConfigKeys=no\n", + "\n", "# Put CVS lock files in this directory rather than directly in the repository.\n", "#LockDir=/var/lock/cvs\n", "\n", @@ -849,6 +856,41 @@ rename_rcsfile (temp, real) free (bak); } + +/* + * Walk PATH backwards to the root directory looking for the root of a + * repository. + */ +static char * +in_repository (const char *path) +{ + char *cp = xstrdup (path); + + for (;;) + { + if (isdir (cp)) + { + int foundit; + char *adm = xmalloc (strlen(cp) + strlen(CVSROOTADM) + 2); + sprintf (adm, "%s/%s", cp, CVSROOTADM); + foundit = isdir (adm); + free (adm); + if (foundit) return cp; + } + + /* If last_component() returns the empty string, then cp either + * points at the system root or is the empty string itself. + */ + if (!*last_component (cp) || !strcmp (cp, ".") + || last_component(cp) == cp) + break; + + cp[strlen(cp) - strlen(last_component(cp)) - 1] = '\0'; + } + + return NULL; +} + const char *const init_usage[] = { "Usage: %s %s\n", @@ -870,8 +912,11 @@ init (argc, argv) /* Exit status. */ int err = 0; + char *root_dir; const struct admin_file *fileptr; + assert (!server_active); + umask (cvsumask); if (argc == -1 || argc > 1) @@ -888,6 +933,14 @@ init (argc, argv) } #endif /* CLIENT_SUPPORT */ + root_dir = in_repository (current_parsed_root->directory); + + if (root_dir && strcmp (root_dir, current_parsed_root->directory)) + error (1, 0, + "Cannot initialize repository under existing CVSROOT: `%s'", + root_dir); + free (root_dir); + /* Note: we do *not* create parent directories as needed like the old cvsinit.sh script did. Few utilities do that, and a non-existent parent directory is as likely to be a typo as something diff --git a/contrib/cvs/src/recurse.c b/contrib/cvs/src/recurse.c index 1fb33c1..0f39b67 100644 --- a/contrib/cvs/src/recurse.c +++ b/contrib/cvs/src/recurse.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1986-2005 The Free Software Foundation, Inc. + * Copyright (C) 1986-2008 The Free Software Foundation, Inc. * * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, * and others. @@ -663,7 +663,6 @@ do_recursion (frame) { repository = frame->repository; assert (repository != NULL); - assert (strstr (repository, "/./") == NULL); } fileattr_startdir (repository); @@ -766,7 +765,7 @@ do_recursion (frame) have writelocks in place, and there is no way to get writelocks here. */ if (current_parsed_root->isremote) - notify_check (repository, update_dir); + cvs_notify_check (repository, update_dir); #endif /* CLIENT_SUPPORT */ finfo_struct.repository = repository; |