auth_none.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. /* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */
  10. /*
  11. * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  12. * unrestricted use provided that this legend is included on all tape
  13. * media and as a part of the software program in whole or part. Users
  14. * may copy or modify Sun RPC without charge, but are not authorized
  15. * to license or distribute it to anyone else except as part of a product or
  16. * program developed by the user.
  17. *
  18. * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  19. * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  20. * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  21. *
  22. * Sun RPC is provided with no support and without any obligation on the
  23. * part of Sun Microsystems, Inc. to assist in its use, correction,
  24. * modification or enhancement.
  25. *
  26. * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  27. * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  28. * OR ANY PART THEREOF.
  29. *
  30. * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  31. * or profits or other special, indirect and consequential damages, even if
  32. * Sun has been advised of the possibility of such damages.
  33. *
  34. * Sun Microsystems, Inc.
  35. * 2550 Garcia Avenue
  36. * Mountain View, California 94043
  37. */
  38. #if !defined(lint) && defined(SCCSIDS)
  39. static char sccsid[] =
  40. "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
  41. #endif
  42. /*
  43. * auth_none.c
  44. * Creates a client authentication handle for passing "null"
  45. * credentials and verifiers to remote systems.
  46. *
  47. * Copyright (C) 1984, Sun Microsystems, Inc.
  48. */
  49. #include <rpc/types.h>
  50. #include <rpc/xdr.h>
  51. #include <rpc/auth.h>
  52. #define MAX_MARSHEL_SIZE 20
  53. static void authnone_verf(AUTH *);
  54. static bool_t authnone_validate(AUTH *, struct opaque_auth *);
  55. static bool_t authnone_refresh(AUTH *);
  56. static void authnone_destroy(AUTH *);
  57. static bool_t authnone_marshal(AUTH *client, XDR *xdrs);
  58. struct opaque_auth _null_auth;
  59. static struct auth_ops ops = {
  60. authnone_verf,
  61. authnone_marshal,
  62. authnone_validate,
  63. authnone_refresh,
  64. authnone_destroy
  65. };
  66. static struct authnone_private {
  67. AUTH no_client;
  68. char marshalled_client[MAX_MARSHEL_SIZE];
  69. unsigned int mcnt;
  70. } *authnone_private;
  71. AUTH *authnone_create()
  72. {
  73. register struct authnone_private *ap = authnone_private;
  74. XDR xdr_stream;
  75. register XDR *xdrs;
  76. extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap);
  77. if (ap == 0) {
  78. ap = (struct authnone_private *) rt_malloc (sizeof(*ap));
  79. if (ap == 0) return NULL;
  80. memset(ap, 0, sizeof(*ap));
  81. authnone_private = ap;
  82. }
  83. if (!ap->mcnt) {
  84. ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
  85. ap->no_client.ah_ops = &ops;
  86. xdrs = &xdr_stream;
  87. xdrmem_create(xdrs, ap->marshalled_client,
  88. (unsigned int) MAX_MARSHEL_SIZE, XDR_ENCODE);
  89. (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
  90. (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
  91. ap->mcnt = XDR_GETPOS(xdrs);
  92. XDR_DESTROY(xdrs);
  93. }
  94. return (&ap->no_client);
  95. }
  96. /*ARGSUSED*/
  97. static bool_t authnone_marshal(AUTH *client, XDR *xdrs)
  98. {
  99. register struct authnone_private *ap = authnone_private;
  100. if (ap == 0)
  101. return (0);
  102. return ((*xdrs->x_ops->x_putbytes) (xdrs,
  103. ap->marshalled_client, ap->mcnt));
  104. }
  105. static void authnone_verf(AUTH *x)
  106. {
  107. }
  108. static bool_t authnone_validate(AUTH *x, struct opaque_auth *x1)
  109. {
  110. return (TRUE);
  111. }
  112. static bool_t authnone_refresh(AUTH *x)
  113. {
  114. return (FALSE);
  115. }
  116. static void authnone_destroy(AUTH *x)
  117. {
  118. }