1#!/usr/local/bin/perl 2# Save password quality and change restrictions 3 4use strict; 5use warnings; 6require './acl-lib.pl'; 7our (%in, %text, %config, %access); 8$access{'pass'} || &error($text{'pass_ecannot'}); 9&error_setup($text{'pass_err'}); 10 11my %miniserv; 12&get_miniserv_config(\%miniserv); 13&ReadParse(); 14 15# Validate and store inputs 16if ($in{'minsize_def'}) { 17 delete($miniserv{'pass_minsize'}); 18 } 19else { 20 $in{'minsize'} =~ /^\d+$/ || &error($text{'pass_eminsize'}); 21 $miniserv{'pass_minsize'} = $in{'minsize'}; 22 } 23$miniserv{'pass_regexps'} = join("\t", split(/\r?\n/, $in{'regexps'})); 24$miniserv{'pass_regdesc'} = $in{'regdesc'}; 25if ($in{'maxdays_def'}) { 26 delete($miniserv{'pass_maxdays'}); 27 } 28else { 29 $in{'maxdays'} =~ /^\d+$/ || &error($text{'pass_emaxdays'}); 30 $miniserv{'pass_maxdays'} = $in{'maxdays'}; 31 } 32if ($in{'lockdays_def'}) { 33 delete($miniserv{'pass_lockdays'}); 34 } 35else { 36 $in{'lockdays'} =~ /^\d+$/ || &error($text{'pass_elockdays'}); 37 $miniserv{'pass_lockdays'} = $in{'lockdays'}; 38 } 39$miniserv{'pass_nouser'} = $in{'nouser'}; 40$miniserv{'pass_nodict'} = $in{'nodict'}; 41if ($in{'oldblock_def'}) { 42 delete($miniserv{'pass_oldblock'}); 43 } 44else { 45 $in{'oldblock'} =~ /^\d+$/ || &error($text{'pass_eoldblock'}); 46 $miniserv{'pass_oldblock'} = $in{'oldblock'}; 47 } 48&lock_file($ENV{'MINISERV_CONFIG'}); 49&put_miniserv_config(\%miniserv); 50&unlock_file($ENV{'MINISERV_CONFIG'}); 51 52# For any users with no last change time set, set it now 53my $fixed = 0; 54foreach my $user (&list_users()) { 55 if ($miniserv{'pass_maxdays'} && !$user->{'lastchange'}) { 56 $user->{'lastchange'} = time(); 57 &modify_user($user->{'name'}, $user); 58 $fixed++; 59 } 60 } 61if ($fixed) { 62 &reload_miniserv(); 63 } 64 65&webmin_log("pass"); 66&redirect(""); 67 68