Libht will optionally deal with keeping track of users for you. This is done by keeping a database of current users using either DBM or MSQL. All passwords are encrypted using crypt(3), and a session identifier is created. After connecting up to the login database (hinitlogin), you can log users in by calling hlogin() which returns an hrec containing amongst other things, the session identifier sessid. The session id needs to be bound to each form by placing the following in each form:<input name=sessid value="" type=hidden>The login database itself current looks like this:There is a control program for purging and examining the login database. See the documentation for hloginctl
- sessid: the session identifier, a text string
- user: the login name of the user
- pwd: the user's encrypted password
- facility: the facility that logged this user in
- timeout: the expiration date of this record
- host: the machine the user logged on from
- hits: the number of accesses this record has generated.
- int hinitlogin (char * server, char * facility, char * seed, int deftmo)
- hrec * hlogin (char * uname, char * pwd, char * encpwd)
- hrec * hvrfysession (hrec * in, char * user)
- hrec * hnewlogin (char * uname, char * pwd, char * pwd2, char * pencpwd)
- hrec * hadminlogin (char * uname, char * pwd, char * admin)
- int hpwdfile (char * file, char * user, char * pwd)
- void hloginbindall (hrec * in)
- int hloginpurge (int all)
- hrec * newloginrec ()
- int hinitlogin (char * server, char * facility, char * seed, int deftmo)
- Initialize the login database manager. Facility is a name identifying your program(s). Seed is used for crypt; yes this should be handled internally. Deftmo is the number of seconds that a login record is active.
- hrec * hlogin (char * uname, char * pwd, char * encpwd)
- This is the main function for creating a new session. Pass their username, typed in password, and the encrypted password to check against. The return value is an hrec with the various fields, the most important is "sessid", the session id which should be bound in each of the forms which are logged in with this userid.
- hrec * hvrfysession (hrec * in, char * user)
- hvrfysession takes the incoming record (generally from a POST or GET) and verifies it with the login database. Optionally, a user can be specified for tighter checking, though the host machine, facility, and timeout are still checked.
- hrec * hnewlogin (char * uname, char * pwd, char * pwd2, char * pencpwd)
- hnewlogin allows on the fly account creation. If the user types their password in twice, a new login record is created. This only creates login information for the user, of course. Storing that password for later logins is under the control of the program which handles the user database (a-doy!).
- hrec * hadminlogin (char * uname, char * pwd, char * admin)
- hadminlogin allows for an administrative backdoor or, really, a group password facility. The admin password is stored in crypt(3) format like usual.
- int hpwdfile (char * file, char * user, char * pwd)
- parse a password file like in /etc/passwd, and return the encrypted password of the specified user. Since hpwdfile doesn't consider fields beyond the user name and encrypted password, a normal password file can be used.
- void hloginbindall (hrec * in)
- A convenience function which binds the session id to all of the forms on the current page.
© (copyright) 1997 MTCC Last modified: Fri Apr 25 20:16:39 PDT 1997