More ui-lib.pl conversion
authorJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 22:27:12 +0000 (22:27 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 22:27:12 +0000 (22:27 +0000)
pam/edit_mod.cgi
pam/edit_pam.cgi
pam/lang/en
pam/pam_securetty.so.pl
pam/pam_shells.so.pl
pam/pam_stack.so.pl
pam/pam_tally.so.pl
pam/pam_time.so.pl
pam/pam_unix.so.pl [new file with mode: 0644]
pam/pam_wheel.so.pl

index 038dad1..6d9e746 100755 (executable)
@@ -31,7 +31,7 @@ print &ui_hidden("idx", $in{'idx'});
 print &ui_hidden("midx", $in{'midx'});
 print &ui_hidden("_module", $in{'module'});
 print &ui_hidden("_type", $in{'type'});
-print &ui_table_start($text{'mod_header'}, undef, 4);
+print &ui_table_start($text{'mod_header'}, undef, 2);
 
 # PAM service name
 $t = $text{'desc_'.$pam->{'name'}};
index ef2f005..c294b31 100755 (executable)
@@ -9,17 +9,32 @@ require './pam-lib.pl';
 @pams = &get_pam_config();
 $pam = $pams[$in{'idx'}];
 
-print &ui_table_start($text{'edit_header'}, "width=100%", 2);
+print &ui_table_start($text{'edit_header'}, "width=100%", 2, [ "width=30%" ]);
 
-$t = $text{'desc_'.$pam->{'name'}};
+# Service name
 print &ui_table_row($text{'edit_name'},
-       "<tt>".&html_escape($pam->{'name'})."</tt> ".
-        ($pam->{'desc'} ? "($pam->{'desc'})" : $t ? "($t)" : ""));
+                   "<tt>".&html_escape($pam->{'name'})."</tt>");
+
+# Service description
+$t = $text{'desc_'.$pam->{'name'}};
+if ($pam->{'desc'} || $t) {
+       print &ui_table_row($text{'edit_desc'}, $pam->{'desc'} || $t);
+       }
+
+# File
+print &ui_table_row($text{'edit_file'},
+       "<tt>$pam->{'file'}</tt>");
+
+print &ui_table_end();
 
 foreach $t ('auth', 'account', 'session', 'password') {
-       my $ptable;
-       $ptable .= &ui_form_start("edit_mod.cgi");
+       # Start of section
        local @mods = grep { $_->{'type'} eq $t } @{$pam->{'mods'}};
+       print &ui_form_start("edit_mod.cgi");
+       print &ui_hidden_table_start($text{"edit_header_$t"}, "width=100%", 2,
+                                    $t, @mods ? 1 : 0);
+
+       my $ptable;
        if (@mods) {
                @tds = ( "width=20%", "width=35%", "width=20%",
                         "width=20%", "width=5%" );
@@ -84,13 +99,14 @@ foreach $t ('auth', 'account', 'session', 'password') {
                      &list_modules() ]);
        $ptable .= "&nbsp;";
        $ptable .= &ui_submit($text{'edit_addinc'}, "inc");
-       $ptable .= &ui_form_end();
 
-       print &ui_table_row($text{"edit_header_$t"}, $ptable);
+       print &ui_table_row(undef, $ptable, 2);
+       print &ui_hidden_table_end();
+       print &ui_form_end();
        }
-print &ui_table_end();
 
 # Delete whole service form
+print "<hr>\n";
 print &ui_form_start("delete_pam.cgi");
 print &ui_hidden("idx", $in{'idx'});
 print &ui_form_end([ [ undef, $text{'edit_delete'} ] ]);
index 4e47b0a..90dc90c 100644 (file)
@@ -65,6 +65,7 @@ desc_rhn_register=Redhat Network registration
 desc_system-auth=Common authentication
 desc_cups=CUPS printing
 desc_cupsys=$desc_cups
+desc_libcupsys2=$desc_cups
 desc_ssh=$desc_sshd
 desc_proftpd=ProFTPd file transfer server
 desc_qpopper=$desc_qpop
@@ -81,10 +82,17 @@ desc_config-util=Configuration utilities
 desc_newrole=SELinux new role
 desc_radius=RADIUS dialup login
 desc_pptpconfig=Point-to-point tunneling protocol
+desc_atd=Scheduled commands daemon
+desc_kcheckpass=KDE password checker
+desc_common-account=Common account verification
+desc_common-auth=Common authentication
+desc_common-password=Common password change
+desc_common-session=Common session setup
 
 edit_title=Edit PAM Service
 edit_header=PAM service details
 edit_name=Service name
