home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTPasswd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  4.6 KB  |  130 lines

  1. /*                                   PASSWORD FILE ROUTINES
  2.                                              
  3.  */
  4.  
  5. #ifndef HTPASSWD_H
  6. #define HTPASSWD_H
  7.  
  8. #ifndef HTUTILS_H
  9. #include "HTUtils.h"
  10. #endif /* HTUTILS_H */
  11. #include "HTList.h"
  12.  
  13. #ifdef SHORT_NAMES
  14. #define HTAAenPw        HTAA_encryptPasswd
  15. #define HTAApwMa        HTAA_passwdMatch
  16. #define HTAAFrPR        HTAAFile_readPasswdRec
  17. #define HTAAchPw        HTAA_checkPasswd
  18. #endif /* SHORT_NAMES */
  19.  
  20. /*
  21.  
  22. User Authentication
  23.  
  24.    HTAA_checkPassword(username,password,passwdfile)opens the password file, and checks if
  25.    the username-password pair is correct. Return value is YES, if and only if they are
  26.    correct. Otherwise, and also if the open fails, returns NO.
  27.    
  28.    If the given password file name is NULL or an empty string, the default password file
  29.    name is used (macro PASSWD_FILE).
  30.    
  31.  */
  32.  
  33. /* PUBLIC                                               HTAA_checkPassword()
  34. **                      VALIDATE A USERNAME-PASSWORD PAIR
  35. ** ON ENTRY:
  36. **      username        is a null-terminated string containing
  37. **                      the client's username.
  38. **      password        is a null-terminated string containing
  39. **                      the client's corresponding password.
  40. **      filename        is a null-terminated absolute filename
  41. **                      for password file.
  42. **                      If NULL or empty, the value of
  43. **                      PASSWD_FILE is used.
  44. ** ON EXIT:
  45. **      returns         YES, if the username-password pair was correct.
  46. **                      NO, otherwise; also, if open fails.
  47. */
  48. PUBLIC BOOL HTAA_checkPassword PARAMS((CONST char * username,
  49.                                        CONST char * password,
  50.                                        CONST char * filename));
  51. /*
  52.  
  53. Password File Maintenance Routines
  54.  
  55.  */
  56.  
  57. /* PUBLIC                                               HTAA_encryptPasswd()
  58. **              ENCRYPT PASSWORD TO THE FORM THAT IT IS SAVED
  59. **              IN THE PASSWORD FILE.
  60. ** ON ENTRY:
  61. **      password        is a string of arbitrary lenght.
  62. **
  63. ** ON EXIT:
  64. **      returns         password in one-way encrypted form.
  65. **
  66. ** NOTE:
  67. **      Uses currently the C library function crypt(), which
  68. **      only accepts at most 8 characters long strings and produces
  69. **      always 13 characters long strings. This function is
  70. **      called repeatedly so that longer strings can be encrypted.
  71. **      This is of course not as safe as encrypting the entire
  72. **      string at once, but then again, we are not that paranoid
  73. **      about the security inside the machine.
  74. **
  75. */
  76. PUBLIC char *HTAA_encryptPasswd PARAMS((CONST char * password));
  77.  
  78.  
  79. /* PUBLIC                                               HTAA_passwdMatch()
  80. **              VERIFY THE CORRECTNESS OF A GIVEN PASSWORD
  81. **              AGAINST A ONE-WAY ENCRYPTED FORM OF PASSWORD.
  82. ** ON ENTRY:
  83. **      password        is cleartext password.
  84. **      encrypted       is one-way encrypted password, as returned
  85. **                      by function HTAA_encryptPasswd().
  86. **                      This is typically read from the password
  87. **                      file.
  88. **
  89. ** ON EXIT:
  90. **      returns         YES, if password matches the encrypted one.
  91. **                      NO, if not, or if either parameter is NULL.
  92. */
  93. PUBLIC BOOL HTAA_passwdMatch PARAMS((CONST char * password,
  94.                                      CONST char * encrypted));
  95.  
  96.  
  97. /* PUBLIC                                               HTAAFile_readPasswdRec()
  98. **                      READ A RECORD FROM THE PASSWORD FILE
  99. ** ON ENTRY:
  100. **      fp              open password file
  101. **      out_username    buffer to put the read username, must be at
  102. **                      least MAX_USERNAME_LEN+1 characters long.
  103. **      out_passwd      buffer to put the read password, must be at
  104. **                      least MAX_PASSWORD_LEN+1 characters long.
  105. ** ON EXIT:
  106. **      returns         EOF on end of file,
  107. **                      otherwise the number of read fields
  108. **                      (i.e. in a correct case returns 2).
  109. **      out_username    contains the null-terminated read username.
  110. **      out_password    contains the null-terminated read password.
  111. **
  112. ** FORMAT OF PASSWORD FILE:
  113. **      username:password:maybe real name or other stuff
  114. **                              (may include even colons)
  115. **
  116. **      There may be whitespace (blanks or tabs) in the beginning and
  117. **      the end of each field. They are ignored.
  118. */
  119. PUBLIC int HTAAFile_readPasswdRec PARAMS((FILE * fp,
  120.                                           char * out_username,
  121.                                           char * out_password));
  122. /*
  123.  
  124.  */
  125.  
  126. #endif /* not HTPASSWD_H */
  127. /*
  128.  
  129.    End of file HTPasswd.h.  */
  130.