diff options
author | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
commit | cbeb0b26e4c7caa8d1b47de791a7418dc20a4567 (patch) | |
tree | e0f7e445de1aa22a42ef873dc4b1118a8105ae93 /src/cmd/auth/factotum | |
parent | 226d80b8213821af0cbf092d1507c52b504fd368 (diff) | |
download | plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.gz plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.bz2 plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.zip |
Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.
Diffstat (limited to 'src/cmd/auth/factotum')
-rw-r--r-- | src/cmd/auth/factotum/apop.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/attr.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/chap.c | 21 | ||||
-rw-r--r-- | src/cmd/auth/factotum/cpu.c | 6 | ||||
-rw-r--r-- | src/cmd/auth/factotum/ctl.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/dat.h | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/fs.c | 4 | ||||
-rw-r--r-- | src/cmd/auth/factotum/main.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/p9any.c | 4 | ||||
-rw-r--r-- | src/cmd/auth/factotum/p9cr.c | 10 | ||||
-rw-r--r-- | src/cmd/auth/factotum/p9sk1.c | 4 | ||||
-rw-r--r-- | src/cmd/auth/factotum/proto.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/rpc.c | 2 | ||||
-rw-r--r-- | src/cmd/auth/factotum/secstore.c | 72 | ||||
-rw-r--r-- | src/cmd/auth/factotum/test.c | 2 |
15 files changed, 69 insertions, 68 deletions
diff --git a/src/cmd/auth/factotum/apop.c b/src/cmd/auth/factotum/apop.c index 5703571d..992cc0ad 100644 --- a/src/cmd/auth/factotum/apop.c +++ b/src/cmd/auth/factotum/apop.c @@ -148,7 +148,7 @@ struct ServerState enum { - APOPCHALLEN = 128, + APOPCHALLEN = 128 }; static int apopchal(ServerState*, int, char[APOPCHALLEN]); diff --git a/src/cmd/auth/factotum/attr.c b/src/cmd/auth/factotum/attr.c index 2f2511b9..1c037a53 100644 --- a/src/cmd/auth/factotum/attr.c +++ b/src/cmd/auth/factotum/attr.c @@ -143,7 +143,7 @@ hasqueries(Attr *a) char *ignored[] = { "role", - "disabled", + "disabled" }; static int diff --git a/src/cmd/auth/factotum/chap.c b/src/cmd/auth/factotum/chap.c index 2b258902..b27f64a7 100644 --- a/src/cmd/auth/factotum/chap.c +++ b/src/cmd/auth/factotum/chap.c @@ -33,7 +33,7 @@ enum { MShashlen = 16, MSchallen = 8, - MSresplen = 24, + MSresplen = 24 }; static int @@ -315,7 +315,7 @@ out: keyclose(s.k); free(user); free(resp); -// xioclose(s.asfd); +/* xioclose(s.asfd); */ return ret; } @@ -411,16 +411,17 @@ chaproles[] = }; Proto chap = { -.name= "chap", -.roles= chaproles, -.checkkey= chapcheck, -.keyprompt= "user? !password?", + "chap", + chaproles, + "user? !password?", + chapcheck }; Proto mschap = { -.name= "mschap", -.roles= chaproles, -.checkkey= chapcheck, -.keyprompt= "user? !password?", + "mschap", + chaproles, + "user? !password?", + chapcheck }; + diff --git a/src/cmd/auth/factotum/cpu.c b/src/cmd/auth/factotum/cpu.c index da8280ad..46399049 100644 --- a/src/cmd/auth/factotum/cpu.c +++ b/src/cmd/auth/factotum/cpu.c @@ -56,7 +56,7 @@ struct AuthMethod { { { "p9", p9auth, srvp9auth,}, { "netkey", netkeyauth, netkeysrvauth,}, -// { "none", noauth, srvnoauth,}, +/* { "none", noauth, srvnoauth,}, */ { nil, nil} }; AuthMethod *am = authmethod; /* default is p9 */ @@ -687,7 +687,7 @@ enum Qdir, Qcpunote, - Nfid = 32, + Nfid = 32 }; struct { @@ -697,7 +697,7 @@ struct { } fstab[] = { [Qdir] { ".", {Qdir, 0, QTDIR}, DMDIR|0555 }, - [Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 }, + [Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 } }; typedef struct Note Note; diff --git a/src/cmd/auth/factotum/ctl.c b/src/cmd/auth/factotum/ctl.c index d426f86f..6195bb84 100644 --- a/src/cmd/auth/factotum/ctl.c +++ b/src/cmd/auth/factotum/ctl.c @@ -17,7 +17,7 @@ static char *msg[] = { "key", "delkey", - "debug", + "debug" }; static int diff --git a/src/cmd/auth/factotum/dat.h b/src/cmd/auth/factotum/dat.h index eaf94caf..49377f40 100644 --- a/src/cmd/auth/factotum/dat.h +++ b/src/cmd/auth/factotum/dat.h @@ -13,7 +13,7 @@ enum RpcWriteHex, /* thread stack size - big buffers for printing */ - STACK = 65536, + STACK = 65536 }; typedef struct Conv Conv; diff --git a/src/cmd/auth/factotum/fs.c b/src/cmd/auth/factotum/fs.c index 68e86289..08894ae6 100644 --- a/src/cmd/auth/factotum/fs.c +++ b/src/cmd/auth/factotum/fs.c @@ -12,7 +12,7 @@ enum Qlog, Qctl, Qneedkey, - Qconv, + Qconv }; static int qtop; @@ -41,7 +41,7 @@ static struct "rpc", Qrpc, 0666, "proto", Qprotolist, 0444, "log", Qlog, 0600|DMEXCL, - "conv", Qconv, 0400, + "conv", Qconv, 0400 }; static void diff --git a/src/cmd/auth/factotum/main.c b/src/cmd/auth/factotum/main.c index b18cbf3d..010b5d51 100644 --- a/src/cmd/auth/factotum/main.c +++ b/src/cmd/auth/factotum/main.c @@ -26,7 +26,7 @@ threadmain(int argc, char *argv[]) char *mtpt; char err[ERRMAX]; -// mtpt = "/mnt"; +/* mtpt = "/mnt"; */ mtpt = nil; owner = getuser(); quotefmtinstall(); diff --git a/src/cmd/auth/factotum/p9any.c b/src/cmd/auth/factotum/p9any.c index 789d4d70..0267a616 100644 --- a/src/cmd/auth/factotum/p9any.c +++ b/src/cmd/auth/factotum/p9any.c @@ -15,7 +15,7 @@ extern Proto p9sk1, p9sk2, p9cr; static Proto* okproto[] = { &p9sk1, - nil, + nil }; static int @@ -267,6 +267,6 @@ p9anyroles[] = Proto p9any = { "p9any", - p9anyroles, + p9anyroles }; diff --git a/src/cmd/auth/factotum/p9cr.c b/src/cmd/auth/factotum/p9cr.c index abbad4c4..32cccb82 100644 --- a/src/cmd/auth/factotum/p9cr.c +++ b/src/cmd/auth/factotum/p9cr.c @@ -197,7 +197,7 @@ out: enum { - MAXCHAL = 64, + MAXCHAL = 64 }; typedef struct State State; @@ -222,7 +222,7 @@ enum SHaveChal, SNeedResp, - Maxphase, + Maxphase }; static char *phasenames[Maxphase] = @@ -231,7 +231,7 @@ static char *phasenames[Maxphase] = [CHaveResp] "CHaveResp", [SHaveChal] "SHaveChal", -[SNeedResp] "SNeedResp", +[SNeedResp] "SNeedResp" }; static void @@ -525,7 +525,7 @@ Proto p9cr = .write= p9crwrite, .read= p9crread, .close= p9crclose, -.keyprompt= "user? !password?", +.keyprompt= "user? !password?" }; Proto vnc = @@ -536,5 +536,5 @@ Proto vnc = .read= p9crread, .close= p9crclose, .keyprompt= "!password?", -.addkey= vncaddkey, +.addkey= vncaddkey }; diff --git a/src/cmd/auth/factotum/p9sk1.c b/src/cmd/auth/factotum/p9sk1.c index 04981e58..46156939 100644 --- a/src/cmd/auth/factotum/p9sk1.c +++ b/src/cmd/auth/factotum/p9sk1.c @@ -343,11 +343,11 @@ Proto p9sk1 = { p9sk1roles, "user? dom? !password?", p9sk1check, - p9sk1close, + p9sk1close }; Proto p9sk2 = { "p9sk2", - p9sk2roles, + p9sk2roles }; diff --git a/src/cmd/auth/factotum/proto.c b/src/cmd/auth/factotum/proto.c index 97da15ec..daf90cdd 100644 --- a/src/cmd/auth/factotum/proto.c +++ b/src/cmd/auth/factotum/proto.c @@ -23,7 +23,7 @@ Proto *prototab[] = { &p9sk2, &pass, &rsa, - nil, + nil }; Proto* diff --git a/src/cmd/auth/factotum/rpc.c b/src/cmd/auth/factotum/rpc.c index 350a0795..ad894330 100644 --- a/src/cmd/auth/factotum/rpc.c +++ b/src/cmd/auth/factotum/rpc.c @@ -41,7 +41,7 @@ char *rpcname[] = "start", "write", "readhex", - "writehex", + "writehex" }; static int diff --git a/src/cmd/auth/factotum/secstore.c b/src/cmd/auth/factotum/secstore.c index 0156e170..315de0eb 100644 --- a/src/cmd/auth/factotum/secstore.c +++ b/src/cmd/auth/factotum/secstore.c @@ -10,9 +10,9 @@ enum{ CHK = 16}; enum{ MAXFILESIZE = 10*1024*1024 }; -enum{// PW status bits +enum{/* PW status bits */ Enabled = (1<<0), - STA = (1<<1), // extra SecurID step + STA = (1<<1) /* extra SecurID step */ }; static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n"; @@ -75,28 +75,28 @@ havesecstore(void) return strcmp((char*)buf, "!account exists") == 0; } -// delimited, authenticated, encrypted connection -enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated +/* delimited, authenticated, encrypted connection */ +enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */ typedef struct SConn SConn; -extern SConn* newSConn(int); // arg is open file descriptor +extern SConn* newSConn(int); /* arg is open file descriptor */ struct SConn{ void *chan; int secretlen; - int (*secret)(SConn*, uchar*, int);// - int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer + int (*secret)(SConn*, uchar*, int);/* */ + int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */ int (*write)(SConn*, uchar*, int); - void (*free)(SConn*); // also closes file descriptor + void (*free)(SConn*); /* also closes file descriptor */ }; -// secret(s,b,dir) sets secret for digest, encrypt, using the secretlen -// bytes in b to form keys for the two directions; -// set dir=0 in client, dir=1 in server +/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */ +/* bytes in b to form keys for the two directions; */ +/* set dir=0 in client, dir=1 in server */ -// error convention: write !message in-band +/* error convention: write !message in-band */ #define readstr secstore_readstr static void writerr(SConn*, char*); -static int readstr(SConn*, char*); // call with buf of size Maxmsg+1 - // returns -1 upon error, with error message in buf +static int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */ + /* returns -1 upon error, with error message in buf */ typedef struct ConnState { uchar secret[SHA1dlen]; @@ -105,8 +105,8 @@ typedef struct ConnState { } ConnState; typedef struct SS{ - int fd; // file descriptor for read/write of encrypted data - int alg; // if nonzero, "alg sha rc4_128" + int fd; /* file descriptor for read/write of encrypted data */ + int alg; /* if nonzero, "alg sha rc4_128" */ ConnState in, out; } SS; @@ -123,7 +123,7 @@ SC_secret(SConn *conn, uchar *sigma, int direction) hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil); hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil); } - setupRC4state(&ss->in.rc4, ss->in.secret, 16); // restrict to 128 bits + setupRC4state(&ss->in.rc4, ss->in.secret, 16); /* restrict to 128 bits */ setupRC4state(&ss->out.rc4, ss->out.secret, 16); ss->alg = 1; return 0; @@ -174,7 +174,7 @@ SC_read(SConn *conn, uchar *buf, int n) werrstr("!SC_read invalid count"); return -1; } - len = (count[0]&0x7f)<<8 | count[1]; // SSL-style count; no pad + len = (count[0]&0x7f)<<8 | count[1]; /* SSL-style count; no pad */ if(ss->alg){ len -= SHA1dlen; if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){ @@ -328,7 +328,7 @@ getfile(SConn *conn, uchar *key, int nkey) if((len = atoi(s)) < 0){ werrstr("secstore: remote file %s does not exist", gf); return -1; - }else if(len > MAXFILESIZE){//assert + }else if(len > MAXFILESIZE){/*assert */ werrstr("secstore: implausible file size %d for %s", len, gf); return -1; } @@ -400,7 +400,7 @@ typedef struct PAKparams{ static PAKparams *pak; -// This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E. +/* This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E. */ static void initPAKparams(void) { @@ -422,8 +422,8 @@ initPAKparams(void) "2A6E0BAE08B14258F8C03CC1B30E0DDADFCF7CEDF0727684D3D255F1", nil, 16, nil); } -// H = (sha(ver,C,sha(passphrase)))^r mod p, -// a hash function expensive to attack by brute force. +/* H = (sha(ver,C,sha(passphrase)))^r mod p, */ +/* a hash function expensive to attack by brute force. */ static void longhash(char *ver, char *C, uchar *passwd, mpint *H) { @@ -449,7 +449,7 @@ longhash(char *ver, char *C, uchar *passwd, mpint *H) mpexp(H, pak->r, pak->p, H); } -// Hi = H^-1 mod p +/* Hi = H^-1 mod p */ static char * PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi) { @@ -462,8 +462,8 @@ PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi) return mptoa(Hi, 64, nil, 0); } -// another, faster, hash function for each party to -// confirm that the other has the right secrets. +/* another, faster, hash function for each party to */ +/* confirm that the other has the right secrets. */ static void shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest) { @@ -485,12 +485,12 @@ shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi sha1((uchar*)Hi, strlen(Hi), digest, state); } -// On input, conn provides an open channel to the server; -// C is the name this client calls itself; -// pass is the user's passphrase -// On output, session secret has been set in conn -// (unless return code is negative, which means failure). -// If pS is not nil, it is set to the (alloc'd) name the server calls itself. +/* On input, conn provides an open channel to the server; */ +/* C is the name this client calls itself; */ +/* pass is the user's passphrase */ +/* On output, session secret has been set in conn */ +/* (unless return code is negative, which means failure). */ +/* If pS is not nil, it is set to the (alloc'd) name the server calls itself. */ static int PAKclient(SConn *conn, char *C, char *pass, char **pS) { @@ -503,7 +503,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS) hexHi = PAK_Hi(C, pass, H, Hi); - // random 1<=x<=q-1; send C, m=g**x H + /* random 1<=x<=q-1; send C, m=g**x H */ x = mprand(164, genrandom, nil); mpmod(x, pak->q, x); if(mpcmp(x, mpzero) == 0) @@ -517,7 +517,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS) snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm); conn->write(conn, (uchar*)mess, strlen(mess)); - // recv g**y, S, check hash1(g**xy) + /* recv g**y, S, check hash1(g**xy) */ if(readstr(conn, mess) < 0){ fprint(2, "error: %s\n", mess); writerr(conn, "couldn't read g**y"); @@ -556,18 +556,18 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS) goto done; } - // send hash2(g**xy) + /* send hash2(g**xy) */ shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest); enc64(kc, sizeof kc, digest, SHA1dlen); snprint(mess2, Maxmsg, "k'=%s\n", kc); conn->write(conn, (uchar*)mess2, strlen(mess2)); - // set session key + /* set session key */ shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest); memset(hexsigma, 0, strlen(hexsigma)); n = conn->secret(conn, digest, 0); memset(digest, 0, SHA1dlen); - if(n < 0){//assert + if(n < 0){/*assert */ writerr(conn, "can't set secret"); goto done; } diff --git a/src/cmd/auth/factotum/test.c b/src/cmd/auth/factotum/test.c index b4104898..c9403c0b 100644 --- a/src/cmd/auth/factotum/test.c +++ b/src/cmd/auth/factotum/test.c @@ -41,7 +41,7 @@ Test test[] = "cram", proxyserver, proxyclient, "p9sk1", proxyserver, proxyclient, "p9sk2", proxyserver, proxyclient, - "p9any", proxyserver, proxyclient, + "p9any", proxyserver, proxyclient }; void |