Mailpop3 to use factotum

7 views
Skip to first unread message

caer...@gmail.com

unread,
Jun 8, 2007, 5:44:32 PM6/8/07
to
This change to Mailpop3 makes it use factotum to find the
user and password for the given pop server passed in
using the -s arg. Start Feedkey first so that it will
prompt for user and password if it isn't already in factotum.

--- /n/acme-0.9.4/appl/acme/acme/mail/Mailpop3.b Thu May 31 23:20:28 EDT 2007
+++ /n/local/appl/acme/acme/mail/Mailpop3.b Fri Jun 08 18:07:30 EDT 2007
@@ -11,6 +11,8 @@
arg: Arg;
include "encoding.m";
enc: Encoding;
+include "factotum.m";
+
mailpop3 : module {
init : fn(ctxt : ref Draw->Context, argl : list of string);
};
@@ -152,6 +154,11 @@
't' => usessl = 1;
's' => server = arg->earg();
}
+ if(server != nil){
+ factotum := load Factotum Factotum->PATH;
+ factotum->init();
+ (user, pwd) = factotum->getuserpasswd(sys->sprint("proto=pass service=pop3 dom=%s", server));
+ }
args = arg->argv();
main();
}
@@ -1068,34 +1075,36 @@
b.leng = 0;
b.readonly = readonly;
b.w = Win.wnew();
- b.w.wwritebody("Password:");
b.w.wname("Mail/box/");
- b.w.wclean();
- b.w.wselect("$");
- b.w.ctlwrite("noecho\n");
b.cevent = chan of Event;
spawn b.w.wslave(b.cevent);
- e := ref Event;
- for (;;) {
- sleep(1000);
- s := b.w.wreadall();
- lens := len s;
- if (lens >= 10 && s[0:9] == "Password:" && s[lens-1] == '\n') {
- pwd = s[9:lens-1];
- for (i := 0; i < lens; i++)
- s[i] = '\b';
- b.w.wwritebody(s);
- break;
- }
- alt {
- *e = <-b.cevent =>
- b.event(e);
+ if(pwd == nil){
+ b.w.wwritebody("Password:");
+ b.w.wclean();
+ b.w.wselect("$");
+ b.w.ctlwrite("noecho\n");
+ e := ref Event;
+ for (;;) {
+ sleep(1000);
+ s := b.w.wreadall();
+ lens := len s;
+ if (lens >= 10 && s[0:9] == "Password:" && s[lens-1] == '\n') {
+ pwd = s[9:lens-1];
+ for (i := 0; i < lens; i++)
+ s[i] = '\b';
+ b.w.wwritebody(s);
break;
- * =>
- break;
+ }
+ alt {
+ *e = <-b.cevent =>
+ b.event(e);
+ break;
+ * =>
+ break;
+ }
}
+ b.w.ctlwrite("echo\n");
}
- b.w.ctlwrite("echo\n");
pop3open(1);
pop3init(b);
while((m = m.read(b)) != nil){

Reply all
Reply to author
Forward
0 new messages