This file is indexed.

/usr/bin/imsetup is in im 1:151-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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
#! /usr/bin/perl
################################################################
###
###		    imsetup: setup command for IM
###
### Author:  Internet Message Group <img@mew.org>
### Created: May  9, 1997
### Revised: Feb 15, 2010
###

BEGIN {
    use lib '/usr/share/perl5';
};

$Prog = 'imsetup';
my $VERSION_DATE = "20110525";
my $VERSION_NUMBER = "151";
my $VERSION = "${Prog} version ${VERSION_DATE}(IM${VERSION_NUMBER})";
my $VERSION_INFORMATION = "${Prog} (IM ${VERSION_NUMBER}) ${VERSION_DATE}
Copyright (C) 1999 IM developing team
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
";

##
## Require packages
##

use File::Copy;
use Sys::Hostname;
use IM::Config qw(init_opt read_opt read_cfg use_cl no_sync help);
use IM::Util;
use IM::Address qw(extract_addr);
use integer;
use strict;
use vars qw($Prog $EXPLANATION @OptConfig
	    $opt_fromdomain $opt_noharm $opt_usecl $opt_nosync
	    $opt_help $opt_version);

##
## Environments
##

my $imdir = ".im";
my $config = "Config";
my $alias = "Aliases";

my $home = $ENV{'HOME'};
my $address;
my $username;
my $mail = "Mail";
my $news = "News";
my $usecl;
my $nosync;
my $src = "local";
my $mailbox_style = "mbox";
my $auth = "";
my($user, $host) = split(/\@/, $address);
my $keep = 0;
my $smtpserver = "localhost";

my($mhdir, $mhalias, $domain, $nntpservers);

$EXPLANATION = "$VERSION
setup for IM

Usage: $Prog [Options]
";

@OptConfig = (
    'FromDomain;s;;' => 'Default domain name for mail address',
    'noharm;b;;' => "Do execute setup, show what will be performed",
    'help;b;;'    => "Display this help and exit",
    'version,V;b;;' => "Output version information and exit",
    );

##
## Profile and option processing
##

init_opt(\@OptConfig);
read_cfg();
read_opt(\@ARGV); # help?
print("${VERSION_INFORMATION}") && exit $EXIT_SUCCESS if $opt_version;
help($EXPLANATION) && exit $EXIT_SUCCESS if $opt_help;

##
## Main
##

if ($opt_fromdomain =~ /\./) {
    $address = im_getlogin() . "\@" . $opt_fromdomain;
} else {
    $address = im_getlogin() . "\@" . get_domain_name();
}
$usecl = use_cl() ? 'yes' : 'no';
$nosync = no_sync() ? 'yes' : 'no';

&read_conf();
&check_im_directory();
&make_conf_file();
&copy_alias_file();

sub get_domain_name() {
    my $hostname = hostname();
    unless ($hostname =~ /\./) {
	my($h) = gethostbyname($hostname);
	$hostname = $h if ($h);
    }
    $hostname =~ s/^[^.]+\.//;

    return $hostname;
}

