auth_none.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #if !defined(lint) && defined(SCCSIDS)
  31. static char sccsid[] =
  32. "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
  33. #endif
  34. /*
  35. * auth_none.c
  36. * Creates a client authentication handle for passing "null"
  37. * credentials and verifiers to remote systems.
  38. *
  39. * Copyright (C) 1984, Sun Microsystems, Inc.
  40. */
  41. #include <rpc/types.h>
  42. #include <rpc/xdr.h>
  43. #include <rpc/auth.h>
  44. #define MAX_MARSHEL_SIZE 20
  45. /*
  46. * Authenticator operations routines
  47. */
  48. static void authnone_verf();
  49. static void authnone_destroy();
  50. static bool_t authnone_marshal();
  51. static bool_t authnone_validate();
  52. static bool_t authnone_refresh();
  53. static struct auth_ops ops = {
  54. authnone_verf,
  55. authnone_marshal,
  56. authnone_validate,
  57. authnone_refresh,
  58. authnone_destroy
  59. };
  60. static struct authnone_private {
  61. AUTH no_client;
  62. char marshalled_client[MAX_MARSHEL_SIZE];
  63. u_int mcnt;
  64. } *authnone_private;
  65. AUTH *authnone_create()
  66. {
  67. register struct authnone_private *ap = authnone_private;
  68. XDR xdr_stream;
  69. register XDR *xdrs;
  70. if (ap == 0) {
  71. ap = (struct authnone_private *) calloc(1, sizeof(*ap));
  72. if (ap == 0)
  73. return (0);
  74. authnone_private = ap;
  75. }
  76. if (!ap->mcnt) {
  77. ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
  78. ap->no_client.ah_ops = &ops;
  79. xdrs = &xdr_stream;
  80. xdrmem_create(xdrs, ap->marshalled_client,
  81. (u_int) MAX_MARSHEL_SIZE, XDR_ENCODE);
  82. (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
  83. (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
  84. ap->mcnt = XDR_GETPOS(xdrs);
  85. XDR_DESTROY(xdrs);
  86. }
  87. return (&ap->no_client);
  88. }
  89. /*ARGSUSED*/ static bool_t authnone_marshal(client, xdrs)
  90. AUTH *client;
  91. XDR *xdrs;
  92. {
  93. register struct authnone_private *ap = authnone_private;
  94. if (ap == 0)
  95. return (0);
  96. return ((*xdrs->x_ops->x_putbytes) (xdrs,
  97. ap->marshalled_client, ap->mcnt));
  98. }
  99. static void authnone_verf()
  100. {
  101. }
  102. static bool_t authnone_validate()
  103. {
  104. return (TRUE);
  105. }
  106. static bool_t authnone_refresh()
  107. {
  108. return (FALSE);
  109. }
  110. static void authnone_destroy()
  111. {
  112. }