+edit_file=Configuration file
 edit_header_auth=Authentication steps
 edit_header_account=Account verification steps
 edit_header_session=Session setup steps
@@ -142,6 +150,7 @@ pam_desgold.so=DESGold smartcard authentication
 pam_console.so=Console only check
 pam_xauth.so=X authentication
 pam_stack.so=Call other PAM service
+pam_foreground.so=Console setup
 
 control_requisite=Requisite
 control_required=Required
@@ -180,6 +189,15 @@ pwdb_nullok=Accept null passwords?
 pwdb_md5=Use MD5-encrypted passwords?
 pwdb_nodelay=Delay after failed login?
 
+unix_nullok_secure=Accept null passwords on secure TTYs?
+unix_min=Minimum password length
+unix_nomin=None
+unix_max=Maximum password length
+unix_nomax=No limit
+unix_obscure=Prevent use of easy passwords?
+unix_emin=Missing or invalid minimum password length
+unix_emax=Missing or invalid maximum password length
+
 listfile_item=Search file for
 listfile_item_user=Username
 listfile_item_tty=TTY
index 611c567..a60fe74 100644 (file)
@@ -4,12 +4,8 @@
 sub display_module_args
 {
 local $file = "/etc/securetty";
-print "<tr> <td valign=top><b>$text{'securetty_ttys'}</b></td>\n";
-print "<td><textarea name=ttys rows=5 cols=20>";
-open(FILE, $file);
-while(<FILE>) { print; }
-close(FILE);
-print "</textarea></td> </tr>\n";
+print &ui_table_row($text{'securetty_ttys'},
+       &ui_textarea("ttys", &read_file_contents($file), 5, 40), 3);
 }
 
 # parse_module_args(&service, &module, &args)
index 6cf72e8..e112ded 100644 (file)
@@ -4,12 +4,8 @@
 sub display_module_args
 {
 local $file = "/etc/shells";
-print "<tr> <td valign=top><b>$text{'shells_shells'}</b></td>\n";
-print "<td><textarea name=shells rows=5 cols=30>";
-open(FILE, $file);
-while(<FILE>) { print; }
-close(FILE);
-print "</textarea></td> </tr>\n";
+print &ui_table_row($text{'shells_shells'},
+       &ui_textarea("shells", &read_file_contents($file), 5, 40), 3);
 }
 
 # parse_module_args(&service, &module, &args)
index 5b2ff52..61319f1 100644 (file)
@@ -3,21 +3,13 @@
 # display_args(&service, &module, &args)
 sub display_module_args
 {
-print "<tr> <td><b>$text{'stack_service'}</b></td>\n";
-print "<td><select name=service>\n";
-local $found;
-foreach $c (&get_pam_config()) {
-       printf "<option value=%s %s>%s\n",
-               $c->{'name'},
-               $_[2]->{'service'} eq $c->{'name'} ? 'selected' : '',
-               $text{"desc_".$c->{'name'}} ? $text{"desc_".$c->{'name'}}
-                                           : $c->{'name'};
-       $found++ if ($_[2]->{'service'} eq $c->{'name'});
-       }
-if ($_[2]->{'service'} && !$found) {
-       print "<option checked>$_[2]->{'service'}\n";
-       }
-print "</select></td> </tr>\n";
+print &ui_table_row($text{'stack_service'},
+    &ui_select("service", $_[2]->{'service'},
+       [ map { [ $_->{'name'},
+                 $_->{'name'}.($text{'desc_'.$_->{'name'}} ?
+                               " (".$text{'desc_'.$_->{'name'}}.")" : "") ] }
+             &get_pam_config() ],
+       1, 0, $_[2]->{'service'} ? 1 : 0), 3);
 }
 
 # parse_module_args(&service, &module, &args)