sub read_conf() {
    $home = &input_config("Where is your home directory?", $home);
    &scan_mh_conf();

    my $mymail = "$home/$mail";
    my $mynews = "$home/$news";
    my $qhome = quotemeta($home);

    do {
	do {
	    $mymail = &input_config("Where is your Mail directory?", $mymail);
	} until (($mail = $mymail) =~ s!^$qhome/!!
		 || &input_confirm("Sure to use $mail which is not beneath "
				   . "your home directory?"));
    } while (! &check_and_create_directory($mymail));

    do {
	do {
	    $mynews = &input_config("Where is your News directory?", $mynews);
	} until (($news = $mynews) =~ s!^$qhome/!!
		 || &input_confirm("Sure to use $news which is not beneath "
				   . "your home directory?"));
    } while (! &check_and_create_directory($mynews));

    $address = &input_config("What is your E-mail address(es)?", $address);

    do {
        $src = &input_config("What kind of mail spool do you use? (local/POP/IMAP)", $src);
    } while (! ($src =~ /^local$|^pop$|^imap$/i));
  
    if ($src =~ /^local/i) {
	do {
	    $mailbox_style = &input_config("What kind of mailbox style do you use? (mbox/maildir)", $mailbox_style);
	} while (! ($mailbox_style =~ /^mbox$|^maildir$/i));
    }

    if ($src =~ /^pop|^imap/i) {
        my $a = extract_addr($address);
        if ($src =~ /^pop/i) {
            $auth = "POP";
            do {
                $auth = &input_config("What kind of POP authentication mechanism? (POP/APOP/RPOP)", $auth);
            } while (! ($auth =~ /^pop$|^apop$|^rpop$/i));
        } else {
            $auth = "AUTH";
            do {
                $auth = &input_config("What kind of IMAP authentication mechanism? (AUTH/LOGIN)", $auth);
            } while (! ($auth =~ /^auth$|^login$/i));
        }
        ($user, $host) = split(/\@/, $a);
        $host = "mail." . $host;
        $user = &input_config("What is your $src account name?", $user);
        $host = &input_config("What is your $src server name or IP address?", $host);

    } 

    if ($src =~ /^pop/i) {
	$keep = &input_config("Do you want to preserve messages?\n"
                        . "0 (delete immediately), -1 (preserve forever),\n"
			. "N > 0 (delete messages after N days) "
			, $keep);
    }

    if ($src =~ /^pop|^imap/i) { $smtpserver = $host; }
    $smtpserver = &input_config("What is your SMTP server name or IP address?", $smtpserver);

    $usecl = &input_config("Do you want to use value of Content-Length"
			   . " header for delimitation for local\nmail?"
			   . " (Answer yes if your OS supports Content-Length"
			   . " header like Solaris 2.x,\notherwise answer no.)"
			   , $usecl);

    if ($nosync ne 'yes') {
	$nosync = 
	    &input_config("Does your system can detect write errors without"
			  . " fsync(2)? (You can answer yes,\n"
			  . "if your home directory is on local file system,"
			  . " otherwise answer no.)"
			  , $nosync eq 'undefined' ? 'no' : $nosync);
    }

    print "\n";
}

sub input_config($$) {
    my($msg, $default) = @_;
    my $ret;

    print "$msg [$default] ";
    chomp($ret = <STDIN>);
    $ret = $default if ($ret =~ /^\s*$/);
    return $ret;
}

sub input_confirm($;$) {
    my($msg, $default) = @_;
    my $ret;

    $default = "yes" if $default eq "";

    print "$msg [$default] ";
    chomp($ret = <STDIN>);
    $ret = $default if ($ret =~ /^\s*$/);
    return $ret =~ m/^y/i;
}

sub scan_mh_conf() {
    my $mh_profile = "$home/.mh_profile";
    if (-f $mh_profile) {
	open(MH_PROFILE, $mh_profile);
	while (<MH_PROFILE>) {
	    chomp;
	    if (/^Path:\s*(.*)/i) {
		$mhdir = $mail =  $1;
		$mail =~ s/($home|~)\///;
	    }
	    if (/^Aliasfile:\s*(.*)/i) {
		$mhalias = $1;
	    }
	    if (!$mhalias && /^ali:\s*-alias\s*(.*)/i) {
		$mhalias = $1;
	    }
	    if (/^Alternate-Mailboxes:\s*(.*)/i) {
		$address = $1;
	    }
	}
    } else {
	$mhdir = $mail;
	$mhalias = 'aliases';
    }
}

sub check_im_directory() {
    if (-x "$home/$imdir") {
	print "$home/$imdir is already exist.\n";
    } else {
	if (!$opt_noharm) {
	    if (mkdir("$home/$imdir", 0700) == 0) {
		die "Fail to create $home/$imdir directory: $!\n";
	    }
	    print "Directory $home/$imdir created.\n";
	}
    }
}

