diff -Nrup cvs-1.12.12.orig/src/server.c cvs-1.12.12/src/server.c --- cvs-1.12.12.orig/src/server.c 2005-04-14 14:13:29.000000000 +0000 +++ cvs-1.12.12/src/server.c 2006-08-08 00:29:05.000000000 +0000 @@ -5843,6 +5843,79 @@ struct request requests[] = /* * This server request is not ignored by the secondary. */ + +/* Hack by Robin H. Johnson . + * Allow the server ENV to specify what request types are to be ignored. + */ + +static char blocked_requests[BUFSIZ] = ""; + +#ifdef EBUG + + +#define DBG_FILE "/tmp/cvs-debug" +FILE *debuglog = NULL; +#define DBG(fmt, args...) \ + fprintf(debuglog, "debug: " fmt "\n", ## args) +#else +#define DBG(fmt, args...) +#endif + +static void build_blocked_requests() { + char *tmp = getenv("CVS_BLOCK_REQUESTS"); + + if (tmp != NULL && strlen(tmp) > 0) { + + // split it to get the value + tmp = strstr(tmp, "="); + + // if it is defined and empty, just return. + if(tmp == NULL || strlen(tmp) <= 1) + return; + + //set the seperator to be a space, for searching reasons + *tmp = ' '; + + // move to our custom buffer + strncat(blocked_requests, tmp, sizeof(blocked_requests)-strlen(blocked_requests)); + + //add a space on the end as well for searching + strncat(blocked_requests, " ", sizeof(blocked_requests)-strlen(blocked_requests)); + + } +#ifdef EBUG + if ((debuglog = fopen(DBG_FILE, "a+")) == NULL) + debuglog = stderr; +#endif + DBG("blocklist=%s\n", blocked_requests ? blocked_requests : "NULL"); + + // now blocked_requests contains the list of every request that we do not + // want to serve +} + +// returns 0 if we should serve this request +// use as if(checker(FOO)) continue; +static int serve_valid_requests_checker(char *reqname) { + char needle[BUFSIZ] = " "; + char *tmp; + + if(strlen(blocked_requests)) < 1)) + return 0; + + // we want to look for ' 'reqname' ' + snprintf(needle, sizeof(needle), " %s ", reqname); + + // now do the search + tmp = strstr(blocked_requests, needle); + DBG("checking request='%s' result=%d\n", reqname, tmp != NULL); + + if (tmp != NULL) + return 1; + + return 0; + +} + static void serve_valid_requests (char *arg) { @@ -5860,12 +5933,16 @@ serve_valid_requests (char *arg) #endif /* PROXY_SUPPORT */ ) return; + + build_blocked_requests(); buf_output0 (buf_to_net, "Valid-requests"); for (rq = requests; rq->name != NULL; rq++) { if (rq->func != NULL) { + if(serve_valid_requests_checker(rq->name)) + continue; buf_append_char (buf_to_net, ' '); buf_output0 (buf_to_net, rq->name); }