2 # Save SMTP authentication options
4 require './postfix-lib.pl';
8 $access{'client'} || &error($text{'opts_ecannot'});
10 &error_setup($text{'client_err'});
12 &lock_postfix_files();
14 if ($in{'client_def'}) {
16 &set_current_value("smtpd_client_restrictions",
17 "__DEFAULT_VALUE_IE_NOT_IN_CONFIG_FILE__");
21 @opts = split(/[\s,]+/,&get_current_value("smtpd_client_restrictions"));
22 %oldopts = map { $_, 1 } @opts;
23 %newopts = map { $_, 1 } split(/\0/, $in{'client'});
25 # Save boolean options
26 foreach $o (&list_client_restrictions()) {
27 if ($newopts{$o} && !$oldopts{$o}) {
30 elsif (!$newopts{$o} && $oldopts{$o}) {
31 @opts = grep { $_ ne $o } @opts;
35 # Save options with values
36 foreach $o (&list_multi_client_restrictions()) {
37 # Find all current positions
39 for(my $i=0; $i<@opts; $i++) {
40 push(@pos, $i) if ($opts[$i] eq $o);
43 # Make sure something was entered
45 $in{"value_$o"} =~ /\S/ ||
46 &error(&text('client_evalue', $text{'sasl_'.$o}));
49 # Sync with values entered
50 @v = split(/\s+/, $in{"value_$o"});
51 for(my $i=0; $i<@pos || $i<@v; $i++) {
52 if ($i<@pos && $i<@v) {
54 $opts[$pos[$i]+1] = $v[$i];
56 elsif ($i<@pos && $i>=@v) {
58 splice(@opts, $pos[$i], 2);
60 elsif ($i>=@pos && $i<@v) {
61 # Adding a value, at the end
62 push(@opts, $o, $v[$i]);
67 &set_current_value("smtpd_client_restrictions", join(" ", @opts));
70 &unlock_postfix_files();
74 &webmin_log("client");