PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/backup/builder.in.sv.gnu.org/usr/src/patched/cvs-patches/cvs-allow-root-regexp.patch

#
Patch | 359 lines | 342 code | 17 blank | 0 comment | 0 complexity | 31547e6baa432906ba1c75160bd3f428 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. Index: ChangeLog
  2. ===================================================================
  3. RCS file: /cvsroot/cvs/ccvs/ChangeLog,v
  4. retrieving revision 1.1348
  5. retrieving revision 1.1349
  6. diff -u -r1.1348 -r1.1349
  7. --- ChangeLog 8 May 2007 12:35:53 -0000 1.1348
  8. +++ ChangeLog 9 May 2007 23:58:28 -0000 1.1349
  9. @@ -1,3 +1,8 @@
  10. +2007-05-09 Derek Price <derek@ximbiot.com>
  11. + and Sylvain Beucler <beuc@beuc.net>
  12. +
  13. + * NEWS: Documented --allow-root-regexp.
  14. +
  15. 2007-05-07 Derek Price <derek@ximbiot.com>
  16. * NEWS: Note removal of remote `cvs init'.
  17. Index: NEWS
  18. ===================================================================
  19. RCS file: /cvsroot/cvs/ccvs/NEWS,v
  20. retrieving revision 1.367
  21. retrieving revision 1.368
  22. diff -u -r1.367 -r1.368
  23. --- NEWS 8 May 2007 12:35:53 -0000 1.367
  24. +++ NEWS 9 May 2007 23:58:28 -0000 1.368
  25. @@ -23,6 +23,9 @@
  26. * When UseNewInfoFmtStrings is enabled, the %{vV} formats will now
  27. expose the real version instead of NONE for removed files.
  28. +* A new command line option, --allow-root-regexp, was added which allows
  29. +acceptable repositories to be specified using a list of regular expressions.
  30. +
  31. BUG FIXES
  32. * The CVS server will no longer allow clients to run `cvs init'.
  33. Index: doc/ChangeLog
  34. ===================================================================
  35. RCS file: /cvsroot/cvs/ccvs/doc/ChangeLog,v
  36. retrieving revision 1.978
  37. retrieving revision 1.979
  38. diff -u -r1.978 -r1.979
  39. --- doc/ChangeLog 8 May 2007 12:35:53 -0000 1.978
  40. +++ doc/ChangeLog 9 May 2007 23:44:25 -0000 1.979
  41. @@ -1,3 +1,8 @@
  42. +2007-05-09 Derek Price <derek@ximbiot.com>
  43. + and Sylvain Beucler <beuc@beuc.net>
  44. +
  45. + * cvs.texinfo: Document --allow-root-regexp.
  46. +
  47. 2007-05-07 Derek Price <derek@ximbiot.com>
  48. * cvsclient.text: Remove references to remote `init' command.
  49. Index: doc/cvs.texinfo
  50. ===================================================================
  51. RCS file: /cvsroot/cvs/ccvs/doc/cvs.texinfo,v
  52. retrieving revision 1.698
  53. retrieving revision 1.699
  54. diff -u -r1.698 -r1.699
  55. --- doc/cvs.texinfo 12 Sep 2006 20:30:25 -0000 1.698
  56. +++ doc/cvs.texinfo 9 May 2007 23:44:25 -0000 1.699
  57. @@ -2604,15 +2604,19 @@
  58. The @samp{--allow-root} option specifies the allowable
  59. @sc{cvsroot} directory. Clients which attempt to use a
  60. different @sc{cvsroot} directory will not be allowed to
  61. -connect. If there is more than one @sc{cvsroot}
  62. -directory which you want to allow, repeat the option.
  63. +connect. To allow a whole class of @sc{cvsroot}, specify
  64. +a regular expression to match allowed directories with the
  65. +@samp{--allow-root-regexp} option. These options may be
  66. +used in conjunction and both options may be repeated to
  67. +allow access to multiple @sc{cvsroot} directories and
  68. +classes of directories.
  69. (Unfortunately, many versions of @code{inetd} have very small
  70. limits on the number of arguments and/or the total length
  71. of the command. The usual solution to this problem is
  72. to have @code{inetd} run a shell script which then invokes
  73. @sc{cvs} with the necessary arguments.)
  74. - If your @code{inetd} wants a symbolic service
  75. +If your @code{inetd} wants a symbolic service
  76. name instead of a raw port number, then put this in
  77. @file{/etc/services}:
  78. @@ -12332,10 +12336,15 @@
  79. @table @code
  80. @item --allow-root=@var{rootdir}
  81. -Specify legal @sc{cvsroot} directory (server only) (not
  82. -in @sc{cvs} 1.9 and older). See @ref{Password
  83. +Specify acceptable @sc{cvsroot} directory (server only).
  84. +Appeared in @sc{cvs} 1.10. See @ref{Password
  85. authentication server}.
  86. +@item --allow-root-regexp=@var{rootdir}
  87. +Specify a regular expression which matches acceptable
  88. +@sc{cvsroot} directories (server only). Appeared in @sc{cvs}
  89. +1.12.14. See @ref{Password authentication server}.
  90. +
  91. @item -a
  92. Authenticate all communication (client only) (not in @sc{cvs}
  93. 1.9 and older). See @ref{Global options}.
  94. @@ -15944,6 +15953,7 @@
  95. specific reason for denying authorization. Check that
  96. the username and password specified are correct and
  97. that the @code{CVSROOT} specified is allowed by @samp{--allow-root}
  98. +or @samp{--allow-root-regexp}
  99. in @file{inetd.conf}. See @ref{Password authenticated}.
  100. @item cvs @var{command}: Bad root @var{directory}
  101. Index: doc/stamp-vti
  102. ===================================================================
  103. RCS file: /cvsroot/cvs/ccvs/doc/stamp-vti,v
  104. retrieving revision 1.200
  105. retrieving revision 1.201
  106. diff -u -r1.200 -r1.201
  107. --- doc/stamp-vti 8 May 2007 12:35:53 -0000 1.200
  108. +++ doc/stamp-vti 9 May 2007 23:44:25 -0000 1.201
  109. @@ -1,4 +1,4 @@
  110. -@set UPDATED 26 October 2006
  111. -@set UPDATED-MONTH October 2006
  112. +@set UPDATED 9 May 2007
  113. +@set UPDATED-MONTH May 2007
  114. @set EDITION 1.12.13.1
  115. @set VERSION 1.12.13.1
  116. Index: doc/version.texi
  117. ===================================================================
  118. RCS file: /cvsroot/cvs/ccvs/doc/version.texi,v
  119. retrieving revision 1.202
  120. retrieving revision 1.203
  121. diff -u -r1.202 -r1.203
  122. --- doc/version.texi 8 May 2007 12:35:53 -0000 1.202
  123. +++ doc/version.texi 9 May 2007 23:44:25 -0000 1.203
  124. @@ -1,4 +1,4 @@
  125. -@set UPDATED 26 October 2006
  126. -@set UPDATED-MONTH October 2006
  127. +@set UPDATED 9 May 2007
  128. +@set UPDATED-MONTH May 2007
  129. @set EDITION 1.12.13.1
  130. @set VERSION 1.12.13.1
  131. Index: src/ChangeLog
  132. ===================================================================
  133. RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
  134. retrieving revision 1.3508
  135. retrieving revision 1.3509
  136. diff -u -r1.3508 -r1.3509
  137. --- src/ChangeLog 8 May 2007 12:35:53 -0000 1.3508
  138. +++ src/ChangeLog 9 May 2007 23:54:33 -0000 1.3509
  139. @@ -1,3 +1,19 @@
  140. +2007-05-09 Derek Price <derek@ximbiot.com>
  141. + for Sylvain Beucler <beuc@beuc.net>
  142. +
  143. + * main.c (main): Use new root_allow_regexp_add function, declare
  144. + new --allow-root-regexp option parameter.
  145. + * root.c: Added new functions root_allow_regexp_add and
  146. + root_allow_compare_regexp, new variables
  147. + root_allow_regexp. Modified root_allow_ok, root_allow_used and
  148. + root_allow_free. The code adds the matched repository path to
  149. + root_allow as if specified using --allow-root. --allow-root is not
  150. + mandatory anymore if --allow-root-regexp is used instead.
  151. + (Original 2001/2004 patches from Roland Mas <lolando@debian.org>.)
  152. +
  153. + * sanity.sh: Added test cases as pserver-3b and pserver-3c,
  154. + updated pserver-3.
  155. +
  156. 2007-05-07 Derek Price <derek@ximbiot.com>
  157. * mkmodules.c (init): Assert that the server is not active.
  158. Index: src/main.c
  159. ===================================================================
  160. RCS file: /cvsroot/cvs/ccvs/src/main.c,v
  161. retrieving revision 1.268
  162. retrieving revision 1.269
  163. diff -u -r1.268 -r1.269
  164. --- src/main.c 17 May 2006 15:24:30 -0000 1.268
  165. +++ src/main.c 9 May 2007 23:54:33 -0000 1.269
  166. @@ -576,6 +576,7 @@
  167. {"verify-arg", required_argument, NULL, 12},
  168. #ifdef SERVER_SUPPORT
  169. {"allow-root", required_argument, NULL, 3},
  170. + {"allow-root-regexp", required_argument, NULL, 14},
  171. {"timeout", required_argument, NULL, 13},
  172. #endif /* SERVER_SUPPORT */
  173. {0, 0, 0, 0}
  174. @@ -823,6 +824,10 @@
  175. /* --allow-root */
  176. root_allow_add (optarg, gConfigPath);
  177. break;
  178. + case 14:
  179. + /* --allow-root-regexp */
  180. + root_allow_regexp_add (optarg, gConfigPath);
  181. + break;
  182. case 13:
  183. /* --timeout */
  184. connection_timeout = strtol (optarg, &end, 10);
  185. Index: src/root.c
  186. ===================================================================
  187. RCS file: /cvsroot/cvs/ccvs/src/root.c,v
  188. retrieving revision 1.125
  189. retrieving revision 1.126
  190. diff -u -r1.125 -r1.126
  191. --- src/root.c 24 Apr 2006 18:50:27 -0000 1.125
  192. +++ src/root.c 9 May 2007 23:54:33 -0000 1.126
  193. @@ -285,6 +285,7 @@
  194. directories. Then we can check against them when a remote user
  195. hands us a CVSROOT directory. */
  196. static List *root_allow;
  197. +static List *root_allow_regexp;
  198. static void
  199. delconfig (Node *n)
  200. @@ -308,21 +309,65 @@
  201. }
  202. void
  203. +root_allow_regexp_add (const char *arg, const char *configPath)
  204. +{
  205. + Node *n;
  206. +
  207. + if (!root_allow_regexp) root_allow_regexp = getlist();
  208. + n = getnode();
  209. + n->key = xstrdup (arg);
  210. +
  211. + /* This is a regexp, not the final cvsroot path - we cannot attach
  212. + it a config. So we attach configPath and we'll root_allow_add()
  213. + the actual, matching root in root_allow_compare_regexp() */
  214. + n->data = (void*)configPath;
  215. +
  216. + addnode (root_allow_regexp, n);
  217. +}
  218. +
  219. +void
  220. root_allow_free (void)
  221. {
  222. dellist (&root_allow);
  223. + dellist (&root_allow_regexp);
  224. }
  225. bool
  226. root_allow_used (void)
  227. {
  228. - return root_allow != NULL;
  229. + return root_allow || root_allow_regexp;
  230. +}
  231. +
  232. +/* walklist() callback for determining if 'root_to_check' matches
  233. + n->key (a regexp). If yes, 'root_to_check' will be added as if
  234. + directly specified through --allow-root.
  235. + */
  236. +static int
  237. +root_allow_compare_regexp (Node *n, void *root_to_check)
  238. +{
  239. + int status;
  240. + regex_t re;
  241. +
  242. + if (regcomp(&re, n->key,
  243. + REG_EXTENDED|REG_NOSUB) != 0)
  244. + {
  245. + return 0; /* report error? */
  246. + }
  247. + status = regexec(&re, root_to_check, (size_t) 0, NULL, 0);
  248. + regfree(&re);
  249. + if (status == 0)
  250. + {
  251. + /* n->data contains gConfigPath */
  252. + root_allow_add (root_to_check, n->data);
  253. + return 1;
  254. + }
  255. + return 0;
  256. }
  257. bool
  258. root_allow_ok (const char *arg)
  259. {
  260. - if (!root_allow)
  261. + if (!root_allow_used())
  262. {
  263. /* Probably someone upgraded from CVS before 1.9.10 to 1.9.10
  264. or later without reading the documentation about
  265. @@ -334,12 +379,18 @@
  266. back "error" rather than waiting for the next request which
  267. expects responses. */
  268. printf ("\
  269. -error 0 Server configuration missing --allow-root in inetd.conf\n");
  270. +error 0 Server configuration missing --allow-root or --allow-root-regexp in inetd.conf\n");
  271. exit (EXIT_FAILURE);
  272. }
  273. + /* Look for 'arg' in the list of full-path allowed roots */
  274. if (findnode (root_allow, arg))
  275. return true;
  276. +
  277. + /* Match 'arg' against the list of allowed roots regexps */
  278. + if (walklist (root_allow_regexp, root_allow_compare_regexp, (void*)arg))
  279. + return true;
  280. +
  281. return false;
  282. }
  283. Index: src/root.h
  284. ===================================================================
  285. RCS file: /cvsroot/cvs/ccvs/src/root.h,v
  286. retrieving revision 1.24
  287. retrieving revision 1.25
  288. diff -u -r1.24 -r1.25
  289. --- src/root.h 24 Apr 2006 18:50:27 -0000 1.24
  290. +++ src/root.h 9 May 2007 23:54:33 -0000 1.25
  291. @@ -89,6 +89,7 @@
  292. __attribute__ ((__malloc__));
  293. void Create_Root (const char *dir, const char *rootdir);
  294. void root_allow_add (const char *, const char *configPath);
  295. +void root_allow_regexp_add (const char *, const char *configPath);
  296. void root_allow_free (void);
  297. bool root_allow_used (void);
  298. bool root_allow_ok (const char *);
  299. Index: src/sanity.sh
  300. ===================================================================
  301. RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
  302. retrieving revision 1.1175
  303. retrieving revision 1.1176
  304. diff -u -r1.1175 -r1.1176
  305. --- src/sanity.sh 8 May 2007 12:35:53 -0000 1.1175
  306. +++ src/sanity.sh 9 May 2007 23:54:33 -0000 1.1176
  307. @@ -31622,7 +31622,7 @@
  308. willfail: :whocares
  309. EOF
  310. dotest_fail pserver-3 "$servercvs pserver" \
  311. -"error 0 Server configuration missing --allow-root in inetd.conf" <<EOF
  312. +"error 0 Server configuration missing --allow-root or --allow-root-regexp in inetd.conf" <<EOF
  313. BEGIN AUTH REQUEST
  314. $CVSROOT_DIRNAME
  315. testme
  316. @@ -31640,6 +31640,27 @@
  317. END AUTH REQUEST
  318. EOF
  319. + regexp='^'`dirname ${CVSROOT_DIRNAME}`'/[^/]+$'
  320. + dotest pserver-3b "${testcvs} --allow-root-regexp=$regexp pserver" \
  321. +"I LOVE YOU" <<EOF
  322. +BEGIN AUTH REQUEST
  323. +${CVSROOT_DIRNAME}
  324. +testme
  325. +Ay::'d
  326. +END AUTH REQUEST
  327. +EOF
  328. +
  329. + regexp='^'`dirname ${CVSROOT_DIRNAME}`'/[^/]+$'
  330. + dotest_fail pserver-3c "${testcvs} --allow-root-regexp=$regexp pserver" \
  331. +"$CPROG pserver: ${CVSROOT_DIRNAME}/subdir: no such repository
  332. +I HATE YOU" <<EOF
  333. +BEGIN AUTH REQUEST
  334. +${CVSROOT_DIRNAME}/subdir
  335. +testme
  336. +Ay::'d
  337. +END AUTH REQUEST
  338. +EOF
  339. +
  340. # Confirm that not sending a newline during auth cannot constitute
  341. # a denial-of-service attack. This assumes that PATH_MAX is less
  342. # than 65536 bytes. If PATH_MAX is larger than 65535 bytes, this