This file is indexed.

/usr/share/doc/libnet-imap-simple-perl/examples/imap.pl is in libnet-imap-simple-perl 1.2206-1.

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
#!/usr/bin/perl
require 'lib/Net/IMAP/Simple.pm';
print "Square brackets: [] indicate optional arguments\n\n";
print "IMAP Server[:port] [localhost]: ";

while(<>){
	chomp;
	$_ ||= 'localhost';
	$imap = Net::IMAP::Simple->new($_, port => 143, timeout => 90) || die "$Net::IMAP::Simple::errstr\n";
	if($imap){
		print "Connected.\n";
		last;
	} else {
		print "Connection to $_ failed: $Net::IMAP::Simple::errstr\n";
		print "IMAP Server[:port]: ";
	}
}

print "User: ";
while(<>){
	chomp;
	$user = $_;
	if(!$user){
		print "Blank user not allowed\n";
		print "User: ";
	} else {
		last;
	}
}

print "Password: ";
system("stty -echo");
while(<>){
	chomp;
	if(!$imap->login($user, $_)){
		print "Login failed: " . $imap->errstr . "\n";
	} else {
		my $msgs = $imap->select("INBOX");
		print "Messages in INBOX: $msgs\n";
		last;
	}
}

system("stty echo");
print "\n";

my $ptc = qq{
 Please enter a command:

 help                   - This help screen
 list                   - List all folders / mail boxes accessable by this account
 folders		- List all folders within <box>
 select box <box>       - Select a mail box
 select folder <folder> - Select a folder within <box>, format: Some.Folder.I.Own
                          which looks like: Some/Folder/I/Own
 exit                   - Disconnect and close

};

print $ptc . "[root] ";

my %o;
while(<>){
	chomp;
	my (@folders, %boxes);
	my @folders = $imap->mailboxes;
	for(@folders){
		$boxes{ (split(/\./))[0] } = 1;
	}

	my @io = split(/\s+/, $_);

	if($io[0] eq 'select'){
		if($io[1] eq 'box'){
			if(!$boxes{ $io[2] }){
				print $ptc . "Invalid mail box: $io\n\n";
			} else {
				print "\n-- Mail box successfully selected --\n    $io[2]\n\n";
				$o{box} = $io[2];
			}
		} elsif($io[1] eq 'folder'){
			my $c = $imap->select($io[2]);
			if(!defined $c){
				print $ptc . "Select error: " . $imap->errstr . "\n\n";
			} else {
				print "-- Folder information: $io[2] --\n";
				print " Messages: " . $c . "\n";
				print "   Recent: " . $imap->recent . "\n";
				print "    Flags: " . $imap->flags . "\n";
				print "Flag List: " . join(" ", $imap->flags) . "\n\n";
		#		$o{folder} = $io[2];
			}
		} else {
			print $ptc . "Invalid select option\n\n";
		}
	} elsif($io[0] eq 'list'){
		print "-- Avaliable mail folders/boxes --\n";
		for(keys %boxes){
			print "Mail box: $_\n";
		}
		print "\n";
	} elsif($io[0] eq 'folders' && $o{box}){
		print "-- Listing folders in: $o{box} --\n";
		my $x = $o{box};
		$x =~ s/(\W)/\\$1/g;
		for(@folders){
			if(/^$x/){
				my $msgs = $imap->select($_);
				if(!defined $msgs){
					print "Failed to read: $o{box} -> $_: " . $imap->errstr . "\n";
				} else {
					printf("$o{box} -> $_ " . (" " x (30 - length($_))) . "[%06d]\n",  $msgs);
				}
			}
		}
		print "\n";
	} elsif($io[0] eq 'exit' || $io[0] eq 'quit'){
		print "Good bye!\n\n";
		$imap->quit;
		exit;
	} elsif($io[0] eq 'help'){
		print $ptc;
	} else {
		print $ptc . "Invalid command: $io[0]\n\n";
	}

	print "[" . ($o{box} ? $o{box} : 'root') . ($o{folder} ? " -> $o{folder}" : '') . "] ";
}