ref: 21618850343af89d5a70f7d53a2ec32066e2ec20
parent: 2ec9006e9ef02e5e13ff51eaabac23b9695ed113
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Aug 20 21:18:36 EDT 2014
secstore: improve error messages, newSConn() can't fail
--- a/sys/src/cmd/auth/secstore/SConn.c
+++ b/sys/src/cmd/auth/secstore/SConn.c
@@ -169,8 +169,6 @@
SS *ss;
SConn *conn;
- if(fd < 0)
- return nil;
ss = (SS*)emalloc(sizeof(*ss));
conn = (SConn*)emalloc(sizeof(*conn));
ss->fd = fd;
--- a/sys/src/cmd/auth/secstore/secstore.c
+++ b/sys/src/cmd/auth/secstore/secstore.c
@@ -414,14 +414,10 @@
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;
+ fprint(2, "secstore: can't dial %s: %r\n", dest);
+ exits("dial failed");
}
- if((c->conn = newSConn(fd)) == nil){
- free(c);
- return nil;
- }
+ c->conn = newSConn(fd);
ntry++;
if(!pass_stdin && !pass_nvram){
pass = getpassm("secstore password: ");
@@ -478,7 +474,7 @@
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 @@
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("");
}
--- a/sys/src/cmd/auth/secstore/secstored.c
+++ b/sys/src/cmd/auth/secstore/secstored.c
@@ -228,8 +228,7 @@
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");