From 5df2a340bc2eda3eece9918f3f1b9ffc35ba1e5b Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 15 Oct 2008 21:53:52 +0000 Subject: [PATCH] Handle default vs 0 better on AIX --- useradmin/edit_user.cgi | 19 +++++++++++-------- useradmin/lang/en | 20 +++++++++++--------- useradmin/save_user.cgi | 21 +++++++++++++++------ useradmin/user-lib.pl | 4 ---- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/useradmin/edit_user.cgi b/useradmin/edit_user.cgi index 68d56ef20..00cb24aed 100755 --- a/useradmin/edit_user.cgi +++ b/useradmin/edit_user.cgi @@ -339,8 +339,7 @@ elsif ($pft == 4 && $access{'peopt'}) { $n eq "" ? $text{'uedit_never'} : $text{'uedit_unknown'})); - if ($uinfo{'expire'}) { - $uinfo{'expire'} =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/; + if ($uinfo{'expire'} =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/) { $emon = $1; $eday = $2; $ehour = $3; @@ -355,20 +354,24 @@ elsif ($pft == 4 && $access{'peopt'}) { } $emon =~ s/0(\d)/$1/; # strip leading 0 print &ui_table_row(&hlink($text{'expire'}, "expire"), - &date_input($eday, $emon, $eyear, 'expire'). - " ".&ui_textbox("expireh", $ehour, 3). - "/".&ui_textbox("expiremi", $emin, 3)); + &ui_radio("expire_def", $uinfo{'expire'} eq '' ? 1 : + $uinfo{'expire'} eq '0' ? 2 : 0, + [ [ 1, $text{'uedit_sys'} ], + [ 2, $text{'uedit_never'} ], + [ 0, &date_input($eday, $emon, $eyear, 'expire'). + " ".&ui_textbox("expireh", $ehour, 3). + "/".&ui_textbox("expiremi", $emin, 3) ] ])); # Minimum and maximum ages in weeks print &ui_table_row(&hlink($text{'min_weeks'}, "min_weeks"), - &ui_textbox("min", $uinfo{'min'}, 5)); + &ui_opt_textbox("min", $uinfo{'min'}, 5, $text{'uedit_sys'})); print &ui_table_row(&hlink($text{'max_weeks'}, "max_weeks"), - &ui_textbox("max", $uinfo{'max'}, 5)); + &ui_opt_textbox("max", $uinfo{'max'}, 5, $text{'uedit_sys'})); # Warning days print &ui_table_row(&hlink($text{'warn'}, "warn"), - &ui_textbox("warn", $uinfo{'warn'}, 5)); + &ui_opt_textbox("warn", $uinfo{'warn'}, 5, $text{'uedit_sys'})); # AIX-specific flags print &ui_table_row(&hlink($text{'flags'}, "flags"), diff --git a/useradmin/lang/en b/useradmin/lang/en index cdf1301f1..f05e5a2d1 100644 --- a/useradmin/lang/en +++ b/useradmin/lang/en @@ -123,6 +123,8 @@ uedit_forcechange=Force change at next login? uedit_uid_def=Automatic uedit_uid_calc=Calculated uedit_disabled=Login temporarily disabled +uedit_sys=System default +uedit_never=Never usave_err=Failed to save user usave_eedit=You cannot edit this user @@ -156,16 +158,16 @@ usave_emin='$1' is not a valid minimum change period usave_emax='$1' is not a valid maximum change period usave_ewarn='$1' is not a valid warning period usave_einactive='$1' is not a valid inactive period -usave_eexpire=invalid expiry date -usave_echange=invalid change date +usave_eexpire=Invalid expiry date +usave_echange=Invalid change date usave_eclass='$1' is not a valid login class -usave_emove=failed to move home directory : $1 -usave_emkdir=couldn't create home directory : $1 -usave_echown=couldn't chown home directory : $1 -usave_echmod=couldn't chmod home directory : $1 -usave_eoffice=office cannot contain a : character -usave_eworkph=work phone cannot contain a : character -usave_ehomeph=home phone cannot contain a : character +usave_emove=Failed to move home directory : $1 +usave_emkdir=Couldn't create home directory : $1 +usave_echown=Couldn't chown home directory : $1 +usave_echmod=Couldn't chmod home directory : $1 +usave_eoffice=Office cannot contain a : character +usave_eworkph=Work phone cannot contain a : character +usave_ehomeph=Home phone cannot contain a : character usave_edigestmd5=Your system has MD5 passwords enabled, but neither the perl MD5 or Digest::MD5 module is not installed.

To force the use of normal encrypted passwords, adjust your module configuration.

Or have Webmin download and install the Digest::MD5 module for you. usave_emaking=Before update command failed : $1 usave_epasswd_min=Password must be at least $1 letters long diff --git a/useradmin/save_user.cgi b/useradmin/save_user.cgi index 4f5323e34..344129328 100755 --- a/useradmin/save_user.cgi +++ b/useradmin/save_user.cgi @@ -390,9 +390,19 @@ elsif ($pft == 1 || $pft == 6) { } elsif ($pft == 4) { # Validate AIX-style password inputs - if ($in{'expired'} ne "" && $in{'expirem'} ne "" - && $in{'expirey'} ne "" ) { + if ($in{'expire_def'} == 1) { + # System default expiry date + $expire = undef; + } + elsif ($in{'expire_def'} == 2) { + # Never expires + $expire = "0"; + } + else { # Add a leading zero if only 1 digit long + $in{'expirem'} =~ /^\d+$/ && $in{'expired'} =~ /^\d+$/ && + $in{'expireh'} =~ /^\d+$/ && $in{'expiremi'} =~ /^\d+$/ && + $in{'expirey'} =~ /^\d+$/ || &error($text{'usave_eexpire'}); $in{'expirem'} =~ s/^(\d)$/0$1/; $in{'expired'} =~ s/^(\d)$/0$1/; $in{'expireh'} =~ s/^(\d)$/0$1/; @@ -406,15 +416,14 @@ elsif ($pft == 4) { $in{'expiremi'} = "01" if $in{'expiremi'} eq ""; $expire="$in{'expirem'}$in{'expired'}$in{'expireh'}$in{'expiremi'}$in{'expirey'}"; } - else { $expire = ""; } if ($access{'peopt'}) { $user{'admin'} = $in{'flags'} =~ /admin/; $user{'admchg'} = $in{'flags'} =~ /admchg/; $user{'nocheck'} = $in{'flags'} =~ /nocheck/; $user{'expire'} = $expire; - $user{'min'} = $in{'min'}; - $user{'max'} = $in{'max'}; - $user{'warn'} = $in{'warn'}; + $user{'min'} = $in{'min_def'} ? undef : $in{'min'}; + $user{'max'} = $in{'max_def'} ? undef : $in{'max'}; + $user{'warn'} = $in{'warn_def'} ? undef : $in{'warn'}; } else { $user{'admin'} = $ouser{'admin'}; diff --git a/useradmin/user-lib.pl b/useradmin/user-lib.pl index a7905f909..1c2c9cd31 100644 --- a/useradmin/user-lib.pl +++ b/useradmin/user-lib.pl @@ -216,19 +216,15 @@ else { elsif (/^\s*([^=\s]+)\s*=\s*(.*)/) { if ($1 eq 'expires') { $lastuser->{'expire'} = $2; - $lastuser->{'expire'} =~ s/^0$//; } elsif ($1 eq 'minage') { $lastuser->{'min'} = $2; - $lastuser->{'min'} =~ s/^0$//; } elsif ($1 eq 'maxage') { $lastuser->{'max'} = $2; - $lastuser->{'max'} =~ s/^0$//; } elsif ($1 eq 'pwdwarntime') { $lastuser->{'warn'} = $2; - $lastuser->{'warn'} =~ s/^0$//; } } }