This file is indexed.

/usr/share/courier/webadmin/webadmin.pm is in courier-webadmin 0.76.3-5+deb9u1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#
# Copyright 2001 Double Precision, Inc.  See COPYING for
# distribution information.

1;

sub validhostname {

    my $h=shift;

    return $1 if $h =~ /^\s*([a-zA-Z0-9\-\.]+)\s*$/;
    return undef;
}

# Attempt to weed out syntactically invalid addresses

sub validaddress {
    my $addr=shift;

    $addr =~ s/^\s+//;
    $addr =~ s/\s+$//;

    return undef if $addr =~ /[\s,\"\\:;<>\[\]!%\(\)[:cntrl:]]/;

    my $host="";

    if ($addr =~ /(.*)@(.*)/)
    {
	($addr, $host)=($1, $2);

	return undef unless defined ($host=validhostname($host));

	$host=lc($host);
	$host="\@$host";
    }

    return "$addr$host";
}

# An entry in the alias file can be either an address, a program call
# or a mailbox filepath.

sub validaliasaddress {
    my $a=shift;

    $a =~ s/^\s+//;

    if ($a =~ /^[\/\|]/)
    {
	return undef if $a =~ /[\\\*\?\~\'\"\[\][:cntrl:]]/;
	return $a;
    }

    return validaddress($a);
}

# Parse an RFC 822 addrlist

sub addrlist {
    my @list;

    my $str=shift;

    return () if $str =~ /[\:\;<>\[\]\!\%\(\)[:cntrl:]]/;

    while ($str =~ /./)
    {
	if ($str =~ /^[\s,](.*)/)
	{
	    $str=$1;
	    next;
	}

	if ($str =~ /^[\/\|]/)
	{
	    return undef if $str =~ /[\"\\]/;
	    push @list, $str;
	    last;
	}

	my $inq=0;
	my $s="";
	my $ch;

	while ($str =~ /^(.)(.*)$/)
	{
	    ($ch, $str)=($1, $2);

	    ++$inq if $ch eq "\"";

	    if (! ($inq & 1))
	    {
		last if $ch eq ",";
		last if $ch =~ /\s/;
	    }

	    if ($ch eq "\\" && $str =~ /^(.)(.*)$/)
	    {
		$s .= $ch;
		($ch, $str)=($1, $2);
	    }
	    $s .= $ch;
	}

	$s=$1 if $inq == 2 && $s =~ /^\"(.*)\"$/;
	push @list, $s;
    }

    return @list;

}

# Read our aliases file

sub readaliases {

    my %aliases;

    my $fh=OpenConfigFile("aliases/webadmin");

    if (defined $fh)
    {
	my $n;

	while (<$fh>)
	{
	    chomp;

	    next if /^#/;

	    my $l=$_;

	    ($n, $l)=($1, $2) if $l =~ /^([^:\s]+):\s*(.*)/;

	    $l =~ s/^\s*//;
	    next if $l eq "";

	    my @a=addrlist($l);

	    next if $#a < 0;

	    $aliases{$n}=[] unless defined $aliases{$n};

	    my $aa=$aliases{$n};

	    push @$aa, @a;
	}
	close($fh);
    }

    return \%aliases;
}

sub savealiases {
    my $aliases=shift;

    my $fh=NewConfigFile("aliases/webadmin");

    print $fh "# Automatically generated by webadmin - DO NOT EDIT THIS FILE\n";
    foreach (sort keys %$aliases)
    {
	my $key=$_;

	my $aa=$$aliases{$key};

	my @aa=@$aa;

	while ($#aa >= 0)
	{
	    my @addy=splice(@aa, 0, 5);

	    grep {
		$_ =~ s/^([\/\|].*)/"\"$1\""/e;
	    } @addy;

	    print $fh "\n$key: " . join(",", @addy) . "\n";
	}
    }
    close ($fh);
}

# Automatically update locals

sub addacceptmailfor {
    my $domain=validhostname(shift);

    return unless defined $domain;

    my @l;

    foreach(ReadMultiLineConfigFile("esmtpacceptmailfor.dir/webadmin"))
    {
	push @l, $_ unless lc($_) eq lc($domain);
    }

    push @l, $domain;

    SaveMultiLineConfigFile("esmtpacceptmailfor.dir/webadmin", \@l);
    changed("$sbindir/makeacceptmailfor");
}

sub delacceptmailfor {
    my $domain=validhostname(shift);

    my @l;

    foreach(ReadMultiLineConfigFile("esmtpacceptmailfor.dir/webadmin"))
    {
	push @l, $_ unless lc($_) eq lc($domain);
    }

    SaveMultiLineConfigFile("esmtpacceptmailfor.dir/webadmin", \@l);
    changed("$sbindir/makeacceptmailfor");
}

# Convenient functions for validating input

sub param {
    my $s=$cgi->param(shift);

    $s =~ s/^\s+//;
    $s =~ s/\s+$//;
    return $s;
}

sub required {
    foreach (@_)
    {
	return 0 unless param($_);
    }
    return 1;
}