From faf7e6f1513d2582f4a6eed04aaf8ec97028e27b Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 2 May 2009 20:31:43 +0000 Subject: sync, OpenCVS --- anoncvssh.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 8 deletions(-) (limited to 'anoncvssh.c') diff --git a/anoncvssh.c b/anoncvssh.c index 62af922..0832b8c 100644 --- a/anoncvssh.c +++ b/anoncvssh.c @@ -57,18 +57,24 @@ #endif /* - * Account and host name to be used when accessing the - * CVS repository remotely + * Hostname to be used when accessing the remote repository. */ #ifndef HOSTNAME -#define HOSTNAME "anoncvs@anoncvs1.usa.openbsd.org" +#define HOSTNAME "anoncvs1.usa.openbsd.org" #endif /* - * $CVSROOT is created based on HOSTNAME and LOCALROOT above + * Username to be used when accessing the remote repository. + */ +#ifndef USERNAME +#define USERNAME "anoncvs" +#endif + +/* + * $CVSROOT is created based on USERNAME HOSTNAME and LOCALROOT above */ #ifndef CVSROOT -#define CVSROOT HOSTNAME ":"LOCALROOT +#define CVSROOT USERNAME "@" HOSTNAME ":"LOCALROOT #endif /* @@ -98,7 +104,13 @@ /* Define ANONCVS_USER if you want anoncvssh to complain if invoked by * anyone other than root or ANONCVS_USER. */ -/* #define ANONCVS_USER "anoncvs" */ +/* #define ANONCVS_USER USERNAME */ + +/* + * If you want to be able to run an alternate OpenCVS binary on your + * anoncvs server, define OPENCVS_USER as the user who will invoke it. + */ +#define OPENCVS_USER "opencvs" int main __P((int, char *[])); @@ -120,6 +132,9 @@ char *argv[]; #ifdef DEBUG int i; #endif /* DEBUG */ +#if defined(OPENCVS_USER) + int opencvs; +#endif pw = getpwuid(getuid()); if (pw == NULL) { @@ -159,6 +174,13 @@ char *argv[]; chdir("/"); setuid(pw->pw_uid); +#if defined(OPENCVS_USER) + if (!strcmp(pw->pw_name, OPENCVS_USER)) + opencvs = 1; + else + opencvs = 0; +#endif + /* * program now "safe" */ @@ -170,7 +192,15 @@ char *argv[]; int slen; struct sockaddr_in my_sa, peer_sa; char *us, *them; - + +#if defined(OPENCVS_USER) + if (opencvs == 1) { + fprintf(stderr, "OpenCVS does not support pserver\n"); + sleep(10); + exit(1); + } +#endif + slen = sizeof(my_sa); if (getsockname(0, (struct sockaddr *) &my_sa, &slen) != 0) { @@ -216,6 +246,10 @@ char *argv[]; fprintf(stderr,"version of CVS on your local machine.\n"); fprintf(stderr,"Then set your CVSROOT environment variable "); fprintf(stderr,"to the following value:\n"); +#if defined(OPENCVS_USER) + fprintf(stderr, "\t%s@%s:%s for OpenCVS\n", OPENCVS_USER, + HOSTNAME, LOCALROOT); +#endif fprintf(stderr,"\t%s\n\n", CVSROOT); #ifdef DEBUG fprintf(stderr, "argc = %d\n", argc); @@ -225,7 +259,18 @@ char *argv[]; sleep(10); exit(0); } - execle("/usr/bin/cvs", "cvs", "server", (char *)NULL, env); + +#if defined(OPENCVS_USER) + if (opencvs == 1) { + execle("/usr/bin/opencvs", "opencvs", + "server", (char *)NULL, env); + } else { +#endif + execle("/usr/bin/cvs", "cvs", "server", (char *)NULL, env); +#if defined(OPENCVS_USER) + } +#endif + perror("execle: cvs"); fprintf(stderr, "unable to exec CVS server!\n"); exit(1); -- cgit v1.2.3