new feature, pserver configuration file support
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
new feature, pserver configuration file support
- From: eric [at] cirr.com (Eric Schnoebelen)
- To: cvsd-users [at] lists.arthurdejong.org
- Subject: new feature, pserver configuration file support
- Date: Tue, 04 Oct 2011 19:02:45 -0500
Attached is an implementation to add support for the pserver
configuration file that was added in CVS 1.12.??.
The change in CVS 1.12 adds an argument to the "[p]server"
sub-command, allowing the user to specify a specific
configuration file.
In the case of cvsd, using it allows the repository operator to
override the configuration variables/values in a repository's
CVSROOT/config file.
The new configuration option in cvsd.conf is "CvsConfig", and if
variable has a value, it adds the option "-c" and the associated
filename to toe cvs command line after "pserver" is added.
I am using it to override the vendor provided configuration
files in my anonymous CVS mirrors of NetBSD and OpenBSD
(anoncvs.cirr.com:2401/cvsroot for NetBSD and
anoncvs.cirr.com:2401/cvs for OpenBSD)
Thank you for your consideration,
        Eric Schnoebelen
--
Eric Schnoebelen                eric@cirr.com            http://www.cirr.com
          Programming is the art of debugging a blank sheet of paper.
cvs diff: Diffing .
Index: cfg.c
===================================================================
RCS file: /arthur/cvsd/cfg.c,v
retrieving revision 1.9
diff -b -u -w -r1.9 cfg.c
--- cfg.c       4 Oct 2011 19:30:41 -0000       1.9
+++ cfg.c       4 Oct 2011 23:50:22 -0000
@@ -68,6 +68,7 @@
   cfg->maxconnections = 0;
   cfg->cvscmd     = NULL; /* default is set according to configured rootjail */
   cfg->cvsargs    = NULL; /* autom. allocated by add_cvsarg() */
+  cfg->cvsconf    = NULL;
   cfg->cvsenv     = default_environment;
   return cfg;
 }
Index: cfg.h
===================================================================
RCS file: /arthur/cvsd/cfg.h,v
retrieving revision 1.6
diff -b -u -w -r1.6 cfg.h
--- cfg.h       21 May 2006 14:36:01 -0000      1.6
+++ cfg.h       4 Oct 2011 23:50:22 -0000
@@ -112,6 +112,9 @@
   /* the arguments that will be passed */
   char **cvsargs;
 
+  /* an optional configuration file */
+  char *cvsconf;
+
   /* the environment that should be used */
   char **cvsenv;
 
Index: cfgfile.c
===================================================================
RCS file: /arthur/cvsd/cfgfile.c,v
retrieving revision 1.19
diff -b -u -w -r1.19 cfgfile.c
--- cfgfile.c   29 Dec 2005 15:02:10 -0000      1.19
+++ cfgfile.c   4 Oct 2011 23:50:22 -0000
@@ -490,6 +490,34 @@
     }
     else if (strcmp(opts[0],"Log")==0)
       parse_option_log(filename,lnr,opts,nopts);
+    else if (strcmp(opts[0], "CvsConfig") == 0) 
+    {
+      if (nopts!=2)
+      {
+        log_log(LOG_ERR,"%s:%d: CvsConfig: wrong number of 
arguments",filename,lnr);
+        exit(1);
+      }
+      /* only accept absolute paths, abort otherwise */
+      if (*opts[1]!='/')
+      {
+        log_log(LOG_ERR,"%s:%d: CvsCommand: '%s' must be an absolute 
path",filename,lnr,opts[1]);
+        exit(1);
+      }
+      /*
+       * XXX -- validate the path name 
+       *    (by concatinating rootjail and cvsconf)?
+       */
+      /* save value */
+      if (cfg->cvsconf!=NULL)
+      {
+        log_log(LOG_ERR,"%s:%d: CvsConfig: can only be specified 
once",filename,lnr);
+        exit(1);
+      }
+      else
+      {
+        cfg->cvsconf=xstrdup(opts[1]);
+      }
+    }
     else
     {
       log_log(LOG_ERR,"%s:%d: unrecognized line",filename,lnr);
Index: cvsd.c
===================================================================
RCS file: /arthur/cvsd/cvsd.c,v
retrieving revision 1.124
diff -b -u -w -r1.124 cvsd.c
--- cvsd.c      29 Jan 2011 21:20:02 -0000      1.124
+++ cvsd.c      4 Oct 2011 23:50:23 -0000
@@ -716,6 +716,12 @@
   /* add cvs action */
   cfg_addcvsarg(cfg,"pserver"); /* run cvs as pserver */
 
+  /* add any CVS (1.12.*) server configuration file */
+  if (cfg->cvsconf != NULL) {
+    cfg_addcvsarg(cfg, "-c");
+    cfg_addcvsarg(cfg, cfg->cvsconf);
+  }
+
   /* dump all arguments */
   for (i=0;cfg->cvsargs[i]!=NULL;i++)
     log_log(LOG_DEBUG,"debug: cvsargs[%d]: %s",i,cfg->cvsargs[i]);
Index: cvsd.conf-dist
===================================================================
RCS file: /arthur/cvsd/cvsd.conf-dist,v
retrieving revision 1.19
diff -b -u -w -r1.19 cvsd.conf-dist
--- cvsd.conf-dist      7 Dec 2007 13:20:54 -0000       1.19
+++ cvsd.conf-dist      4 Oct 2011 23:50:23 -0000
@@ -38,6 +38,14 @@
 #  For example, to enable read-only access to the
 #  repository, pass the -R option.
 
+# CvsConfig <arg>
+#  Path to a cvs.conf file as supported by CVS v 1.12.xx (and later)
+#  useful when mirroring an entire repository, and the master
+#  repository CVSROOT/config is not suitable for use on the mirror
+#  CvsConfig (with a preceeding "-n") is appended to the CVS command
+#  line after the "pserver" command.
+# CvsConfig /etc/cvs.conf
+
 # Nice <num>
 #  This specifies the nice value (on most systems
 #  ranging from -20 to 20) where the smaller the number
-- 
To unsubscribe send an email to
cvsd-users-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/cvsd-users/
- new feature, pserver configuration file support,
Eric Schnoebelen