cvs.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. Index: src/server.c
  2. ===================================================================
  3. RCS file: /cvs/ccvs/src/server.c,v
  4. diff -u -d -r1.275 -r1.277
  5. --- src/server.c 18 Jun 2002 13:35:28 -0000 1.275
  6. +++ src/server.c 14 Aug 2002 13:21:55 -0000 1.277
  7. @@ -5010,6 +5010,8 @@
  8. int argc;
  9. char **argv;
  10. {
  11. + char *error_prog_name; /* Used in error messages */
  12. +
  13. if (argc == -1)
  14. {
  15. static const char *const msg[] =
  16. @@ -5165,39 +5167,18 @@
  17. /* Small for testing. */
  18. argument_vector_size = 1;
  19. argument_vector =
  20. - (char **) malloc (argument_vector_size * sizeof (char *));
  21. - if (argument_vector == NULL)
  22. - {
  23. - /*
  24. - * Strictly speaking, we're not supposed to output anything
  25. - * now. But we're about to exit(), give it a try.
  26. - */
  27. - printf ("E Fatal server error, aborting.\n\
  28. -error ENOMEM Virtual memory exhausted.\n");
  29. -
  30. - /* I'm doing this manually rather than via error_exit ()
  31. - because I'm not sure whether we want to call server_cleanup.
  32. - Needs more investigation.... */
  33. -
  34. -#ifdef SYSTEM_CLEANUP
  35. - /* Hook for OS-specific behavior, for example socket subsystems on
  36. - NT and OS2 or dealing with windows and arguments on Mac. */
  37. - SYSTEM_CLEANUP ();
  38. -#endif
  39. -
  40. - exit (EXIT_FAILURE);
  41. - }
  42. -
  43. + (char **) xmalloc (argument_vector_size * sizeof (char *));
  44. argument_count = 1;
  45. /* This gets printed if the client supports an option which the
  46. server doesn't, causing the server to print a usage message.
  47. - FIXME: probably should be using program_name here.
  48. FIXME: just a nit, I suppose, but the usage message the server
  49. prints isn't literally true--it suggests "cvs server" followed
  50. by options which are for a particular command. Might be nice to
  51. say something like "client apparently supports an option not supported
  52. by this server" or something like that instead of usage message. */
  53. - argument_vector[0] = "cvs server";
  54. + error_prog_name = xmalloc( strlen(program_name) + 8 );
  55. + sprintf(error_prog_name, "%s server", program_name);
  56. + argument_vector[0] = error_prog_name;
  57. while (1)
  58. {
  59. @@ -5270,6 +5251,7 @@
  60. }
  61. free (orig_cmd);
  62. }
  63. + free(error_prog_name);
  64. server_cleanup (0);
  65. return 0;
  66. }
  67. @@ -5419,8 +5401,8 @@
  68. int found_it = 0;
  69. int namelen;
  70. - /* We don't use current_parsed_root->directory because it hasn't been set yet
  71. - * -- our `repository' argument came from the authentication
  72. + /* We don't use current_parsed_root->directory because it hasn't been
  73. + * set yet -- our `repository' argument came from the authentication
  74. * protocol, not the regular CVS protocol.
  75. */
  76. @@ -5578,7 +5560,7 @@
  77. {
  78. /* No cvs password found, so try /etc/passwd. */
  79. - const char *found_passwd = NULL;
  80. + char *found_passwd = NULL;
  81. struct passwd *pw;
  82. #ifdef HAVE_GETSPNAM
  83. struct spwd *spw;
  84. Index: src/server.c
  85. ===================================================================
  86. RCS file: /cvs/ccvs/src/server.c,v
  87. diff -u -d -r1.279 -r1.280
  88. --- src/server.c 16 Sep 2002 14:56:25 -0000 1.279
  89. +++ src/server.c 4 Oct 2002 19:56:01 -0000 1.280
  90. @@ -3213,10 +3213,13 @@
  91. buf_flush (buf_to_net, 1);
  92. buf_shutdown (protocol_inbuf);
  93. buf_free (protocol_inbuf);
  94. + protocol_inbuf = NULL;
  95. buf_shutdown (stderrbuf);
  96. buf_free (stderrbuf);
  97. + stderrbuf = NULL;
  98. buf_shutdown (stdoutbuf);
  99. buf_free (stdoutbuf);
  100. + stdoutbuf = NULL;
  101. }
  102. if (errs)
  103. @@ -4891,9 +4894,9 @@
  104. status = buf_shutdown (buf_from_net);
  105. if (status != 0)
  106. - {
  107. error (0, status, "shutting down buffer from client");
  108. - }
  109. + buf_free (buf_from_net);
  110. + buf_from_net = NULL;
  111. }
  112. if (dont_delete_temp)
  113. @@ -4902,6 +4905,9 @@
  114. {
  115. (void) buf_flush (buf_to_net, 1);
  116. (void) buf_shutdown (buf_to_net);
  117. + buf_free (buf_to_net);
  118. + buf_to_net = NULL;
  119. + error_use_protocol = 0;
  120. }
  121. return;
  122. }
  123. @@ -5003,6 +5009,9 @@
  124. {
  125. (void) buf_flush (buf_to_net, 1);
  126. (void) buf_shutdown (buf_to_net);
  127. + buf_free (buf_to_net);
  128. + buf_to_net = NULL;
  129. + error_use_protocol = 0;
  130. }
  131. }
  132. @@ -5146,25 +5155,6 @@
  133. }
  134. }
  135. -#ifdef SIGABRT
  136. - (void) SIG_register (SIGABRT, server_cleanup);
  137. -#endif
  138. -#ifdef SIGHUP
  139. - (void) SIG_register (SIGHUP, server_cleanup);
  140. -#endif
  141. -#ifdef SIGINT
  142. - (void) SIG_register (SIGINT, server_cleanup);
  143. -#endif
  144. -#ifdef SIGQUIT
  145. - (void) SIG_register (SIGQUIT, server_cleanup);
  146. -#endif
  147. -#ifdef SIGPIPE
  148. - (void) SIG_register (SIGPIPE, server_cleanup);
  149. -#endif
  150. -#ifdef SIGTERM
  151. - (void) SIG_register (SIGTERM, server_cleanup);
  152. -#endif
  153. -
  154. /* Now initialize our argument vector (for arguments from the client). */
  155. /* Small for testing. */
  156. @@ -6352,12 +6342,12 @@
  157. if (len == 0)
  158. len = strlen (str);
  159. #ifdef SERVER_SUPPORT
  160. - if (error_use_protocol)
  161. + if (error_use_protocol && buf_to_net != NULL)
  162. {
  163. buf_output (saved_output, str, len);
  164. buf_copy_lines (buf_to_net, saved_output, 'M');
  165. }
  166. - else if (server_active)
  167. + else if (server_active && protocol != NULL)
  168. {
  169. buf_output (saved_output, str, len);
  170. buf_copy_lines (protocol, saved_output, 'M');
  171. Index: src/server.c
  172. ===================================================================
  173. RCS file: /cvs/ccvs/src/server.c,v
  174. diff -u -d -r1.280 -r1.281
  175. --- src/server.c 4 Oct 2002 19:56:01 -0000 1.280
  176. +++ src/server.c 25 Oct 2002 19:35:07 -0000 1.281
  177. @@ -710,17 +710,7 @@
  178. cause deadlock, as noted in server_cleanup. */
  179. buf_flush (buf_to_net, 1);
  180. - /* I'm doing this manually rather than via error_exit ()
  181. - because I'm not sure whether we want to call server_cleanup.
  182. - Needs more investigation.... */
  183. -
  184. -#ifdef SYSTEM_CLEANUP
  185. - /* Hook for OS-specific behavior, for example socket subsystems on
  186. - NT and OS2 or dealing with windows and arguments on Mac. */
  187. - SYSTEM_CLEANUP ();
  188. -#endif
  189. -
  190. - exit (EXIT_FAILURE);
  191. + error_exit ();
  192. }
  193. else if (rs->status == rs_optional)
  194. rs->status = rs_not_supported;
  195. @@ -5080,18 +5070,7 @@
  196. printf ("E Fatal server error, aborting.\n\
  197. error ENOMEM Virtual memory exhausted.\n");
  198. - /* I'm doing this manually rather than via error_exit ()
  199. - because I'm not sure whether we want to call server_cleanup.
  200. - Needs more investigation.... */
  201. -
  202. -#ifdef SYSTEM_CLEANUP
  203. - /* Hook for OS-specific behavior, for example socket
  204. - subsystems on NT and OS2 or dealing with windows
  205. - and arguments on Mac. */
  206. - SYSTEM_CLEANUP ();
  207. -#endif
  208. -
  209. - exit (EXIT_FAILURE);
  210. + error_exit ();
  211. }
  212. strcpy (server_temp_dir, Tmpdir);
  213. @@ -5575,17 +5554,7 @@
  214. printf ("E Fatal error, aborting.\n\
  215. error 0 %s: no such user\n", username);
  216. - /* I'm doing this manually rather than via error_exit ()
  217. - because I'm not sure whether we want to call server_cleanup.
  218. - Needs more investigation.... */
  219. -
  220. -#ifdef SYSTEM_CLEANUP
  221. - /* Hook for OS-specific behavior, for example socket subsystems on
  222. - NT and OS2 or dealing with windows and arguments on Mac. */
  223. - SYSTEM_CLEANUP ();
  224. -#endif
  225. -
  226. - exit (EXIT_FAILURE);
  227. + error_exit ();
  228. }
  229. /* Allow for dain bramaged HPUX passwd aging
  230. @@ -5635,16 +5604,7 @@
  231. outweighs this. */
  232. printf ("error 0 no such user %s in CVSROOT/passwd\n", username);
  233. - /* I'm doing this manually rather than via error_exit ()
  234. - because I'm not sure whether we want to call server_cleanup.
  235. - Needs more investigation.... */
  236. -
  237. -#ifdef SYSTEM_CLEANUP
  238. - /* Hook for OS-specific behavior, for example socket subsystems on
  239. - NT and OS2 or dealing with windows and arguments on Mac. */
  240. - SYSTEM_CLEANUP ();
  241. -#endif
  242. - exit (EXIT_FAILURE);
  243. + error_exit ();
  244. }
  245. else
  246. {
  247. @@ -5901,12 +5861,8 @@
  248. {
  249. printf ("E Fatal error, aborting.\n\
  250. error %s getpeername or getsockname failed\n", strerror (errno));
  251. -#ifdef SYSTEM_CLEANUP
  252. - /* Hook for OS-specific behavior, for example socket subsystems on
  253. - NT and OS2 or dealing with windows and arguments on Mac. */
  254. - SYSTEM_CLEANUP ();
  255. -#endif
  256. - exit (EXIT_FAILURE);
  257. +
  258. + error_exit ();
  259. }
  260. #ifdef SO_KEEPALIVE
  261. @@ -5932,12 +5888,8 @@
  262. {
  263. printf ("E Fatal error, aborting.\n\
  264. error 0 kerberos: %s\n", krb_get_err_text(status));
  265. -#ifdef SYSTEM_CLEANUP
  266. - /* Hook for OS-specific behavior, for example socket subsystems on
  267. - NT and OS2 or dealing with windows and arguments on Mac. */
  268. - SYSTEM_CLEANUP ();
  269. -#endif
  270. - exit (EXIT_FAILURE);
  271. +
  272. + error_exit ();
  273. }
  274. memcpy (kblock, auth.session, sizeof (C_Block));
  275. @@ -5948,12 +5900,8 @@
  276. {
  277. printf ("E Fatal error, aborting.\n\
  278. error 0 kerberos: can't get local name: %s\n", krb_get_err_text(status));
  279. -#ifdef SYSTEM_CLEANUP
  280. - /* Hook for OS-specific behavior, for example socket subsystems on
  281. - NT and OS2 or dealing with windows and arguments on Mac. */
  282. - SYSTEM_CLEANUP ();
  283. -#endif
  284. - exit (EXIT_FAILURE);
  285. +
  286. + error_exit ();
  287. }
  288. /* Switch to run as this user. */
  289. Index: src/buffer.c
  290. ===================================================================
  291. RCS file: /cvs/ccvs/src/buffer.c,v
  292. diff -u -d -r1.19 -r1.20
  293. --- src/buffer.c 20 May 2002 18:27:55 -0000 1.19
  294. +++ src/buffer.c 24 Oct 2002 19:54:58 -0000 1.20
  295. @@ -1392,8 +1392,7 @@
  296. if (buf->input)
  297. {
  298. - if (! buf_empty_p (buf)
  299. - || getc (bc->fp) != EOF)
  300. + if ( !buf_empty_p (buf) )
  301. {
  302. # ifdef SERVER_SUPPORT
  303. if (server_active)