X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/e5fdb505321acd188b5e0a16b71e760f1f0511dd..96a0410113c3f9e823c80a93c83aceb8d77b937b:/reg_svr/admin_call.c diff --git a/reg_svr/admin_call.c b/reg_svr/admin_call.c index e84c1601..ff6d2ea6 100644 --- a/reg_svr/admin_call.c +++ b/reg_svr/admin_call.c @@ -4,36 +4,21 @@ * $Header$ * * Copyright (C) 1987 by the Massachusetts Institute of Technology + * For copying and distribution information, please see the file + * . * * Utility functions for communication with the Kerberos admin_server * * Original version written by Jeffery I. Schiller, January 1987 * Completely gutted and rewritten by Bill Sommerfeld, August 1987 * - * $Log$ - * Revision 1.5 1988-08-01 00:42:54 qjb - * Changed names of kerberos calls to new names from old ones. - * - * Revision 1.4 87/09/09 14:59:06 wesommer - * Allocate a new socket each time rather than keeping one around, - * due to protocol problems. - * - * Revision 1.3 87/09/04 22:30:34 wesommer - * Un-crock the KDC host (oops -- this one got distributed!!). - * - * Revision 1.2 87/08/22 17:13:59 wesommer - * Make admin_errmsg external rather than static. - * Crock up KDC host. - * - * Revision 1.1 87/08/07 13:50:37 wesommer - * Initial revision - * */ #ifndef lint static char *rcsid_admin_call_c = "$Header$"; #endif lint +#include #include #include #include @@ -43,14 +28,15 @@ static char *rcsid_admin_call_c = "$Header$"; #include #include +#include #include #include "admin_err.h" #include "admin_server.h" #include "prot.h" #include "krb.h" +#include "krb_et.h" -extern int krb_err_base; /* Offset between com_err and kerberos codes */ extern int errno; /* System call error numbers */ extern long gethostid(); @@ -65,6 +51,7 @@ static struct sockaddr_in my_addr; /* address bound to admin_fd. */ static int my_addr_len; /* size of above address. */ static char krbrlm[REALM_SZ]; /* Local kerberos realm */ +static char krbhost[BUFSIZ]; /* Name of server for local realm */ char admin_errmsg[BUFSIZ]; /* Server error message */ /* @@ -79,9 +66,9 @@ int admin_call_init() struct hostent *hp; /* host to talk to */ struct servent *sp; /* service to talk to */ - init_kadm_err_tbl(); - if (status = get_krbrlm(krbrlm, 1)) { - status += krb_err_base; + initialize_kadm_error_table(); + if (status = krb_get_lrealm(krbrlm, 1)) { + status += ERROR_TABLE_BASE_krb; goto punt; } @@ -89,7 +76,11 @@ int admin_call_init() * Locate server. */ - hp = gethostbyname(KERB_HOST); + if (status = krb_get_krbhst(krbhost, krbrlm, 1)) { + status += ERROR_TABLE_BASE_krb; + goto punt; + } + hp = gethostbyname(krbhost); if (!hp) { status = ADMIN_UNKNOWN_HOST; goto punt; @@ -104,6 +95,16 @@ int admin_call_init() bcopy((char *)hp->h_addr, (char *)&admin_addr.sin_addr, hp->h_length); admin_addr.sin_port = sp->s_port; + /* lowercase & truncate hostname becuase it will be used as an + * instance name. + */ + { + char *s; + for (s = krbhost; *s && *s != '.'; s++) + if (isupper(*s)) + *s = tolower(*s); + *s = 0; + } inited = 1; } return 0; @@ -195,8 +196,8 @@ admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd) * find our session key. */ - if (status = krb_get_cred("changepw", "kerberos", krbrlm, &cred)) { - status += krb_err_base; + if (status = krb_get_cred("changepw", krbhost, krbrlm, &cred)) { + status += ERROR_TABLE_BASE_krb; goto bad; } @@ -265,9 +266,9 @@ admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd) * and know who we are. */ - if (status = krb_mk_req(&authent, "changepw", "kerberos", krbrlm, + if (status = krb_mk_req(&authent, "changepw", krbhost, krbrlm, checksum)) { - status += krb_err_base; + status += ERROR_TABLE_BASE_krb; goto bad; } @@ -366,7 +367,7 @@ admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd) &admin_addr, &my_addr, &msg_data); if (status) { - status += krb_err_base; + status += ERROR_TABLE_BASE_krb; goto bad; } bp = msg_data.app_data; @@ -417,14 +418,3 @@ static u_char *strapp(dest, source, end) return dest + length; } } - -/* - * Local Variables: - * mode: c - * c-indent-level: 4 - * c-continued-statement-offset: 4 - * c-brace-offset: -4 - * c-argdecl-indent: 4 - * c-label-offset: -4 - * End: - */