secstore: improve error messages, newSConn() can't fail
This commit is contained in:
parent
2ec9006e9e
commit
2161885034
3 changed files with 7 additions and 14 deletions
|
@ -169,8 +169,6 @@ newSConn(int fd)
|
|||
SS *ss;
|
||||
SConn *conn;
|
||||
|
||||
if(fd < 0)
|
||||
return nil;
|
||||
ss = (SS*)emalloc(sizeof(*ss));
|
||||
conn = (SConn*)emalloc(sizeof(*conn));
|
||||
ss->fd = fd;
|
||||
|
|
|
@ -414,14 +414,10 @@ login(char *id, char *dest, int pass_stdin, int pass_nvram)
|
|||
if(verbose)
|
||||
fprint(2, "dialing %s\n", dest);
|
||||
if((fd = dial(dest, nil, nil, nil)) < 0){
|
||||
fprint(2, "secstore: can't dial %s\n", dest);
|
||||
free(c);
|
||||
return nil;
|
||||
}
|
||||
if((c->conn = newSConn(fd)) == nil){
|
||||
free(c);
|
||||
return nil;
|
||||
fprint(2, "secstore: can't dial %s: %r\n", dest);
|
||||
exits("dial failed");
|
||||
}
|
||||
c->conn = newSConn(fd);
|
||||
ntry++;
|
||||
if(!pass_stdin && !pass_nvram){
|
||||
pass = getpassm("secstore password: ");
|
||||
|
@ -478,7 +474,7 @@ login(char *id, char *dest, int pass_stdin, int pass_nvram)
|
|||
readstr(c->conn, s); /* TODO: check for error? */
|
||||
}
|
||||
if(strcmp(s, "OK") != 0){
|
||||
fprint(2, "%s: %s\n", argv0, s);
|
||||
fprint(2, "secstore: %s\n", s);
|
||||
c->conn->free(c->conn);
|
||||
free(c);
|
||||
return nil;
|
||||
|
@ -563,12 +559,12 @@ main(int argc, char **argv)
|
|||
c = login(user, tcpserve, pass_stdin, pass_nvram);
|
||||
free(tcpserve);
|
||||
if(c == nil)
|
||||
sysfatal("secstore authentication failed");
|
||||
sysfatal("authentication failed");
|
||||
if(chpass)
|
||||
rc = chpasswd(c, user);
|
||||
else
|
||||
rc = cmd(c, gfile, Gflag, pfile, rfile);
|
||||
if(rc < 0)
|
||||
sysfatal("secstore cmd failed");
|
||||
sysfatal("cmd failed");
|
||||
exits("");
|
||||
}
|
||||
|
|
|
@ -228,8 +228,7 @@ dologin(int fd, char *S, int forceSTA)
|
|||
rv = -1;
|
||||
|
||||
/* collect the first message */
|
||||
if((conn = newSConn(fd)) == nil)
|
||||
return -1;
|
||||
conn = newSConn(fd);
|
||||
if(readstr(conn, msg) < 0){
|
||||
fprint(2, "secstored: remote: %s: %r\n", msg);
|
||||
writerr(conn, "can't read your first message");
|
||||
|
|
Loading…
Reference in a new issue