3 # Display the modules for some PAM service
5 require './pam-lib.pl';
8 &ui_print_header(undef, $text{'edit_title'}, "");
9 @pams = &get_pam_config();
10 $pam = $pams[$in{'idx'}];
12 print &ui_table_start($text{'edit_header'}, "width=100%", 2, [ "width=30%" ]);
15 print &ui_table_row($text{'edit_name'},
16 "<tt>".&html_escape($pam->{'name'})."</tt>");
19 $t = $text{'desc_'.$pam->{'name'}};
20 if ($pam->{'desc'} || $t) {
21 print &ui_table_row($text{'edit_desc'}, $pam->{'desc'} || $t);
25 print &ui_table_row($text{'edit_file'},
26 "<tt>$pam->{'file'}</tt>");
28 print &ui_table_end();
30 foreach $t ('auth', 'account', 'session', 'password') {
32 local @mods = grep { $_->{'type'} eq $t } @{$pam->{'mods'}};
33 print &ui_form_start("edit_mod.cgi");
34 print &ui_hidden_table_start($text{"edit_header_$t"}, "width=100%", 2,
39 @tds = ( "width=20%", "width=35%", "width=20%",
40 "width=20%", "width=5%" );
41 $ptable .= &ui_columns_start([ $text{'edit_mod'},
43 $text{'edit_control'},
45 $text{'edit_move'} ], \@tds);
47 local $mn = $m->{'module'};
50 if ($m->{'control'} eq 'include') {
52 push(@cols, "<a href='edit_inc.cgi?".
53 "idx=$pam->{'index'}&midx=$m->{'index'}'>".
54 &text('edit_inc', "<tt>$mn</tt>")."</a>");
55 @rtds = ( "colspan=4", "width=5%" );
59 push(@cols, "<a href='edit_mod.cgi?".
60 "idx=$pam->{'index'}&midx=$m->{'index'}'>".
62 push(@cols, $text{$mn});
63 push(@cols, $text{'control_'.$m->{'control'}});
64 push(@cols, $m->{'args'});
68 if ($m eq $mods[$#mods]) {
69 $mv .= "<img src=images/gap.gif>";
72 $mv .= "<a href='move.cgi?idx=$pam->{'index'}&".
73 "midx=$m->{'index'}&down=1'><img ".
74 "src=images/down.gif border=0></a>";
77 $mv .= "<img src=images/gap.gif>";
80 $mv .= "<a href='move.cgi?idx=$pam->{'index'}&".
81 "midx=$m->{'index'}&up=1'><img ".
82 "src=images/up.gif border=0></a>";
85 $ptable .= &ui_columns_row(\@cols, \@rtds);
87 $ptable .= &ui_columns_end();
90 $ptable .= "<b>$text{'edit_none'}</b><p>\n";
94 $ptable .= &ui_hidden("idx", $in{'idx'});
95 $ptable .= &ui_hidden("type", $t);
96 $ptable .= &ui_submit($text{'edit_addmod'}),"\n";
97 $ptable .= &ui_select("module", undef,
98 [ map { [ $_, $text{$_} ? "$_ ($text{$_})" : $_ ] }
101 if (&include_style(\@pams) == 2) {
102 $ptable .= &ui_submit($text{'edit_addinc'}, "inc");
105 print &ui_table_row(undef, $ptable, 2);
106 print &ui_hidden_table_end();
107 print &ui_form_end();
110 # Show section for other includes
111 if (&include_style(\@pams) == 3) {
112 @incs = grep { $_->{'include'} } @{$pam->{'mods'}};
113 %inced = map { $_->{'include'}, 1 } @incs;
114 print &ui_form_start("save_incs.cgi");
115 print &ui_hidden("idx", $in{'idx'});
116 print &ui_hidden_table_start($text{'edit_iheader'}, "width=100%", 2,
117 "incs", @incs ? 1 : 0);
119 foreach $p (sort { $a->{'name'} cmp $b->{'name'} } @pams) {
120 $desc = $p->{'name'};
121 $dstr = $p->{'desc'} || $text{'desc_'.$p->{'name'}};
122 $desc .= " ($dstr)" if ($dstr);
123 push(@grid, &ui_checkbox("inc", $p->{'name'}, $desc,
124 $inced{$p->{'name'}}));
126 print &ui_table_row(undef, &ui_grid_table(\@grid, 2), 2);
127 print &ui_hidden_table_end();
128 print &ui_form_end([ [ undef, $text{'save'} ] ]);
131 # Delete whole service form
133 print &ui_form_start("delete_pam.cgi");
134 print &ui_hidden("idx", $in{'idx'});
135 print &ui_form_end([ [ undef, $text{'edit_delete'} ] ]);
137 &ui_print_footer("", $text{'index_return'});