sub check_and_create_directory($) {
    my $dir = shift;

    if (! -x $dir) {
	if (&input_confirm("$dir does not exist. Create it?")) {
	    print "Creating $dir directory.\n";
	    if (!$opt_noharm) {
		if (mkdir("$dir", 0700) == 0) {
		    die "Fail to create $dir directory: $!\n";
		}
		print "Directory $dir created.\n";
	    }
	    return 1;
	}
	else {
	    return 0;
	}
    }
    return 1;
}

sub copy_alias_file() {
    my $im_alias = "$home/$imdir/$alias";
    my $mh_alias = "$home/$mhdir/$mhalias";

    if (! -f $mh_alias) {
	$mh_alias = $mhalias;
    }

    if (-f $mh_alias && ! -f $im_alias) {
	print "Copy $mh_alias to $im_alias.\n";
	if (!$opt_noharm) {
	    copy($mh_alias, $im_alias);
	}
    }
}

sub make_conf_file() {
    my $im_config = "$home/$imdir/$config";

    if (-f $im_config) {
	print "Backup $im_config to $im_config.bak.\n";
	if (!$opt_noharm) {
	    rename ("$im_config", "$im_config.bak");
	}
    }

    print "Setup $im_config.\n";
    if (!$opt_noharm) {
	my $a = extract_addr($address);
	($username, $domain) = split(/\@/, $a);
	$nntpservers = $ENV{'NNTPSERVER'} || "localhost";
	open(CONFIG, ">$im_config");
	print CONFIG <<"---";
################################################################
###
### Sample ~/.im/Config
###
### Syntax::
###	key=value
###
###  * "key=value" is equivalent to "--key=value" style command option.
###  * "key" must start at the beginning of the line.
###  * "=" must follow after "key" without white spaces.
###  * White spaces are allowed between "=" and "value".
###  * ":" can be used instead of "=".
###  * Characters after "#" are ignored.
###
### The following examples are all the same:
###	key=value
###	key=  value
###	key:value
###     key:  value
###
### \$variable will be expanded.
### '~' will be expanded.
###

##
## Individual information
##

Address=$address
FromDomain=$domain
ToDomain=$domain
#Name=Full Name			# commentary name for my mail address
				# should not contain 8bit characters
#AddrRegex=
#Org=The Mew Organization	# for news posting
User=$username

##
## Default global parameters
##

### Directories (relative to ~/)
MailDir=$mail
NewsDir=$news			# for saved news

### Folders in \$MailDir
#InboxFolder=+inbox		# default destination of imget
#DraftFolder=+draft
#TrashFolder=+trash		# default destination of message removal in Mew

### Folder style in \$NewsDir (saved news articles)
#PreserveDot=off		# off: /news/group/, on: /news.group/

### Mode for creation
#FolderMode=0700
#MsgMode=0600

### To keep state of IM commands (CurrentFolder, etc.)
#ContextFile=Context		# relative to ~/.im/


##
## Default settings
##

## Address Book
#AddrBookFile=Addrbook		# relative to ~/.im/
#AddrBookFile=\${HOME}/Mail/Addrbook	# if you share Addrbook with Mew 2
## Mail address aliases
#AliasesFile=Aliases		# relative to ~/.im/
## PetName: mail address aliases for displaying
#PetnameFile=Petnames		# relative to ~/.im/

## Message-ID database
#MsgDBFile=msgiddb		# location (relative to ~/.im/)
#MsgDBType=DB			# type of database (DB, NDBM, SDBM)

## To call user defined subroutines (relative to ~/.im/)
#GetChkSbr=getchk.sbr		# hooks for imget
#GetSbr=get.sbr			# hooks for imget
#ScanSbr=scan.sbr		# hooks for imget/imls

## Working folders
#Src=\$InboxFolder		# default source of most commands
#Imrm.Src=\$TrashFolder		# default source for message cleanups

## imget/imls specific
#ScanSbr=scan.sbr		# hook for special processing (rel. to ~/.im/)
#Form=%+5n %m%d %-14A %S || %b	# default format for scanning
#AllowCRLF=no			# saved messages may contain CRLF (DOS style)
#Width=80			# default width for scanning
#JisSafe=on			# escape seq. of JIS char. should be managed
#Indent=2			# indent step for threading

## Servers
Smtpservers=$smtpserver
#Smtpservers=localhost		# default server for SMTP
#EmgSmtpSvrs=12.34.56.78,localhost	# SMTP server just for error return
#NntpServers=localhost		# default server for NNTP

## imget specific
#GetSbr=get.sbr			# hook for special processing (rel. to ~/.im/)
---

	if ($src =~ /^local/i) {
	    if ($mailbox_style =~ /^maildir/i) {
		print CONFIG <<"---";
MBoxStyle=qmail
Imget.Src=local:\${HOME}/Maildir
keep=$keep
---
	    } else {
		print CONFIG <<"---";
Imget.Src=local
keep=$keep
---
	    }
	}
        print CONFIG <<"---";
#Imget.Src=local		# default source of imget (local mailbox)
#lock=flock			# locking style of local mailbox
#rpath=append			# conversion of UNIX From into Return-Path:
#PopHistory=pophist-{POPSERVERID}	# to save last state (relative to ~/.im/)
#NntpHistory=newshist		# to save last state (relative to ~/.im/)
#MboxFilter=bogofilter -p -M -I	# filter for mbox file
#MboxFilter=spamoracle mark
#MBoxFilter=bsfilter --spam-cutoff 0.85 --pipe --insert-flag --mbox 2>/dev/null
#MBoxStyle=qmail		# in case of qmail (maildir format)
#Imget.Src=local:\${HOME}/Maildir
UseCL=$usecl			# Use value of Content-Length header
NoSync=$nosync			# Do not need fsync(2) on writing file
#FsyncNumber=0			# if 0, system call number of fsync is guessed
#SshPath=/usr/bin/ssh		# Path name of SSH program

---
        if ($src =~ /^pop/i) {
            print CONFIG <<"---";
Imget.Src=pop
PopAccount=/$auth:$user\@$host
keep=$keep
---
        }
        print CONFIG <<"---";
#Imget.Src=pop
#PopAccount=/APOP\@localhost	# account info for POP access
#PopAccount=/APOP:user\@host	# account info with user name
#PopAccount=/APOP:user\@host/110	# account info with user name and port number
#Keep=7				# preserve read messages on server
#ProtoKeep=UIDL			# how to know which message is unread
				# (UIDL, LAST, STATUS, MSGID)
#IgnorePostPet=yes		# leave messages for PostPet on POP server

---
        if ($src =~ /^imap/i) {
            print CONFIG <<"---";
Imget.Src=imap%INBOX
ImapAccount=/$auth:$user\@$host
keep=$keep
---
        }
        print CONFIG <<"---";
#Imget.Src=imap%INBOX
#ImapAccount=/AUTH\@localhost	# account info for IMAP access
#ImapAccount=/AUTH:user\@host	# account info with user name
#HttpProxy=proxy-server:8080	# proxy server for HTTP access
#NoProxy=http://.*my.domain/	# URL regex not to use Proxy server
#UsePwAgent=yes			# use password agent
#PwAgentPort=0			# Port to connect pwagent with TCP/IP
				# 0 to use UNIX domain socket
				# NOTE: non-0 (e.g. 6543) is insecure
				#       on multi-user system
#PwAgentTmpDir=pwagtmp		# temporary directory (relative to ~/.im/)

# be careful on security if you wish to use PwFiles!
#UsePwFiles=yes			# use password files
#PwFiles=password		# password files (relative to ~/.im/)

#MailFoldersFile=~/Mail/.folders

#UseTouchFile=yes		# use time-stamp file
#TouchFile=.mew-touch		# time-stamp file for message folders

#NamazuV2=yes			# use Namazu version 2 (1.9.x or late)
#NamazuDir=Namazu		# relative to ~/
#NamazuLockDir=nmzlock		# lock directory (relative to ~/.im/)
#MknmzOptions=--decode-base64	# additional options for mknmz
#MknmzIncludeFile=~/Namazu/mknmz-inc.pl	# mknmz -I <file>
#MknmzIgnoreFoldersRegex=\+(attach|draft|trash|queue|postq|schedule)

## imput specific
#FccDir=\$MailDir		# directory for FCC folders
#QueueDir=queue			# directory for to store messages to be sent
#UseXDispatcher=yes		# use X-Dispatcher field
#MsgIdUser=\${USER}		# user part for creation of Message-Id:
#MsgIdDomain=\${HOST}		# if you want to use FQDN of dispatching host
#ObeyMTAdomain=yes		# do not append domainpart to addresses by imput
#NoMsgIdForNews=yes		# do not insert Message-Id: when posting as news
#NewsGMTdate=yes		# use GMT for Date: when posting as news
#UseLines=yes			# generate Lines header line
#JPheader=yes			# encode ISO-2022-JP with RFC2047
#Defcode=EUC			# default code in case no way to judge SJIS/EUCj
#JPconv=yes			# convert SJIS/EUCj to ISO-2022-JP
#NoHdrFolding=yes		# do not fold long header line when encoding
#HdrQEncoding=yes		# use Q-encoding to encode ISO-2022-JP
#NameInComment=yes		# yes: (Full Name) Addr, no: Full Name <Addr>
#Lines=3000			# unit to split a message to partial
#Annotate=yes			# annotate on parent messages (MsgDB required)

# Common operational settings
#Help=no
#Quiet=no
#Noharm=no
#Verbose=no
#Debug=


#case mew
#FromDomain=mew.org

#case queue
#JustQueuing=yes
#Queuing=yes

#case news
#Assoc=	+inbox=nntp:fj.mail.system.sendmail;\\
#	+inbox=nntp:fj.mail
#Count=10

#case default
# -- global setting again --
---
    }
}

