auth_none.c 3.1 KB

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