Index: src/main.cpp =================================================================== RCS file: /cvs/cvsnt/src/main.c,v retrieving revision 1.71.2.151.6.68 diff -c -r1.71.2.151.6.68 main.cpp *** src/main.cpp 15 Nov 2011 03:01:30 -0000 1.71.2.151.6.68 --- src/main.cpp 16 Nov 2011 05:37:24 -0000 *************** *** 60,65 **** --- 60,66 ---- const char *command_name; const char *server_verb; const char *warn_error_1, *warn_error_2; + int always_close_trig; unsigned int preferred_lsadll; unsigned int l_no_priv_ignore; *************** *** 159,164 **** --- 160,169 ---- /* 0=Any, 1=Request compr., 2=Require compr. */ extern int compression_level; + extern const char *g_anonymous_user; + extern const char *g_force_branch; + extern const char *g_anon_force_branch; + extern int g_is_anonymous; extern const char *allowed_clients; extern int nowarn_fourtyone; extern int nowarn_twozero; *************** *** 707,712 **** --- 712,724 ---- read_only_server = atoi(buffer); #ifdef SERVER_SUPPORT + if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","ForceBranch",buffer,sizeof(buffer))) + g_force_branch = xstrdup(buffer); + if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","AnonForceBranch",buffer,sizeof(buffer))) + g_anon_force_branch = xstrdup(buffer); + if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","AnonymousUsername",buffer,sizeof(buffer))) + g_anonymous_user = xstrdup(buffer); + if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","AllowedClients",buffer,sizeof(buffer))) allowed_clients = xstrdup(buffer); if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","Warn2041",buffer,sizeof(buffer))) Index: src/server.cpp =================================================================== RCS file: /cvs/cvsnt/src/server.c,v retrieving revision 1.106.2.210.6.127 diff -c -r1.106.2.210.6.127 server.cpp *** src/server.cpp 15 Nov 2011 03:01:30 -0000 1.106.2.210.6.127 --- src/server.cpp 17 Nov 2011 07:32:38 -0000 *************** *** 67,72 **** --- 67,73 ---- char server_sticky_tagname[1024]; int use_owner_author=0; int use_sticky_tagname=0; + #endif const char *current_username=NULL; *************** *** 233,238 **** --- 234,244 ---- /* 0=Any, 1=Request compr., 2=Require compr. */ int compression_level = 0; + int g_is_anonymous=0; + const char *g_anonymous_user = NULL; + const char *g_force_branch = NULL; + const char *g_anon_force_branch = NULL; + /* Regexp of clients allowed to connect */ const char *allowed_clients = NULL; int nowarn_fourtyone = 0; *************** *** 242,247 **** --- 248,254 ---- int do_print_version = 0; int do_print_after = 0; + static void server_write_entries(); static void server_write_renames(); *************** *** 1734,1745 **** protocol_encryption_enabled = PROTOCOL_AUTHENTICATION; } ! static void serve_directory (char *arg) { - int status; - char *repos; - - status = server_read_line (buf_from_net, &repos, (int *) NULL); if (status == 0) { if (!outside_root (repos)) --- 1741,1748 ---- protocol_encryption_enabled = PROTOCOL_AUTHENTICATION; } ! static void serve_directory_repos (char *arg, char *repos, int status) { if (status == 0) { if (!outside_root (repos)) *************** *** 1764,1769 **** --- 1767,1781 ---- } } + static void serve_directory (char *arg) + { + int status; + char *repos; + + status = server_read_line (buf_from_net, &repos, (int *) NULL); + serve_directory_repos (arg, repos, status); + } + static void serve_static_directory (char *arg) { FILE *f; *************** *** 5688,5923 **** char * stdinbuf = 0, *stdinbuftrix[10] = {0,0,0,0,0,0,0,0,0,0}; int stdinbufcount=0; ! int server () { ! cvs::wildcard_filename ac; static int check_done=0; static int do_check_version; ! static int got_ok_client_version=0; ! const char *log = CProtocolLibrary::GetEnvironment("CVS_SERVER_LOG"); ! global_edit_bugnum_hack = 0; ! global_editors_bugnum_hack = 0; ! do_check_version =0; ! ac = serv_client_version?serv_client_version:""; ! ! if(!log) ! { ! static char logbuf[256]; ! if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","ServerLogFile",logbuf,sizeof(logbuf))) ! log = logbuf; ! } ! ! /* Ignore argc and argv. They might be from .cvsrc. */ ! if(!buf_to_net) ! buf_to_net = fd_buffer_initialize (STDOUT_FILENO, 0, outbuf_memory_error); ! if(!buf_from_net) ! buf_from_net = stdio_buffer_initialize (stdin, 1, outbuf_memory_error); ! ! use_sticky_tagname=0; ! ! /* Set up logfiles, if any. */ ! if (log) ! { ! int len = strlen (log); ! char *buf = (char*)xmalloc (len + 64); ! char *p; ! FILE *fp; ! ! sprintf(buf,"%s-%d",log,(int)getpid()); ! p = buf + strlen(buf); ! ! /* Open logfiles in binary mode so that they reflect ! exactly what was transmitted and received (that is ! more important than that they be maximally ! convenient to view). */ ! strcpy (p, ".out"); ! fp = open_file (buf, "wb"); ! if (fp == NULL) ! error (0, errno, "opening to-server logfile %s", buf); ! else ! buf_to_net = log_buffer_initialize (buf_to_net, fp, 0, ! (BUFMEMERRPROC) NULL); ! ! strcpy (p, ".in"); ! fp = open_file (buf, "wb"); ! if (fp == NULL) ! error (0, errno, "opening from-server logfile %s", buf); ! else ! buf_from_net = log_buffer_initialize (buf_from_net, fp, 1, ! (BUFMEMERRPROC) NULL); ! ! xfree (buf); ! } ! ! stdout_buf = cvs_protocol_wrap_buffer_initialize(buf_to_net, 'M'); ! stderr_buf = cvs_protocol_wrap_buffer_initialize(buf_to_net, 'E'); ! ! TRACE(99,"Server start stuff"); ! /* OK, now figure out where we stash our temporary files. */ ! { ! char *p; ! ! /* The code which wants to chdir into server_temp_dir is not set ! up to deal with it being a relative path. So give an error ! for that case. */ ! if (!isabsolute (Tmpdir)) ! { ! error(1,0,"Value of %s for TMPDIR is not absolute", Tmpdir); ! } ! else ! { ! int status; ! int i = 0; ! ! server_temp_dir = (char*)xmalloc (strlen (Tmpdir) + 256); ! if (server_temp_dir == NULL) ! { ! error(1,ENOMEM,"Fatal server error, aborting."); ! } ! strcpy (server_temp_dir, Tmpdir); ! ! /* Remove a trailing slash from TMPDIR if present. */ ! p = server_temp_dir + strlen (server_temp_dir) - 1; ! if (*p == '/') ! *p = '\0'; ! ! /* ! * I wanted to use cvs-serv/PID, but then you have to worry about ! * the permissions on the cvs-serv directory being right. So ! * use cvs-servPID. ! */ ! strcat (server_temp_dir, "/cvs-serv"); ! ! p = server_temp_dir + strlen (server_temp_dir); ! sprintf (p, "%ld", (long) getpid ()); ! ! orig_server_temp_dir = server_temp_dir; ! ! TRACE(3,"Server temp dir is %s",server_temp_dir); ! ! /* Create the temporary directory, and set the mode to ! 700, to discourage random people from tampering with ! it. */ ! /* mkdir_p is a bad idea here as an incorrect server_temp_dir ! could put a directory pretty much anywhere in error.. eg. trying ! to create c:\windows\temp on Windows 7 for example. */ ! while ((status = mkdir_p(server_temp_dir, 0777)) == EEXIST) // Was mkdir_p ! { ! static const char suffix[] = "abcdefghijklmnopqrstuvwxyz"; ! ! if (i >= sizeof suffix - 1) break; ! if (i == 0) p = server_temp_dir + strlen (server_temp_dir); ! p[0] = suffix[i++]; ! p[1] = '\0'; ! } ! if (status != 0) ! { ! error(1,errno,"can't create temporary directory %s",server_temp_dir); ! } ! #ifndef CHMOD_BROKEN ! else if (chmod (server_temp_dir, S_IRWXU) < 0) ! { ! error(1,errno,"cannot change permissions on temporary directory %s", ! fn_root(server_temp_dir)); ! } ! #endif ! else if (CVS_CHDIR (server_temp_dir) < 0) ! { ! error(1,errno,"cannot change to temporary directory %s", ! fn_root(server_temp_dir)); ! } ! #ifdef _WIN32 ! if(!filenames_case_insensitive) ! add_to_ci_directory_list(server_temp_dir); ! #endif ! } ! } ! ! TRACE(99,"Server register for signals"); ! #ifdef SIGABRT ! (void) SIG_register (SIGABRT, server_cleanup); ! #endif ! #ifdef SIGHUP ! (void) SIG_register (SIGHUP, server_cleanup); ! #endif ! #ifdef SIGINT ! (void) SIG_register (SIGINT, server_cleanup); ! #endif ! #ifdef SIGQUIT ! (void) SIG_register (SIGQUIT, server_cleanup); ! #endif ! #ifdef SIGPIPE ! (void) SIG_register (SIGPIPE, server_cleanup); ! #endif ! #ifdef SIGTERM ! (void) SIG_register (SIGTERM, server_cleanup); ! #endif ! ! /* Now initialize our argument vector (for arguments from the client). */ ! ! /* Small for testing. */ ! argument_vector_size = 1; ! argument_vector = ! (char **) xmalloc (argument_vector_size * sizeof (char *)); ! if (argument_vector == NULL) ! { ! /* ! * Strictly speaking, we're not supposed to output anything ! * now. But we're about to exit(), give it a try. ! */ ! TRACE(99,"Fatal server error, aborting. error ENOMEM Virtual memory exhausted."); ! printf ("E Fatal server error, aborting.\nerror ENOMEM Virtual memory exhausted.\n"); ! ! /* I'm doing this manually rather than via error_exit () ! because I'm not sure whether we want to call server_cleanup. ! Needs more investigation.... */ ! ! #ifdef SYSTEM_CLEANUP ! /* Hook for OS-specific behavior, for example socket subsystems on ! NT and OS2 or dealing with windows and arguments on Mac. */ ! SYSTEM_CLEANUP (); ! #endif ! if(current_username) ! xfree(current_username); ! ! CCvsgui::Close(EXIT_FAILURE); ! exit (EXIT_FAILURE); ! } ! argument_count = 1; ! /* This gets printed if the client supports an option which the ! server doesn't, causing the server to print a usage message. ! FIXME: probably should be using program_name here. ! FIXME: just a nit, I suppose, but the usage message the server ! prints isn't literally true--it suggests "cvs server" followed ! by options which are for a particular command. Might be nice to ! say something like "client apparently supports an option not supported ! by this server" or something like that instead of usage message. */ ! argument_vector[0] = "cvs server"; - int times_through=0; - while (1) - { - char *cmd, *orig_cmd; - struct request *rq; - int status; - times_through++; - - TRACE(99,"server: read a 'server line' from client."); - status = server_read_line (buf_from_net, &cmd, (int *) NULL); - if (status == -2) - { - buf_output0 (buf_to_net, "E Fatal server error, aborting.\n\ - error ENOMEM Virtual memory exhausted.\n"); - break; - } - TRACE(99,"server: read line status = %d cmd = '%s'.",status,(status==0)?PATCH_NULL(cmd):"bad status"); - if (status != 0) - break; - if(!*cmd) - continue; - - orig_cmd = cmd; for (rq = requests; rq->name != NULL; ++rq) if (strncmp (cmd, rq->name, strlen (rq->name)) == 0) { --- 5700,5722 ---- char * stdinbuf = 0, *stdinbuftrix[10] = {0,0,0,0,0,0,0,0,0,0}; int stdinbufcount=0; ! enum servercmd_modetype { ! scmdmNormal, scmdmPushStore, scmdmReplay ! }; ! typedef enum servercmd_modetype scmdmtype; ! ! int servergo(char *cmd) ! { ! static int got_ok_client_version=0; static int check_done=0; static int do_check_version; ! cvs::wildcard_filename ac; ! struct request *rq; ! ac = serv_client_version?serv_client_version:""; ! do_check_version =0; for (rq = requests; rq->name != NULL; ++rq) if (strncmp (cmd, rq->name, strlen (rq->name)) == 0) { *************** *** 6198,6210 **** buf_append_char (buf_to_net, '\''); buf_append_char (buf_to_net, '\n'); } ! xfree (orig_cmd); ! } ! // An edit might have left the client connection open, in which case ! // close it here ! if(proxy_active && server_started) ! cleanup_and_close_server(); TRACE(3,"server finishing, call server_cleanup()"); server_cleanup (0); --- 5997,6443 ---- buf_append_char (buf_to_net, '\''); buf_append_char (buf_to_net, '\n'); } ! return 0; ! } ! int server () ! { ! static int do_check_version; ! const char *log = CProtocolLibrary::GetEnvironment("CVS_SERVER_LOG"); ! global_edit_bugnum_hack = 0; ! global_editors_bugnum_hack = 0; ! do_check_version =0; ! ! if(!log) ! { ! static char logbuf[256]; ! if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","ServerLogFile",logbuf,sizeof(logbuf))) ! log = logbuf; ! } ! ! /* Ignore argc and argv. They might be from .cvsrc. */ ! if(!buf_to_net) ! buf_to_net = fd_buffer_initialize (STDOUT_FILENO, 0, outbuf_memory_error); ! if(!buf_from_net) ! buf_from_net = stdio_buffer_initialize (stdin, 1, outbuf_memory_error); ! ! use_sticky_tagname=0; ! ! /* Set up logfiles, if any. */ ! if (log) ! { ! int len = strlen (log); ! char *buf = (char*)xmalloc (len + 64); ! char *p; ! FILE *fp; ! ! sprintf(buf,"%s-%d",log,(int)getpid()); ! p = buf + strlen(buf); ! ! /* Open logfiles in binary mode so that they reflect ! exactly what was transmitted and received (that is ! more important than that they be maximally ! convenient to view). */ ! strcpy (p, ".out"); ! fp = open_file (buf, "wb"); ! if (fp == NULL) ! error (0, errno, "opening to-server logfile %s", buf); ! else ! buf_to_net = log_buffer_initialize (buf_to_net, fp, 0, ! (BUFMEMERRPROC) NULL); ! ! strcpy (p, ".in"); ! fp = open_file (buf, "wb"); ! if (fp == NULL) ! error (0, errno, "opening from-server logfile %s", buf); ! else ! buf_from_net = log_buffer_initialize (buf_from_net, fp, 1, ! (BUFMEMERRPROC) NULL); ! ! xfree (buf); ! } ! ! stdout_buf = cvs_protocol_wrap_buffer_initialize(buf_to_net, 'M'); ! stderr_buf = cvs_protocol_wrap_buffer_initialize(buf_to_net, 'E'); ! ! TRACE(99,"Server start stuff"); ! /* OK, now figure out where we stash our temporary files. */ ! { ! char *p; ! ! /* The code which wants to chdir into server_temp_dir is not set ! up to deal with it being a relative path. So give an error ! for that case. */ ! if (!isabsolute (Tmpdir)) ! { ! error(1,0,"Value of %s for TMPDIR is not absolute", Tmpdir); ! } ! else ! { ! int status; ! int i = 0; ! ! server_temp_dir = (char*)xmalloc (strlen (Tmpdir) + 256); ! if (server_temp_dir == NULL) ! { ! error(1,ENOMEM,"Fatal server error, aborting."); ! } ! strcpy (server_temp_dir, Tmpdir); ! ! /* Remove a trailing slash from TMPDIR if present. */ ! p = server_temp_dir + strlen (server_temp_dir) - 1; ! if (*p == '/') ! *p = '\0'; ! ! /* ! * I wanted to use cvs-serv/PID, but then you have to worry about ! * the permissions on the cvs-serv directory being right. So ! * use cvs-servPID. ! */ ! strcat (server_temp_dir, "/cvs-serv"); ! ! p = server_temp_dir + strlen (server_temp_dir); ! sprintf (p, "%ld", (long) getpid ()); ! ! orig_server_temp_dir = server_temp_dir; ! ! TRACE(3,"Server temp dir is %s",server_temp_dir); ! ! /* Create the temporary directory, and set the mode to ! 700, to discourage random people from tampering with ! it. */ ! /* mkdir_p is a bad idea here as an incorrect server_temp_dir ! could put a directory pretty much anywhere in error.. eg. trying ! to create c:\windows\temp on Windows 7 for example. */ ! while ((status = mkdir_p(server_temp_dir, 0777)) == EEXIST) // Was mkdir_p ! { ! static const char suffix[] = "abcdefghijklmnopqrstuvwxyz"; ! ! if (i >= sizeof suffix - 1) break; ! if (i == 0) p = server_temp_dir + strlen (server_temp_dir); ! p[0] = suffix[i++]; ! p[1] = '\0'; ! } ! if (status != 0) ! { ! error(1,errno,"can't create temporary directory %s",server_temp_dir); ! } ! #ifndef CHMOD_BROKEN ! else if (chmod (server_temp_dir, S_IRWXU) < 0) ! { ! error(1,errno,"cannot change permissions on temporary directory %s", ! fn_root(server_temp_dir)); ! } ! #endif ! else if (CVS_CHDIR (server_temp_dir) < 0) ! { ! error(1,errno,"cannot change to temporary directory %s", ! fn_root(server_temp_dir)); ! } ! #ifdef _WIN32 ! if(!filenames_case_insensitive) ! add_to_ci_directory_list(server_temp_dir); ! #endif ! } ! } ! ! TRACE(99,"Server register for signals"); ! #ifdef SIGABRT ! (void) SIG_register (SIGABRT, server_cleanup); ! #endif ! #ifdef SIGHUP ! (void) SIG_register (SIGHUP, server_cleanup); ! #endif ! #ifdef SIGINT ! (void) SIG_register (SIGINT, server_cleanup); ! #endif ! #ifdef SIGQUIT ! (void) SIG_register (SIGQUIT, server_cleanup); ! #endif ! #ifdef SIGPIPE ! (void) SIG_register (SIGPIPE, server_cleanup); ! #endif ! #ifdef SIGTERM ! (void) SIG_register (SIGTERM, server_cleanup); ! #endif ! ! /* Now initialize our argument vector (for arguments from the client). */ ! ! /* Small for testing. */ ! argument_vector_size = 1; ! argument_vector = ! (char **) xmalloc (argument_vector_size * sizeof (char *)); ! if (argument_vector == NULL) ! { ! /* ! * Strictly speaking, we're not supposed to output anything ! * now. But we're about to exit(), give it a try. ! */ ! TRACE(99,"Fatal server error, aborting. error ENOMEM Virtual memory exhausted."); ! printf ("E Fatal server error, aborting.\nerror ENOMEM Virtual memory exhausted.\n"); ! ! /* I'm doing this manually rather than via error_exit () ! because I'm not sure whether we want to call server_cleanup. ! Needs more investigation.... */ ! ! #ifdef SYSTEM_CLEANUP ! /* Hook for OS-specific behavior, for example socket subsystems on ! NT and OS2 or dealing with windows and arguments on Mac. */ ! SYSTEM_CLEANUP (); ! #endif ! if(current_username) ! xfree(current_username); ! ! CCvsgui::Close(EXIT_FAILURE); ! exit (EXIT_FAILURE); ! } ! ! argument_count = 1; ! /* This gets printed if the client supports an option which the ! server doesn't, causing the server to print a usage message. ! FIXME: probably should be using program_name here. ! FIXME: just a nit, I suppose, but the usage message the server ! prints isn't literally true--it suggests "cvs server" followed ! by options which are for a particular command. Might be nice to ! say something like "client apparently supports an option not supported ! by this server" or something like that instead of usage message. */ ! argument_vector[0] = "cvs server"; ! std::vector servercmnds; ! scmdmtype servercmd_mode; ! servercmd_mode = scmdmNormal; ! servercmnds.clear(); ! ! int times_through=0; ! while (1) ! { ! char *cmd, *orig_cmd; ! int status; ! int servercmd_arg, servercmd_dir, servercmd_sticky, servercmd_entry, servercmd_entryx; ! int servercmd_export, servercmd_rdiff, servercmd_log, servercmd_rlog, servercmd_diff, servercmd_update, servercmd_co; ! times_through++; ! ! ! TRACE(99,"server: read a 'server line' from client - line %d.",times_through); ! cmd=NULL; ! status = server_read_line (buf_from_net, &cmd, (int *) NULL); ! if (status == -2) ! { ! buf_output0 (buf_to_net, "E Fatal server error, aborting.\n\ ! error ENOMEM Virtual memory exhausted.\n"); ! break; ! } ! TRACE(99,"server: read line status = %d cmd = '%s'.",status,(status==0)?PATCH_NULL(cmd):"bad status"); ! if (status != 0) ! break; ! if(!*cmd) ! continue; ! ! orig_cmd = cmd; ! ! // what I really need to do is 'bundle' all these requests together ! // until I have a verb so I can decide what to do with the arguments ! // ! // Argument -d ! // Argument -P ! // Argument -I ! // Argument ! . .. core RCSLOG tags TAGS RCS SCCS .make.state .nse_depinfo #* .#* cvslog.* ,* CVS CVS.adm .del-* *.a *.olb *.o *.obj *.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe *.dll *.pdb *.lib *.ncb *.ilk *.exp *.suo .DS_Store _$* *$ *.lo *.pch *.idb *.class ~* ! // Argument -W ! // Argument *.Z -k 'b' ! // Argument -u ! // Argument -- ! // Directory . ! // /cvs/cvsnt ! // Sticky TCVSNT_BRANCH_2_5_03_2382:1.1.4.1 ! // Entry /version.h/1.1.2.5/Wed Nov 16 23:52:57 2011//TCVSNT_BRANCH_2_5_03_2382 ! // EntryExtra /version.h/////// ! // Argument version.h ! // update ! // ! if ( (g_force_branch) || ( g_anon_force_branch && g_is_anonymous ) ) ! { ! servercmd_arg=servercmd_dir=servercmd_sticky=servercmd_entry=servercmd_entryx=-1; ! servercmd_export=servercmd_rdiff=servercmd_rlog=servercmd_log=servercmd_diff=servercmd_update=servercmd_co=0; ! if ( ((servercmd_arg=strncmp(cmd,"Argument",8))==0) || ! ( ((servercmd_dir=strncmp(cmd,"Directory",9))==0) && ((cmd[9]==' ')||(cmd[9]=='\0')) ) || ! ((servercmd_sticky=strncmp(cmd,"Sticky",6))==0) || ! ( ((servercmd_entry=strncmp(cmd,"Entry",5))==0) && ((cmd[5]==' ')||(cmd[5]=='\0')) ) || ! ((servercmd_entryx=strncmp(cmd,"EntryExtra",10))==0) ) ! { ! TRACE(99,"Push back command=\"%s\".",cmd); ! servercmd_mode = scmdmPushStore; ! servercmnds.push_back(cmd); ! if ((servercmd_dir==0)&& ((cmd[9]==' ')||(cmd[9]=='\0'))) ! { ! int servercmd_dir_status; ! char *servercmd_dir_repos; ! ! servercmd_dir_status = server_read_line (buf_from_net, &servercmd_dir_repos, (int *) NULL); ! TRACE(99,"Push back supplementary command=\"%s\".",cmd); ! servercmnds.push_back(servercmd_dir_repos); ! } ! //TRACE(99,"Push --- flush buffers %s%s",(stderr_buf)?"stderr ":"",(stdout_buf)?"stdout ":""); ! //buf_send_output(stderr_buf); ! //buf_send_output(stdout_buf); ! } ! else ! if ( ((servercmd_export=strncmp(cmd,"export",6))==0) || ! ((servercmd_rdiff=strncmp(cmd,"rdiff",5))==0) || ! ((servercmd_log=strncmp(cmd,"log",3))==0) || ! ((servercmd_rlog=strncmp(cmd,"rlog",4))==0) || ! ((servercmd_diff=strncmp(cmd,"diff",4))==0) || ! ((servercmd_update=strncmp(cmd,"update",6))==0) || ! ((servercmd_co=strncmp(cmd,"co",2))==0) ) { ! ! ! int servercmd_delete; ! int servercmd_insert; ! bool servercmd_branch; ! /* now we traverse the stored commands looking for this we may need to 'fix' */ ! servercmd_delete=-1; ! servercmd_insert=-1; ! servercmd_branch=false; ! for (int scmdj = 0; scmdj < servercmnds.size(); scmdj++) ! { ! TRACE(99,"inspect command=\"%s\".",servercmnds[scmdj].c_str()); ! if (strncmp(servercmnds[scmdj].c_str(),"Sticky",6)==0) ! { ! cvs::string branchtest, tagtest; ! cvs::string stickyfix; ! TRACE(99,"inspect sticky command=\"%s\".",servercmnds[scmdj].c_str()); ! ! cvs::sprintf(tagtest, 256, "Sticky N%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! cvs::sprintf(branchtest, 256, "Sticky T%s:",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! if ( (tagtest.compare(servercmnds[scmdj].c_str()) != 0) && ! (branchtest.compare(servercmnds[scmdj].c_str()) != 0) ) ! { ! // need to ignore this or replace it with what we'd prefer... ! TRACE(99,"inspected sticky command=\"%s\" must be deleted or replaced.",servercmnds[scmdj].c_str()); ! //servercmd_delete=scmdj; ! servercmd_branch=true; ! cvs::sprintf(stickyfix, 256, "Sticky N%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! TRACE(99,"replacing sticky with \"%s\".",stickyfix.c_str()); ! servercmnds[scmdj]=stickyfix.c_str(); ! } ! } ! else ! if (strncmp(servercmnds[scmdj].c_str(),"Argument",8)==0) ! { ! cvs::string argumentfix; ! if (strstr(servercmnds[scmdj].c_str(),"-r:")!=NULL) { ! TRACE(99,"Here is =\"%s\" but we really want to set argument -r %s:%s.",servercmnds[scmdj].c_str(),( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch,( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! cvs::sprintf(argumentfix, 256, "Argument -r%s:%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch,( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! servercmnds[scmdj]=argumentfix.c_str(); ! servercmd_branch=true; ! } ! else ! if ( (strstr(servercmnds[scmdj].c_str(),"-r")!=NULL) && ((servercmd_export==0||servercmd_co==0)) ) { ! TRACE(99,"Here is =\"%s\" [co] (%s) but we really want to set argument %s.",servercmnds[scmdj].c_str(),servercmnds[scmdj+1].c_str(),( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! cvs::sprintf(argumentfix, 256, "Argument %s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! servercmnds[scmdj+1]=argumentfix.c_str(); ! servercmd_branch=true; ! } ! else ! if (strstr(servercmnds[scmdj].c_str(),"-r")!=NULL) { ! TRACE(99,"Here is [non co] =\"%s\" (%s) but we really want to set argument %s.",servercmnds[scmdj].c_str(),servercmnds[scmdj+2].c_str(),( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! cvs::sprintf(argumentfix, 256, "Argument %s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! servercmnds[scmdj+2]=argumentfix.c_str(); ! servercmd_branch=true; ! } ! else ! if ( ((strstr(servercmnds[scmdj].c_str(),"-D")!=NULL) && (servercmd_co==0||servercmd_diff==0||servercmd_rdiff==0||servercmd_export==0||servercmd_update==0)) ! || ((strstr(servercmnds[scmdj].c_str(),"-d")!=NULL) && (servercmd_log==0||servercmd_rlog==0)) ) { ! TRACE(99,"Here is date \"%s\" but we really want to set argument -r %s:%s.",servercmnds[scmdj].c_str(),( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch,( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! cvs::sprintf(argumentfix, 256, "Argument -r%s:%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch,( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! servercmnds[scmdj]=argumentfix.c_str(); ! servercmd_branch=true; ! } ! else ! if (servercmd_insert==-1) servercmd_insert=scmdj; ! } ! } ! if (servercmd_delete!=-1) ! { ! TRACE(99,"Delete playback item %d, \"%s\".",servercmd_delete,servercmnds[servercmd_delete].c_str()); ! servercmnds.erase(servercmnds.begin()+servercmd_delete); ! } ! if (!servercmd_branch) ! { ! if (servercmd_insert==-1) ! servercmd_insert=servercmnds.size()-1; ! ! cvs::string argumentinsert; ! TRACE(99,"Insert playback item %d, \"%s\".",servercmd_insert,(servercmd_update==0)?"Sticky":"Argument -r"); ! if (servercmd_update==0) ! cvs::sprintf(argumentinsert, 256, "Sticky N%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! else ! if (servercmd_export==0||servercmd_co==0) ! { ! cvs::sprintf(argumentinsert, 256, "Argument %s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! TRACE(99,"Insert \"%s\".",argumentinsert.c_str()); ! servercmnds.insert(servercmnds.begin()+servercmd_insert,argumentinsert.c_str()); ! cvs::sprintf(argumentinsert, 256, "Argument -r"); ! } ! else ! cvs::sprintf(argumentinsert, 256, "Argument -r%s:%s",( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch,( g_anon_force_branch && g_is_anonymous )?g_anon_force_branch:g_force_branch); ! TRACE(99,"Insert \"%s\".",argumentinsert.c_str()); ! servercmnds.insert(servercmnds.begin()+servercmd_insert,argumentinsert.c_str()); ! } ! servercmd_mode = scmdmReplay; ! } ! else ! // So things like this would be just 'passed': ! // ! // Valid-responses ! // valid-requests ! // UseUnchanged ! // Root /cvs ! // server-codepage ! // client-version ! // Valid-RcsOptions ! // read-cvsignore ! // read-cvswrappers ! // read-cvsrc2 ! // ! servercmd_mode = scmdmReplay; ! ! if (servercmd_mode == scmdmReplay) ! { ! /* now we unravel the stored commands */ ! TRACE(99,"Playback %lu verbs.",(unsigned long)servercmnds.size()); ! for (int scmdi = 0; scmdi < servercmnds.size(); scmdi++) ! { ! cmd=xstrdup(servercmnds[scmdi].c_str()); ! if ( ((strncmp(cmd,"Directory",9))==0) && ((cmd[9]==' ')||(cmd[9]=='\0')) ) ! { ! char *repos=xstrdup(servercmnds[++scmdi].c_str()); ! char *cmdarg= (*(cmd+9)=='\0')?(cmd+9):(cmd+10); ! TRACE(99,"play Directory %s and supplementary=\"%s\".",cmdarg,repos); ! serve_directory_repos (cmdarg, repos, 0); ! } ! else ! { ! TRACE(99,"play command=\"%s\".",cmd); ! servergo(cmd); ! } ! } ! servercmnds.clear(); ! servercmd_mode = scmdmNormal; ! cmd=orig_cmd; ! } ! } ! if (servercmd_mode == scmdmNormal) ! { ! TRACE(99,"process in realtime command=\"%s\".",cmd); ! servergo(cmd); ! } ! ! xfree (orig_cmd); ! } ! ! // An edit might have left the client connection open, in which case ! // close it here ! if(proxy_active && server_started) ! cleanup_and_close_server(); TRACE(3,"server finishing, call server_cleanup()"); server_cleanup (0); *************** *** 6377,6383 **** CVS_Username = xstrdup(username); #endif #endif ! #if HAVE_PUTENV /* Set LOGNAME, USER and CVS_USER in the environment, in case they are already set to something else. */ --- 6610,6621 ---- CVS_Username = xstrdup(username); #endif #endif ! g_is_anonymous=0; ! if ((CVS_Username != NULL) && (g_anonymous_user != NULL)) ! if ((*CVS_Username != '\0') && (*g_anonymous_user != '\0')) ! if (strcmp(CVS_Username, g_anonymous_user)==0) ! g_is_anonymous=1; ! #if HAVE_PUTENV /* Set LOGNAME, USER and CVS_USER in the environment, in case they are already set to something else. */ *************** *** 6442,6447 **** --- 6680,6691 ---- /* Make sure our CVS_Username has been set. */ if (CVS_Username == NULL) CVS_Username = xstrdup(username); + + g_is_anonymous=0; + if ((CVS_Username != NULL) && (g_anonymous_user != NULL)) + if ((*CVS_Username != '\0') && (*g_anonymous_user != '\0')) + if (strcmp(CVS_Username, g_anonymous_user)==0) + g_is_anonymous=1; #endif #ifdef HAVE_PUTENV *************** *** 6885,6890 **** --- 7129,7139 ---- /* Set CVS_Username here, in allocated space. It might or might not be the same as host_user. */ CVS_Username = xstrdup(username); + g_is_anonymous=0; + if ((CVS_Username != NULL) && (g_anonymous_user != NULL)) + if ((*CVS_Username != '\0') && (*g_anonymous_user != '\0')) + if (strcmp(CVS_Username, g_anonymous_user)==0) + g_is_anonymous=1; } return host_user; *************** *** 7087,7092 **** --- 7336,7346 ---- else CVS_Username = xstrdup(getcaller()); TRACE(4,"Set CVS Username to \"%s\"",PATCH_NULL(CVS_Username)); + g_is_anonymous=0; + if ((CVS_Username != NULL) && (g_anonymous_user != NULL)) + if ((*CVS_Username != '\0') && (*g_anonymous_user != '\0')) + if (strcmp(CVS_Username, g_anonymous_user)==0) + g_is_anonymous=1; } else TRACE(4,"Has CVS Username"); *************** *** 7172,7177 **** --- 7426,7436 ---- } CVS_Username = xstrdup((const char *)&buf[1]); + g_is_anonymous=0; + if ((CVS_Username != NULL) && (g_anonymous_user != NULL)) + if ((*CVS_Username != '\0') && (*g_anonymous_user != '\0')) + if (strcmp(CVS_Username, g_anonymous_user)==0) + g_is_anonymous=1; xfree(buf);