aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2011-11-28 09:21:01 -0500
committerRuss Cox <rsc@swtch.com>2011-11-28 09:21:01 -0500
commit0c9524b72197871c435464d064fdcc3dd5437581 (patch)
tree9cc2ad44b896b5918ee355722ee84e140c754510 /src/cmd/upas
parent2fc68b6d8ebc0479318fa9764bfaa7ff58165fc3 (diff)
downloadplan9port-0c9524b72197871c435464d064fdcc3dd5437581.tar.gz
plan9port-0c9524b72197871c435464d064fdcc3dd5437581.tar.bz2
plan9port-0c9524b72197871c435464d064fdcc3dd5437581.zip
mailfs: add -u user argument
R=rsc CC=plan9port.codebot http://codereview.appspot.com/5435052
Diffstat (limited to 'src/cmd/upas')
-rw-r--r--src/cmd/upas/nfs/imap.c10
-rw-r--r--src/cmd/upas/nfs/imap.h2
-rw-r--r--src/cmd/upas/nfs/main.c10
3 files changed, 16 insertions, 6 deletions
diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c
index 7523a447..c2aed9a5 100644
--- a/src/cmd/upas/nfs/imap.c
+++ b/src/cmd/upas/nfs/imap.c
@@ -18,6 +18,7 @@ struct Imap
int ticks; /* until boom! */
char* server;
char* root;
+ char* user;
int mode;
int fd;
Biobuf b;
@@ -91,7 +92,7 @@ static Sx* zBrdsx(Imap*);
*/
Imap*
-imapconnect(char *server, int mode, char *root)
+imapconnect(char *server, int mode, char *root, char *user)
{
Imap *z;
@@ -101,6 +102,7 @@ imapconnect(char *server, int mode, char *root)
z = emalloc(sizeof *z);
z->server = estrdup(server);
z->mode = mode;
+ z->user = user;
if(root)
if(root[0] != 0 && root[strlen(root)-1] != '/')
z->root = smprint("%s/", root);
@@ -200,7 +202,11 @@ imaplogin(Imap *z)
Sx *sx;
UserPasswd *up;
- if((up = auth_getuserpasswd(auth_getkey, "proto=pass role=client service=imap server=%q", z->server)) == nil){
+ if(z->user != nil)
+ up = auth_getuserpasswd(auth_getkey, "proto=pass role=client service=imap server=%q user=%q", z->server, z->user);
+ else
+ up = auth_getuserpasswd(auth_getkey, "proto=pass role=client service=imap server=%q", z->server);
+ if(up == nil){
werrstr("getuserpasswd - %r");
return -1;
}
diff --git a/src/cmd/upas/nfs/imap.h b/src/cmd/upas/nfs/imap.h
index e5d9954e..774964a5 100644
--- a/src/cmd/upas/nfs/imap.h
+++ b/src/cmd/upas/nfs/imap.h
@@ -2,7 +2,7 @@ typedef struct Imap Imap;
#pragma incomplete Imap
void imapcheckbox(Imap *z, Box *b);
-Imap* imapconnect(char *server, int mode, char *root);
+Imap* imapconnect(char *server, int mode, char *root, char *user);
int imapcopylist(Imap *z, char *nbox, Msg **m, uint nm);
void imapfetchraw(Imap *z, Part *p);
void imapfetchrawbody(Imap *z, Part *p);
diff --git a/src/cmd/upas/nfs/main.c b/src/cmd/upas/nfs/main.c
index 68792dc2..ebcf701c 100644
--- a/src/cmd/upas/nfs/main.c
+++ b/src/cmd/upas/nfs/main.c
@@ -22,14 +22,14 @@ Imap *imap;
void
usage(void)
{
- fprint(2, "usage: mailfs [-DVtx] [-m mtpt] [-s srvname] [-r root] server\n");
+ fprint(2, "usage: mailfs [-DVtx] [-m mtpt] [-s srvname] [-r root] [-u user] server\n");
threadexitsall("usage");
}
void
threadmain(int argc, char **argv)
{
- char *server, *srvname, *root;
+ char *server, *srvname, *root, *user;
int mode;
char *mtpt;
@@ -37,6 +37,7 @@ threadmain(int argc, char **argv)
root = "";
mode = Unencrypted;
mtpt = nil;
+ user = nil;
ARGBEGIN{
default:
usage();
@@ -55,6 +56,9 @@ threadmain(int argc, char **argv)
case 't':
mode = Tls;
break;
+ case 'u':
+ user = EARGF(usage());
+ break;
case 'x':
mode = Cmd;
break;
@@ -74,7 +78,7 @@ threadmain(int argc, char **argv)
boxinit();
fsinit0();
- if((imap = imapconnect(server, mode, root)) == nil)
+ if((imap = imapconnect(server, mode, root, user)) == nil)
sysfatal("imapconnect: %r");
threadpostmountsrv(&fs, srvname, mtpt, 0);
}