annotate APOPtools/apoppasswd @ 1:28a55bc1110c imapext-2007-1

[mq]: imapext
author yuuji@gentei.org
date Mon, 14 Sep 2009 19:23:11 +0900
parents
children d741b3ecc917
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
1 #!/usr/local/bin/perl
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
2 # Customize these variables.
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
3 # If you change APOPFILEBASE, change the same variable in apopcall.c too.
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
4 # See http://www.gentei.org/~yuuji/software/imapext/
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
5
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
6 $HOME=$ENV{"HOME"};
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
7
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
8 $DEFAULTMAILDIR = "Maildir"; # Must be same as ../src/osdep/unix/Makefile
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
9
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
10 $APOPFILEBASE = ".apop"; # "$HOME/$APOPFILEBASE" is the password file
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
11 # $APOPFILEBASE = "$DEFAULTMAILDIR/apop";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
12 # $APOPFILEBASE = "Mail/apop";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
13
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
14 $ENCODER = "cat";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
15 # $ENCODER = "gzip";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
16 # $ENCODER = "uuencode $$|gzip";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
17
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
18 $DECODER = "cat";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
19 # $DECODER = "gzip -dc";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
20 # $DECODER = "gzip -dc | uudecode";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
21
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
22 $DOTQMAIL = ".qmail"; # qmail
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
23 # $DOTQMAIL = ".forward"; # Postfix
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
24
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
25 $XADDR_DELIM = "-"; # qmail
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
26 # $XADDR_DELIM = "+"; # Postfix
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
27
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
28 $HERE = "."; # qmail
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
29 # $HERE = "~"; # Postfix
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
30
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
31 $EXT = "";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
32 $force = 0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
33 $base = 0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
34
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
35 $APOPFILE = "$HOME/$APOPFILEBASE";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
36
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
37 sub handler {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
38 system "stty echo";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
39 print STDERR "Abort:\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
40 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
41 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
42
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
43 $SIG{'INT'} = $SIG{'KILL'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'handler';
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
44
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
45 while ($_=$ARGV[0], /^-.+/ && shift) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
46 if (/^-e/) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
47 $APOPFILE .= $XADDR_DELIM . ($EXT=shift);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
48 } elsif (/^-b/) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
49 $base++;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
50 } elsif (/^-c/) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
51 $create++;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
52 } elsif (/^-s/) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
53 $stream++;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
54 # and exit;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
55 } elsif (/^-h/) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
56 &usage; # and exit
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
57 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
58 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
59
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
60 sub checkmaildir {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
61 local($dotqmail) = ("$HOME/$DOTQMAIL");
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
62 local($maildir) = ($DEFAULTMAILDIR); # default
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
63 $dotqmail .= "$XADDR_DELIM$EXT" if $EXT;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
64 $maildir .= "-$EXT" if $EXT;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
65 unless (-f "$dotqmail") {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
66 if ($create) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
67 if (open(DQMAIL, "> $dotqmail")) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
68 print DQMAIL "$HERE/$maildir/\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
69 print "File [$dotqmail] created\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
70 close(DQMAIL);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
71 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
72 } else {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
73 print "$dotqmail file does not exist.\n"; # should go to stdout
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
74 print "Your should create $maildir first!\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
75 print "(-c option automatically makes it)\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
76 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
77 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
78 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
79 if (-s $dotqmail) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
80 $maildir='';
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
81 if (open(DQMAIL, "< $dotqmail")) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
82 while (<DQMAIL>) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
83 s/[\r\n \t]*$//g;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
84 next if /#/;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
85 next unless m,\./.*/,;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
86 chop; # strip trailing "/"
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
87 $maildir = $_;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
88 last;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
89 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
90 close(DQMAIL);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
91 $maildir = $DEFAULTMAILDIR if $maildir eq '';
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
92 unless (-d "$HOME/$maildir"
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
93 && -d "$HOME/$maildir/new"
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
94 && -d "$HOME/$maildir/cur"
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
95 && -d "$HOME/$maildir/tmp") {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
96 if ($create) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
97 mkdir "$HOME/$maildir", 0700;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
98 mkdir "$HOME/$maildir/new", 0700;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
99 mkdir "$HOME/$maildir/cur", 0700;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
100 mkdir "$HOME/$maildir/tmp", 0700;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
101 print "Maildir [$maildir/] created\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
102 } else {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
103 print "Maildir($maildir) does not exist\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
104 print "Your should do maildirmake $maildir first!\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
105 print "(-c option automatically makes it)\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
106 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
107 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
108 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
109 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
110 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
111 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
112
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
113 sub usage {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
114 local($mydir, $myname) = ($0 =~ m,(.*)/(.*),);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
115 print<<_EOU_;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
116 $myname Change Mail password for imap-4.7+qmailapop
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
117 Usage: $myname [options]
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
118 Options are...
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
119 -e EXT Set target email address to "user-EXT"
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
120 -c If no .qmail file and Maildir, create them
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
121
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
122 _EOU_
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
123 exit 0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
124 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
125
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
126 if ($stream) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
127 &stream;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
128 exit; # not reached
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
129 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
130 $OK=0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
131 until ($OK) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
132 system "stty -echo";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
133 print STDERR "Enter APOP Password: ";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
134 $new1 = <>;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
135 print STDERR "\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
136 if (length($new1) == 1) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
137 print STDERR "Canceled\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
138 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
139 } elsif (length($new1) < 9) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
140 print STDERR "Password is too short! Please use more than 8 chars.\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
141 next;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
142 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
143 print STDERR "Again APOP Password: ";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
144 $new2 = <>;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
145 if ($new1 eq $new2) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
146 $OK=1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
147 } else {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
148 print STDERR "\nPassword mismatch! Try again.\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
149 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
150 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
151 #OK
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
152 &checkmaildir;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
153 system "stty echo";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
154 open(NP, "| $ENCODER > $APOPFILE") || die "Cannot write on $APOPFILE\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
155 print NP "$new1";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
156 close(NP);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
157 chmod 0600, $APOPFILE;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
158 print STDERR "\nUpdated APOP password successfully.\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
159
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
160 sub stream { # Must match with old password
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
161 local($PASS, $old, $new1, $new2, $master) = (0);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
162 local($masterfile) = ($APOPFILE);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
163 $masterfile = "$HOME/$APOPFILEBASE" if $base;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
164 exit 1 if ($> == 0);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
165 while (<>) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
166 chop;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
167 if (/^PASS (.*)$/i) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
168 $old = $1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
169 } elsif (/^NEW (.*)/i) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
170 $new1 = $1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
171 } elsif (/^NEW2 (.*)/i) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
172 $new2 = $1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
173 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
174 last if ("$new1" ne "" && "$new2" ne "");
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
175 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
176 if (-s $APOPFILE || ($base && -f $masterfile)) { # Already exist
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
177 if (open(OLD, "$DECODER $masterfile |")) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
178 ($master = <OLD>) =~ s/[\n\r]$//g;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
179 close(OLD);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
180 } else {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
181 print "Old password file corrupted.\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
182 print "Please ask to administrator.\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
183 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
184 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
185 if ($master ne $old) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
186 print "Illegal password\nBye\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
187 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
188 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
189 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
190 if ($new1 ne $new2) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
191 print "Password(new) mismatch\nBye\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
192 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
193 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
194 # OK, now begin to create!
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
195 &checkmaildir;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
196 if (open(P, "| $ENCODER > $APOPFILE")) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
197 # open success
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
198 print P "$new1\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
199 close(P);
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
200 chmod 0600, $APOPFILE;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
201 if (-s $APOPFILE) {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
202 print "Success!\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
203 exit 0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
204 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
205 } else {
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
206 print "Cannot output to $APOPFILE\nBye\n";
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
207 exit 1;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
208 }
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
209 exit 0;
28a55bc1110c [mq]: imapext
yuuji@gentei.org
parents:
diff changeset
210 }

yatex.org