index adfbb40..eb87f4f 100644 (file)
@@ -3,33 +3,21 @@
 # display_args(&service, &module, &args)
 sub display_module_args
 {
-print "<tr> <td><b>$text{'tally_deny'}</b></td>\n";
-printf "<td nowrap><input type=radio name=deny_def value=1 %s> %s\n",
-       $_[2]->{'deny'} ? '' : 'checked', $text{'default'};
-printf "<input type=radio name=deny_def value=0 %s>\n",
-       $_[2]->{'deny'} ? 'checked' : '';
-print "<input name=deny size=5 value='$_[2]->{'deny'}'></td>\n";
-
-print "<td><b>$text{'tally_reset'}</b></td>\n";
-printf "<td><input type=radio name=reset value=0 %s> %s\n",
-       defined($_[2]->{'reset'}) || defined($_[2]->{'no_reset'}) ?
-       '' : 'checked', $text{'default'};
-printf "<input type=radio name=reset value=1 %s> %s\n",
-       defined($_[2]->{'reset'}) ? 'checked' : '', $text{'yes'};
-printf "<input type=radio name=reset value=2 %s> %s</td> </tr>\n",
-       defined($_[2]->{'no_reset'}) ? 'checked' : '', $text{'no'};
-
-print "<tr> <td><b>$text{'tally_magic'}</b></td>\n";
-printf "<td><input type=radio name=magic value=1 %s> %s\n",
-       defined($_[2]->{'no_magic_root'}) ? 'checked' : '', $text{'yes'};
-printf "<input type=radio name=magic value=0 %s> %s</td>\n",
-       defined($_[2]->{'no_magic_root'}) ? '' : 'checked', $text{'no'};
-
-print "<td><b>$text{'tally_root'}</b></td>\n";
-printf "<td><input type=radio name=root value=1 %s> %s\n",
-      defined($_[2]->{'even_deny_root_account'}) ? 'checked' : '', $text{'yes'};
-printf "<input type=radio name=root value=0 %s> %s</td> </tr>\n",
-      defined($_[2]->{'even_deny_root_account'}) ? '' : 'checked', $text{'no'};
+print &ui_table_row($text{'tally_deny'},
+       &ui_opt_textbox("deny", $_[2]->{'deny'}, 5, $text{'default'}));
+
+print &ui_table_row($text{'tally_reset'},
+       &ui_radio("reset", defined($_[2]->{'reset'}) ? 1 :
+                          defined($_[2]->{'no_reset'}) ? 2 : 0,
+                 [ [ 0, $text{'default'} ],
+                   [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]));
+
+print &ui_table_row($text{'tally_magic'},
+       &ui_yesno_radio("magic", defined($_[2]->{'no_magic_root'}) ? 1 : 0));
+
+print &ui_table_row($text{'tally_root'},
+       &ui_yesno_radio("root",
+               defined($_[2]->{'even_deny_root_account'}) ? 1 : 0));
 }
 
 # parse_module_args(&service, &module, &args)
index 43ac8d2..01602c6 100644 (file)
@@ -14,22 +14,23 @@ while(<FILE>) {
                }
        }
 close(FILE);
-print "<tr> <td colspan=4><table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'time_services'}</b></td> ",
-      "<td><b>$text{'time_ttys'}</b></td> ",
-      "<td><b>$text{'time_users'}</b></td> ",
-      "<td><b>$text{'time_times'}</b></td> </tr>\n";
+local $tt = &ui_columns_start([ $text{'time_services'},
+                               $text{'time_ttys'},
+                               $text{'time_users'},
+                               $text{'time_times'} ]);
 local $i = 0;
 foreach $t (@time, [ ]) {
-       print "<tr>\n";
-       print "<td><input name=services_$i size=25 value='$t->[0]'></td>\n";
-       print "<td><input name=ttys_$i size=25 value='$t->[1]'></td>\n";
-       print "<td><input name=users_$i size=25 value='$t->[2]'></td>\n";
-       print "<td><input name=times_$i size=25 value='$t->[3]'></td>\n";
-       print "</tr>\n";
+       $tt .= &ui_columns_row([
+               &ui_textbox("services_$i", $t->[0], 25),
+               &ui_textbox("ttys_$i", $t->[1], 25),
+               &ui_textbox("users_$i", $t->[2], 25),
+               &ui_textbox("times_$i", $t->[3], 25),
+               ]);
        $i++;
        }
-print "</table><br>$text{'time_info'}</td> </tr>\n";
+$tt .= &ui_columns_end();
+$tt .= "<br>".$text{'time_info'};
+print &ui_table_row(undef, $tt, 4);
 }
 
 # parse_module_args(&service, &module, &args)
