home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / nfsd / src / pcnfsd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-24  |  1.9 KB  |  76 lines

  1. /*  PCNFSD functions
  2.  
  3.     ©1999 Joseph Walton
  4.  
  5.     This software is distributed under the terms of the GNU General Public
  6.     License; either version 2 of the License, or (at your option) any
  7.     later version.
  8. */
  9.  
  10. /*
  11.    Only one PCNFSD procedure is actually supported - auth.
  12.     This may be of some use as it is, or it may be of use
  13.     as a basis for further development.
  14. */
  15.  
  16. #include "rpc.h"
  17. #include "pcnfsd.h"
  18.  
  19. int pcnfsd_procedure(struct Call *call, int32 *ptr, int32 *limit,
  20.     int32 *rptr, int32 *rlimit)
  21. {
  22.     if (call->c_version != PCNFSD_VERSION) {
  23.         *rptr++ = P_ENUM(PROG_MISMATCH);
  24.         *rptr++ = P_UINT(PCNFSD_VERSION);
  25.         *rptr = P_UINT(PCNFSD_VERSION);
  26.         return 8;
  27.     }
  28.  
  29.     switch (call->c_procedure) {
  30.         case PCNFSD_PROC_NULL:
  31.             *rptr = P_ENUM(SUCCESS);
  32.             return 6;
  33.  
  34.         case PCNFSD_PROC_AUTH:
  35.  
  36.             /*
  37.                 This is what you'd do if you were going to do anything
  38.                 with the usercode and password supplied.
  39.  
  40.             char identBuffer[IDENTLEN + 1],
  41.                 pwBuffer[PASSWORDLEN + 1];
  42.  
  43.             ptr = getString(ptr, limit, identBuffer, sizeof(identBuffer));
  44.             ptr = getString(ptr, limit, pwBuffer, sizeof(pwBuffer));
  45.  
  46.             if (!ptr) {
  47.                 *rptr++ = P_ENUM(GARBAGE_ARGS);
  48.                 return 6;
  49.             }
  50.  
  51.             decode(indentBuffer);
  52.             decode(pwBuffer);
  53.             */
  54.  
  55.             /* Frankly, we're not bothered what they said */
  56.             *rptr++ = P_ENUM(SUCCESS);
  57.             *rptr++ = P_ENUM(AUTH_RES_FAKE);
  58.             *rptr++ = P_UINT(UID_NOBODY);
  59.             *rptr = P_UINT(GID_NOGROUP);
  60.             return 9;
  61.  
  62.         default:
  63.             *rptr = P_ENUM(PROC_UNAVAIL);
  64.             return 6;
  65.     }
  66. }
  67.  
  68. /* The strings passed are encoded in a rather simple-minded fashion. */
  69. static void decode(STRPTR s)
  70. {
  71.     while (*s) {
  72.         *s++ = (*s ^ 0x5b) & 0x7f;
  73.     }
  74. }
  75.  
  76.