From 3c6ce91e5a23fa2cb742cb3f6759cec3ece10249 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 10 Jul 2009 13:52:16 +0100 Subject: [PATCH] Roughly prototype the kauth directory A first pass at prototyping and warning reduction for the kauth directory. kauth is plagued by the des key type problems, and no attempt to remedy this has been made. Some other complex warnings remain - it didn't seem worth the effort to do this in too much detail, as it's dying soon. Reviewed-on: http://gerrit.openafs.org/23 Verified-by: Jeffrey Altman Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- src/kauth/admin_tools.c | 22 ++++++------ src/kauth/authclient.c | 17 +++++---- src/kauth/client.c | 5 ++- src/kauth/kaauxdb.c | 3 +- src/kauth/kadatabase.h | 40 +++++++++++++++++++++ src/kauth/kalog.c | 9 ++--- src/kauth/kalog.h | 3 ++ src/kauth/kaprocs.c | 46 +++++++----------------- src/kauth/kaprocs.h | 23 ++++++++++++ src/kauth/kaserver.c | 43 +++++++++-------------- src/kauth/kautils.c | 1 + src/kauth/kkids.c | 6 ++-- src/kauth/kkids.h | 17 +++++++++ src/kauth/klog.c | 4 +-- src/kauth/knfs.c | 30 ++++++---------- src/kauth/kpasswd.c | 13 ++++--- src/kauth/kpwvalid.c | 1 + src/kauth/krb_tf.c | 5 ++- src/kauth/krb_udp.c | 93 +++++++++++++++---------------------------------- src/kauth/read_passwd.c | 30 +++++----------- src/kauth/rebuild.c | 2 ++ src/kauth/user.c | 3 +- 22 files changed, 213 insertions(+), 203 deletions(-) create mode 100644 src/kauth/kadatabase.h create mode 100644 src/kauth/kaprocs.h create mode 100644 src/kauth/kkids.h diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c index 4f6c7cb..9f27b31 100644 --- a/src/kauth/admin_tools.c +++ b/src/kauth/admin_tools.c @@ -38,10 +38,13 @@ #include #include #include +#include +#include #include "kauth.h" #include "kautils.h" #include "kaport.h" +#include "kkids.h" #define CMD_PARSER_AMBIG_FIX 1 /* allow ambiguous aliases */ @@ -56,7 +59,7 @@ static char myName[510]; /* almost like whoami save with path and without : */ static int finished; static int zero_argc; static char **zero_argv; -afs_uint32 ka_islocked(); +afs_uint32 ka_islocked(char *, char *, afs_uint32 *); afs_int32 DefaultCell(void) @@ -749,7 +752,7 @@ StringToKey(struct cmd_syndesc *as, void *arock) } ucstring(realm, realm, sizeof(realm)); } else { - if (code = DefaultCell()) + if ((code = DefaultCell())) return code; ucstring(realm, cell, sizeof(realm)); } @@ -962,7 +965,7 @@ ListTicket(struct ktc_principal *server, int verbose) return 0; } -static +static int GetTicket(struct cmd_syndesc *as, void *arock) { int code; @@ -984,7 +987,7 @@ GetTicket(struct cmd_syndesc *as, void *arock) return KABADCMD; } if (server.cell[0] == 0) { - if (code = DefaultCell()) + if ((code = DefaultCell())) return code; strcpy(server.cell, cell); } else { @@ -1008,7 +1011,7 @@ GetTicket(struct cmd_syndesc *as, void *arock) return code; } -static +static int GetPassword(struct cmd_syndesc *as, void *arock) { int code; @@ -1285,7 +1288,6 @@ NoAuth(struct cmd_syndesc *as, void *arock) static int MyBeforeProc(struct cmd_syndesc *as, void *arock) { - extern struct passwd *getpwuid(); struct ktc_encryptionKey key; struct ktc_principal auth_server, auth_token, client; char realm[MAXKTCREALMLEN]; @@ -1540,7 +1542,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) /* These are some helpful command that deal with the cache managers tokens. */ -static +static int ForgetTicket(struct cmd_syndesc *as, void *arock) { afs_int32 code; @@ -1594,7 +1596,7 @@ ForgetTicket(struct cmd_syndesc *as, void *arock) return 0; } -static +static int ListTickets(struct cmd_syndesc *as, void *arock) { afs_int32 code = 0; @@ -1614,7 +1616,7 @@ ListTickets(struct cmd_syndesc *as, void *arock) return code; } if (server.cell[0] == 0) { - if (code = DefaultCell()) + if ((code = DefaultCell())) return code; strcpy(server.cell, cell); } else { @@ -1816,7 +1818,7 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[]) strcpy(whoami, "kas"); - if (code = cmd_Dispatch(cmd_argc, cmd_argv)) { + if ((code = cmd_Dispatch(cmd_argc, cmd_argv))) { return code; } diff --git a/src/kauth/authclient.c b/src/kauth/authclient.c index 36e3d1b..ef81d33 100644 --- a/src/kauth/authclient.c +++ b/src/kauth/authclient.c @@ -394,21 +394,26 @@ CheckTicketAnswer(ka_BBS * oanswer, afs_int32 challenge, if ((field) && strcmp (field, strings)) return KABADPROTOCOL;\ strings += len+1 +#define chknostr() \ + len = strlen(strings); \ + if (len > MAXKTCNAMELEN) return KABADPROTOCOL; \ + strings += len+1 + if (caller) { chkstr(caller->name); chkstr(caller->instance); chkstr(caller->cell); } else { - chkstr(0); - chkstr(0); - chkstr(0); + chknostr(); + chknostr(); + chknostr(); } if (server) { chkstr(server->name); chkstr(server->instance); } else { - chkstr(0); - chkstr(0); + chknostr(); + chknostr(); } if (oanswer->SeqLen - @@ -563,7 +568,6 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con ubik_Call(KAA_Authenticate, conn, 0, name, instance, start, end, &arequest, &oanswer, 0, 0); if (code == RXGEN_OPCODE) { - extern int KAA_Authenticate_old(); oanswer.MaxSeqLen = sizeof(answer_old); oanswer.SeqBody = (char *)&answer_old; version = 0; @@ -680,7 +684,6 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st ubik_Call(KAT_GetTicket, conn, 0, auth_token->kvno, auth_domain, &aticket, name, instance, &atimes, &oanswer); if (code == RXGEN_OPCODE) { - extern int KAT_GetTicket_old(); oanswer.SeqLen = 0; /* this may be set by first call */ oanswer.MaxSeqLen = sizeof(answer_old); oanswer.SeqBody = (char *)&answer_old; diff --git a/src/kauth/client.c b/src/kauth/client.c index 7e641d1..b489d46 100644 --- a/src/kauth/client.c +++ b/src/kauth/client.c @@ -30,6 +30,7 @@ #include "afs/kautils.h" #include "afs/pthread_glock.h" #include "des/des.h" +#include #else /* defined(UKERNEL) */ #include @@ -184,9 +185,7 @@ ka_ReadPassword(char *prompt, int verify, char *cell, /* This performs the backslash quoting defined by AC_ParseLoginName. */ static char -map_char(str, ip) - char *str; - int *ip; +map_char(char *str, int *ip) { char c = str[*ip]; if (c == '\\') { diff --git a/src/kauth/kaauxdb.c b/src/kauth/kaauxdb.c index 4314c16..07eb668 100644 --- a/src/kauth/kaauxdb.c +++ b/src/kauth/kaauxdb.c @@ -25,6 +25,8 @@ #endif #include #include +#define UBIK_INTERNALS +#include #include "ubik_int.h" #include "kauth.h" #include "kaserver.h" @@ -168,7 +170,6 @@ kaux_inc(afs_int32 to, afs_uint32 locktime) int kaux_islocked(afs_int32 to, u_int attempts, u_int locktime) { - extern int ubeacon_Debug(), ubeacon_AmSyncSite(); unsigned int nfailures, myshare; afs_uint32 lasttime; struct ubik_debug beaconinfo; diff --git a/src/kauth/kadatabase.h b/src/kauth/kadatabase.h new file mode 100644 index 0000000..34c0536 --- /dev/null +++ b/src/kauth/kadatabase.h @@ -0,0 +1,40 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef _KAUTH_KADATABASE_H +#define _KAUTH_KADATABASE_H +extern int kawrite(struct ubik_trans *, afs_int32, char *, afs_int32); +extern int karead(struct ubik_trans *, afs_int32, char *, afs_int32); +extern int update_admin_count(struct ubik_trans *, int); + +extern int ka_LookupKvno(struct ubik_trans *, char *, char *, afs_int32, + struct ktc_encryptionKey *); + +extern afs_int32 AllocBlock(struct ubik_trans *, struct kaentry *); +extern afs_int32 FreeBlock(struct ubik_trans *, afs_int32); + +extern afs_int32 FindBlock(struct ubik_trans *, char *, char *, afs_int32 *, + struct kaentry *); +extern afs_int32 ThreadBlock(struct ubik_trans *, afs_int32, struct kaentry *); + +extern afs_int32 UnthreadBlock(struct ubik_trans *, struct kaentry *); + +extern afs_int32 NextBlock(struct ubik_trans *, afs_int32, struct kaentry *, + afs_int32 *); + +extern afs_int32 ka_DelKey(struct ubik_trans *tt, afs_int32 tentryaddr, + struct kaentry *tentry); + +extern afs_int32 ka_LookupKvno(struct ubik_trans *tt, char *name, + char *inst, afs_int32 kvno, + struct ktc_encryptionKey *key); +extern afs_int32 ka_LookupKey(struct ubik_trans *, char *, char *, + afs_int32 *, struct ktc_encryptionKey *); + +#endif diff --git a/src/kauth/kalog.c b/src/kauth/kalog.c index 335c971..de0bd97 100644 --- a/src/kauth/kalog.c +++ b/src/kauth/kalog.c @@ -40,7 +40,8 @@ extern afs_int32 verbose_track; DBM *kalog_db; -kalog_Init() +void +kalog_Init(void) { OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */ SetupLogSignals(); @@ -52,9 +53,9 @@ kalog_Init() } /* log a ticket usage */ -kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type) - char *principal, *instance, *sprincipal, *sinstance, *realm; - int hostaddr, type; +void +kalog_log(char *principal, char *instance, char *sprincipal, + char *sinstance, char *realm, int hostaddr, int type) { char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */ datum key, data; diff --git a/src/kauth/kalog.h b/src/kauth/kalog.h index ca71fb6..d42bfeb 100644 --- a/src/kauth/kalog.h +++ b/src/kauth/kalog.h @@ -52,3 +52,6 @@ typedef struct { #else #define KALOG(a,b,c,d,e,f,g) ka_log(a,b,c,d,e,f,g) #endif + +extern void kalog_log(char *, char *, char *, char *, char *, int, int); +extern void kalog_Init(void); diff --git a/src/kauth/kaprocs.c b/src/kauth/kaprocs.c index dae855a..9674673 100644 --- a/src/kauth/kaprocs.c +++ b/src/kauth/kaprocs.c @@ -47,34 +47,15 @@ #include "kauth_internal.h" #include "afs/audit.h" +#include "kadatabase.h" +#include "kaprocs.h" + extern struct ubik_dbase *KA_dbase; struct kaheader cheader; Date cheaderReadTime; /* time cheader last read in */ extern struct afsconf_dir *KA_conf; /* for getting cell info */ -afs_int32 kamCreateUser(struct rx_call *call, char *aname, char *ainstance, - EncryptionKey ainitpw); -afs_int32 ChangePassWord(struct rx_call *call, char *aname, char *ainstance, - ka_CBS *arequest, ka_BBS *oanswer); -afs_int32 kamSetPassword(struct rx_call *call, char *aname, char *ainstance, - afs_int32 akvno, EncryptionKey apassword); -afs_int32 kamSetFields(struct rx_call *call, char *aname, char *ainstance, - afs_int32 aflags, Date aexpiration, - afs_int32 alifetime, afs_int32 amaxAssociates, - afs_uint32 misc_auth_bytes, afs_int32 spare2); -afs_int32 kamDeleteUser(struct rx_call *call, char *aname, char *ainstance); -afs_int32 kamGetEntry(struct rx_call *call, char *aname, char *ainstance, - afs_int32 aversion, kaentryinfo *aentry); -afs_int32 kamListEntry(struct rx_call *call, afs_int32 previous_index, - afs_int32 *index, afs_int32 *count, kaident *name); -afs_int32 kamGetStats(struct rx_call *call, afs_int32 version, - afs_int32 *admin_accounts, kasstats *statics, - kadstats *dynamics); -afs_int32 kamGetPassword(struct rx_call *call, char *name, - EncryptionKey *password); -afs_int32 kamGetRandomKey(struct rx_call *call, EncryptionKey *key); -afs_int32 kamDebug(struct rx_call *call, afs_int32 version, - int checkDB, struct ka_debugInfo *info); + char lrealm[MAXKTCREALMLEN]; @@ -95,15 +76,13 @@ static afs_int32 autoCPWInterval; static afs_int32 autoCPWUpdates; static afs_int32 set_password(struct ubik_trans *tt, char *name, - char *instance, EncryptionKey *password, + char *instance, + struct ktc_encryptionKey *password, afs_int32 kvno, afs_int32 caller); - -extern afs_int32 InitAuthServ(struct ubik_trans **tt, int lock, - int *this_op); static afs_int32 impose_reuse_limits(EncryptionKey *password, struct kaentry *tentry); static int create_user(struct ubik_trans *tt, char *name, char *instance, - EncryptionKey *key, afs_int32 caller, + struct ktc_encryptionKey *key, afs_int32 caller, afs_int32 flags); /* This routine is called whenever an RPC interface needs the time. It uses @@ -260,7 +239,7 @@ initialize_database(struct ubik_trans *tt) parameter passes some information about the command line arguments. */ afs_int32 -init_kaprocs(char *lclpath, int initFlags) +init_kaprocs(const char *lclpath, int initFlags) { int code; struct ubik_trans *tt; @@ -571,7 +550,8 @@ special_name(char *name, char *instance) static int create_user(struct ubik_trans *tt, char *name, char *instance, - EncryptionKey *key, afs_int32 caller, afs_int32 flags) + struct ktc_encryptionKey *key, afs_int32 caller, + afs_int32 flags) { register int code; afs_int32 to; @@ -822,7 +802,7 @@ impose_reuse_limits(EncryptionKey *password, struct kaentry *tentry) static afs_int32 set_password(struct ubik_trans *tt, char *name, char *instance, - EncryptionKey *password, afs_int32 kvno, afs_int32 caller) + struct ktc_encryptionKey *password, afs_int32 kvno, afs_int32 caller) { afs_int32 code; afs_int32 to; /* offset of block */ @@ -880,7 +860,7 @@ set_password(struct ubik_trans *tt, char *name, char *instance, tentry.change_password_time = htonl(now); - if (code = kawrite(tt, to, &tentry, sizeof(tentry))) + if ((code = kawrite(tt, to, (char *) &tentry, sizeof(tentry)))) return (KAIO); return (0); } @@ -1470,7 +1450,7 @@ kamSetFields(struct rx_call *call, tentry.modification_time = htonl(now); tentry.modification_id = htonl(caller); - code = kawrite(tt, tentry_offset, &tentry, sizeof(tentry)); + code = kawrite(tt, tentry_offset, (char *) &tentry, sizeof(tentry)); if (code) goto abort; diff --git a/src/kauth/kaprocs.h b/src/kauth/kaprocs.h new file mode 100644 index 0000000..9bc6f8b --- /dev/null +++ b/src/kauth/kaprocs.h @@ -0,0 +1,23 @@ +extern afs_int32 init_kaprocs(const char *, int); +extern afs_int32 InitAuthServ(struct ubik_trans **, int, int *); +extern afs_int32 kamCreateUser(struct rx_call *, char *, char *, + EncryptionKey); +extern afs_int32 ChangePassWord(struct rx_call *, char *, char *, ka_CBS *, + ka_BBS *); +extern afs_int32 kamSetPassword(struct rx_call *, char *, char *, afs_int32, + EncryptionKey apassword); +extern afs_int32 kamSetFields(struct rx_call *, char *, char *, afs_int32, + Date, afs_int32, afs_int32, afs_uint32, + afs_int32 spare2); +extern afs_int32 kamDeleteUser(struct rx_call *, char *, char *); +extern afs_int32 kamGetEntry(struct rx_call *, char *, char *, afs_int32, + kaentryinfo *); +extern afs_int32 kamListEntry(struct rx_call *, afs_int32, afs_int32 *, + afs_int32 *, kaident *); +extern afs_int32 kamGetStats(struct rx_call *, afs_int32, afs_int32 *, + kasstats *, kadstats *); +extern afs_int32 kamGetPassword(struct rx_call *, char *, EncryptionKey *); +extern afs_int32 kamGetRandomKey(struct rx_call *, EncryptionKey *); +extern afs_int32 kamDebug(struct rx_call *, afs_int32, int, + struct ka_debugInfo *); + diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c index bae8146..535387f 100644 --- a/src/kauth/kaserver.c +++ b/src/kauth/kaserver.c @@ -40,12 +40,14 @@ #include #include #include +#include #include #include #include "kauth.h" #include "kautils.h" #include "kaserver.h" - +#include "kadatabase.h" +#include "kaprocs.h" struct kadstats dynamic_statistics; struct ubik_dbase *KA_dbase; @@ -72,8 +74,7 @@ static int debugOutput; /* check whether caller is authorized to manage RX statistics */ int -KA_rxstat_userok(call) - struct rx_call *call; +KA_rxstat_userok(struct rx_call *call) { return afsconf_SuperUser(KA_conf, call, NULL); } @@ -92,7 +93,7 @@ es_Report(char *fmt, ...) } static void -initialize_dstats() +initialize_dstats(void) { memset(&dynamic_statistics, 0, sizeof(dynamic_statistics)); dynamic_statistics.start_time = time(0); @@ -100,10 +101,8 @@ initialize_dstats() } static int -convert_cell_to_ubik(cellinfo, myHost, serverList) - struct afsconf_cell *cellinfo; - afs_int32 *myHost; - afs_int32 *serverList; +convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost, + afs_int32 *serverList) { int i; char hostname[64]; @@ -128,10 +127,7 @@ convert_cell_to_ubik(cellinfo, myHost, serverList) } static afs_int32 -kvno_admin_key(rock, kvno, key) - char *rock; - afs_int32 kvno; - struct ktc_encryptionKey *key; +kvno_admin_key(void *rock, afs_int32 kvno, struct ktc_encryptionKey *key) { return ka_LookupKvno(0, KA_ADMIN_NAME, KA_ADMIN_INST, kvno, key); @@ -147,9 +143,8 @@ kvno_admin_key(rock, kvno, key) #include "AFS_component_version_number.c" -main(argc, argv) - int argc; - char *argv[]; +int +main(int argc, char *argv[]) { afs_int32 code; char *whoami = argv[0]; @@ -171,15 +166,11 @@ main(argc, argv) struct rx_securityClass *sca[1]; struct rx_securityClass *scm[3]; - extern int afsconf_ClientAuthSecure(); - extern int afsconf_ServerAuth(); - extern int afsconf_CheckAuth(); - extern int rx_stackSize; - extern int KAA_ExecuteRequest(); - extern int KAT_ExecuteRequest(); - extern int KAM_ExecuteRequest(); - extern int RXSTATS_ExecuteRequest(); + extern int KAA_ExecuteRequest(struct rx_call *); + extern int KAT_ExecuteRequest(struct rx_call *); + extern int KAM_ExecuteRequest(struct rx_call *); + extern int RXSTATS_ExecuteRequest(struct rx_call *); #ifdef AFS_AIX32_ENV /* @@ -291,7 +282,7 @@ main(argc, argv) goto usage; } } - if (code = ka_CellConfig(cellservdb)) + if ((code = ka_CellConfig(cellservdb))) goto abort; cell = ka_LocalCell(); KA_conf = afsconf_Open(cellservdb); @@ -323,7 +314,7 @@ main(argc, argv) afsconf_GetExtendedCellInfo(KA_conf, cell, AFSCONF_KAUTHSERVICE, &cellinfo, &clones); if (servers) { - if (code = ubik_ParseServerList(argc, argv, &myHost, serverList)) { + if ((code = ubik_ParseServerList(argc, argv, &myHost, serverList))) { afs_com_err(whoami, code, "Couldn't parse server list"); exit(1); } @@ -455,7 +446,7 @@ main(argc, argv) if (init_kaprocs(lclpath, initFlags)) return -1; - if (code = init_krb_udp()) { + if ((code = init_krb_udp())) { ViceLog(0, ("Failed to initialize UDP interface; code = %d.\n", code)); ViceLog(0, ("Running without UDP access.\n")); diff --git a/src/kauth/kautils.c b/src/kauth/kautils.c index b115b24..f6f1df2 100644 --- a/src/kauth/kautils.c +++ b/src/kauth/kautils.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "kauth.h" #include "kautils.h" diff --git a/src/kauth/kkids.c b/src/kauth/kkids.c index dc4d943..6c5f140 100644 --- a/src/kauth/kkids.c +++ b/src/kauth/kkids.c @@ -24,6 +24,7 @@ #include #include #else +#include #include #include #endif @@ -34,6 +35,8 @@ #include #include +#include "kkids.h" + #define MAXNAME 100 #define MAXSIZE 2048 @@ -300,7 +303,6 @@ is_secure(char *dir) struct ViceIoctl blob; struct AclEntry *te; char space[2046]; - int secure = 1; afs_int32 code; struct Acl *ta; @@ -465,7 +467,7 @@ give_to_child(char *pw) /* quickly and painlessly */ int -terminate_child(char *pw) +terminate_child(void) { int rc; rc = 0; diff --git a/src/kauth/kkids.h b/src/kauth/kkids.h new file mode 100644 index 0000000..5c35b24 --- /dev/null +++ b/src/kauth/kkids.h @@ -0,0 +1,17 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef _KAUTH_KKIDS_H +#define _KAUTH_KKIDS_H + +extern int init_child(char *); +extern int password_bad(char *); +extern int give_to_child(char *); +extern int terminate_child(void); +#endif diff --git a/src/kauth/klog.c b/src/kauth/klog.c index de46639..2402c4e 100644 --- a/src/kauth/klog.c +++ b/src/kauth/klog.c @@ -215,7 +215,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) afs_com_err(rn, code, "Can't get local cell name!"); KLOGEXIT(code); } - if (code = ka_CellToRealm(lcell, lrealm, 0)) + if ((code = ka_CellToRealm(lcell, lrealm, 0))) goto nocell; strcpy(instance, ""); @@ -342,7 +342,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) if (!foundExplicitCell) strcpy(realm, lcell); - if (code = ka_CellToRealm(realm, realm, &local)) { + if ((code = ka_CellToRealm(realm, realm, &local))) { if (!Silent) afs_com_err(rn, code, "Can't convert cell to realm"); KLOGEXIT(code); diff --git a/src/kauth/knfs.c b/src/kauth/knfs.c index 987ad46..b87740c 100644 --- a/src/kauth/knfs.c +++ b/src/kauth/knfs.c @@ -50,11 +50,8 @@ struct ClearToken { }; -static -SetSysname(ahost, auid, sysname) - afs_int32 ahost; - afs_int32 auid; - char *sysname; +static int +SetSysname(afs_int32 ahost, afs_int32 auid, char *sysname) { afs_int32 code; afs_int32 pheader[6]; @@ -93,10 +90,8 @@ SetSysname(ahost, auid, sysname) } -static -GetTokens(ahost, auid) - afs_int32 ahost; - afs_int32 auid; +static int +GetTokens(afs_int32 ahost, afs_int32 auid) { struct ViceIoctl iob; afs_int32 pheader[6]; @@ -229,10 +224,8 @@ GetTokens(ahost, auid) } -static -NFSUnlog(ahost, auid) - afs_int32 ahost; - afs_int32 auid; +static int +NFSUnlog(afs_int32 ahost, afs_int32 auid) { afs_int32 code; afs_int32 pheader[6]; @@ -263,10 +256,8 @@ NFSUnlog(ahost, auid) } /* Copy the AFS service token into the kernel for a particular host and user */ -static -NFSCopyToken(ahost, auid) - afs_int32 ahost; - afs_int32 auid; +static int +NFSCopyToken(afs_int32 ahost, afs_int32 auid) { struct ktc_principal client, server; struct ktc_token theTicket; @@ -433,9 +424,8 @@ cmdproc(register struct cmd_syndesc *as, void *arock) #include "AFS_component_version_number.c" -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { register struct cmd_syndesc *ts; register afs_int32 code; diff --git a/src/kauth/kpasswd.c b/src/kauth/kpasswd.c index 1013e4c..e40fdd3 100644 --- a/src/kauth/kpasswd.c +++ b/src/kauth/kpasswd.c @@ -33,8 +33,12 @@ #include #include #include +#include +#include #include "kauth.h" #include "kautils.h" +#include "kkids.h" + #ifndef AFS_NT40_ENV #include #endif @@ -75,9 +79,6 @@ int CommandProc(struct cmd_syndesc *, void *); static int zero_argc; static char **zero_argv; -extern int init_child(char *myname); -extern int give_to_child(char *pw); -extern int terminate_child(char *pw); #ifdef AFS_NT40_ENV struct passwd { @@ -164,6 +165,7 @@ read_pass(char *passwd, int len, char *prompt, int verify) return code; } +#if 0 static int password_ok(char *newpw, int *insist) { @@ -176,6 +178,7 @@ password_ok(char *newpw, int *insist) } return 1; /* lie about it */ } +#endif static char rn[] = "kpasswd"; /* Routine name */ static int Pipe = 0; /* reading from a pipe */ @@ -546,7 +549,7 @@ CommandProc(struct cmd_syndesc *as, void *arock) conn = 0; } rx_Finalize(); - terminate_child(NULL); + terminate_child(); exit(code); no_change: /* yuck, yuck, yuck */ @@ -557,6 +560,6 @@ CommandProc(struct cmd_syndesc *as, void *arock) memset(npasswd, 0, sizeof(npasswd)); printf("Password for '%s' in cell '%s' unchanged.\n\n", pw->pw_name, cell); - terminate_child(NULL); + terminate_child(); exit(code ? code : 1); } diff --git a/src/kauth/kpwvalid.c b/src/kauth/kpwvalid.c index e310b96..bfd5f27 100644 --- a/src/kauth/kpwvalid.c +++ b/src/kauth/kpwvalid.c @@ -21,6 +21,7 @@ #include "AFS_component_version_number.c" /* returns 0 if the password is long enough, otherwise non-zero */ +int main(int argc, char *argv[]) { char oldpassword[512]; diff --git a/src/kauth/krb_tf.c b/src/kauth/krb_tf.c index 09c0eae..285205c 100644 --- a/src/kauth/krb_tf.c +++ b/src/kauth/krb_tf.c @@ -220,8 +220,7 @@ static unsigned char align_rec_3[] = { #endif /* AFSLITTLE_ENDIAN */ afs_int32 -krb_write_ticket_file(realm) - char *realm; +krb_write_ticket_file(char *realm) { char ticket_file[AFSDIR_PATH_MAX]; int fd; @@ -245,7 +244,7 @@ krb_write_ticket_file(realm) /* Use the KRBTKFILE environment variable if it exists, otherwise fall * back upon /tmp/tkt(uid}. */ - if (tf_name = (char *)getenv("KRBTKFILE")) + if ((tf_name = (char *)getenv("KRBTKFILE"))) (void)sprintf(ticket_file, "%s", tf_name); else (void)sprintf(ticket_file, "%s/tkt%d", gettmpdir(), getuid()); diff --git a/src/kauth/krb_udp.c b/src/kauth/krb_udp.c index 8e5bdd5..c51c485 100644 --- a/src/kauth/krb_udp.c +++ b/src/kauth/krb_udp.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include "kauth.h" @@ -47,6 +49,7 @@ #include "kaport.h" #include "afs/audit.h" #include "kalog.h" +#include "kadatabase.h" /* my kerberos error codes */ #define KERB_ERR_BAD_MSG_TYPE 99 @@ -118,18 +121,10 @@ FiveMinuteCheckLWP(void *unused) static afs_int32 -create_cipher(cipher, cipherLen, sessionKey, sname, sinst, start, end, kvno, - ticket, ticketLen, key) - char *cipher; - int *cipherLen; - struct ktc_encryptionKey *sessionKey; - char *sname; - char *sinst; - Date start, end; - afs_int32 kvno; - char *ticket; - int ticketLen; - struct ktc_encryptionKey *key; +create_cipher(char *cipher, int *cipherLen, + struct ktc_encryptionKey *sessionKey, char *sname, + char *sinst, Date start, Date end, afs_int32 kvno, + char *ticket, int ticketLen, struct ktc_encryptionKey *key) { char *answer; int slen; @@ -168,7 +163,7 @@ create_cipher(cipher, cipherLen, sessionKey, sname, sinst, start, end, kvno, printf("\n"); } - if (code = des_key_sched(key, schedule)) + if ((code = des_key_sched(key, schedule))) printf("In KAAuthenticate: key_sched returned %d\n", code); des_pcbc_encrypt(cipher, cipher, len, schedule, key, ENCRYPT); *cipherLen = round_up_to_ebs(len); @@ -182,14 +177,8 @@ create_cipher(cipher, cipherLen, sessionKey, sname, sinst, start, end, kvno, } static afs_int32 -create_reply(ans, name, inst, startTime, endTime, kvno, cipher, cipherLen) - struct packet *ans; - char *name; - char *inst; - Date startTime, endTime; - afs_int32 kvno; - char *cipher; - int cipherLen; +create_reply(struct packet *ans, char *name, char *inst, Date startTime, + Date endTime, afs_int32 kvno, char *cipher, int cipherLen) { char *answer = ans->data; int slen; @@ -223,14 +212,9 @@ create_reply(ans, name, inst, startTime, endTime, kvno, cipher, cipherLen) } static afs_int32 -check_auth(pkt, auth, authLen, key, name, inst, cell) - struct packet *pkt; - char *auth; - int authLen; - struct ktc_encryptionKey *key; - char *name; - char *inst; - char *cell; +check_auth(struct packet *pkt, char *auth, int authLen, + struct ktc_encryptionKey *key, char *name, char *inst, + char *cell) { char *packet; des_key_schedule schedule; @@ -260,15 +244,9 @@ check_auth(pkt, auth, authLen, key, name, inst, cell) } afs_int32 -UDP_Authenticate(ksoc, client, name, inst, startTime, endTime, sname, sinst) - int ksoc; - struct sockaddr_in *client; - char *name; - char *inst; - Date startTime; - Date endTime; - char *sname; - char *sinst; +UDP_Authenticate(int ksoc, struct sockaddr_in *client, char *name, + char *inst, Date startTime, Date endTime, char *sname, + char *sinst) { struct ubik_trans *tt; afs_int32 to; /* offset of block */ @@ -290,7 +268,7 @@ UDP_Authenticate(ksoc, client, name, inst, startTime, endTime, sname, sinst) COUNT_REQ(UAuthenticate); if (!name_instance_legal(name, inst)) return KERB_ERR_NAME_EXP; /* KABADNAME */ - if (code = InitAuthServ(&tt, LOCKREAD, this_op)) + if ((code = InitAuthServ(&tt, LOCKREAD, this_op))) return code; code = FindBlock(tt, name, inst, &to, &tentry); @@ -414,15 +392,9 @@ UDP_Authenticate(ksoc, client, name, inst, startTime, endTime, sname, sinst) } afs_int32 -UDP_GetTicket(ksoc, pkt, kvno, authDomain, ticket, ticketLen, auth, authLen) - int ksoc; - struct packet *pkt; - afs_int32 kvno; - char *authDomain; - char *ticket; - int ticketLen; - char *auth; - int authLen; +UDP_GetTicket(int ksoc, struct packet *pkt, afs_int32 kvno, + char *authDomain, char *ticket, int ticketLen, char *auth, + int authLen) { afs_int32 code; struct ktc_encryptionKey tgskey; @@ -460,7 +432,7 @@ UDP_GetTicket(ksoc, pkt, kvno, authDomain, ticket, ticketLen, auth, authLen) COUNT_REQ(UGetTicket); - if (code = InitAuthServ(&tt, LOCKREAD, this_op)) + if ((code = InitAuthServ(&tt, LOCKREAD, this_op))) goto fail; code = ka_LookupKvno(tt, KA_TGS_NAME, @@ -621,11 +593,7 @@ UDP_GetTicket(ksoc, pkt, kvno, authDomain, ticket, ticketLen, auth, authLen) } static int -err_packet(ksoc, pkt, code, reason) - int ksoc; - struct packet *pkt; - afs_int32 code; - char *reason; +err_packet(int ksoc, struct packet *pkt, afs_int32 code, char *reason) { struct packet ans; char *answer = ans.data; @@ -678,9 +646,7 @@ err_packet(ksoc, pkt, code, reason) } int -process_udp_auth(ksoc, pkt) - int ksoc; - struct packet *pkt; +process_udp_auth(int ksoc, struct packet *pkt) { char *packet = pkt->rest; char name[MAXKTCNAMELEN]; @@ -747,9 +713,7 @@ process_udp_auth(ksoc, pkt) } int -process_udp_appl(ksoc, pkt) - int ksoc; - struct packet *pkt; +process_udp_appl(int ksoc, struct packet *pkt) { char *packet = pkt->rest; afs_int32 kvno; @@ -792,9 +756,7 @@ process_udp_appl(ksoc, pkt) } void -process_udp_request(ksoc, pkt) - int ksoc; - struct packet *pkt; +process_udp_request(int ksoc, struct packet *pkt) { char *packet = pkt->data; unsigned char version, auth_msg_type; @@ -915,10 +877,11 @@ SocketListener(void *unused) #include "AFS_component_version_number.c" -main() +int +main(int, char **) #else afs_int32 -init_krb_udp() +init_krb_udp(void) #endif { struct sockaddr_in taddr; diff --git a/src/kauth/read_passwd.c b/src/kauth/read_passwd.c index 8883653..7f52eee 100644 --- a/src/kauth/read_passwd.c +++ b/src/kauth/read_passwd.c @@ -24,8 +24,7 @@ #include #include #else -char *strcpy(); -int strcmp(); +#include #endif #if defined(AFS_AIX_ENV) #include @@ -53,10 +52,7 @@ int read_pw_string(); /*** Routines ****************************************************** */ int -des_read_password(k, prompt, verify) - C_Block *k; - char *prompt; - int verify; +des_read_password(C_Block *k, char *prompt, int verify) { int ok; char key_string[BUFSIZ]; @@ -84,9 +80,7 @@ des_read_password(k, prompt, verify) */ static int -good_gets(s, max) - char *s; - int max; +good_gets(char *s, int max) { int l; /* length of string read */ if (!fgets(s, max, stdin)) { @@ -112,11 +106,7 @@ good_gets(s, max) #endif int -read_pw_string(s, max, prompt, verify) - char *s; - int max; - char *prompt; - int verify; +read_pw_string(char *s, int max, char *prompt, int verify) { int ok = 0; int len; /* password length */ @@ -240,10 +230,10 @@ read_pw_string(s, max, prompt, verify) * this can be static since we should never have more than * one set saved.... */ -static int (*old_sigfunc[NSIG]) (); +static int (*old_sigfunc[NSIG]) (int); static -push_signals() +push_signals(void) { register i; for (i = 0; i < NSIG; i++) @@ -251,7 +241,7 @@ push_signals() } static -pop_signals() +pop_signals(void) { register i; for (i = 0; i < NSIG; i++) @@ -259,9 +249,7 @@ pop_signals() } static void -sig_restore(sig, code, scp) - int sig, code; - struct sigcontext *scp; +sig_restore(int sig, int code, struct sigcontext *scp) { longjmp(env, 1); } @@ -269,7 +257,7 @@ sig_restore(sig, code, scp) #if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) static int -catch() +catch(void) { ++intrupt; } diff --git a/src/kauth/rebuild.c b/src/kauth/rebuild.c index 5fde292..987d9d4 100644 --- a/src/kauth/rebuild.c +++ b/src/kauth/rebuild.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include diff --git a/src/kauth/user.c b/src/kauth/user.c index 1c409df..7245966 100644 --- a/src/kauth/user.c +++ b/src/kauth/user.c @@ -42,6 +42,7 @@ #include #else #include +#include #endif #include #include @@ -191,7 +192,7 @@ ka_UserAuthenticateGeneral(afs_int32 flags, char *name, char *instance, #if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_USR_LINUX20_ENV) && (!defined(AFS_XBSD_ENV) || defined(AFS_FBSD_ENV)) /* handle smoothly the case where no AFS system calls exists (yet) */ - old = (int (*)())signal(SIGSYS, SIG_IGN); + old = signal(SIGSYS, SIG_IGN); #endif #ifdef AFS_DECOSF_ENV (void)signal(SIGTRAP, SIG_IGN); -- 1.9.4