diff --git a/pam/pam_unix.so.pl b/pam/pam_unix.so.pl
new file mode 100644 (file)
index 0000000..af48a93
--- /dev/null
@@ -0,0 +1,67 @@
+# display args for pam_unix.so
+
+# display_args(&service, &module, &args)
+sub display_module_args
+{
+print &ui_table_row($text{'pwdb_shadow'},
+       &ui_yesno_radio("shadow", defined($_[2]->{'shadow'}) ? 1 : 0));
+
+print &ui_table_row($text{'pwdb_md5'},
+       &ui_yesno_radio("md5", defined($_[2]->{'md5'}) ? 1 : 0));
+
+print &ui_table_row($text{'pwdb_nullok'},
+       &ui_yesno_radio("nullok", defined($_[2]->{'nullok'}) ? 1 : 0));
+
+print &ui_table_row($text{'unix_nullok_secure'},
+       &ui_yesno_radio("nullok_secure",
+                       defined($_[2]->{'nullok_secure'}) ? 1 : 0));
+
+if ($_[1]->{'type'} eq 'password') {
+       # Password-change specific options
+       print &ui_table_row($text{'unix_min'},
+               &ui_opt_textbox("min", $_[2]->{'min'}, 5, $text{'unix_nomin'}));
+
+       print &ui_table_row($text{'unix_max'},
+               &ui_opt_textbox("max", $_[2]->{'max'}, 5, $text{'unix_nomax'}));
+
+       print &ui_table_row($text{'unix_obscure'},
+               &ui_yesno_radio("obscure",defined($_[2]->{'obscure'}) ? 1 : 0));
+       }
+}
+
+# parse_module_args(&service, &module, &args)
+sub parse_module_args
+{
+if ($in{'nullok'}) { $_[2]->{'nullok'} = ""; }
+else { delete($_[2]->{'nullok'}); }
+
+if ($in{'nullok_secure'}) { $_[2]->{'nullok_secure'} = ""; }
+else { delete($_[2]->{'nullok_secure'}); }
+
+if ($in{'shadow'}) { $_[2]->{'shadow'} = ""; }
+else { delete($_[2]->{'shadow'}); }
+
+if ($in{'md5'}) { $_[2]->{'md5'} = ""; }
+else { delete($_[2]->{'md5'}); }
+
+if ($_[1]->{'type'} eq 'password') {
+       if ($in{'min_def'}) {
+               delete($_[2]->{'min'});
+               }
+       else {
+               $in{'min'} =~ /^\d+$/ || &error($text{'unix_emin'});
+               $_[2]->{'min'} = $in{'min'};
+               }
+
+       if ($in{'max_def'}) {
+               delete($_[2]->{'max'});
+               }
+       else {
+               $in{'max'} =~ /^\d+$/ || &error($text{'unix_emax'});
+               $_[2]->{'max'} = $in{'max'};
+               }
+
+       if ($in{'obscure'}) { $_[2]->{'obscure'} = ""; }
+       else { delete($_[2]->{'obscure'}); }
+       }
+}
index fcc75f7..7da64ab 100644 (file)
@@ -3,25 +3,15 @@
 # display_args(&service, &module, &args)
 sub display_module_args
 {
-print "<tr> <td><b>$text{'wheel_group'}</b></td>\n";
-printf "<td colspan=3><input type=radio name=group_def value=1 %s> %s\n",
-       $_[2]->{'group'} ? '' : 'checked', $text{'wheel_group_def'};
-printf "<input type=radio name=group_def value=0 %s>\n",
-       $_[2]->{'group'} ? 'checked' : '';
-print "<input name=group size=8 value='$_[2]->{'group'}'> ",
-      &group_chooser_button("group"),"</td> </tr>\n";
+print &ui_table_row($text{'wheel_group'},
+       &ui_opt_textbox("group", $_[2]->{'group'}, 8, $text{'wheel_group_def'}).
+       " ".&group_chooser_button("group"), 3);
 
-print "<tr> <td><b>$text{'wheel_trust'}</b></td>\n";
-printf "<td><input type=radio name=trust value=1 %s> %s\n",
-       defined($_[2]->{'trust'}) ? 'checked' : '', $text{'yes'};
-printf "<input type=radio name=trust value=0 %s> %s</td>\n",
-       defined($_[2]->{'trust'}) ? '' : 'checked', $text{'no'};
+print &ui_table_row($text{'wheel_trust'},
+       &ui_yesno_radio("trust", defined($_[2]->{'trust'}) ? 1 : 0));
 
-print "<td><b>$text{'wheel_deny'}</b></td>\n";
-printf "<td><input type=radio name=deny value=1 %s> %s\n",
-       defined($_[2]->{'deny'}) ? 'checked' : '', $text{'yes'};
-printf "<input type=radio name=deny value=0 %s> %s</td> </tr>\n",
-       defined($_[2]->{'deny'}) ? '' : 'checked', $text{'no'};
+print &ui_table_row($text{'wheel_deny'},
+       &ui_yesno_radio("deny", defined($_[2]->{'deny'}) ? 1 : 0));
 }
 
 # parse_module_args(&service, &module, &args)