OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

950 lines
29 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../libtirpc/libtirpc-0.2.3-rc2.patch
  5. # Copyright (C) 2011 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 40dcc63eecbd1dfc30363351a61167353bb814a4 Mon Sep 17 00:00:00 2001
  17. From: Steve Dickson <steved@redhat.com>
  18. Date: Sat, 18 Jun 2011 09:49:40 -0400
  19. Subject: [PATCH 01/11] Do not skip records with nonblocking connections
  20. With non-blocking connections, do not skip records when receiving
  21. the streams since entire value messages can be ignored which
  22. in cause the entire stream to become out of sync.
  23. For example, two mounts simultaneously send two unmaps
  24. commands. The first one is read, then the second thrown
  25. away due to skipping the record. Skipping this record
  26. will cause XDR error later in processing of the stream.
  27. Signed-off-by: Steve Dickson <steved@redhat.com>
  28. ---
  29. src/svc_vc.c | 6 +++++-
  30. 1 files changed, 5 insertions(+), 1 deletions(-)
  31. diff --git libtirpc-0.2.2/src/svc_vc.c libtirpc-0.2.3-rc2/src/svc_vc.c
  32. index aaaf2d7..87406f1 100644
  33. --- libtirpc-0.2.2/src/svc_vc.c
  34. +++ libtirpc-0.2.3-rc2/src/svc_vc.c
  35. @@ -610,7 +610,11 @@ svc_vc_recv(xprt, msg)
  36. }
  37. xdrs->x_op = XDR_DECODE;
  38. - (void)xdrrec_skiprecord(xdrs);
  39. + /*
  40. + * No need skip records with nonblocking connections
  41. + */
  42. + if (cd->nonblock == FALSE)
  43. + (void)xdrrec_skiprecord(xdrs);
  44. if (xdr_callmsg(xdrs, msg)) {
  45. cd->x_id = msg->rm_xid;
  46. return (TRUE);
  47. --
  48. 1.7.2.3
  49. From 84570a5f6c5d588d38fb4d42fb13048e62bea71d Mon Sep 17 00:00:00 2001
  50. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  51. Date: Mon, 20 Jun 2011 13:32:58 -0400
  52. Subject: [PATCH 02/11] PCSEC_GSS_SVC_PRIVACY failure.
  53. in authgss_prot.c:xdr_rpc_gss_wrap_data(), gss_wrap() is called in the
  54. svc == RPCSEC_GSS_SVC_PRIVACY conditional block with databuf.length
  55. uninitialized.
  56. Initialization performed in the svc == RPCSEC_GSS_SVC_INTEGRITY
  57. conditional block should be moved.
  58. Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
  59. Signed-off-by: Steve Dickson <steved@redhat.com>
  60. ---
  61. src/authgss_prot.c | 2 +-
  62. 1 files changed, 1 insertions(+), 1 deletions(-)
  63. diff --git libtirpc-0.2.2/src/authgss_prot.c libtirpc-0.2.3-rc2/src/authgss_prot.c
  64. index 9d7fa09..0168318 100644
  65. --- libtirpc-0.2.2/src/authgss_prot.c
  66. +++ libtirpc-0.2.3-rc2/src/authgss_prot.c
  67. @@ -161,6 +161,7 @@ xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr,
  68. databuflen = end - start - 4;
  69. XDR_SETPOS(xdrs, start + 4);
  70. databuf.value = XDR_INLINE(xdrs, databuflen);
  71. + databuf.length = databuflen;
  72. xdr_stat = FALSE;
  73. @@ -169,7 +170,6 @@ xdr_rpc_gss_wrap_data(XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr,
  74. XDR_SETPOS(xdrs, start);
  75. if (!xdr_u_int(xdrs, (u_int *)&databuflen))
  76. return (FALSE);
  77. - databuf.length = databuflen;
  78. /* Checksum rpc_gss_data_t. */
  79. maj_stat = gss_get_mic(&min_stat, ctx, qop,
  80. --
  81. 1.7.2.3
  82. From 1e786fc401ff625fdcec3e0bdc495125feb0a070 Mon Sep 17 00:00:00 2001
  83. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  84. Date: Mon, 20 Jun 2011 13:33:35 -0400
  85. Subject: [PATCH 03/11] Use of lseek() in xdr_rec.c:xdrrec_getpos().
  86. The use of lseek() in xdr_rec.c:xdrrec_getpos() without checking for
  87. ESPIPE will fail to handle the common case, resulting in poor behavior
  88. in calling code. (In particular auth_gss.c:authgss_marshal() calls
  89. gss_get_mic() with rpcbuf.length set to -1, with spectacular results.)
  90. The original MIT Krb5 RPC code lacks this addition, which I'm unclear of
  91. the utility of in the first place.
  92. Reverting to the MIT code permits correct function of a trivial RPC
  93. client using GSS.
  94. Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
  95. Signed-off-by: Steve Dickson <steved@redhat.com>
  96. ---
  97. src/xdr_rec.c | 27 +++++++++++++--------------
  98. 1 files changed, 13 insertions(+), 14 deletions(-)
  99. diff --git libtirpc-0.2.2/src/xdr_rec.c libtirpc-0.2.3-rc2/src/xdr_rec.c
  100. index 4e815d7..2aca623 100644
  101. --- libtirpc-0.2.2/src/xdr_rec.c
  102. +++ libtirpc-0.2.3-rc2/src/xdr_rec.c
  103. @@ -64,7 +64,6 @@
  104. #include <rpc/clnt.h>
  105. #include <stddef.h>
  106. #include "rpc_com.h"
  107. -#include <unistd.h>
  108. static bool_t xdrrec_getlong(XDR *, long *);
  109. static bool_t xdrrec_putlong(XDR *, const long *);
  110. static bool_t xdrrec_getbytes(XDR *, char *, u_int);
  111. @@ -330,22 +329,22 @@ xdrrec_getpos(xdrs)
  112. RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
  113. off_t pos;
  114. - pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1);
  115. - if (pos != -1)
  116. - switch (xdrs->x_op) {
  117. + switch (xdrs->x_op) {
  118. - case XDR_ENCODE:
  119. - pos += rstrm->out_finger - rstrm->out_base;
  120. - break;
  121. + case XDR_ENCODE:
  122. + pos = rstrm->out_finger - rstrm->out_base
  123. + - BYTES_PER_XDR_UNIT;
  124. + break;
  125. - case XDR_DECODE:
  126. - pos -= rstrm->in_boundry - rstrm->in_finger;
  127. - break;
  128. + case XDR_DECODE:
  129. + pos = rstrm->in_boundry - rstrm->in_finger
  130. + - BYTES_PER_XDR_UNIT;
  131. + break;
  132. - default:
  133. - pos = (off_t) -1;
  134. - break;
  135. - }
  136. + default:
  137. + pos = (off_t) -1;
  138. + break;
  139. + }
  140. return ((u_int) pos);
  141. }
  142. --
  143. 1.7.2.3
  144. From 2abb87646f696726f4ee3a89db6ebfc8adbd9b9b Mon Sep 17 00:00:00 2001
  145. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  146. Date: Mon, 20 Jun 2011 13:34:34 -0400
  147. Subject: [PATCH 04/11] AUTH_WRAP/AUTH_UNWRAP support.
  148. Client code lacks support for authenticator wrapping/unwrapping, which
  149. is particularly useful when using GSS.
  150. Verified for both tcp & udp using a trivial RPC client against a MIT
  151. Krb5 server.
  152. Signed-off-by: Steve Dickson <steved@redhat.com>
  153. ---
  154. src/auth_des.c | 8 ++++++++
  155. src/auth_none.c | 8 ++++++++
  156. src/auth_unix.c | 8 ++++++++
  157. src/clnt_dg.c | 10 +++++++---
  158. src/clnt_vc.c | 5 +++--
  159. 5 files changed, 34 insertions(+), 5 deletions(-)
  160. diff --git libtirpc-0.2.2/src/auth_des.c libtirpc-0.2.3-rc2/src/auth_des.c
  161. index 37e7667..829c817 100644
  162. --- libtirpc-0.2.2/src/auth_des.c
  163. +++ libtirpc-0.2.3-rc2/src/auth_des.c
  164. @@ -472,6 +472,12 @@ authdes_destroy(AUTH *auth)
  165. FREE(auth, sizeof(AUTH));
  166. }
  167. +static bool_t
  168. +authdes_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)
  169. +{
  170. + return ((*xfunc)(xdrs, xwhere));
  171. +}
  172. +
  173. static struct auth_ops *
  174. authdes_ops(void)
  175. {
  176. @@ -487,6 +493,8 @@ authdes_ops(void)
  177. ops.ah_validate = authdes_validate;
  178. ops.ah_refresh = authdes_refresh;
  179. ops.ah_destroy = authdes_destroy;
  180. + ops.ah_wrap = authdes_wrap;
  181. + ops.ah_unwrap = authdes_wrap;
  182. }
  183. mutex_unlock(&authdes_ops_lock);
  184. return (&ops);
  185. diff --git libtirpc-0.2.2/src/auth_none.c libtirpc-0.2.3-rc2/src/auth_none.c
  186. index a439ec6..008c589 100644
  187. --- libtirpc-0.2.2/src/auth_none.c
  188. +++ libtirpc-0.2.3-rc2/src/auth_none.c
  189. @@ -155,6 +155,12 @@ authnone_destroy(AUTH *client)
  190. {
  191. }
  192. +static bool_t
  193. +authnone_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)
  194. +{
  195. + return ((*xfunc)(xdrs, xwhere));
  196. +}
  197. +
  198. static struct auth_ops *
  199. authnone_ops()
  200. {
  201. @@ -170,6 +176,8 @@ authnone_ops()
  202. ops.ah_validate = authnone_validate;
  203. ops.ah_refresh = authnone_refresh;
  204. ops.ah_destroy = authnone_destroy;
  205. + ops.ah_wrap = authnone_wrap;
  206. + ops.ah_unwrap = authnone_wrap;
  207. }
  208. mutex_unlock(&ops_lock);
  209. return (&ops);
  210. diff --git libtirpc-0.2.2/src/auth_unix.c libtirpc-0.2.3-rc2/src/auth_unix.c
  211. index c2469da..5b8990f 100644
  212. --- libtirpc-0.2.2/src/auth_unix.c
  213. +++ libtirpc-0.2.3-rc2/src/auth_unix.c
  214. @@ -396,6 +396,12 @@ marshal_new_auth(auth)
  215. XDR_DESTROY(xdrs);
  216. }
  217. +static bool_t
  218. +authunix_wrap(AUTH *auth, XDR *xdrs, xdrproc_t xfunc, caddr_t xwhere)
  219. +{
  220. + return ((*xfunc)(xdrs, xwhere));
  221. +}
  222. +
  223. static struct auth_ops *
  224. authunix_ops()
  225. {
  226. @@ -411,6 +417,8 @@ authunix_ops()
  227. ops.ah_validate = authunix_validate;
  228. ops.ah_refresh = authunix_refresh;
  229. ops.ah_destroy = authunix_destroy;
  230. + ops.ah_wrap = authunix_wrap;
  231. + ops.ah_unwrap = authunix_wrap;
  232. }
  233. mutex_unlock(&ops_lock);
  234. return (&ops);
  235. diff --git libtirpc-0.2.2/src/clnt_dg.c libtirpc-0.2.3-rc2/src/clnt_dg.c
  236. index 79fed5d..4a1f60a 100644
  237. --- libtirpc-0.2.2/src/clnt_dg.c
  238. +++ libtirpc-0.2.3-rc2/src/clnt_dg.c
  239. @@ -366,7 +366,7 @@ call_again:
  240. if ((! XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
  241. (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
  242. - (! (*xargs)(xdrs, argsp))) {
  243. + (! AUTH_WRAP(cl->cl_auth, xdrs, xargs, argsp))) {
  244. cu->cu_error.re_status = RPC_CANTENCODEARGS;
  245. goto out;
  246. }
  247. @@ -400,8 +400,8 @@ get_reply:
  248. * (We assume that this is actually only executed once.)
  249. */
  250. reply_msg.acpted_rply.ar_verf = _null_auth;
  251. - reply_msg.acpted_rply.ar_results.where = resultsp;
  252. - reply_msg.acpted_rply.ar_results.proc = xresults;
  253. + reply_msg.acpted_rply.ar_results.where = NULL;
  254. + reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
  255. fd.fd = cu->cu_fd;
  256. fd.events = POLLIN;
  257. @@ -512,6 +512,10 @@ get_reply:
  258. &reply_msg.acpted_rply.ar_verf)) {
  259. cu->cu_error.re_status = RPC_AUTHERROR;
  260. cu->cu_error.re_why = AUTH_INVALIDRESP;
  261. + } else if (! AUTH_UNWRAP(cl->cl_auth, &reply_xdrs,
  262. + xresults, resultsp)) {
  263. + if (cu->cu_error.re_status == RPC_SUCCESS)
  264. + cu->cu_error.re_status = RPC_CANTDECODERES;
  265. }
  266. if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) {
  267. xdrs->x_op = XDR_FREE;
  268. diff --git libtirpc-0.2.2/src/clnt_vc.c libtirpc-0.2.3-rc2/src/clnt_vc.c
  269. index 359063c..097cae8 100644
  270. --- libtirpc-0.2.2/src/clnt_vc.c
  271. +++ libtirpc-0.2.3-rc2/src/clnt_vc.c
  272. @@ -364,7 +364,7 @@ call_again:
  273. if ((! XDR_PUTBYTES(xdrs, ct->ct_u.ct_mcallc, ct->ct_mpos)) ||
  274. (! XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
  275. (! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
  276. - (! (*xdr_args)(xdrs, args_ptr))) {
  277. + (! AUTH_WRAP(cl->cl_auth, xdrs, xdr_args, args_ptr))) {
  278. if (ct->ct_error.re_status == RPC_SUCCESS)
  279. ct->ct_error.re_status = RPC_CANTENCODEARGS;
  280. (void)xdrrec_endofrecord(xdrs, TRUE);
  281. @@ -420,7 +420,8 @@ call_again:
  282. &reply_msg.acpted_rply.ar_verf)) {
  283. ct->ct_error.re_status = RPC_AUTHERROR;
  284. ct->ct_error.re_why = AUTH_INVALIDRESP;
  285. - } else if (! (*xdr_results)(xdrs, results_ptr)) {
  286. + } else if (! AUTH_UNWRAP(cl->cl_auth, xdrs,
  287. + xdr_results, results_ptr)) {
  288. if (ct->ct_error.re_status == RPC_SUCCESS)
  289. ct->ct_error.re_status = RPC_CANTDECODERES;
  290. }
  291. --
  292. 1.7.2.3
  293. From 82cc2e6129c872c8be09381055f2fb5641c5e6fe Mon Sep 17 00:00:00 2001
  294. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  295. Date: Mon, 20 Jun 2011 13:34:56 -0400
  296. Subject: [PATCH 05/11] SVCAUTH_WRAP/SVCAUTH_UNWRAP
  297. Server code lacks support for authenticator wrapping/unwrapping, which
  298. is particularly useful when using GSS.
  299. Verified for both tcp & udp using a trivial RPC server against an MIT
  300. Krb5 client.
  301. Signed-off-by: Frank Filz <ffilzlnx@us.ibm.com>
  302. Signed-off-by: Steve Dickson <steved@redhat.com>
  303. ---
  304. src/svc.c | 11 +++--------
  305. src/svc_auth_unix.c | 5 +++++
  306. src/svc_dg.c | 31 +++++++++++++++++++++++++++++--
  307. src/svc_vc.c | 37 ++++++++++++++++++++++++++++++++++---
  308. tirpc/rpc/svc_auth.h | 18 ++++++++++++------
  309. 5 files changed, 83 insertions(+), 19 deletions(-)
  310. diff --git libtirpc-0.2.2/src/svc.c libtirpc-0.2.3-rc2/src/svc.c
  311. index b4a63d0..08cd6c9 100644
  312. --- libtirpc-0.2.2/src/svc.c
  313. +++ libtirpc-0.2.3-rc2/src/svc.c
  314. @@ -77,9 +77,6 @@ static struct svc_callout
  315. extern rwlock_t svc_lock;
  316. extern rwlock_t svc_fd_lock;
  317. -#ifdef HAVE_LIBGSSAPI
  318. -extern struct svc_auth_ops svc_auth_gss_ops;
  319. -#endif
  320. static struct svc_callout *svc_find (rpcprog_t, rpcvers_t,
  321. struct svc_callout **, char *);
  322. @@ -717,11 +714,9 @@ svc_getreq_common (fd)
  323. SVC_DESTROY (xprt);
  324. break;
  325. }
  326. - else if ((xprt->xp_auth != NULL)
  327. -#ifdef HAVE_LIBGSSAPI
  328. - && (xprt->xp_auth->svc_ah_ops != &svc_auth_gss_ops)
  329. -#endif
  330. - ) {
  331. + else if ((xprt->xp_auth != NULL) &&
  332. + (xprt->xp_auth->svc_ah_private == NULL))
  333. + {
  334. xprt->xp_auth = NULL;
  335. }
  336. }
  337. diff --git libtirpc-0.2.2/src/svc_auth_unix.c libtirpc-0.2.3-rc2/src/svc_auth_unix.c
  338. index ce83859..9585069 100644
  339. --- libtirpc-0.2.2/src/svc_auth_unix.c
  340. +++ libtirpc-0.2.3-rc2/src/svc_auth_unix.c
  341. @@ -43,6 +43,8 @@
  342. #include <rpc/rpc.h>
  343. +extern SVCAUTH svc_auth_none;
  344. +
  345. /*
  346. * Unix longhand authenticator
  347. */
  348. @@ -67,6 +69,8 @@ _svcauth_unix(rqst, msg)
  349. assert(rqst != NULL);
  350. assert(msg != NULL);
  351. + rqst->rq_xprt->xp_auth = &svc_auth_none;
  352. +
  353. area = (struct area *) rqst->rq_clntcred;
  354. aup = &area->area_aup;
  355. aup->aup_machname = area->area_machname;
  356. @@ -142,5 +146,6 @@ _svcauth_short(rqst, msg)
  357. struct svc_req *rqst;
  358. struct rpc_msg *msg;
  359. {
  360. + rqst->rq_xprt->xp_auth = &svc_auth_none;
  361. return (AUTH_REJECTEDCRED);
  362. }
  363. diff --git libtirpc-0.2.2/src/svc_dg.c libtirpc-0.2.3-rc2/src/svc_dg.c
  364. index 66a56ee..5ef9df2 100644
  365. --- libtirpc-0.2.2/src/svc_dg.c
  366. +++ libtirpc-0.2.3-rc2/src/svc_dg.c
  367. @@ -134,6 +134,7 @@ svc_dg_create(fd, sendsize, recvsize)
  368. su->su_cache = NULL;
  369. xprt->xp_fd = fd;
  370. xprt->xp_p2 = su;
  371. + xprt->xp_auth = NULL;
  372. xprt->xp_verf.oa_base = su->su_verfbody;
  373. svc_dg_ops(xprt);
  374. xprt->xp_rtaddr.maxlen = sizeof (struct sockaddr_storage);
  375. @@ -234,10 +235,27 @@ svc_dg_reply(xprt, msg)
  376. bool_t stat = FALSE;
  377. size_t slen;
  378. + xdrproc_t xdr_results;
  379. + caddr_t xdr_location;
  380. + bool_t has_args;
  381. +
  382. + if (msg->rm_reply.rp_stat == MSG_ACCEPTED &&
  383. + msg->rm_reply.rp_acpt.ar_stat == SUCCESS) {
  384. + has_args = TRUE;
  385. + xdr_results = msg->acpted_rply.ar_results.proc;
  386. + xdr_location = msg->acpted_rply.ar_results.where;
  387. +
  388. + msg->acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
  389. + msg->acpted_rply.ar_results.where = NULL;
  390. + } else
  391. + has_args = FALSE;
  392. +
  393. xdrs->x_op = XDR_ENCODE;
  394. XDR_SETPOS(xdrs, 0);
  395. msg->rm_xid = su->su_xid;
  396. - if (xdr_replymsg(xdrs, msg)) {
  397. + if (xdr_replymsg(xdrs, msg) &&
  398. + (!has_args ||
  399. + (SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  400. struct msghdr *msg = &su->su_msghdr;
  401. struct iovec iov;
  402. @@ -264,7 +282,12 @@ svc_dg_getargs(xprt, xdr_args, args_ptr)
  403. xdrproc_t xdr_args;
  404. void *args_ptr;
  405. {
  406. - return (*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr);
  407. + if (! SVCAUTH_UNWRAP(xprt->xp_auth, &(su_data(xprt)->su_xdrs),
  408. + xdr_args, args_ptr)) {
  409. + (void)svc_freeargs(xprt, xdr_args, args_ptr);
  410. + return FALSE;
  411. + }
  412. + return TRUE;
  413. }
  414. static bool_t
  415. @@ -288,6 +311,10 @@ svc_dg_destroy(xprt)
  416. xprt_unregister(xprt);
  417. if (xprt->xp_fd != -1)
  418. (void)close(xprt->xp_fd);
  419. + if (xprt->xp_auth != NULL) {
  420. + SVCAUTH_DESTROY(xprt->xp_auth);
  421. + xprt->xp_auth = NULL;
  422. + }
  423. XDR_DESTROY(&(su->su_xdrs));
  424. (void) mem_free(rpc_buffer(xprt), su->su_iosz);
  425. (void) mem_free(su, sizeof (*su));
  426. diff --git libtirpc-0.2.2/src/svc_vc.c libtirpc-0.2.3-rc2/src/svc_vc.c
  427. index 87406f1..74632e2 100644
  428. --- libtirpc-0.2.2/src/svc_vc.c
  429. +++ libtirpc-0.2.3-rc2/src/svc_vc.c
  430. @@ -172,6 +172,7 @@ svc_vc_create(fd, sendsize, recvsize)
  431. xprt->xp_p1 = r;
  432. xprt->xp_p2 = NULL;
  433. xprt->xp_p3 = NULL;
  434. + xprt->xp_auth = NULL;
  435. xprt->xp_verf = _null_auth;
  436. svc_vc_rendezvous_ops(xprt);
  437. xprt->xp_port = (u_short)-1; /* It is the rendezvouser */
  438. @@ -283,6 +284,7 @@ makefd_xprt(fd, sendsize, recvsize)
  439. xdrrec_create(&(cd->xdrs), sendsize, recvsize,
  440. xprt, read_vc, write_vc);
  441. xprt->xp_p1 = cd;
  442. + xprt->xp_auth = NULL;
  443. xprt->xp_verf.oa_base = cd->verf_body;
  444. svc_vc_ops(xprt); /* truely deals with calls */
  445. xprt->xp_port = 0; /* this is a connection, not a rendezvouser */
  446. @@ -412,6 +414,10 @@ __svc_vc_dodestroy(xprt)
  447. XDR_DESTROY(&(cd->xdrs));
  448. mem_free(cd, sizeof(struct cf_conn));
  449. }
  450. + if (xprt->xp_auth != NULL) {
  451. + SVCAUTH_DESTROY(xprt->xp_auth);
  452. + xprt->xp_auth = NULL;
  453. + }
  454. if (xprt->xp_rtaddr.buf)
  455. mem_free(xprt->xp_rtaddr.buf, xprt->xp_rtaddr.maxlen);
  456. if (xprt->xp_ltaddr.buf)
  457. @@ -632,8 +638,13 @@ svc_vc_getargs(xprt, xdr_args, args_ptr)
  458. assert(xprt != NULL);
  459. /* args_ptr may be NULL */
  460. - return ((*xdr_args)(&(((struct cf_conn *)(xprt->xp_p1))->xdrs),
  461. - args_ptr));
  462. +
  463. + if (! SVCAUTH_UNWRAP(xprt->xp_auth,
  464. + &(((struct cf_conn *)(xprt->xp_p1))->xdrs),
  465. + xdr_args, args_ptr)) {
  466. + return FALSE;
  467. + }
  468. + return TRUE;
  469. }
  470. static bool_t
  471. @@ -662,15 +673,35 @@ svc_vc_reply(xprt, msg)
  472. XDR *xdrs;
  473. bool_t rstat;
  474. + xdrproc_t xdr_results;
  475. + caddr_t xdr_location;
  476. + bool_t has_args;
  477. +
  478. assert(xprt != NULL);
  479. assert(msg != NULL);
  480. cd = (struct cf_conn *)(xprt->xp_p1);
  481. xdrs = &(cd->xdrs);
  482. + if (msg->rm_reply.rp_stat == MSG_ACCEPTED &&
  483. + msg->rm_reply.rp_acpt.ar_stat == SUCCESS) {
  484. + has_args = TRUE;
  485. + xdr_results = msg->acpted_rply.ar_results.proc;
  486. + xdr_location = msg->acpted_rply.ar_results.where;
  487. +
  488. + msg->acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
  489. + msg->acpted_rply.ar_results.where = NULL;
  490. + } else
  491. + has_args = FALSE;
  492. +
  493. xdrs->x_op = XDR_ENCODE;
  494. msg->rm_xid = cd->x_id;
  495. - rstat = xdr_replymsg(xdrs, msg);
  496. + rstat = FALSE;
  497. + if (xdr_replymsg(xdrs, msg) &&
  498. + (!has_args ||
  499. + (SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  500. + rstat = TRUE;
  501. + }
  502. (void)xdrrec_endofrecord(xdrs, TRUE);
  503. return (rstat);
  504. }
  505. diff --git libtirpc-0.2.2/tirpc/rpc/svc_auth.h libtirpc-0.2.3-rc2/tirpc/rpc/svc_auth.h
  506. index 659e90c..14269d1 100644
  507. --- libtirpc-0.2.2/tirpc/rpc/svc_auth.h
  508. +++ libtirpc-0.2.3-rc2/tirpc/rpc/svc_auth.h
  509. @@ -44,17 +44,23 @@
  510. /*
  511. * Interface to server-side authentication flavors.
  512. */
  513. -typedef struct {
  514. +typedef struct SVCAUTH {
  515. struct svc_auth_ops {
  516. - int (*svc_ah_wrap)(void);
  517. - int (*svc_ah_unwrap)(void);
  518. - int (*svc_ah_destroy)(void);
  519. + int (*svc_ah_wrap)(struct SVCAUTH *, XDR *, xdrproc_t,
  520. + caddr_t);
  521. + int (*svc_ah_unwrap)(struct SVCAUTH *, XDR *, xdrproc_t,
  522. + caddr_t);
  523. + int (*svc_ah_destroy)(struct SVCAUTH *);
  524. } *svc_ah_ops;
  525. caddr_t svc_ah_private;
  526. } SVCAUTH;
  527. -#define SVCAUTH_DESTROY(cred) ((*(cred)->svc_ah_ops->svc_ah_destroy)())
  528. -#define svcauth_destroy(cred) ((*(cred)->svc_ah_ops->svc_ah_destroy)())
  529. +#define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \
  530. + ((*((auth)->svc_ah_ops->svc_ah_wrap))(auth, xdrs, xfunc, xwhere))
  531. +#define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \
  532. + ((*((auth)->svc_ah_ops->svc_ah_unwrap))(auth, xdrs, xfunc, xwhere))
  533. +#define SVCAUTH_DESTROY(auth) \
  534. + ((*((auth)->svc_ah_ops->svc_ah_destroy))(auth))
  535. /*
  536. * Server side authenticator
  537. --
  538. 1.7.2.3
  539. From 6c43043ececc2e9f613dc86086c7ac4970aeb690 Mon Sep 17 00:00:00 2001
  540. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  541. Date: Mon, 20 Jun 2011 13:35:54 -0400
  542. Subject: [PATCH 06/11] auth_null used when auth_none is appropriate
  543. svc_auth.c uses a fake entry function for AUTH_NULL (AUTH_NONE) when the
  544. use of the svc_auth_none is appropriate.
  545. With the previous patches to make use of WRAP/UNWRAP svc_auth_none is
  546. required.
  547. Signed-off-by: Steve Dickson <steved@redhat.com>
  548. ---
  549. src/svc_auth.c | 13 ++-----------
  550. tirpc/rpc/auth.h | 2 +-
  551. 2 files changed, 3 insertions(+), 12 deletions(-)
  552. diff --git libtirpc-0.2.2/src/svc_auth.c libtirpc-0.2.3-rc2/src/svc_auth.c
  553. index c6b3a0b..e80d5f9 100644
  554. --- libtirpc-0.2.2/src/svc_auth.c
  555. +++ libtirpc-0.2.3-rc2/src/svc_auth.c
  556. @@ -98,8 +98,8 @@ _authenticate(rqst, msg)
  557. rqst->rq_xprt->xp_verf.oa_length = 0;
  558. cred_flavor = rqst->rq_cred.oa_flavor;
  559. switch (cred_flavor) {
  560. - case AUTH_NULL:
  561. - dummy = _svcauth_null(rqst, msg);
  562. + case AUTH_NONE:
  563. + dummy = _svcauth_none(rqst, msg);
  564. return (dummy);
  565. case AUTH_SYS:
  566. dummy = _svcauth_unix(rqst, msg);
  567. @@ -132,15 +132,6 @@ _authenticate(rqst, msg)
  568. return (AUTH_REJECTEDCRED);
  569. }
  570. -/*ARGSUSED*/
  571. -enum auth_stat
  572. -_svcauth_null(rqst, msg)
  573. - struct svc_req *rqst;
  574. - struct rpc_msg *msg;
  575. -{
  576. - return (AUTH_OK);
  577. -}
  578. -
  579. /*
  580. * Allow the rpc service to register new authentication types that it is
  581. * prepared to handle. When an authentication flavor is registered,
  582. diff --git libtirpc-0.2.2/tirpc/rpc/auth.h libtirpc-0.2.3-rc2/tirpc/rpc/auth.h
  583. index 734e6b9..f669ae4 100644
  584. --- libtirpc-0.2.2/tirpc/rpc/auth.h
  585. +++ libtirpc-0.2.3-rc2/tirpc/rpc/auth.h
  586. @@ -373,7 +373,7 @@ __END_DECLS
  587. __BEGIN_DECLS
  588. struct svc_req;
  589. struct rpc_msg;
  590. -enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *);
  591. +enum auth_stat _svcauth_none (struct svc_req *, struct rpc_msg *);
  592. enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *);
  593. enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *);
  594. __END_DECLS
  595. --
  596. 1.7.2.3
  597. From 8271dfe7ec97a993fe3e369c9e02165f54f32322 Mon Sep 17 00:00:00 2001
  598. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  599. Date: Mon, 20 Jun 2011 13:42:18 -0400
  600. Subject: [PATCH 07/11] Reference count AUTHs
  601. RPCSEC GSSv3 has the concept of a parent and a compound credential. As
  602. the normal course of operation involves using multiple AUTHs per client
  603. connection, and providing parent and compounds AUTHs when creating a
  604. GSSv3 AUTH, we need a way of reference counting them so that
  605. AUTH_DESTROY does not free them out from under a GSSv3 AUTH that is
  606. using them.
  607. Signed-off-by: Steve Dickson <steved@redhat.com>
  608. ---
  609. src/auth_des.c | 1 +
  610. src/auth_gss.c | 2 ++
  611. src/auth_unix.c | 1 +
  612. tirpc/rpc/auth.h | 35 +++++++++++++++++++++++++++++++----
  613. 4 files changed, 35 insertions(+), 4 deletions(-)
  614. diff --git libtirpc-0.2.2/src/auth_des.c libtirpc-0.2.3-rc2/src/auth_des.c
  615. index 829c817..f0c8b8c 100644
  616. --- libtirpc-0.2.2/src/auth_des.c
  617. +++ libtirpc-0.2.3-rc2/src/auth_des.c
  618. @@ -223,6 +223,7 @@ authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,
  619. goto failed;
  620. }
  621. ad->ad_nis_srvr = NULL; /* not needed any longer */
  622. + auth_get(auth); /* Reference for caller */
  623. return (auth);
  624. failed:
  625. diff --git libtirpc-0.2.2/src/auth_gss.c libtirpc-0.2.3-rc2/src/auth_gss.c
  626. index df3017a..98f0341 100644
  627. --- libtirpc-0.2.2/src/auth_gss.c
  628. +++ libtirpc-0.2.3-rc2/src/auth_gss.c
  629. @@ -200,6 +200,8 @@ authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec)
  630. if (!authgss_refresh(auth))
  631. auth = NULL;
  632. + else
  633. + auth_get(auth); /* Reference for caller */
  634. clnt->cl_auth = save_auth;
  635. diff --git libtirpc-0.2.2/src/auth_unix.c libtirpc-0.2.3-rc2/src/auth_unix.c
  636. index 5b8990f..4b9b13f 100644
  637. --- libtirpc-0.2.2/src/auth_unix.c
  638. +++ libtirpc-0.2.3-rc2/src/auth_unix.c
  639. @@ -162,6 +162,7 @@ authunix_create(machname, uid, gid, len, aup_gids)
  640. */
  641. auth->ah_cred = au->au_origcred;
  642. marshal_new_auth(auth);
  643. + auth_get(auth); /* Reference for caller */
  644. return (auth);
  645. #ifndef _KERNEL
  646. cleanup_authunix_create:
  647. diff --git libtirpc-0.2.2/tirpc/rpc/auth.h libtirpc-0.2.3-rc2/tirpc/rpc/auth.h
  648. index f669ae4..5f66e67 100644
  649. --- libtirpc-0.2.2/tirpc/rpc/auth.h
  650. +++ libtirpc-0.2.3-rc2/tirpc/rpc/auth.h
  651. @@ -203,8 +203,22 @@ typedef struct __auth {
  652. } *ah_ops;
  653. void *ah_private;
  654. + int ah_refcnt;
  655. } AUTH;
  656. +static __inline int
  657. +auth_get(AUTH *auth)
  658. +{
  659. + return __sync_add_and_fetch(&auth->ah_refcnt, 1);
  660. +}
  661. +
  662. +static __inline int
  663. +auth_put(AUTH *auth)
  664. +{
  665. + return __sync_sub_and_fetch(&auth->ah_refcnt, 1);
  666. +}
  667. +
  668. +
  669. /*
  670. * Authentication ops.
  671. @@ -234,10 +248,23 @@ typedef struct __auth {
  672. #define auth_refresh(auth, msg) \
  673. ((*((auth)->ah_ops->ah_refresh))(auth, msg))
  674. -#define AUTH_DESTROY(auth) \
  675. - ((*((auth)->ah_ops->ah_destroy))(auth))
  676. -#define auth_destroy(auth) \
  677. - ((*((auth)->ah_ops->ah_destroy))(auth))
  678. +#define AUTH_DESTROY(auth) \
  679. + do { \
  680. + int refs; \
  681. + if ((refs = auth_put((auth))) == 0) \
  682. + ((*((auth)->ah_ops->ah_destroy))(auth));\
  683. + log_debug("%s: auth_put(), refs %d\n", \
  684. + __func__, refs); \
  685. + } while (0)
  686. +
  687. +#define auth_destroy(auth) \
  688. + do { \
  689. + int refs; \
  690. + if ((refs = auth_put((auth))) == 0) \
  691. + ((*((auth)->ah_ops->ah_destroy))(auth));\
  692. + log_debug("%s: auth_put(), refs %d\n", \
  693. + __func__, refs); \
  694. + } while (0)
  695. #define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \
  696. ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \
  697. --
  698. 1.7.2.3
  699. From e1cd6dc047c2f4d08f66776bc0206eeb5092f1f8 Mon Sep 17 00:00:00 2001
  700. From: Matthew N. Dodd <matthew.nygard.dodd@gmail.com>
  701. Date: Mon, 20 Jun 2011 13:45:11 -0400
  702. Subject: [PATCH 08/11] Use correct AUTH when calling RPCSEC_GSS_DESTROY.
  703. When using multiple AUTHs per client connection, calling
  704. AUTH_DESTROY(auth) may result in 'cl_auth' being set to something other
  705. than 'auth'.
  706. Avoid this by saving and restoring 'cl_auth' across the
  707. RPCSEC_GSS_DESTROY clnt_call().
  708. Signed-off-by: Steve Dickson <steved@redhat.com>
  709. ---
  710. src/auth_gss.c | 11 +++++++++++
  711. 1 files changed, 11 insertions(+), 0 deletions(-)
  712. diff --git libtirpc-0.2.2/src/auth_gss.c libtirpc-0.2.3-rc2/src/auth_gss.c
  713. index 98f0341..a992049 100644
  714. --- libtirpc-0.2.2/src/auth_gss.c
  715. +++ libtirpc-0.2.3-rc2/src/auth_gss.c
  716. @@ -557,9 +557,20 @@ authgss_destroy_context(AUTH *auth)
  717. if (gd->gc.gc_ctx.length != 0) {
  718. if (gd->established) {
  719. + AUTH *save_auth = NULL;
  720. +
  721. + /* Make sure we use the right auth_ops */
  722. + if (gd->clnt->cl_auth != auth) {
  723. + save_auth = gd->clnt->cl_auth;
  724. + gd->clnt->cl_auth = auth;
  725. + }
  726. +
  727. gd->gc.gc_proc = RPCSEC_GSS_DESTROY;
  728. clnt_call(gd->clnt, NULLPROC, (xdrproc_t)xdr_void, NULL,
  729. (xdrproc_t)xdr_void, NULL, AUTH_TIMEOUT);
  730. +
  731. + if (save_auth != NULL)
  732. + gd->clnt->cl_auth = save_auth;
  733. }
  734. gss_release_buffer(&min_stat, &gd->gc.gc_ctx);
  735. /* XXX ANDROS check size of context - should be 8 */
  736. --
  737. 1.7.2.3
  738. From 5f9d6c0f7fc2dd1db56ec8bfad3661306fde3b5c Mon Sep 17 00:00:00 2001
  739. From: Mike Frysinger <vapier@gentoo.org>
  740. Date: Mon, 20 Jun 2011 13:48:56 -0400
  741. Subject: [PATCH 09/11] Add multiple inclusion protection to rpc/des.h
  742. If you try to include this file multiple times, you get a build failure
  743. due to redefinitions of enums and such.
  744. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  745. Signed-off-by: Steve Dickson <steved@redhat.com>
  746. ---
  747. tirpc/rpc/des.h | 5 +++++
  748. 1 files changed, 5 insertions(+), 0 deletions(-)
  749. diff --git libtirpc-0.2.2/tirpc/rpc/des.h libtirpc-0.2.3-rc2/tirpc/rpc/des.h
  750. index e3d6897..d2881ad 100644
  751. --- libtirpc-0.2.2/tirpc/rpc/des.h
  752. +++ libtirpc-0.2.3-rc2/tirpc/rpc/des.h
  753. @@ -33,6 +33,9 @@
  754. * Copyright (c) 1986 by Sun Microsystems, Inc.
  755. */
  756. +#ifndef _RPC_DES_H_
  757. +#define _RPC_DES_H_
  758. +
  759. #define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
  760. #define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
  761. @@ -80,3 +83,5 @@ struct desparams {
  762. * Software DES.
  763. */
  764. extern int _des_crypt( char *, int, struct desparams * );
  765. +
  766. +#endif
  767. --
  768. 1.7.2.3
  769. From ebd3e644a79fa92b3b780d87d8028fcf64364abd Mon Sep 17 00:00:00 2001
  770. From: Mike Frysinger <vapier@gentoo.org>
  771. Date: Mon, 20 Jun 2011 13:52:14 -0400
  772. Subject: [PATCH 10/11] Revert "Include des_crypt in build"
  773. The des_crypt code requires the crypt_client code (which wasn't
  774. added), and that code requires a currently undefined function
  775. (namely xdr_desresp). Since I have no idea what that's about,
  776. and this change ends up breaking some systems, just revert it.
  777. Once we have a patch that improves portability without breaking
  778. existing systems, we can revisit this.
  779. This reverts commit 9bdcba10aa67ce3f67810c7aaac944a00dcfcee5.
  780. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
  781. Signed-off-by: Steve Dickson <steved@redhat.com>
  782. ---
  783. src/Makefile.am | 2 +-
  784. 1 files changed, 1 insertions(+), 1 deletions(-)
  785. diff --git libtirpc-0.2.2/src/Makefile.am libtirpc-0.2.3-rc2/src/Makefile.am
  786. index 7ee8cbc..6731ff9 100644
  787. --- libtirpc-0.2.2/src/Makefile.am
  788. +++ libtirpc-0.2.3-rc2/src/Makefile.am
  789. @@ -50,7 +50,7 @@ libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c cln
  790. rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
  791. rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_generic.c \
  792. svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \
  793. - auth_time.c auth_des.c authdes_prot.c des_crypt.c
  794. + auth_time.c auth_des.c authdes_prot.c
  795. ## XDR
  796. libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c
  797. --
  798. 1.7.2.3
  799. From e6bdc5761e5340b0df03c2b5c344b04feabaad9e Mon Sep 17 00:00:00 2001
  800. From: Steve Dickson <steved@redhat.com>
  801. Date: Wed, 20 Jul 2011 09:47:49 -0400
  802. Subject: [PATCH 11/11] Segfault in SVCAUTH_WRAP call
  803. The xprt->xp_auth pointer need to be checked before
  804. used in the SVCAUTH_WRAP call since it can be NULL
  805. during error conditions.
  806. Signed-off-by: Steve Dickson <steved@redhat.com>
  807. ---
  808. src/svc_dg.c | 4 ++--
  809. src/svc_vc.c | 4 ++--
  810. 2 files changed, 4 insertions(+), 4 deletions(-)
  811. diff --git libtirpc-0.2.2/src/svc_dg.c libtirpc-0.2.3-rc2/src/svc_dg.c
  812. index 5ef9df2..081db61 100644
  813. --- libtirpc-0.2.2/src/svc_dg.c
  814. +++ libtirpc-0.2.3-rc2/src/svc_dg.c
  815. @@ -254,8 +254,8 @@ svc_dg_reply(xprt, msg)
  816. XDR_SETPOS(xdrs, 0);
  817. msg->rm_xid = su->su_xid;
  818. if (xdr_replymsg(xdrs, msg) &&
  819. - (!has_args ||
  820. - (SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  821. + (!has_args || (xprt->xp_auth &&
  822. + SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  823. struct msghdr *msg = &su->su_msghdr;
  824. struct iovec iov;
  825. diff --git libtirpc-0.2.2/src/svc_vc.c libtirpc-0.2.3-rc2/src/svc_vc.c
  826. index 74632e2..4c70de8 100644
  827. --- libtirpc-0.2.2/src/svc_vc.c
  828. +++ libtirpc-0.2.3-rc2/src/svc_vc.c
  829. @@ -698,8 +698,8 @@ svc_vc_reply(xprt, msg)
  830. msg->rm_xid = cd->x_id;
  831. rstat = FALSE;
  832. if (xdr_replymsg(xdrs, msg) &&
  833. - (!has_args ||
  834. - (SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  835. + (!has_args || (xprt->xp_auth &&
  836. + SVCAUTH_WRAP(xprt->xp_auth, xdrs, xdr_results, xdr_location)))) {
  837. rstat = TRUE;
  838. }
  839. (void)xdrrec_endofrecord(xdrs, TRUE);
  840. --
  841. 1.7.2.3