__END__

=head1 NAME

imsetup - setup for IM

=head1 SYNOPSIS

B<imsetup> [OPTIONS]

=head1 DESCRIPTION

The I<imsetup> command is a setup program for IM.

This command is provided by IM (Internet Message).

=head1 OPTIONS

=over 5

=item I<-f, --fromdomain=STRING>

Default domain name for mail address.

=item I<-n, --noharm={on,off}>

Do execute setup, show what will be performed.

=item I<-h, --help>

Display help message and exit.

=item I<--version>

Output version information and exit.

=back

=head1 COPYRIGHT

IM (Internet Message) is copyrighted by IM developing team.
You can redistribute it and/or modify it under the modified BSD
license.  See the copyright file for more details.

=cut

### Copyright (C) 1997, 1998, 1999 IM developing team
### All rights reserved.
### 
### Redistribution and use in source and binary forms, with or without
### modification, are permitted provided that the following conditions
### are met:
### 
### 1. Redistributions of source code must retain the above copyright
###    notice, this list of conditions and the following disclaimer.
### 2. Redistributions in binary form must reproduce the above copyright
###    notice, this list of conditions and the following disclaimer in the
###    documentation and/or other materials provided with the distribution.
### 3. Neither the name of the team nor the names of its contributors
###    may be used to endorse or promote products derived from this software
###    without specific prior written permission.
### 
### THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
### ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
### PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
### LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
### CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
### SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
### BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
### WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
### OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
### IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

### Local Variables:
### mode: perl
### End: