1#!/usr/local/bin/perl 2# edit_mod.cgi 3# Edit one PAM authentication module for some service 4 5require './pam-lib.pl'; 6&ReadParse(); 7if ($in{'inc'}) { 8 # Redirect to include form 9 &redirect("edit_inc.cgi?idx=$in{'idx'}&type=$in{'type'}"); 10 return; 11 } 12 13@pam = &get_pam_config(); 14$pam = $pam[$in{'idx'}]; 15if ($in{'midx'} ne '') { 16 $mod = $pam->{'mods'}->[$in{'midx'}]; 17 $module = $mod->{'module'}; 18 $module =~ s/^.*\///; 19 $type = $mod->{'type'}; 20 &ui_print_header(undef, $text{'mod_edit'}, ""); 21 } 22else { 23 $module = $in{'module'}; 24 $type = $in{'type'}; 25 $mod = { 'type' => $type }; 26 &ui_print_header(undef, $text{'mod_create'}, ""); 27 } 28 29 30print &ui_form_start("save_mod.cgi"); 31print &ui_hidden("idx", $in{'idx'}); 32print &ui_hidden("midx", $in{'midx'}); 33print &ui_hidden("_module", $in{'module'}); 34print &ui_hidden("_type", $in{'type'}); 35print &ui_table_start($text{'mod_header'}, "width=100%", 2); 36 37# PAM service name 38$t = $text{'desc_'.$pam->{'name'}}; 39print &ui_table_row($text{'mod_name'}, 40 "<tt>".&html_escape($pam->{'name'})."</tt> ". 41 ($pam->{'desc'} ? "($pam->{'desc'})" : $t ? "($t)" : "")); 42 43# PAM module name 44$t = $text{$module}; 45print &ui_table_row($text{'mod_mod'}, 46 "<tt>$module</tt> ".($t ? "($t)" : "")); 47 48print &ui_table_row($text{'mod_type'}, 49 $text{'mod_type_'.$type}); 50 51# Control mode 52print &ui_table_row($text{'mod_control'}, 53 &ui_select("control", $mod->{'control'}, 54 [ map { [ $_, $text{'control_'.$_}." (". 55 $text{'control_desc_'.$_}.")" ] } 56 ('required', 'requisite', 'sufficient', 'optional') ], 57 1, 0, $in{'midx'} eq '' ? 0 : 1)); 58 59if (-r "./$module.pl") { 60 do "./$module.pl"; 61 if (!$module_has_no_args) { 62 print &ui_table_hr(); 63 foreach $a (split(/\s+/, $mod->{'args'})) { 64 if ($a =~ /^([^\s=]+)=(\S*)$/) { 65 $args{$1} = $2; 66 } 67 else { 68 $args{$a} = ""; 69 } 70 } 71 &display_module_args($pam, $mod, \%args); 72 } 73 } 74else { 75 # Text-only args 76 print &ui_table_hr(); 77 print &ui_table_row($text{'mod_args'}, 78 &ui_textbox("args", $mod->{'args'}, 60), 3); 79 } 80 81print &ui_table_end(); 82 83if ($in{'midx'} ne '') { 84 print &ui_form_end([ [ undef, $text{'save'} ], 85 [ 'delete', $text{'delete'} ] ]); 86 } 87else { 88 print &ui_form_end([ [ undef, $text{'create'} ] ]); 89 } 90 91&ui_print_footer("edit_pam.cgi?idx=$in{'idx'}", $text{'edit_return'}, 92 "", $text{'index_return'}); 93 94