Winbind client-side cleanups.
[ira/wip.git] / source3 / nsswitch / pam_winbind.c
1 /* pam_winbind module
2
3    Copyright Andrew Tridgell <tridge@samba.org> 2000
4    Copyright Tim Potter <tpot@samba.org> 2000
5    Copyright Andrew Bartlett <abartlet@samba.org> 2002
6
7    largely based on pam_userdb by Christian Gafton <gafton@redhat.com> 
8    also contains large slabs of code from pam_unix by Elliot Lee <sopwith@redhat.com>
9    (see copyright below for full details)
10 */
11
12 #include "pam_winbind.h"
13
14 /* data tokens */
15
16 #define MAX_PASSWD_TRIES        3
17
18 /* some syslogging */
19 static void _pam_log(int err, const char *format, ...)
20 {
21         va_list args;
22
23         va_start(args, format);
24         openlog(MODULE_NAME, LOG_CONS|LOG_PID, LOG_AUTH);
25         vsyslog(err, format, args);
26         va_end(args);
27         closelog();
28 }
29
30 static int _pam_parse(int argc, const char **argv)
31 {
32         int ctrl;
33         /* step through arguments */
34         for (ctrl = 0; argc-- > 0; ++argv) {
35
36                 /* generic options */
37                 
38                 if (!strcmp(*argv,"debug"))
39                         ctrl |= WINBIND_DEBUG_ARG;
40                 else if (!strcasecmp(*argv, "use_authtok"))
41                         ctrl |= WINBIND_USE_AUTHTOK_ARG;
42                 else if (!strcasecmp(*argv, "use_first_pass"))
43                         ctrl |= WINBIND_USE_FIRST_PASS_ARG;
44                 else if (!strcasecmp(*argv, "try_first_pass"))
45                         ctrl |= WINBIND_TRY_FIRST_PASS_ARG;
46                 else if (!strcasecmp(*argv, "unknown_ok"))
47                         ctrl |= WINBIND_UNKNOWN_OK_ARG;
48                 else {
49                         _pam_log(LOG_ERR, "pam_parse: unknown option; %s", *argv);
50                 }
51         }
52         
53         return ctrl;
54 }
55
56 /* --- authentication management functions --- */
57
58 /* Attempt a conversation */
59
60 static int converse(pam_handle_t *pamh, int nargs,
61                     struct pam_message **message,
62                     struct pam_response **response)
63 {
64     int retval;
65     struct pam_conv *conv;
66
67     retval = pam_get_item(pamh, PAM_CONV, (const void **) &conv ) ;
68     if (retval == PAM_SUCCESS) {
69         retval = conv->conv(nargs, (const struct pam_message **)message,
70                             response, conv->appdata_ptr);
71     }
72         
73     return retval; /* propagate error status */
74 }
75
76
77 static int _make_remark(pam_handle_t * pamh, int type, const char *text)
78 {
79         int retval = PAM_SUCCESS;
80
81         struct pam_message *pmsg[1], msg[1];
82         struct pam_response *resp;
83         
84         pmsg[0] = &msg[0];
85         msg[0].msg = text;
86         msg[0].msg_style = type;
87         
88         resp = NULL;
89         retval = converse(pamh, 1, pmsg, &resp);
90         
91         if (resp) {
92                 _pam_drop_reply(resp, 1);
93         }
94         return retval;
95 }
96
97 static int pam_winbind_request(enum winbindd_cmd req_type,
98                                struct winbindd_request *request,
99                                struct winbindd_response *response)
100 {
101
102         /* Fill in request and send down pipe */
103         init_request(request, req_type);
104         
105         if (write_sock(request, sizeof(*request)) == -1) {
106                 _pam_log(LOG_ERR, "write to socket failed!");
107                 close_sock();
108                 return PAM_SERVICE_ERR;
109         }
110         
111         /* Wait for reply */
112         if (read_reply(response) == -1) {
113                 _pam_log(LOG_ERR, "read from socket failed!");
114                 close_sock();
115                 return PAM_SERVICE_ERR;
116         }
117
118         /* We are done with the socket - close it and avoid mischeif */
119         close_sock();
120
121         /* Copy reply data from socket */
122         if (response->result != WINBINDD_OK) {
123                 if (response->data.auth.pam_error != PAM_SUCCESS) {
124                         _pam_log(LOG_ERR, "request failed, PAM error was %d, NT error was %s", 
125                                  response->data.auth.pam_error,
126                                  response->data.auth.nt_status_string);
127                         return response->data.auth.pam_error;
128                 } else {
129                         _pam_log(LOG_ERR, "request failed, but PAM error 0!");
130                         return PAM_SERVICE_ERR;
131                 }
132         }
133         
134         return PAM_SUCCESS;
135 }
136
137 /* talk to winbindd */
138 static int winbind_auth_request(const char *user, const char *pass, int ctrl)
139 {
140         struct winbindd_request request;
141         struct winbindd_response response;
142         int retval;
143
144         ZERO_STRUCT(request);
145
146         strncpy(request.data.auth.user, user, 
147                 sizeof(request.data.auth.user)-1);
148
149         strncpy(request.data.auth.pass, pass, 
150                 sizeof(request.data.auth.pass)-1);
151         
152         retval = pam_winbind_request(WINBINDD_PAM_AUTH, &request, &response);
153
154         switch (retval) {
155         case PAM_AUTH_ERR:
156                 /* incorrect password */
157                 _pam_log(LOG_WARNING, "user `%s' denied access (incorrect password)", user);
158                 return retval;
159         case PAM_ACCT_EXPIRED:
160                 /* account expired */
161                 _pam_log(LOG_WARNING, "user `%s' account expired", user);
162                 return retval;
163         case PAM_AUTHTOK_EXPIRED:
164                 /* password expired */
165                 _pam_log(LOG_WARNING, "user `%s' password expired", user);
166                 return retval;
167         case PAM_NEW_AUTHTOK_REQD:
168                 /* password expired */
169                 _pam_log(LOG_WARNING, "user `%s' new password required", user);
170                 return retval;
171         case PAM_USER_UNKNOWN:
172                 /* the user does not exist */
173                 if (ctrl & WINBIND_DEBUG_ARG)
174                         _pam_log(LOG_NOTICE, "user `%s' not found",
175                                  user);
176                 if (ctrl & WINBIND_UNKNOWN_OK_ARG) {
177                         return PAM_IGNORE;
178                 }        
179                 return retval;
180         case PAM_SUCCESS:
181                 /* Otherwise, the authentication looked good */
182                 _pam_log(LOG_NOTICE, "user '%s' granted acces", user);
183                 return retval;
184         default:
185                 /* we don't know anything about this return value */
186                 _pam_log(LOG_ERR, "internal module error (retval = %d, user = `%s'",
187                          retval, user);
188                 return retval;
189         }
190      /* should not be reached */
191 }
192
193 /* talk to winbindd */
194 static int winbind_chauthtok_request(const char *user, const char *oldpass,
195                                      const char *newpass)
196 {
197         struct winbindd_request request;
198         struct winbindd_response response;
199
200         ZERO_STRUCT(request);
201
202         if (request.data.chauthtok.user == NULL) return -2;
203
204         strncpy(request.data.chauthtok.user, user, 
205                 sizeof(request.data.chauthtok.user) - 1);
206
207         if (oldpass != NULL) {
208             strncpy(request.data.chauthtok.oldpass, oldpass, 
209                     sizeof(request.data.chauthtok.oldpass) - 1);
210         } else {
211             request.data.chauthtok.oldpass[0] = '\0';
212         }
213         
214         if (newpass != NULL) {
215             strncpy(request.data.chauthtok.newpass, newpass, 
216                     sizeof(request.data.chauthtok.newpass) - 1);
217         } else {
218             request.data.chauthtok.newpass[0] = '\0';
219         }
220         
221         return pam_winbind_request(WINBINDD_PAM_CHAUTHTOK, &request, &response);
222 }
223
224 /*
225  * Checks if a user has an account
226  *
227  * return values:
228  *       1  = User not found
229  *       0  = OK
230  *      -1  = System error
231  */
232 static int valid_user(const char *user)
233 {
234         if (getpwnam(user)) return 0;
235         return 1;
236 }
237
238 static char *_pam_delete(register char *xx)
239 {
240     _pam_overwrite(xx);
241     _pam_drop(xx);
242     return NULL;
243 }
244
245 /*
246  * obtain a password from the user
247  */
248
249 static int _winbind_read_password(pam_handle_t * pamh
250                                   ,unsigned int ctrl
251                                   ,const char *comment
252                                   ,const char *prompt1
253                                   ,const char *prompt2
254                                   ,const char **pass)
255 {
256         int authtok_flag;
257         int retval;
258         const char *item;
259         char *token;
260
261         /*
262          * make sure nothing inappropriate gets returned
263          */
264
265         *pass = token = NULL;
266
267         /*
268          * which authentication token are we getting?
269          */
270
271         authtok_flag = on(WINBIND__OLD_PASSWORD, ctrl) ? PAM_OLDAUTHTOK : PAM_AUTHTOK;
272
273         /*
274          * should we obtain the password from a PAM item ?
275          */
276
277         if (on(WINBIND_TRY_FIRST_PASS_ARG, ctrl) || on(WINBIND_USE_FIRST_PASS_ARG, ctrl)) {
278                 retval = pam_get_item(pamh, authtok_flag, (const void **) &item);
279                 if (retval != PAM_SUCCESS) {
280                         /* very strange. */
281                         _pam_log(LOG_ALERT, 
282                                  "pam_get_item returned error to unix-read-password"
283                             );
284                         return retval;
285                 } else if (item != NULL) {      /* we have a password! */
286                         *pass = item;
287                         item = NULL;
288                         return PAM_SUCCESS;
289                 } else if (on(WINBIND_USE_FIRST_PASS_ARG, ctrl)) {
290                         return PAM_AUTHTOK_RECOVER_ERR;         /* didn't work */
291                 } else if (on(WINBIND_USE_AUTHTOK_ARG, ctrl)
292                            && off(WINBIND__OLD_PASSWORD, ctrl)) {
293                         return PAM_AUTHTOK_RECOVER_ERR;
294                 }
295         }
296         /*
297          * getting here implies we will have to get the password from the
298          * user directly.
299          */
300
301         {
302                 struct pam_message msg[3], *pmsg[3];
303                 struct pam_response *resp;
304                 int i, replies;
305
306                 /* prepare to converse */
307
308                 if (comment != NULL) {
309                         pmsg[0] = &msg[0];
310                         msg[0].msg_style = PAM_TEXT_INFO;
311                         msg[0].msg = comment;
312                         i = 1;
313                 } else {
314                         i = 0;
315                 }
316
317                 pmsg[i] = &msg[i];
318                 msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
319                 msg[i++].msg = prompt1;
320                 replies = 1;
321
322                 if (prompt2 != NULL) {
323                         pmsg[i] = &msg[i];
324                         msg[i].msg_style = PAM_PROMPT_ECHO_OFF;
325                         msg[i++].msg = prompt2;
326                         ++replies;
327                 }
328                 /* so call the conversation expecting i responses */
329                 resp = NULL;
330                 retval = converse(pamh, i, pmsg, &resp);
331
332                 if (resp != NULL) {
333
334                         /* interpret the response */
335
336                         if (retval == PAM_SUCCESS) {    /* a good conversation */
337
338                                 token = x_strdup(resp[i - replies].resp);
339                                 if (token != NULL) {
340                                         if (replies == 2) {
341
342                                                 /* verify that password entered correctly */
343                                                 if (!resp[i - 1].resp
344                                                     || strcmp(token, resp[i - 1].resp)) {
345                                                         _pam_delete(token);     /* mistyped */
346                                                         retval = PAM_AUTHTOK_RECOVER_ERR;
347                                                         _make_remark(pamh                                                                   ,PAM_ERROR_MSG, MISTYPED_PASS);
348                                                 }
349                                         }
350                                 } else {
351                                         _pam_log(LOG_NOTICE
352                                                  ,"could not recover authentication token");
353                                 }
354
355                         }
356                         /*
357                          * tidy up the conversation (resp_retcode) is ignored
358                          * -- what is it for anyway? AGM
359                          */
360
361                         _pam_drop_reply(resp, i);
362
363                 } else {
364                         retval = (retval == PAM_SUCCESS)
365                             ? PAM_AUTHTOK_RECOVER_ERR : retval;
366                 }
367         }
368
369         if (retval != PAM_SUCCESS) {
370                 if (on(WINBIND_DEBUG_ARG, ctrl))
371                         _pam_log(LOG_DEBUG,
372                                  "unable to obtain a password");
373                 return retval;
374         }
375         /* 'token' is the entered password */
376
377         /* we store this password as an item */
378         
379         retval = pam_set_item(pamh, authtok_flag, token);
380         _pam_delete(token);     /* clean it up */
381         if (retval != PAM_SUCCESS
382             || (retval = pam_get_item(pamh, authtok_flag
383                                       ,(const void **) &item))
384             != PAM_SUCCESS) {
385                 
386                 _pam_log(LOG_CRIT, "error manipulating password");
387                 return retval;
388                 
389         }
390
391         *pass = item;
392         item = NULL;            /* break link to password */
393
394         return PAM_SUCCESS;
395 }
396
397 PAM_EXTERN
398 int pam_sm_authenticate(pam_handle_t *pamh, int flags,
399                         int argc, const char **argv)
400 {
401      const char *username;
402      const char *password;
403      int retval = PAM_AUTH_ERR;
404     
405      /* parse arguments */
406      int ctrl = _pam_parse(argc, argv);
407
408      /* Get the username */
409      retval = pam_get_user(pamh, &username, NULL);
410      if ((retval != PAM_SUCCESS) || (!username)) {
411         if (ctrl & WINBIND_DEBUG_ARG)
412             _pam_log(LOG_DEBUG,"can not get the username");
413         return PAM_SERVICE_ERR;
414      }
415      
416      retval = _winbind_read_password(pamh, ctrl, NULL, 
417                                      "Password: ", NULL,
418                                      &password);
419      
420      if (retval != PAM_SUCCESS) {
421          _pam_log(LOG_ERR, "Could not retrieve user's password");
422          return PAM_AUTHTOK_ERR;
423      }
424      
425      if (ctrl & WINBIND_DEBUG_ARG) {
426
427              /* Let's not give too much away in the log file */
428
429 #ifdef DEBUG_PASSWORD
430          _pam_log(LOG_INFO, "Verify user `%s' with password `%s'",
431                   username, password);
432 #else
433          _pam_log(LOG_INFO, "Verify user `%s'", username);
434 #endif
435      }
436
437      /* Now use the username to look up password */
438      return winbind_auth_request(username, password, ctrl);
439 }
440
441 PAM_EXTERN
442 int pam_sm_setcred(pam_handle_t *pamh, int flags,
443                    int argc, const char **argv)
444 {
445     return PAM_SUCCESS;
446 }
447
448 /*
449  * Account management. We want to verify that the account exists 
450  * before returning PAM_SUCCESS
451  */
452 PAM_EXTERN
453 int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags,
454                    int argc, const char **argv)
455 {
456     const char *username;
457     int retval = PAM_USER_UNKNOWN;
458
459     /* parse arguments */
460     int ctrl = _pam_parse(argc, argv);
461
462     /* Get the username */
463     retval = pam_get_user(pamh, &username, NULL);
464     if ((retval != PAM_SUCCESS) || (!username)) {
465         if (ctrl & WINBIND_DEBUG_ARG)
466             _pam_log(LOG_DEBUG,"can not get the username");
467         return PAM_SERVICE_ERR;
468     }
469
470     /* Verify the username */
471     retval = valid_user(username);
472     switch (retval) {
473         case -1:
474             /* some sort of system error. The log was already printed */
475             return PAM_SERVICE_ERR;
476         case 1:
477             /* the user does not exist */
478             if (ctrl & WINBIND_DEBUG_ARG)
479                 _pam_log(LOG_NOTICE, "user `%s' not found",
480                          username);
481             if (ctrl & WINBIND_UNKNOWN_OK_ARG)
482                 return PAM_IGNORE;
483             return PAM_USER_UNKNOWN;
484         case 0:
485             /* Otherwise, the authentication looked good */
486             _pam_log(LOG_NOTICE, "user '%s' granted acces", username);
487             return PAM_SUCCESS;
488         default:
489             /* we don't know anything about this return value */
490             _pam_log(LOG_ERR, "internal module error (retval = %d, user = `%s'",
491                      retval, username);
492             return PAM_SERVICE_ERR;
493     }
494     
495     /* should not be reached */
496     return PAM_IGNORE;
497 }
498 PAM_EXTERN
499 int pam_sm_open_session(pam_handle_t *pamh, int flags,
500                 int argc, const char **argv)
501 {
502         /* parse arguments */
503         int ctrl = _pam_parse(argc, argv);
504         if (ctrl & WINBIND_DEBUG_ARG)
505               _pam_log(LOG_DEBUG,"libpam_winbind:pam_sm_open_session handler");
506         return PAM_SUCCESS;
507 }
508 PAM_EXTERN
509 int pam_sm_close_session(pam_handle_t *pamh, int flags,
510                 int argc, const char **argv)
511 {
512         /* parse arguments */
513         int ctrl = _pam_parse(argc, argv);
514         if (ctrl & WINBIND_DEBUG_ARG)
515               _pam_log(LOG_DEBUG,"libpam_winbind:pam_sm_close_session handler");
516         return PAM_SUCCESS;
517 }
518
519
520
521 PAM_EXTERN int pam_sm_chauthtok(pam_handle_t * pamh, int flags,
522                                 int argc, const char **argv)
523 {
524         unsigned int lctrl;
525         int retval;
526         unsigned int ctrl = _pam_parse(argc, argv);
527
528         /* <DO NOT free() THESE> */
529         const char *user;
530         char *pass_old, *pass_new;
531         /* </DO NOT free() THESE> */
532
533         char *Announce;
534         
535         int retry = 0;
536
537         /*
538          * First get the name of a user
539          */
540         retval = pam_get_user(pamh, &user, "Username: ");
541         if (retval == PAM_SUCCESS) {
542                 if (user == NULL) {
543                         _pam_log(LOG_ERR, "username was NULL!");
544                         return PAM_USER_UNKNOWN;
545                 }
546                 if (retval == PAM_SUCCESS && on(WINBIND_DEBUG_ARG, ctrl))
547                         _pam_log(LOG_DEBUG, "username [%s] obtained",
548                                  user);
549         } else {
550                 if (on(WINBIND_DEBUG_ARG, ctrl))
551                         _pam_log(LOG_DEBUG,
552                                  "password - could not identify user");
553                 return retval;
554         }
555
556         /*
557          * obtain and verify the current password (OLDAUTHTOK) for
558          * the user.
559          */
560
561         if (flags & PAM_PRELIM_CHECK) {
562                 
563                 /* instruct user what is happening */
564 #define greeting "Changing password for "
565                 Announce = (char *) malloc(sizeof(greeting) + strlen(user));
566                 if (Announce == NULL) {
567                 _pam_log(LOG_CRIT, 
568                          "password - out of memory");
569                 return PAM_BUF_ERR;
570                 }
571                 (void) strcpy(Announce, greeting);
572                 (void) strcpy(Announce + sizeof(greeting) - 1, user);
573 #undef greeting
574                 
575                 lctrl = ctrl | WINBIND__OLD_PASSWORD;
576                 retval = _winbind_read_password(pamh, lctrl
577                                                 ,Announce
578                                                 ,"(current) NT password: "
579                                                 ,NULL
580                                                 ,(const char **) &pass_old);
581                 free(Announce);
582                 
583                 if (retval != PAM_SUCCESS) {
584                         _pam_log(LOG_NOTICE
585                                  ,"password - (old) token not obtained");
586                         return retval;
587                 }
588                 /* verify that this is the password for this user */
589                 
590                 retval = winbind_auth_request(user, pass_old, ctrl);
591                 
592                 if (retval != PAM_ACCT_EXPIRED 
593                     && retval != PAM_AUTHTOK_EXPIRED
594                     && retval != PAM_NEW_AUTHTOK_REQD 
595                     && retval != PAM_SUCCESS) {
596                         pass_old = NULL;
597                         return retval;
598                 }
599                 
600                 retval = pam_set_item(pamh, PAM_OLDAUTHTOK, (const void *) pass_old);
601                 pass_old = NULL;
602                 if (retval != PAM_SUCCESS) {
603                         _pam_log(LOG_CRIT, 
604                                  "failed to set PAM_OLDAUTHTOK");
605                 }
606         } else if (flags & PAM_UPDATE_AUTHTOK) {
607         
608                 /*
609                  * obtain the proposed password
610                  */
611                 
612                 /*
613                  * get the old token back. 
614                  */
615                 
616                 retval = pam_get_item(pamh, PAM_OLDAUTHTOK
617                                       ,(const void **) &pass_old);
618                 
619                 if (retval != PAM_SUCCESS) {
620                         _pam_log(LOG_NOTICE, "user not authenticated");
621                         return retval;
622                 }
623                 
624                 lctrl = ctrl;
625                 
626                 if (on(WINBIND_USE_AUTHTOK_ARG, lctrl)) {
627                         ctrl = WINBIND_USE_FIRST_PASS_ARG | lctrl;
628                 }
629                 retry = 0;
630                 retval = PAM_AUTHTOK_ERR;
631                 while ((retval != PAM_SUCCESS) && (retry++ < MAX_PASSWD_TRIES)) {
632                         /*
633                          * use_authtok is to force the use of a previously entered
634                          * password -- needed for pluggable password strength checking
635                          */
636                         
637                         retval = _winbind_read_password(pamh, lctrl
638                                                         ,NULL
639                                                         ,"Enter new NT password: "
640                                                         ,"Retype new NT password: "
641                                                         ,(const char **) &pass_new);
642                         
643                         if (retval != PAM_SUCCESS) {
644                                 if (on(WINBIND_DEBUG_ARG, ctrl)) {
645                                         _pam_log(LOG_ALERT
646                                                  ,"password - new password not obtained");
647                                 }
648                                 pass_old = NULL;/* tidy up */
649                                 return retval;
650                         }
651
652                         /*
653                          * At this point we know who the user is and what they
654                          * propose as their new password. Verify that the new
655                          * password is acceptable.
656                          */
657                         
658                         if (pass_new[0] == '\0') {/* "\0" password = NULL */
659                                 pass_new = NULL;
660                         }
661                 }
662                 
663                 /*
664                  * By reaching here we have approved the passwords and must now
665                  * rebuild the password database file.
666                  */
667
668                 retval = winbind_chauthtok_request(user, pass_old, pass_new);
669                 _pam_overwrite(pass_new);
670                 _pam_overwrite(pass_old);
671                 pass_old = pass_new = NULL;
672         } else {
673                 retval = PAM_SERVICE_ERR;
674         }
675         
676         return retval;
677 }
678
679 #ifdef PAM_STATIC
680
681 /* static module data */
682
683 struct pam_module _pam_winbind_modstruct = {
684      MODULE_NAME,
685      pam_sm_authenticate,
686      pam_sm_setcred,
687      pam_sm_acct_mgmt,
688      pam_sm_open_session,
689      pam_sm_close_session,
690      pam_sm_chauthtok
691 };
692
693 #endif
694
695 /*
696  * Copyright (c) Andrew Tridgell  <tridge@samba.org>   2000
697  * Copyright (c) Tim Potter       <tpot@samba.org>     2000
698  * Copyright (c) Andrew Bartlettt <abartlet@samba.org> 2002
699  * Copyright (c) Jan Rêkorajski 1999.
700  * Copyright (c) Andrew G. Morgan 1996-8.
701  * Copyright (c) Alex O. Yuriev, 1996.
702  * Copyright (c) Cristian Gafton 1996.
703  * Copyright (C) Elliot Lee <sopwith@redhat.com> 1996, Red Hat Software. 
704  *
705  * Redistribution and use in source and binary forms, with or without
706  * modification, are permitted provided that the following conditions
707  * are met:
708  * 1. Redistributions of source code must retain the above copyright
709  *    notice, and the entire permission notice in its entirety,
710  *    including the disclaimer of warranties.
711  * 2. Redistributions in binary form must reproduce the above copyright
712  *    notice, this list of conditions and the following disclaimer in the
713  *    documentation and/or other materials provided with the distribution.
714  * 3. The name of the author may not be used to endorse or promote
715  *    products derived from this software without specific prior
716  *    written permission.
717  *
718  * ALTERNATIVELY, this product may be distributed under the terms of
719  * the GNU Public License, in which case the provisions of the GPL are
720  * required INSTEAD OF the above restrictions.  (This clause is
721  * necessary due to a potential bad interaction between the GPL and
722  * the restrictions contained in a BSD-style copyright.)
723  *
724  * THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED
725  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
726  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
727  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
728  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
729  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
730  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
731  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
732  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
733  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
734  * OF THE POSSIBILITY OF SUCH DAMAGE.
735  */