mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
mailfs: add -u user argument
R=rsc CC=plan9port.codebot http://codereview.appspot.com/5435052
This commit is contained in:
parent
2fc68b6d8e
commit
0c9524b721
3 changed files with 16 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue