diff -Nar --exclude '*~' -u -U 10 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 07:13:29.000000000 -0700 +++ cvs-1.12.12/src/server.c 2006-08-07 17:27:14.174461617 -0700 @@ -5836,43 +5836,101 @@ #undef REQ_LINE }; #endif /* SERVER_SUPPORT or CLIENT_SUPPORT */ #ifdef SERVER_SUPPORT /* * 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. + */ +#define L 4096 +static char blocked_requests[L] = ""; + +#define DBG_FILE "/tmp/cvs-debug" +#define DBG(format,...) { FILE *f = fopen(DBG_FILE,"a+"); fprintf(f,format, ## __VA_ARGS__); fclose(f); } + + +static void build_blocked_requests() { + char* block_requests = getenv("CVS_BLOCK_REQUESTS"); + if(block_requests != NULL) { + // split it to get the value + char *tmp = strstr(block_requests,"="); + // 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,L-strlen(blocked_requests)); + //add a space on the end as well for searching + strncat(blocked_requests," ",L-strlen(blocked_requests)); + } + 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 +} +#undef L +// returns 0 if we should serve this request +// use as if(checker(FOO)) continue; +static int serve_valid_requests_checker(char *reqname) { + if(!blocked_requests) + return 0; + // we want to look for ' 'reqname' ' +#define L 512 + char needle[L] = " "; + strncat(needle,reqname,L-strlen(needle)); + strncat(needle," ",L-strlen(needle)); +#undef L + // now do the search + char* tmp = strstr(blocked_requests,needle); + DBG(stderr,"checking request='%s' result=%d\n",reqname,tmp != NULL); + if(tmp != NULL) + return 1; + + return 0; + +} +#undef DBG +#undef DBG_FILE + static void serve_valid_requests (char *arg) { struct request *rq; /* Since this is processed in the first pass, don't reprocess it in the * second. * * We still print errors since new errors could have been generated in the * second pass. */ if (print_pending_error () #ifdef PROXY_SUPPORT || reprocessing #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); } } buf_output0 (buf_to_net, "\nok\n"); /* The client is waiting for the list of valid requests, so we must send the output now. */ buf_flush (buf_to_net, 1); }