]> eyrie.org Git - kerberos/krb5-strength.git/blob - tools/heimdal-history
1309e90c6dbb7de92c31f0ab444561f4c7128b6f
[kerberos/krb5-strength.git] / tools / heimdal-history
1 #!/usr/bin/perl
2 #
3 # Password history via Heimdal external strength checking.
4 #
5 # This script is meant to be called via the Heimdal external password strength
6 # checking interface and maintains per-user password history that also rejects
7 # one-character permutations.  Password history is stored as Crypt::PBKDF2
8 # hashes with random salt for each password.
9 #
10 # Written by Russ Allbery <eagle@eyrie.org>
11 # Copyright 2013, 2014
12 #     The Board of Trustees of the Leland Stanford Junior University
13
14 ##############################################################################
15 # Declarations and configuration
16 ##############################################################################
17
18 require 5.010;
19 use autodie;
20 use strict;
21 use warnings;
22
23 use DB_File::Lock;
24 use Crypt::PBKDF2;
25 use Fcntl qw(O_CREAT O_RDWR);
26 use File::Basename qw(basename);
27 use Getopt::Long::Descriptive qw(describe_options);
28 use IPC::Run qw(run);
29 use JSON qw(encode_json decode_json);
30 use POSIX qw(setgid setuid);
31 use Readonly;
32 use Sys::Syslog qw(openlog syslog LOG_AUTH LOG_INFO LOG_WARNING);
33
34 # The most convenient interface to Berkeley DB files is ties.
35 ## no critic (Miscellanea::ProhibitTies)
36
37 # The number of PBKDF2 iterations to use when hashing passwords.  This number
38 # should be chosen so as to force the hash operation to take approximately 0.1
39 # seconds on current hardware.
40 Readonly my $HASH_ITERATIONS => 65536;
41
42 # Path to the history database.  Currently, this must be a Berkeley DB file in
43 # the old DB_HASH format.  Keys will be principal names, and values will be a
44 # JSON array of hashes.  Each hash will have two keys: timestamp, which holds
45 # the seconds since UNIX epoch at which the history entry was stored, and
46 # hash, which holds the Crypt::PBKDF2 LDAP-style password hash.
47 Readonly my $HISTORY_PATH => '/var/lib/heimdal-history/history.db';
48
49 # User and group used to do all password history lookups and writes, assuming
50 # that this program is invoked as root and can therefore change UID and GID.
51 Readonly my $HISTORY_USER  => '_history';
52 Readonly my $HISTORY_GROUP => '_history';
53
54 # Path to the Berkeley DB file (DB_HASH format) that stores statistics on
55 # password length of accepted passwords.  Each successful password validation
56 # will increase the counter for that length.  This is read and written with
57 # $HISTORY_USER and $HISTORY_GROUP.
58 Readonly my $LENGTH_STATS_PATH => '/var/lib/heimdal-history/lengths.db';
59
60 # The message to return to the user if we reject the password because it was
61 # found in the user's history.
62 Readonly my $REJECT_MESSAGE => 'password was previously used';
63
64 # The path to the external strength checking program to run.  This is done
65 # first before checking history, and if it fails, that failure is returned as
66 # the failure for this program.
67 Readonly my $STRENGTH_PROGRAM => '/usr/bin/heimdal-strength';
68
69 # User and group used to do password strength checking.  Generally, this
70 # doesn't require any privileges since the strength dictionary is
71 # world-readable.
72 Readonly my $STRENGTH_USER  => 'nobody';
73 Readonly my $STRENGTH_GROUP => 'nogroup';
74
75 ##############################################################################
76 # Utility functions
77 ##############################################################################
78
79 # Change real and effective UID and GID to those for the given user and group.
80 # Does nothing if not running as root.
81 #
82 # $user  - User to change the UID to
83 # $group - Group to change the GID to (and clear all supplemental groups)
84 #
85 # Returns: undef
86 #  Throws: Text exception on any failure
87 sub drop_privileges {
88     my ($user, $group) = @_;
89
90     # If running as root, drop privileges.  Fail if we can't get the UID and
91     # GID corresponding to our users.
92     if ($> == 0 || $< == 0) {
93         my $uid = getpwnam($user)
94           or die "$0: cannot get UID for $user\n";
95         my $gid = getgrnam($group)
96           or die "$0: cannot get GID for $group\n";
97         setgid($gid) or die "$0: cannot setgid to $gid: $!\n";
98         setuid($uid) or die "$0: cannot setuid to $uid: $!\n";
99         if ($> == 0 || $< == 0) {
100             die "$0: failed to drop permissions\n";
101         }
102     }
103     return;
104 }
105
106 ##############################################################################
107 # Logging
108 ##############################################################################
109
110 # Given a list of keys and values for a log message as a hash reference,
111 # return in encoded format following our logging protocol.  The log format is
112 # a set of <key>=<value> parameters separated by a space.  Values containing
113 # whitespace are quoted with double quotes, with any internal double quotes
114 # doubled.
115 #
116 # Here also is defined a custom sort order for the encoded key/value pairs to
117 # keep them in a reasonable order for a human to read.
118 #
119 # $params_ref - Reference to a hash of key/value pairs
120 #
121 # Returns: The encoded format as a string
122 sub encode_log_message {
123     my ($params_ref) = @_;
124
125     # Define the custom sort order for keys.
126     my $order = 1;
127     my %order
128       = map { $_ => $order++ } qw(action principal error result reason);
129
130     # Build the message from the parameters.
131     my $message;
132     for my $key (sort { $order{$a} <=> $order{$b} } keys %{$params_ref}) {
133         my $value = $params_ref->{$key};
134         $value =~ s{ \" }{\"\"}xmsg;
135         if ($value =~ m{ [ \"] }xms) {
136             $value = qq{"$value"};
137         }
138         $message .= qq{$key=$value };
139     }
140     chomp($message);
141     return $message;
142 }
143
144 # Log a non-fatal error encountered while trying to check or store password
145 # history.  This is used for errors where the password is accepted, but we ran
146 # into some anomalous event such as corrupted history data that should be
147 # drawn to the attention of an administrator.  The log format is a set of
148 # <key>=<value> parameters, with the following keys:
149 #
150 # - action:    the action performed (currently always "check")
151 # - principal: the principal to check a password for
152 # - error:     an error message explaining the anomalous situation
153 #
154 # Values containing whitespace are quoted with double quotes, with any
155 # internal double quotes doubled.
156 #
157 # $principal - Principal for which we checked a password
158 # $error     - The error message
159 #
160 # Returns: undef
161 sub log_error {
162     my ($principal, $error) = @_;
163     my $message = encode_log_message(
164         action    => 'check',
165         principal => $principal,
166         error     => $error,
167     );
168     syslog(LOG_WARNING, '%s', $message);
169     return;
170 }
171
172 # Log the disposition of a particular password strength checking request.  All
173 # log messages are logged through syslog at class info.  The log format is a
174 # set of <key>=<value> parameters, with the following keys:
175 #
176 # - action:    the action performed (currently always "check")
177 # - principal: the principal to check a password for
178 # - result:    either "accepted" or "rejected"
179 # - reason:    the reason for a rejection
180 #
181 # Values containing whitespace are quoted with double quotes, with any
182 # internal double quotes doubled.
183 #
184 # $principal - Principal for which we checked a password
185 # $result    - "accepted" or "rejected" per above
186 # $reason    - On rejection, the reason
187 #
188 # Returns: undef
189 sub log_result {
190     my ($principal, $result, $reason) = @_;
191
192     # Create the message.
193     my %message = (
194         action    => 'check',
195         principal => $principal,
196         result    => $result,
197     );
198     if ($result eq 'rejected' && defined($reason)) {
199         $message{reason} = $reason;
200     }
201     my $message = encode_log_message(\%message);
202
203     # Log the message.
204     syslog(LOG_INFO, '%s', $message);
205     return;
206 }
207
208 ##############################################################################
209 # Crypto
210 ##############################################################################
211
212 # Given a password, return the hash for that password.  Hashing is done with
213 # PBKDF2 using SHA-2 as the underlying hash function.  As of version 0.133330,
214 # this uses SHA-256.
215 #
216 # $password - Password to hash
217 #
218 # Returns: Hash encoded in the LDAP-compatible Crypt::PBKDF2 format
219 sub password_hash {
220     my ($password) = @_;
221     my $hasher = Crypt::PBKDF2->new(
222         hash_class => 'HMACSHA2',
223         iterations => $HASH_ITERATIONS,
224     );
225     return $hasher->generate($password);
226 }
227
228 # Given a password and the password history for the user as a reference to a
229 # array, check whether that password is found in the history.  The history
230 # array is expected to contain anonymous hashes.  The only key of interest is
231 # the "hash" key, whose value is expected to be a hash in the LDAP-compatible
232 # Crypt::PBKDF2 format.
233 #
234 # Invalid history entries are ignored for the purposes of this check and
235 # treated as if the entry did not exist.
236 #
237 # $principal   - Principal to check (solely for logging purposes)
238 # $password    - Password to check
239 # $history_ref - Reference to array of anonymous hashes with "hash" keys
240 #
241 # Returns: True if the password matches one of the history hashes, false
242 #          otherwise
243 sub is_in_history {
244     my ($principal, $password, $history_ref) = @_;
245     my $hasher = Crypt::PBKDF2->new(hash_class => 'HMACSHA2');
246
247     # Walk the history looking at each hash key.
248     for my $entry (@{$history_ref}) {
249         my $hash = $entry->{hash};
250         next if !defined($hash);
251
252         # validate throws an exception if the hash is in an invalid format.
253         # Treat that case the same as a miss, but log it.
254         if (eval { $hasher->validate($hash, $password) }) {
255             return 1;
256         } elsif ($@) {
257             log_error($principal, "hash validate failed: $@");
258         }
259     }
260
261     # No match.
262     return;
263 }
264
265 ##############################################################################
266 # Database
267 ##############################################################################
268
269 # Given a principal and a password, determine whether the password was found
270 # in the password history for that user.
271 #
272 # $path      - Path to the history file
273 # $principal - Principal for which to check history
274 # $password  - Check history for this password
275 #
276 # Returns: True if $password is found in history, false otherwise
277 #  Throws: On failure to open, lock, or tie the database
278 sub check_history {
279     my ($path, $principal, $password) = @_;
280
281     # Open and lock the database and retrieve the history for the user.
282     # We have to lock for write so that we can create the database if it
283     # doesn't already exist.  Password change should be infrequent enough
284     # and our window is fast enough that it shouldn't matter.  We do this
285     # in a separate scope so that the history hash goes out of scope and
286     # is freed and unlocked.
287     my $history_json;
288     {
289         my %history;
290         my $mode = O_CREAT | O_RDWR;
291         tie(%history, 'DB_File::Lock', [$path, $mode, oct(600)], 'write')
292           or die "$0: cannot open $path: $!\n";
293         $history_json = $history{$principal};
294     }
295
296     # If there is no history for the user, return the trivial false.
297     if (!defined($history_json)) {
298         return;
299     }
300
301     # Decode history from JSON.  If this fails (corrupt history), treat it as
302     # if the user has no history, but log the error message.
303     my $history_ref = eval { decode_json($history_json) };
304     if (!defined($history_ref)) {
305         log_error($principal, "history JSON decoding failed: $@");
306         return;
307     }
308
309     # Finally, check the password against the hashes in history.
310     return is_in_history($principal, $password, $history_ref);
311 }
312
313 # Write a new history entry to the database given the principal and the
314 # password to record.  History records are stored as JSON arrays of objects,
315 # with keys "timestamp" and "hash".
316 #
317 # $path      - Path to the history file
318 # $principal - Principal for which to check history
319 # $password  - Check history for this password
320 #
321 # Returns: undef
322 #  Throws: On failure to open, lock, or tie the database
323 sub write_history {
324     my ($path, $principal, $password) = @_;
325
326     # Open and lock the database for write.
327     my %history;
328     my $mode = O_CREAT | O_RDWR;
329     tie(%history, 'DB_File::Lock', [$path, $mode, oct(600)], 'write')
330       or die "$0: cannot open $path: $!\n";
331
332     # Read the existing history.  If the existing history is corrupt, treat
333     # that as equivalent to not having any history, but log an error.
334     my $history_json = $history{$principal};
335     my $history_ref;
336     if (defined($history_json)) {
337         $history_ref = eval { decode_json($history_json) };
338         if ($@) {
339             log_error($principal, "history JSON decoding failed: $@");
340         }
341     }
342     if (!defined($history_ref)) {
343         $history_ref = [];
344     }
345
346     # Add a new history entry.
347     my $entry = { timestamp => time(), hash => password_hash($password) };
348     unshift(@{$history_ref}, $entry);
349
350     # Store the encoded data back in the history database.
351     $history{$principal} = encode_json($history_ref);
352
353     # The database is closed and unlocked when %history goes out of scope.
354     # Unfortunately, we lose on error detection here, since there doesn't
355     # appear to be a way to determine whether all the writes succeeded.  But
356     # losing a bit of history in the rare error case of failing to write to
357     # local disk is probably not a big deal.
358     return;
359 }
360
361 # Write statistics about password length.  Given the length of the password
362 # and the path to the length statistics database, increments the counter for
363 # that password length.
364 #
365 # Any failure to open or write to the database is ignored, since this is
366 # considered optional logging and should not block the password change.
367 #
368 # $path   - Path to the length statistics file
369 # $length - Length of the accepted password
370 #
371 # Returns: undef
372 sub update_length_counts {
373     my ($path, $length) = @_;
374
375     # Open and lock the database for write.
376     my %lengths;
377     my $mode = O_CREAT | O_RDWR;
378     tie(%lengths, 'DB_File::Lock', [$path, $mode, oct(600)], 'write')
379       or return;
380
381     # Write each of the hashes.
382     $lengths{$length}++;
383
384     # The database is closed and unlocked when %lengths goes out of scope.
385     return;
386 }
387
388 ##############################################################################
389 # Heimdal password strength protocol
390 ##############################################################################
391
392 # Run another external password strength checker and return the results.  This
393 # allows us to chain to another program that handles the actual strength
394 # checking prior to handling history.
395 #
396 # $principal - Principal attempting to change their password
397 # $password  - The new password
398 #
399 # Returns: Scalar context: true if the password was accepted, false otherwise
400 #          List context: whether the password is okay, the exit status of the
401 #            strength checking program, and the error message if the first
402 #            element is false
403 #  Throws: Text exception on failure to execute the program, or read or write
404 #          from it or to it, or if it fails without an error
405 sub strength_check {
406     my ($principal, $password) = @_;
407
408     # Run the external strength checking program.  If we're root, we'll run it
409     # as the strength checking user and group.
410     my $in = "principal: $principal\nnew-password: $password\nend\n";
411     my $init = sub { drop_privileges($STRENGTH_USER, $STRENGTH_GROUP) };
412     my ($out, $err);
413     run([$STRENGTH_PROGRAM, $principal], \$in, \$out, \$err, init => $init);
414     my $status = ($? >> 8);
415
416     # Check the results.
417     my $okay = ($status == 0 && $out eq "APPROVED\n");
418
419     # If the program failed, collect the error message.
420     if (!$okay) {
421         if ($err) {
422             $err =~ s{ \n .* }{}xms;
423         } else {
424             die "$0: password strength checking failed without an error\n";
425         }
426     }
427
428     # Return the results.
429     return wantarray ? ($okay, $err, $status) : $okay;
430 }
431
432 # Read a Heimdal external password strength checking request from the provided
433 # file handle and return the principal (ignored for our application) and the
434 # password.
435 #
436 # The protocol expects the following data (without leading whitespace) on
437 # standard input, in precisely this order:
438 #
439 #     principal: <principal>
440 #     new-password: <password>
441 #     end
442 #
443 # There is one and only one space after the colon, and any subsequent spaces
444 # are part of the value (such as leading spaces in the password).
445 #
446 # $fh - File handle from which to read
447 #
448 # Returns: Scalar context: the password
449 #          List context: a list of the password and the principal
450 #  Throws: Text exception on any protocol violations or IO errors
451 sub read_change_data {
452     my ($fh) = @_;
453     my @keys = qw(principal new-password);
454     my %data;
455
456     # Read the data elements we expect.  Verify that they come in the correct
457     # order and the correct format.
458     local $/ = "\n";
459     for my $key (@keys) {
460         my $line = readline($fh);
461         if (!defined($line)) {
462             die "$0: truncated input before $key: $!\n";
463         }
464         chomp($line);
465         if ($line =~ s{ \A \Q$key\E : [ ] }{}xms) {
466             $data{$key} = $line;
467         } else {
468             die "$0: unrecognized input line before $key\n";
469         }
470     }
471
472     # The final line of input must be a literal "end\n";
473     my $line = readline($fh);
474     if (!defined($line)) {
475         die "$0: truncated input before end: $!\n";
476     } elsif ($line ne "end\n") {
477         die "$0: unrecognized input line before end\n";
478     }
479
480     # Return the results.
481     my $password  = $data{'new-password'};
482     my $principal = $data{principal};
483     return wantarray ? ($password, $principal) : $password;
484 }
485
486 ##############################################################################
487 # Main routine
488 ##############################################################################
489
490 # Always flush output.
491 STDOUT->autoflush;
492
493 # Clean up the script name for error reporting.
494 my $fullpath = $0;
495 local $0 = basename($0);
496
497 # Parse the argument list.
498 my ($opt, $usage) = describe_options(
499     '%c %o',
500     ['database|d=s', 'Path to the history database, overriding the default'],
501     ['help|h',       'Print usage message and exit'],
502     ['manual|man|m', 'Print full manual and exit'],
503     ['stats|S=s',    'Path to hash of length statistics'],
504     ['strength|s=s', 'Path to strength checking program to run'],
505 );
506 if ($opt->help) {
507     print {*STDOUT} $usage->text
508       or die "$0: cannot write to standard output: $!\n";
509     exit(0);
510 } elsif ($opt->manual) {
511     say {*STDOUT} 'Feeding myself to perldoc, please wait...'
512       or die "$0: cannot write to standard output: $!\n";
513     exec('perldoc', '-t', $fullpath);
514 }
515 my $database = $opt->database || $HISTORY_PATH;
516 my $stats_db = $opt->stats    || $LENGTH_STATS_PATH;
517
518 # Open syslog for result reporting.
519 openlog($0, 'pid', LOG_AUTH);
520
521 # Read the principal and password that we're supposed to check.
522 my ($password, $principal) = read_change_data(\*STDIN);
523
524 # Delegate to the external strength checking program.
525 my ($okay, $error, $status) = strength_check($principal, $password);
526 if (!$okay) {
527     log_result($principal, 'rejected', $error);
528     warn "$error\n";
529     exit($status);
530 }
531
532 # Drop privileges for the rest of the program.
533 drop_privileges($HISTORY_USER, $HISTORY_GROUP);
534
535 # Hash the password and check history.  Exit if a hash is in history.
536 if (check_history($database, $principal, $password)) {
537     log_result($principal, 'rejected', $REJECT_MESSAGE);
538     warn "$REJECT_MESSAGE\n";
539     exit(0);
540 }
541
542 # The password is accepted.  Record it, update the length counter, and return
543 # success.
544 log_result($principal, 'accepted');
545 write_history($database, $principal, $password);
546 say {*STDOUT} 'APPROVED'
547   or die "$0: cannot write to standard output: $!\n";
548 update_length_counts($stats_db, length($password));
549 exit(0);
550
551 __END__
552
553 ##############################################################################
554 # Documentation
555 ##############################################################################
556
557 =for stopwords
558 heimdal-history heimdal-strength Heimdal -hm BerkeleyDB timestamps POSIX
559 whitespace API Allbery sublicense MERCHANTABILITY NONINFRINGEMENT syslog
560 pseudorandom JSON LDAP-compatible PBKDF2 SHA-256
561
562 =head1 NAME
563
564 heimdal-history - Password history via Heimdal external strength checking
565
566 =head1 SYNOPSIS
567
568 B<heimdal-history> [B<-hm>] [B<-d> I<database>] [B<-S> I<length-stats-db>]
569     [B<-s> I<strength-program>] [B<principal>]
570
571 =head1 DESCRIPTION
572
573 B<heimdal-history> is an implementation of password history via the
574 Heimdal external password strength checking interface.  It stores separate
575 history for each principal, hashed using Crypt::PBKDF2 with
576 randomly-generated salt.  (The randomness is from a weak pseudorandom
577 number generator, not strongly random.)
578
579 Password history is stored in a BerkeleyDB DB_HASH file.  The key is the
580 principal.  The value is a JSON array of objects, each of which has two
581 keys.  C<timestamp> contains the time when the history entry was added (in
582 POSIX seconds since UNIX epoch), and C<hash> contains the hash of a
583 previously-used password in the Crypt::PBKDF2 LDAP-compatible format.
584 Passwords are hashed using PBKDF2 (from PKCS#5) with SHA-256 as the
585 underlying hash function using a number of rounds configured in this
586 script.  See L<Crypt::PBKDF2> for more information.
587
588 B<heimdal-history> also checks password strength before checking history.
589 It does so by invoking another program that also uses the Heimdal external
590 password strength checking interface.  By default, it runs
591 B</usr/bin/heimdal-strength>.  Only if that program approves the password
592 does it hash it and check history.
593
594 As with any implementation of the Heimdal external password strength
595 checking protocol, B<heimdal-history> expects, on standard input:
596
597     principal: <principal>
598     new-password: <password>
599     end
600
601 (with no leading whitespace).  <principal> is the principal changing its
602 password (passed to the other password strength checking program but
603 otherwise unused here), and <password> is the new password.  There must
604 be exactly one space after the colon.  Any subsequent spaces are taken to
605 be part of the principal or password.
606
607 If invoked as root, B<heimdal-history> will run the external strength
608 checking program as user C<nobody> and group C<nogroup>, and will check
609 and write to the history database as user C<_history> and group
610 C<_history>.  These users must exist on the system if it is run as root.
611
612 The result of each password check will be logged to syslog (priority
613 LOG_INFO, facility LOG_AUTH).  Each log line will be a set of key/value
614 pairs in the format C<< I<key>=I<value> >>.  The keys are:
615
616 =over 4
617
618 =item action
619
620 The action performed (currently always C<check>).
621
622 =item principal
623
624 The principal for which a password was checked.
625
626 =item error
627
628 An internal error message that did not stop the history check, but which
629 may indicate that something is wrong with the history database (such as
630 corrupted entries or invalid hashes).  If this key is present, neither
631 C<result> nor C<reason> will be present.  There will be a subsequent log
632 message from the same invocation giving the final result of the history
633 check (assuming B<heimdal-history> doesn't exit with a fatal error).
634
635 =item result
636
637 Either C<accepted> or C<rejected>.
638
639 =item reason
640
641 If the password was rejected, the reason for the rejection.
642
643 =back
644
645 The value will be surrounded with double quotes if it contains a double
646 quote or space.  Any double quotes in the value will be doubled, so C<">
647 becomes C<"">.
648
649 =head1 OPTIONS
650
651 =over 4
652
653 =item B<-d> I<database>, B<--database>=I<database>
654
655 Use I<database> as the history database file instead of the default
656 (F</var/lib/heimdal-history/history.db>).  Primarily used for testing,
657 since Heimdal won't pass this argument.
658
659 =item B<-h>, B<--help>
660
661 Print a short usage message and exit.
662
663 =item B<-m>, B<--manual>, B<--man>
664
665 Display this manual and exit.
666
667 =item B<-S> I<length-stats-db>, B<--stats>=I<length-stats-db>
668
669 Use I<length-stats-db> as the database file for password length statistics
670 instead of the default (F</var/lib/heimdal-history/lengths.db>).
671 Primarily used for testing, since Heimdal won't pass this argument.
672
673 =item B<-s> I<strength-program>, B<--strength>=I<strength-program>
674
675 Run I<strength-program> as the external strength-checking program instead
676 of the default (F</usr/bin/heimdal-strength>).  Primarily used for
677 testing, since Heimdal won't pass this argument.
678
679 =back
680
681 =head1 RETURN STATUS
682
683 On approval of the password, B<heimdal-history> will print C<APPROVED> and
684 a newline to standard output and exit with status 0.
685
686 If the password is rejected by the strength checking program or if it (or
687 a version with a single character removed) matches one of the hashes stored
688 in the password history, B<heimdal-history> will print the reason for
689 rejection to standard error and exit with status 0.
690
691 On any internal error, B<heimdal-history> will print the error to standard
692 error and exit with a non-zero status.
693
694 =head1 FILES
695
696 =over 4
697
698 =item F</usr/bin/heimdal-strength>
699
700 The default password strength checking program.  This program must follow
701 the Heimdal external password strength checking API.
702
703 =item F</var/lib/heimdal-history/history.db>
704
705 The default database path.  If B<heimdal-strength> is run as root, this
706 file needs to be readable and writable by user C<_history> and group
707 C<_history>.  If it doesn't exist, it will be created with mode 0600.
708
709 =item F</var/lib/heimdal-history/history.db.lock>
710
711 The lock file used to synchronize access to the history database.  As with
712 the history database, if B<heimdal-strength> is run as root, this file
713 needs to be readable and writable by user C<_history> and group
714 C<_history>.
715
716 =item F</var/lib/heimdal-history/lengths.db>
717
718 The default length statistics path, which will be a BerkeleyDB DB_HASH
719 file of password lengths to counts of passwords with that length.  If
720 B<heimdal-strength> is run as root, this file needs to be readable and
721 writable by user C<_history> and group C<_history>.  If it doesn't exist,
722 it will be created with mode 0600.
723
724 =item F</var/lib/heimdal-history/lengths.db.lock>
725
726 The lock file used to synchronize access to the length statistics
727 database.  As with the length statistics database, if B<heimdal-strength>
728 is run as root, this file needs to be readable and writable by user
729 C<_history> and group C<_history>.
730
731 =back
732
733 =head1 AUTHOR
734
735 Russ Allbery <eagle@eyrie.org>
736
737 =head1 COPYRIGHT AND LICENSE
738
739 Copyright 2013, 2014 The Board of Trustees of the Leland Stanford Junior
740 University
741
742 Permission is hereby granted, free of charge, to any person obtaining a
743 copy of this software and associated documentation files (the "Software"),
744 to deal in the Software without restriction, including without limitation
745 the rights to use, copy, modify, merge, publish, distribute, sublicense,
746 and/or sell copies of the Software, and to permit persons to whom the
747 Software is furnished to do so, subject to the following conditions:
748
749 The above copyright notice and this permission notice shall be included in
750 all copies or substantial portions of the Software.
751
752 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
753 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
754 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
755 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
756 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
757 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
758 DEALINGS IN THE SOFTWARE.
759
760 =head1 SEE ALSO
761
762 L<Crypt::PBKDF2>, L<heimdal-strength(1)>
763
764 =cut