This file is indexed.

/usr/sbin/userdb is in courier-authlib-userdb 0.68.0-4build1.

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

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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#! /usr/bin/perl
#
# Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
# distribution information.

use Fcntl ':flock';

$prefix="/usr";
$exec_prefix="${prefix}";
$userdb="/etc/courier/userdb";

eval {
	die "SYMLINK\n" if -l $userdb;
};

die "ERROR: Wrong userdb command.\n       ($userdb is a symbolic link)\n"
	if $@ eq "SYMLINK\n";

sub usage {
	print "Usage: $0 [path/.../ | -f file ]name set field=value field=value...\n";
	print "       $0 [path/.../ | -f file ]name unset field field...\n";
	print "       $0 [path/.../ | -f file ]name del\n";
	print "       $0 -show [path/... | -f file ] [name]\n";
	exit 1;
}

$name=shift @ARGV;
$doshow=0;

if ($name eq "-show")
{
	$doshow=1;
	$name=shift @ARGV;
}

if ($name eq "-f")
{
	$userdb=shift @ARGV;
	$name=shift @ARGV;
}
elsif ( $name =~ /^(.*)\/([^\/]*)$/ )
{
	$userdb="$userdb/$1";
	$name=$2;
}


if ($doshow)
{
	&usage unless $userdb =~ /./;
}
else
{
	$verb=shift @ARGV;

	&usage unless $verb =~ /./ && $name =~ /./ && $userdb =~ /./;
}

while (defined ($link= &safe_readlink($userdb)))
{
	$userdb .= "/";
	$userdb = "" if $link =~ /^\//;
	$userdb .= $link;
}

$tmpuserdb= $userdb =~ /^(.*)\/([^\/]*)$/ ? "$1/.tmp.$2":".tmp.$userdb";
$lockuserdb= $userdb =~ /^(.*)\/([^\/]*)$/ ? "$1/.lock.$2":".lock.$userdb";

if ( $doshow && ! defined $name)
{
}
else
{
	die "Invalid name: $name\n"
		unless $name =~ /^[\@a-zA-Z0-9\.\-\_\:\+]+$/;
}

grep( (/[\|\n]/ && die "Invalid field or value.\n"), @ARGV);

umask(066);

open(LOCK, ">$lockuserdb") or die "Can't open $lockuserdb: $!";
flock(LOCK,LOCK_EX) || die "Can't lock $lockuserdb: $!";

if ( $doshow )
{
	if (open (OLDFILE, $userdb))
	{
		stat(OLDFILE);
		die "$userdb: not a file.\n" unless -f _;

		while ( defined($_=<OLDFILE>) )
		{
			chop if /\n$/;
			next if /^#/;
			next unless /^([^\t]+)(\t(.*))?$/;
			($addr,$vals)=($1,$3);
			if (defined $name)
			{
				if ($name eq $addr)
				{
					$vals =~ s/\|/\n/g;
					print "$vals\n";
					last;
				}
			}
			else
			{
				print "$addr\n";
			}
		}
	}
	close (OLDFILE);
}
elsif ( $verb eq "set" )
{
	$isatty=1;

	eval {
		$isatty=0 unless -t STDIN;
	} ;

	&doadd;
	$mode= (stat $userdb)[2];
	chmod ($mode & 0777,$tmpuserdb ) if defined $mode;
	rename $tmpuserdb,$userdb;
}
elsif ( $verb eq "unset" )
{
	if ($#ARGV >= 0 && &dodel)
	{
		$mode= (stat $userdb)[2];
		chmod ($mode & 0777 ,$tmpuserdb) if defined $mode;
		rename ($tmpuserdb,$userdb)
	}
}
elsif ( $verb eq "del" )
{
	&usage unless $#ARGV < 0;
	if (&dodel)
	{
		$mode= (stat $userdb)[2];
		chmod ($mode & 0777 ,$tmpuserdb) if defined $mode;
		rename ($tmpuserdb,$userdb)
	}
}
else
{
	&usage;
}
exit 0;

sub doadd {
my (%FIELDS);
my ($key, $in);

	foreach $key (@ARGV)
	{
		next if $key =~ /=/;
		print "$name.$key: " if $isatty;
		exit 1 unless defined ($in=<STDIN>);
		chop $in if $in =~ /\n$/;
		die "Invalid value.\n" if $in =~ /[\|\n]/;
		$key = "$key=$in";
	}

	open (NEWFILE, ">$tmpuserdb") || die "$!\n";
	if (open (OLDFILE, $userdb))
	{
		stat(OLDFILE);
		die "$userdb: not a file.\n" unless -f _;
		while ( defined($_=<OLDFILE>) )
		{
			chop if /\n$/;
			if ( /^([^\t]+)(\t(.*))?$/ && ($1 eq $name))
			{
				grep( (/^([^=]*)(=.*)?$/,
					$FIELDS{$1}="$2"), split(/\|/, $3));
				while ( defined ($key=shift @ARGV))
				{
					$key =~ /^([^=]*)(=.*)?$/;
					$FIELDS{$1}="$2";
				}
				$name="$name\t";
				grep ( $name="$name$_$FIELDS{$_}|",
					keys %FIELDS);
				chop $name;
				print NEWFILE "$name\n" || die "$!\n";
				while (<OLDFILE>)
				{
					print NEWFILE || die "$!\n";
				}
				close (OLDFILE);
				close (NEWFILE) || die "$!\n";
				return;
			}
			print NEWFILE "$_\n" || die "$!\n";
		}
		close (OLDFILE);
	}

	$name="$name\t";
	grep ( $name="$name$_|", @ARGV );
	chop $name;
	print NEWFILE "$name\n" || die "$!\n";
	close (NEWFILE) || die "$!\n";
}

sub dodel {
my (%FIELDS);

	open (NEWFILE, ">$tmpuserdb") || die "$!\n";
	if (open (OLDFILE, $userdb))
	{
		stat(OLDFILE);
		die "$userdb: not a file.\n" unless -f _;
		while ( defined($_=<OLDFILE>) )
		{
			chop if /\n$/;
			if ( /^([^\t]+)(\t(.*))?$/ && ($1 eq $name))
			{
				if ($#ARGV >= 0)
				{
					grep( (/^([^=]*)(=.*)?$/,
						$FIELDS{$1}=$2),
							split(/\|/, $3));
					grep( delete $FIELDS{$_}, @ARGV);

					$name="$name\t";
					grep ( $name="$name$_$FIELDS{$_}|",
						keys %FIELDS);
					chop $name;
					$name="$name\n";
					print NEWFILE "$name" || die "$!\n";
				}
				while (<OLDFILE>)
				{
					print NEWFILE || die "$!\n";
				}
				close (OLDFILE);
				close (NEWFILE) || die "$!\n";
				return (1);
			}
			print NEWFILE "$_\n" || die "$!\n";
		}
		close (OLDFILE);
	}
	unlink "$tmpuserdb";
	return (0);
}

sub safe_readlink {
my ($l)=@_;
my ($err,$link);

	eval {

		$link=readlink($l);
	} ;

	$link=undef if $@;
	return $link;
}