summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-06-22 10:59:24 +0000
committerpeter <peter@FreeBSD.org>1997-06-22 10:59:24 +0000
commite00aed2084aea5f9880023debf362de96dd10ad2 (patch)
tree5f844f9e367fdc809c7ac2e00e2c104f128879c3 /contrib/cvs/src
parent891d25f8be548bdcb7be081005a66c22b10145d5 (diff)
downloadFreeBSD-src-e00aed2084aea5f9880023debf362de96dd10ad2.zip
FreeBSD-src-e00aed2084aea5f9880023debf362de96dd10ad2.tar.gz
merge conflicts
Diffstat (limited to 'contrib/cvs/src')
-rw-r--r--contrib/cvs/src/cvs.h6
-rw-r--r--contrib/cvs/src/import.c142
-rw-r--r--contrib/cvs/src/lock.c2
-rw-r--r--contrib/cvs/src/main.c20
-rw-r--r--contrib/cvs/src/mkmodules.c24
-rw-r--r--contrib/cvs/src/rcs.c12
-rw-r--r--contrib/cvs/src/rcs.h4
-rw-r--r--contrib/cvs/src/server.c47
8 files changed, 204 insertions, 53 deletions
diff --git a/contrib/cvs/src/cvs.h b/contrib/cvs/src/cvs.h
index 4596d0f..5ab21c7 100644
--- a/contrib/cvs/src/cvs.h
+++ b/contrib/cvs/src/cvs.h
@@ -423,10 +423,16 @@ void Subdir_Register PROTO((List *, const char *, const char *));
void Subdir_Deregister PROTO((List *, const char *, const char *));
char *Make_Date PROTO((char *rawdate));
char *Name_Repository PROTO((char *dir, char *update_dir));
+
+
char *Name_Root PROTO((char *dir, char *update_dir));
int parse_cvsroot PROTO((char *CVSroot));
void set_local_cvsroot PROTO((char *dir));
void Create_Root PROTO((char *dir, char *rootdir));
+void root_allow_add PROTO ((char *));
+void root_allow_free PROTO ((void));
+int root_allow_ok PROTO ((char *));
+
int same_directories PROTO((char *dir1, char *dir2));
char *Short_Repository PROTO((char *repository));
char *gca PROTO((char *rev1, char *rev2));
diff --git a/contrib/cvs/src/import.c b/contrib/cvs/src/import.c
index 933e38c..279bcd4 100644
--- a/contrib/cvs/src/import.c
+++ b/contrib/cvs/src/import.c
@@ -18,12 +18,11 @@
#include "cvs.h"
#include "savecwd.h"
+#include <assert.h>
#define FILE_HOLDER ".#cvsxxx"
static char *get_comment PROTO((char *user));
-static int add_rcs_file PROTO((char *message, char *rcs, char *user, char *vtag,
- int targc, char *targv[]));
static int expand_at_signs PROTO((char *buf, off_t size, FILE *fp));
static int add_rev PROTO((char *message, RCSNode *rcs, char *vfile,
char *vers));
@@ -475,7 +474,8 @@ process_import_file (message, vfile, vtag, targc, targv)
* repository nor in the Attic -- create it anew.
*/
add_log ('N', vfile);
- retval = add_rcs_file (message, rcs, vfile, vtag, targc, targv);
+ retval = add_rcs_file (message, rcs, vfile, vhead, vbranch,
+ vtag, targc, targv, logfp);
free (rcs);
return retval;
}
@@ -876,14 +876,36 @@ get_comment (user)
return retval;
}
-static int
-add_rcs_file (message, rcs, user, vtag, targc, targv)
+/* Create a new RCS file from scratch.
+
+ This probably should be moved to rcs.c now that it is called from
+ places outside import.c. */
+int
+add_rcs_file (message, rcs, user, add_vhead, add_vbranch, vtag, targc, targv,
+ add_logfp)
+ /* Log message for the addition. */
char *message;
+ /* Filename of the RCS file to create. */
char *rcs;
+ /* Filename of the file to serve as the contents of the initial
+ revision. */
char *user;
+
+ /* Revision number of head that we are adding. Normally 1.1 but
+ could be another revision as long as ADD_VBRANCH is a branch
+ from it. */
+ char *add_vhead;
+
+ /* Vendor branch to import to, or NULL if none. If non-NULL, then
+ vtag should also be non-NULL. */
+ char *add_vbranch;
char *vtag;
int targc;
char *targv[];
+
+ /* Write errors to here as well as via error (), or NULL if we should
+ use only error (). */
+ FILE *add_logfp;
{
FILE *fprcs, *fpuser;
struct stat sb;
@@ -918,7 +940,7 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
if (fpuser == NULL)
{
/* not fatal, continue import */
- fperror (logfp, 0, errno, "ERROR: cannot read file %s", userfile);
+ fperror (add_logfp, 0, errno, "ERROR: cannot read file %s", userfile);
error (0, errno, "ERROR: cannot read file %s", userfile);
goto read_error;
}
@@ -932,20 +954,36 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
/*
* putadmin()
*/
- if (fprintf (fprcs, "head %s;\012", vhead) < 0 ||
- fprintf (fprcs, "branch %s;\012", vbranch) < 0 ||
- fprintf (fprcs, "access ;\012") < 0 ||
+ if (fprintf (fprcs, "head %s;\012", add_vhead) < 0)
+ goto write_error;
+ if (add_vbranch != NULL)
+ {
+ if (fprintf (fprcs, "branch %s;\012", add_vbranch) < 0)
+ goto write_error;
+ }
+ if (fprintf (fprcs, "access ;\012") < 0 ||
fprintf (fprcs, "symbols ") < 0)
{
goto write_error;
}
- for (i = targc - 1; i >= 0; i--) /* RCS writes the symbols backwards */
- if (fprintf (fprcs, "%s:%s.1 ", targv[i], vbranch) < 0)
+ for (i = targc - 1; i >= 0; i--)
+ {
+ /* RCS writes the symbols backwards */
+ assert (add_vbranch != NULL);
+ if (fprintf (fprcs, "%s:%s.1 ", targv[i], add_vbranch) < 0)
goto write_error;
+ }
+
+ if (add_vbranch != NULL)
+ {
+ if (fprintf (fprcs, "%s:%s", vtag, add_vbranch) < 0)
+ goto write_error;
+ }
+ if (fprintf (fprcs, ";\012") < 0)
+ goto write_error;
- if (fprintf (fprcs, "%s:%s;\012", vtag, vbranch) < 0 ||
- fprintf (fprcs, "locks ; strict;\012") < 0 ||
+ if (fprintf (fprcs, "locks ; strict;\012") < 0 ||
/* XXX - make sure @@ processing works in the RCS file */
fprintf (fprcs, "comment @%s@;\012", get_comment (user)) < 0)
{
@@ -997,16 +1035,33 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
#endif
author = getcaller ();
- if (fprintf (fprcs, "\012%s\012", vhead) < 0 ||
- fprintf (fprcs, "date %s; author %s; state Exp;\012",
- altdate1, author) < 0 ||
- fprintf (fprcs, "branches %s.1;\012", vbranch) < 0 ||
- fprintf (fprcs, "next ;\012") < 0 ||
- fprintf (fprcs, "\012%s.1\012", vbranch) < 0 ||
+ if (fprintf (fprcs, "\012%s\012", add_vhead) < 0 ||
fprintf (fprcs, "date %s; author %s; state Exp;\012",
- altdate2, author) < 0 ||
- fprintf (fprcs, "branches ;\012") < 0 ||
- fprintf (fprcs, "next ;\012\012") < 0 ||
+ altdate1, author) < 0)
+ goto write_error;
+
+ if (fprintf (fprcs, "branches") < 0)
+ goto write_error;
+ if (add_vbranch != NULL)
+ {
+ if (fprintf (fprcs, " %s.1", add_vbranch) < 0)
+ goto write_error;
+ }
+ if (fprintf (fprcs, ";\012") < 0)
+ goto write_error;
+
+ if (fprintf (fprcs, "next ;\012") < 0)
+ goto write_error;
+ if (add_vbranch != NULL)
+ {
+ if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 ||
+ fprintf (fprcs, "date %s; author %s; state Exp;\012",
+ altdate2, author) < 0 ||
+ fprintf (fprcs, "branches ;\012") < 0 ||
+ fprintf (fprcs, "next ;\012\012") < 0)
+ goto write_error;
+ }
+ if (
/*
* putdesc()
*/
@@ -1015,9 +1070,23 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
/*
* putdelta()
*/
- fprintf (fprcs, "\012%s\012", vhead) < 0 ||
- fprintf (fprcs, "log\012") < 0 ||
- fprintf (fprcs, "@Initial revision\012@\012") < 0 ||
+ fprintf (fprcs, "\012%s\012", add_vhead) < 0 ||
+ fprintf (fprcs, "log\012@") < 0)
+ goto write_error;
+ if (add_vbranch != NULL)
+ {
+ /* We are going to put the log message in the revision on the
+ branch. So putting it here too seems kind of redundant, I
+ guess (and that is what CVS has always done, anyway). */
+ if (fprintf (fprcs, "Initial revision\012") < 0)
+ goto write_error;
+ }
+ else
+ {
+ if (expand_at_signs (message, (off_t) strlen (message), fprcs) < 0)
+ goto write_error;
+ }
+ if (fprintf (fprcs, "@\012") < 0 ||
fprintf (fprcs, "text\012@") < 0)
{
goto write_error;
@@ -1041,15 +1110,18 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
goto write_error;
}
}
- if (fprintf (fprcs, "@\012\012") < 0 ||
- fprintf (fprcs, "\012%s.1\012", vbranch) < 0 ||
- fprintf (fprcs, "log\012@") < 0 ||
- expand_at_signs (message, (off_t) strlen (message), fprcs) < 0 ||
- fprintf (fprcs, "@\012text\012") < 0 ||
- fprintf (fprcs, "@@\012") < 0)
- {
+ if (fprintf (fprcs, "@\012\012") < 0)
goto write_error;
+ if (add_vbranch != NULL)
+ {
+ if (fprintf (fprcs, "\012%s.1\012", add_vbranch) < 0 ||
+ fprintf (fprcs, "log\012@") < 0 ||
+ expand_at_signs (message, (off_t) strlen (message), fprcs) < 0 ||
+ fprintf (fprcs, "@\012text\012") < 0 ||
+ fprintf (fprcs, "@@\012") < 0)
+ goto write_error;
}
+
if (fclose (fprcs) == EOF)
{
ierrno = errno;
@@ -1071,7 +1143,7 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
if (chmod (rcs, mode) < 0)
{
ierrno = errno;
- fperror (logfp, 0, ierrno,
+ fperror (add_logfp, 0, ierrno,
"WARNING: cannot change mode of file %s", rcs);
error (0, ierrno, "WARNING: cannot change mode of file %s", rcs);
err++;
@@ -1088,12 +1160,12 @@ write_error:
(void) fclose (fprcs);
write_error_noclose:
(void) fclose (fpuser);
- fperror (logfp, 0, ierrno, "ERROR: cannot write file %s", rcs);
+ fperror (add_logfp, 0, ierrno, "ERROR: cannot write file %s", rcs);
error (0, ierrno, "ERROR: cannot write file %s", rcs);
if (ierrno == ENOSPC)
{
(void) CVS_UNLINK (rcs);
- fperror (logfp, 0, 0, "ERROR: out of space - aborting");
+ fperror (add_logfp, 0, 0, "ERROR: out of space - aborting");
error (1, 0, "ERROR: out of space - aborting");
}
read_error:
diff --git a/contrib/cvs/src/lock.c b/contrib/cvs/src/lock.c
index 6b8fa3d..c8d9bc6 100644
--- a/contrib/cvs/src/lock.c
+++ b/contrib/cvs/src/lock.c
@@ -490,7 +490,7 @@ again:
errno = 0;
while ((dp = readdir (dirp)) != NULL)
{
- if (fnmatch (CVSRFLPAT, dp->d_name, 0) == 0)
+ if (CVS_FNMATCH (CVSRFLPAT, dp->d_name, 0) == 0)
{
#ifdef CVS_FUDGELOCKS
time_t now;
diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c
index dc0d1e8..c11eb40 100644
--- a/contrib/cvs/src/main.c
+++ b/contrib/cvs/src/main.c
@@ -340,13 +340,14 @@ main (argc, argv)
lets us support the `cvs -H cmd'
convention to give help for cmd. */
static struct option long_options[] =
- {
+ {
{"help", 0, NULL, 'H'},
{"version", 0, NULL, 'v'},
{"help-commands", 0, NULL, 1},
{"help-synonyms", 0, NULL, 2},
+ {"allow-root", required_argument, NULL, 3},
{0, 0, 0, 0}
- };
+ };
/* `getopt_long' stores the option index here, but right now we
don't use it. */
int option_index = 0;
@@ -441,9 +442,9 @@ main (argc, argv)
while ((c = getopt_long
(argc, argv, "+QqrwtnRlvb:T:e:d:Hfz:s:x", long_options, &option_index))
!= EOF)
- {
+ {
switch (c)
- {
+ {
case 1:
/* --help-commands */
usage (cmd_usage);
@@ -452,6 +453,10 @@ main (argc, argv)
/* --help-synonyms */
usage (cmd_synonyms());
break;
+ case 3:
+ /* --allow-root */
+ root_allow_add (optarg);
+ break;
case 'Q':
really_quiet = TRUE;
/* FALL THROUGH */
@@ -613,6 +618,12 @@ main (argc, argv)
#if defined(AUTH_SERVER_SUPPORT) && defined(SERVER_SUPPORT)
if (strcmp (command_name, "pserver") == 0)
{
+ /* The reason that --allow-root is not a command option
+ is mainly the comment in server() about how argc,argv
+ might be from .cvsrc. I'm not sure about that, and
+ I'm not sure it is only true of command options, but
+ it seems easier to make it a global option. */
+
/* Gets username and password from client, authenticates, then
switches to run as that user and sends an ACK back to the
client. */
@@ -895,6 +906,7 @@ main (argc, argv)
free (Tmpdir);
if (free_Rcsbin)
free (Rcsbin);
+ root_allow_free ();
#ifdef SYSTEM_CLEANUP
/* Hook for OS-specific behavior, for example socket subsystems on
diff --git a/contrib/cvs/src/mkmodules.c b/contrib/cvs/src/mkmodules.c
index cff993a..ec5d770 100644
--- a/contrib/cvs/src/mkmodules.c
+++ b/contrib/cvs/src/mkmodules.c
@@ -708,6 +708,8 @@ init (argc, argv)
char *info;
/* Name of ,v file for this administrative file. */
char *info_v;
+ /* Exit status. */
+ int err;
const struct admin_file *fileptr;
@@ -739,7 +741,10 @@ init (argc, argv)
strcat (adm, CVSROOTADM);
mkdir_if_needed (adm);
- /* This is needed by the call to "ci" below. */
+ /* This is needed because we pass "fileptr->filename" not "info"
+ to add_rcs_file below. I think this would be easy to change,
+ thus nuking the need for CVS_CHDIR here, but I haven't looked
+ closely (e.g. see wrappers calls within add_rcs_file). */
if ( CVS_CHDIR (adm) < 0)
error (1, errno, "cannot change to directory %s", adm);
@@ -776,16 +781,15 @@ init (argc, argv)
if (fclose (fp) < 0)
error (1, errno, "cannot close %s", info);
}
- /* Now check the file in. FIXME: we could be using
- add_rcs_file from import.c which is faster (if it were
- tweaked slightly). */
- run_setup ("%s%s -x,v/ -q -u -t-", Rcsbin, RCS_CI);
- run_args ("-minitial checkin of %s", fileptr->filename);
- run_arg (fileptr->filename);
- retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
+ /* The message used to say " of " and fileptr->filename after
+ "initial checkin" but I fail to see the point as we know what
+ file it is from the name. */
+ retcode = add_rcs_file ("initial checkin", info_v,
+ fileptr->filename, "1.1", NULL, NULL,
+ 0, NULL, NULL);
if (retcode != 0)
- error (1, retcode == -1 ? errno : 0,
- "failed to check in %s", info);
+ /* add_rcs_file already printed an error message. */
+ err = 1;
}
}
diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c
index ce4f410..834acd9 100644
--- a/contrib/cvs/src/rcs.c
+++ b/contrib/cvs/src/rcs.c
@@ -1050,8 +1050,13 @@ getrcsrev (fp, revp)
do {
c = getc (fp);
if (c == EOF)
+ {
/* FIXME: should be including filename in error message. */
- error (1, errno, "cannot read rcs file");
+ if (ferror (fp))
+ error (1, errno, "cannot read rcs file");
+ else
+ error (1, 0, "unexpected end of file reading rcs file");
+ }
} while (whitespace (c));
if (!(isdigit (c) || c == '.'))
@@ -1075,7 +1080,10 @@ getrcsrev (fp, revp)
if (c == EOF)
{
/* FIXME: should be including filename in error message. */
- error (1, errno, "cannot read rcs file");
+ if (ferror (fp))
+ error (1, errno, "cannot read rcs file");
+ else
+ error (1, 0, "unexpected end of file reading rcs file");
}
}
diff --git a/contrib/cvs/src/rcs.h b/contrib/cvs/src/rcs.h
index 64d03e0..5054fd0 100644
--- a/contrib/cvs/src/rcs.h
+++ b/contrib/cvs/src/rcs.h
@@ -129,3 +129,7 @@ int rcs_change_text PROTO ((const char *, char *, size_t, const char *,
void RCS_setlocalid PROTO ((const char *arg));
void RCS_setincexc PROTO ((const char *arg));
+
+/* From import.c. */
+extern int add_rcs_file PROTO ((char *, char *, char *, char *,
+ char *, char *, int, char **, FILE *));
diff --git a/contrib/cvs/src/server.c b/contrib/cvs/src/server.c
index bc3f4d2..ea40a4c 100644
--- a/contrib/cvs/src/server.c
+++ b/contrib/cvs/src/server.c
@@ -89,7 +89,7 @@ static Key_schedule sched;
the same as the system username the server eventually switches to
run as. CVS_Username gets set iff password authentication is
successful. */
-static char *CVS_Username = NULL;
+char *CVS_Username = NULL;
/* Used to check that same repos is transmitted in pserver auth and in
later CVS protocol. Exported because root.c also uses. */
@@ -3074,6 +3074,42 @@ server_copy_file (file, update_dir, repository, newfile)
/* See server.h for description. */
void
+server_modtime (finfo, vers_ts)
+ struct file_info *finfo;
+ Vers_TS *vers_ts;
+{
+ char date[MAXDATELEN];
+ int year, month, day, hour, minute, second;
+ /* Note that these strings are specified in RFC822 and do not vary
+ according to locale. */
+ static const char *const month_names[] =
+ {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+
+ if (!supported_response ("Mod-time"))
+ return;
+
+ /* The only hard part about this routine is converting the date
+ formats. In terms of functionality it all boils down to the
+ call to RCS_getrevtime. */
+ if (RCS_getrevtime (finfo->rcs, vers_ts->vn_rcs, date, 0) == (time_t) -1)
+ /* FIXME? should we be printing some kind of warning? For one
+ thing I'm not 100% sure whether this happens in non-error
+ circumstances. */
+ return;
+
+ sscanf (date, SDATEFORM, &year, &month, &day, &hour, &minute, &second);
+ sprintf (date, "%d %s %d %d:%d:%d -0000", day,
+ month < 1 || month > 12 ? "???" : month_names[month - 1],
+ year, hour, minute, second);
+ buf_output0 (protocol, "Mod-time ");
+ buf_output0 (protocol, date);
+ buf_output0 (protocol, "\n");
+}
+
+/* See server.h for description. */
+
+void
server_updated (finfo, vers, updated, file_info, checksum)
struct file_info *finfo;
Vers_TS *vers;
@@ -4620,6 +4656,14 @@ pserver_authenticate_connection ()
{
error (1, 0, "bad auth protocol end: %s", tmp);
}
+ if (!root_allow_ok (repository))
+ /* At least for the moment I'm going to do the paranoid
+ security thing and not tell them how it failed. I'm not
+ sure that is a good idea; it is a real pain when one needs
+ to track down what is going on for legitimate reasons.
+ The other issue is that the protocol doesn't really have
+ a good way for anything other than I HATE YOU. */
+ goto i_hate_you;
/* We need the real cleartext before we hash it. */
descrambled_password = descramble (password);
@@ -4633,6 +4677,7 @@ pserver_authenticate_connection ()
}
else
{
+ i_hate_you:
printf ("I HATE YOU\n");
fflush (stdout);
/* I'm doing this manually rather than via error_exit ()
OpenPOWER on IntegriCloud