-/*
+/*
* $Id$
*
* Copyright 1990,1991 by the Massachusetts Institute of Technology
* For distribution and copying rights, see the file "mit-copyright.h"
*/
/*
- * Copyright (c) 2005, 2006
- * The Linux Box Corporation
- * ALL RIGHTS RESERVED
- *
- * Permission is granted to use, copy, create derivative works
- * and redistribute this software and such derivative works
- * for any purpose, so long as the name of the Linux Box
- * Corporation is not used in any advertising or publicity
- * pertaining to the use or distribution of this software
- * without specific, written prior authorization. If the
- * above copyright notice or any other identification of the
- * Linux Box Corporation is included in any copy of any
- * portion of this software, then the disclaimer below must
- * also be included.
- *
- * This software is provided as is, without representation
- * from the Linux Box Corporation as to its fitness for any
- * purpose, and without warranty by the Linux Box Corporation
- * of any kind, either express or implied, including
- * without limitation the implied warranties of
- * merchantability and fitness for a particular purpose. The
- * regents of the Linux Box Corporation shall not be liable
- * for any damages, including special, indirect, incidental, or
- * consequential damages, with respect to any claim arising
- * out of or in connection with the use of the software, even
- * if it has been or is hereafter advised of the possibility of
- * such damages.
+ * Copyright (c) 2005, 2006
+ * The Linux Box Corporation
+ * ALL RIGHTS RESERVED
+ *
+ * Permission is granted to use, copy, create derivative works
+ * and redistribute this software and such derivative works
+ * for any purpose, so long as the name of the Linux Box
+ * Corporation is not used in any advertising or publicity
+ * pertaining to the use or distribution of this software
+ * without specific, written prior authorization. If the
+ * above copyright notice or any other identification of the
+ * Linux Box Corporation is included in any copy of any
+ * portion of this software, then the disclaimer below must
+ * also be included.
+ *
+ * This software is provided as is, without representation
+ * from the Linux Box Corporation as to its fitness for any
+ * purpose, and without warranty by the Linux Box Corporation
+ * of any kind, either express or implied, including
+ * without limitation the implied warranties of
+ * merchantability and fitness for a particular purpose. The
+ * regents of the Linux Box Corporation shall not be liable
+ * for any damages, including special, indirect, incidental, or
+ * consequential damages, with respect to any claim arising
+ * out of or in connection with the use of the software, even
+ * if it has been or is hereafter advised of the possibility of
+ * such damages.
*/
#include <afsconfig.h>
#include <pwd.h>
#include <afs/stds.h>
+#include <afs/ktc.h>
+#include <afs/token.h>
+
#include <krb5.h>
#if defined(HAVE_ET_COM_ERR_H)
#include <et/com_err.h>
#include <afs/venus.h>
#include <afs/ptserver.h>
#include <afs/ptuser.h>
+#include <afs/pterror.h>
#include <afs/dirpath.h>
#include <afs/afsutil.h>
#error "Must have either krb5_princ_size or krb5_principal_get_comp_string"
#endif
-#if !defined(HAVE_KRB5_ENCRYPT_TKT_PART) && defined(HAVE_ENCODE_KRB5_ENC_TKT_PART) && defined(HAVE_KRB5_C_ENCRYPT)
+#if !defined(HAVE_KRB5_ENCRYPT_TKT_PART) && defined(HAVE_ENCODE_KRB5_ENC_TKT_PART) && defined(HAVE_KRB5_C_ENCRYPT)
extern krb5_error_code encode_krb5_enc_tkt_part (const krb5_enc_tkt_part *rep,
krb5_data **code);
krb5_data *data = 0;
int code;
size_t enclen;
-
+
if ((code = encode_krb5_enc_tkt_part(ticket->enc_part2, &data)))
goto Done;
if ((code = krb5_c_encrypt_length(context, key->enctype,
if (code) {
const char *str = afs_error_message(code);
if (strncmp(str, "unknown", strlen("unknown")) == 0) {
+#ifdef HAVE_KRB5_SVC_GET_MSG
+ krb5_svc_get_msg(code,&str);
+#else
str = error_message(code);
+#endif
}
fputs(str, stderr);
fputs(" ", stderr);
+#ifdef HAVE_KRB5_SVC_GET_MSG
+ krb5_free_string(str);
+#endif
}
if (fmt) {
vfprintf(stderr, fmt, ap);
}
static void
-dprintf(char *fmt, ...) {
+afs_dprintf(char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
if ((new_cellinfo = (cellinfo_t *)malloc(sizeof(cellinfo_t))))
memcpy(new_cellinfo, cellinfo, sizeof(cellinfo_t));
-
+
return ((char *)new_cellinfo);
}
}
if (!(configdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))) {
- fprintf(stderr,
+ fprintf(stderr,
"%s: can't get afs configuration (afsconf_Open(%s))\n",
progname, AFSDIR_CLIENT_ETC_DIRPATH);
exit(AKLOG_AFS);
if (realm && realm[0]) {
realm_of_cell = realm;
status = AKLOG_TRYAGAIN;
- dprintf("We were told to authenticate to realm %s.\n", realm);
+ afs_dprintf("We were told to authenticate to realm %s.\n", realm);
} else {
/* Initially, try using afs/cell@USERREALM */
- dprintf("Trying to authenticate to user's realm %s.\n",
+ afs_dprintf("Trying to authenticate to user's realm %s.\n",
realm_of_user);
realm_of_cell = realm_of_user;
status = get_credv5(context, AFSKEY, cell->name, realm_of_cell,
}
if (realm_of_cell[0])
- dprintf("We've deduced that we need to authenticate"
+ afs_dprintf("We've deduced that we need to authenticate"
" to realm %s.\n", realm_of_cell);
else
- dprintf("We've deduced that we need to authenticate "
+ afs_dprintf("We've deduced that we need to authenticate "
"using referrals.\n");
}
}
progname, cell->name);
exit(AKLOG_MISC);
}
- dprintf("We've deduced that we need to authenticate"
+ afs_dprintf("We've deduced that we need to authenticate"
" to realm %s.\n", realm_of_cell);
}
status = get_credv5(context, AFSKEY, cell->name,
}
if (status != 0) {
- dprintf("Kerberos error code returned by get_cred : %d\n", status);
+ afs_dprintf("Kerberos error code returned by get_cred : %d\n", status);
fprintf(stderr, "%s: Couldn't get %s AFS tickets:\n",
progname, cell->name);
afs_com_err(progname, status, "while getting AFS tickets");
*/
static int
rxkad_build_native_token(krb5_context context, krb5_creds *v5cred,
- struct ktc_token **tokenPtr, char **userPtr) {
- char k4name[ANAME_SZ];
- char k4inst[INST_SZ];
- char k4realm[REALM_SZ];
+ struct ktc_tokenUnion **tokenPtr, char **userPtr) {
char username[BUFSIZ];
- struct ktc_token *token;
- int status;
+ struct ktc_tokenUnion *token;
+ struct token_rxkad *rxkadToken;
#ifdef HAVE_NO_KRB5_524
char *p;
int len;
+#else
+ int status;
+ char k4name[ANAME_SZ];
+ char k4inst[INST_SZ];
+ char k4realm[REALM_SZ];
#endif
- dprintf("Using Kerberos V5 ticket natively\n");
+ afs_dprintf("Using Kerberos V5 ticket natively\n");
*tokenPtr = NULL;
*userPtr = NULL;
}
#endif
- token = malloc(sizeof(struct ktc_token));
+ token = malloc(sizeof(struct ktc_tokenUnion));
if (token == NULL)
return ENOMEM;
- memset(token, 0, sizeof(struct ktc_token));
+ memset(token, 0, sizeof(struct ktc_tokenUnion));
- token->kvno = RXKAD_TKT_TYPE_KERBEROS_V5;
- token->startTime = v5cred->times.starttime;;
- token->endTime = v5cred->times.endtime;
- memcpy(&token->sessionKey, get_cred_keydata(v5cred),
+ token->at_type = AFSTOKEN_UNION_KAD;
+ rxkadToken = &token->ktc_tokenUnion_u.at_kad;
+
+ rxkadToken->rk_kvno = RXKAD_TKT_TYPE_KERBEROS_V5;
+ rxkadToken->rk_begintime = v5cred->times.starttime;;
+ rxkadToken->rk_endtime = v5cred->times.endtime;
+ memcpy(&rxkadToken->rk_key, get_cred_keydata(v5cred),
get_cred_keylen(v5cred));
- token->ticketLen = v5cred->ticket.length;
- memcpy(token->ticket, v5cred->ticket.data, token->ticketLen);
+ rxkadToken->rk_ticket.rk_ticket_len = v5cred->ticket.length;
+ rxkadToken->rk_ticket.rk_ticket_val = malloc(v5cred->ticket.length);
+ if (rxkadToken->rk_ticket.rk_ticket_val == NULL) {
+ free(token);
+ return ENOMEM;
+ }
+ memcpy(rxkadToken->rk_ticket.rk_ticket_val, v5cred->ticket.data,
+ rxkadToken->rk_ticket.rk_ticket_len);
*tokenPtr = token;
*userPtr = strdup(username);
#ifdef HAVE_NO_KRB5_524
static int
rxkad_get_converted_token(krb5_context context, krb5_creds *v5cred,
- struct ktc_token **tokenPtr, char **userPtr) {
+ struct ktc_tokenUnion **tokenPtr, char **userPtr) {
*tokenPtr = NULL;
*userPtr = NULL;
#else
static int
rxkad_get_converted_token(krb5_context context, krb5_creds *v5cred,
- struct ktc_token **tokenPtr, char **userPtr) {
+ struct ktc_tokenUnion **tokenPtr, char **userPtr) {
CREDENTIALS cred;
char username[BUFSIZ];
- struct ktc_token *token;
+ struct ktc_tokenUnion *token;
+ struct token_rxkad *rxkadToken;
int status;
*tokenPtr = NULL;
*userPtr = NULL;
- dprintf("Using Kerberos 524 translator service\n");
+ afs_dprintf("Using Kerberos 524 translator service\n");
status = krb5_524_convert_creds(context, v5cred, &cred);
strcat (username, cred.pinst);
}
- token = malloc(sizeof(struct ktc_token));
- memset(token, 0, sizeof(struct ktc_token));
+ token = malloc(sizeof(struct ktc_tokenUnion));
+ if (token == NULL)
+ return ENOMEM;
+ memset(token, 0, sizeof(struct ktc_tokenUnion));
+
+ token->at_type = AFSTOKEN_UNION_KAD;
- token->kvno = cred.kvno;
- token->startTime = cred.issue_date;
+ rxkadToken = &token->ktc_tokenUnion_u.at_kad;
+ rxkadToken->rk_kvno = cred.kvno;
+ rxkadToken->rk_begintime = cred.issue_date;
/*
* It seems silly to go through a bunch of contortions to
* extract the expiration time, when the v5 credentials already
* Note that this isn't a security hole, as the expiration time
* is also contained in the encrypted token
*/
- token->endTime = v5cred->times.endtime;
- memcpy(&token->sessionKey, cred.session, 8);
- token->ticketLen = cred.ticket_st.length;
- memcpy(token->ticket, cred.ticket_st.dat, token->ticketLen);
+ rxkadToken->rk_endtime = v5cred->times.endtime;
+ memcpy(&rxkadToken->rk_key, cred.session, 8);
+ rxkadToken->rk_ticket.rk_ticket_len = cred.ticket_st.length;
+ rxkadToken->rk_ticket.rk_ticket_val = malloc(cred.ticket_st.length);
+ if (rxkadToken->rk_ticket.rk_ticket_val == NULL) {
+ free(token);
+ return ENOMEM;
+ }
+ memcpy(rxkadToken->rk_ticket.rk_ticket_val, cred.ticket_st.dat,
+ rxkadToken->rk_ticket.rk_ticket_len);
+
+ *tokenPtr = token;
+ *userPtr = strdup(username);
return 0;
}
*/
static int
rxkad_get_token(krb5_context context, struct afsconf_cell *cell, char *realm,
- struct ktc_token **token, char **authuser, int *foreign) {
+ struct ktc_tokenUnion **token, char **authuser, int *foreign) {
krb5_creds *v5cred;
char *realmUsed = NULL;
char *username = NULL;
return status;
}
-/*
+/*!
+ * Get the set of tokens for a given cell out of the cache manager
+ *
+ * @param[in] cell
+ * The cellconf structure for the cell to retrieve tokens for
+ * @param[out] tokenPtr
+ * The tokens held for that cell
+ *
+ * @returns
+ * 0 on success, otherwise an error code
+ */
+
+static int
+get_kernel_token(struct afsconf_cell *cell, struct ktc_token **tokenPtr) {
+ struct ktc_principal client, server;
+ struct ktc_token *token;
+ int ret;
+
+ *tokenPtr = NULL;
+
+ strncpy(server.name, AFSKEY, MAXKTCNAMELEN - 1);
+ strncpy(server.instance, AFSINST, MAXKTCNAMELEN - 1);
+ strncpy(server.cell, cell->name, MAXKTCREALMLEN - 1);
+
+ token = malloc(sizeof(struct ktc_token));
+ if (token == NULL)
+ return ENOMEM;
+
+ memset(token, 0, sizeof(struct ktc_token));
+
+ ret = ktc_GetToken(&server, token, sizeof(struct ktc_token), &client);
+ if (ret) {
+ free(token);
+ return ret;
+ }
+
+ *tokenPtr = token;
+ return 0;
+}
+
+/**
+ * Return true if a pair of tokens are directly equivalent
+ */
+static int
+tokens_equal(struct ktc_setTokenData *tokenA, struct ktc_token *tokenB) {
+ return 0;
+/* Bodge bodge bodge
+ return (tokenA != NULL && tokenB != NULL &&
+ tokenA->kvno == tokenB->kvno &&
+ tokenA->ticketLen == tokenB->ticketLen &&
+ !memcmp(&tokenA->sessionKey, &tokenB->sessionKey,
+ sizeof(tokenA->sessionKey)) &&
+ !memcmp(tokenA->ticket, tokenB->ticket, tokenA->ticketLen));
+*/
+}
+
+/*
* Log to a cell. If the cell has already been logged to, return without
* doing anything. Otherwise, log to it and mark that it has been logged
* to.
afs_int32 viceId; /* AFS uid of user */
char *local_cell = NULL;
- struct ktc_principal aserver;
- struct ktc_principal aclient;
- struct ktc_token *token;
- struct ktc_token btoken;
+ struct ktc_tokenUnion *rxkadToken = NULL;
+ struct ktc_setTokenData *token;
+ struct ktc_token *btoken;
struct afsconf_cell cellconf;
/* NULL or empty cell returns information on local cell */
if ((status = get_cellconfig(cell, &cellconf, &local_cell)))
return(status);
- if (linkedcell != NULL && cellconf.linkedCell != NULL) {
- *linkedcell = strdup(cellconf.linkedCell);
- if (*linkedcell == NULL) {
- status = ENOMEM;
- goto out;
+ if (linkedcell != NULL) {
+ if (cellconf.linkedCell != NULL) {
+ *linkedcell = strdup(cellconf.linkedCell);
+ if (*linkedcell == NULL) {
+ status = ENOMEM;
+ goto out;
+ }
+ } else {
+ *linkedcell = NULL;
}
}
if (ll_string(&authedcells, ll_s_check, cellconf.name)) {
- dprintf("Already authenticated to %s (or tried to)\n", cellconf.name);
+ afs_dprintf("Already authenticated to %s (or tried to)\n", cellconf.name);
status = AKLOG_SUCCESS;
goto out;
}
- /*
+ /*
* Record that we have attempted to log to this cell. We do this
* before we try rather than after so that we will not try
* and fail repeatedly for one cell.
*/
ll_string(&authedcells, ll_s_add, cellconf.name);
- /*
+ /*
* Record this cell in the list of zephyr subscriptions. We may
* want zephyr subscriptions even if authentication fails.
* If this is done after we attempt to get tokens, aklog -zsubs
* are in -noauth mode.
*/
if (ll_string(&zsublist, ll_s_add, cellconf.name) == LL_FAILURE) {
- fprintf(stderr,
+ fprintf(stderr,
"%s: failure adding cell %s to zephyr subscriptions list.\n",
progname, cellconf.name);
exit(AKLOG_MISC);
}
if (ll_string(&zsublist, ll_s_add, local_cell) == LL_FAILURE) {
- fprintf(stderr,
+ fprintf(stderr,
"%s: failure adding cell %s to zephyr subscriptions list.\n",
progname, local_cell);
exit(AKLOG_MISC);
}
if (!noauth) {
- dprintf("Authenticating to cell %s (server %s).\n", cellconf.name,
+ afs_dprintf("Authenticating to cell %s (server %s).\n", cellconf.name,
cellconf.hostName[0]);
- status = rxkad_get_token(context, &cellconf, realm, &token,
+ token = token_buildTokenJar(cellconf.name);
+ if (token == NULL) {
+ status = ENOMEM;
+ goto out;
+ }
+
+ status = rxkad_get_token(context, &cellconf, realm, &rxkadToken,
&username, &isForeign);
if (status)
- return status;
+ goto out;
- strncpy(aserver.name, AFSKEY, MAXKTCNAMELEN - 1);
- strncpy(aserver.instance, AFSINST, MAXKTCNAMELEN - 1);
- strncpy(aserver.cell, cellconf.name, MAXKTCREALMLEN - 1);
+ /* We need to keep the token structure around so that we can stick
+ * the viceId into it (once we know it) */
+ status = token_addToken(token, rxkadToken);
+ if (status) {
+ afs_dprintf("Add Token failed with %d", status);
+ goto out;
+ }
if (!force &&
- !ktc_GetToken(&aserver, &btoken, sizeof(btoken), &aclient) &&
- token->kvno == btoken.kvno &&
- token->ticketLen == btoken.ticketLen &&
- !memcmp(&token->sessionKey, &btoken.sessionKey,
- sizeof(token->sessionKey)) &&
- !memcmp(token->ticket, btoken.ticket, token->ticketLen)) {
-
- dprintf("Identical tokens already exist; skipping.\n");
+ !get_kernel_token(&cellconf, &btoken) &&
+ tokens_equal(token, btoken)) {
+ afs_dprintf("Identical tokens already exist; skipping.\n");
status = AKLOG_SUCCESS;
goto out;
}
#endif
if (noprdb) {
- dprintf("Not resolving name %s to id (-noprdb set)\n", username);
+ afs_dprintf("Not resolving name %s to id (-noprdb set)\n", username);
}
else {
- dprintf("About to resolve name %s to id in cell %s.\n", username,
- aserver.cell);
+ afs_dprintf("About to resolve name %s to id in cell %s.\n", username,
+ cellconf.name);
- if (!pr_Initialize (0, AFSDIR_CLIENT_ETC_DIRPATH, aserver.cell))
+ if (!pr_Initialize (0, AFSDIR_CLIENT_ETC_DIRPATH, cellconf.name))
status = pr_SNameToId (username, &viceId);
-
+
if (status)
- dprintf("Error %d\n", status);
+ afs_dprintf("Error %d\n", status);
else
- dprintf("Id %d\n", (int) viceId);
-
+ afs_dprintf("Id %d\n", (int) viceId);
+
/*
* This code is taken from cklog -- it lets people
#ifdef ALLOW_REGISTER
if ((status == 0) && (viceId == ANONYMOUSID) && isForeign) {
- dprintf("doing first-time registration of %s at %s\n",
+ afs_dprintf("doing first-time registration of %s at %s\n",
username, cellconf.name);
viceId = 0;
- strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
- strcpy(aclient.instance, "");
- strncpy(aclient.cell, cellconf.name, MAXKTCREALMLEN - 1);
- if ((status = ktc_SetToken(&aserver, token, &aclient, 0))) {
+
+ status = ktc_SetTokenEx(token);
+ if (status) {
afs_com_err(progname, status,
"while obtaining tokens for cell %s",
cellconf.name);
/*
* In case you're wondering, we don't need to change the
* filename here because we're still connecting to the
- * same cell -- we're just using a different authentication
+ * same cell -- we're just using a different authenticat ion
* level
*/
if ((status = pr_Initialize(1L, AFSDIR_CLIENT_ETC_DIRPATH,
- aserver.cell))) {
+ cellconf.name))) {
printf("Error %d\n", status);
}
}
#endif /* ALLOW_REGISTER */
- /*
- * This is a crock, but it is Transarc's crock, so we have to play
- * along in order to get the functionality. The way the afs id is
- * stored is as a string in the username field of the token.
- * Contrary to what you may think by looking at the code for
- * tokens, this hack (AFS ID %d) will not work if you change %d
- * to something else.
- */
-
if ((status == 0) && (viceId != ANONYMOUSID)) {
- sprintf(username, "AFS ID %d", (int) viceId);
+ rxkadToken->ktc_tokenUnion_u.at_kad.rk_viceid = viceId;
+ token_replaceToken(token, rxkadToken);
}
}
- dprintf("Set username to %s\n", username);
-
- /* Reset the "aclient" structure before we call ktc_SetToken.
- * This structure was first set by the ktc_GetToken call when
- * we were comparing whether identical tokens already existed.
- */
- strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
- strcpy(aclient.instance, "");
- strncpy(aclient.cell, cellconf.name, MAXKTCREALMLEN - 1);
-
- dprintf("Setting tokens. %s / %s @ %s \n", aclient.name,
- aclient.instance, aclient.cell );
+ afs_dprintf("Setting tokens. %s @ %s \n", username, cellconf.name);
#ifndef AFS_AIX51_ENV
- /* on AIX 4.1.4 with AFS 3.4a+ if a write is not done before
- * this routine, it will not add the token. It is not clear what
+ /* on AIX 4.1.4 with AFS 3.4a+ if a write is not done before
+ * this routine, it will not add the token. It is not clear what
* is going on here! So we will do the following operation.
* On AIX 5, it causes the parent program to die, so we won't.
*/
write(2,"",0); /* dummy write */
#endif
- if ((status = ktc_SetToken(&aserver, token, &aclient, afssetpag))) {
- afs_com_err(progname, status, "while obtaining tokens for cell %s",
+ token_setPag(token, afssetpag);
+ status = ktc_SetTokenEx(token);
+ if (status) {
+ afs_com_err(progname, status, "while setting tokens for cell %s",
cellconf.name);
status = AKLOG_TOKEN;
}
}
else
- dprintf("Noauth mode; not authenticating.\n");
+ afs_dprintf("Noauth mode; not authenticating.\n");
out:
+ if (rxkadToken) {
+ free(rxkadToken->ktc_tokenUnion_u.at_kad.rk_ticket.rk_ticket_val);
+ free(rxkadToken);
+ }
+
if (local_cell)
free(local_cell);
if (username)
else {
last_component = our_file;
parent_dir = ".";
- }
-
+ }
+
memset(cellname, 0, sizeof(cellname));
vio.in = last_component;
vio.in_size = strlen(file) + 1;
vio.out_size = sizeof(cellname);
vio.out = cellname;
-
+
if (!pioctl(file, VIOC_FILE_CELL_NAME, &vio, 1)) {
strcat(cellname, VOLMARKERSTRING);
strcat(cellname, mountpoint + 1);
return(FALSE);
}
-/*
- * This routine each time it is called returns the next directory
+/*
+ * This routine each time it is called returns the next directory
* down a pathname. It resolves all symbolic links. The first time
* it is called, it should be called with the name of the path
* to be descended. After that, it should be called with the arguemnt
static char *elast_comp; /* End of last component */
char *t;
int len;
-
+
static int symlinkcount = 0; /* We can't exceed MAXSYMLINKS */
-
+
/* If we are given something for origpath, we are initializing only. */
if (origpath) {
memset(path, 0, sizeof(path));
}
/* We were not given origpath; find then next path to check */
-
+
/* If we've gotten all the way through already, return NULL */
if (last_comp == NULL)
return(NULL);
do {
while (*last_comp == DIR)
strncat(pathtocheck, last_comp++, 1);
- len = (elast_comp = strchr(last_comp, DIR))
+ len = (elast_comp = strchr(last_comp, DIR))
? elast_comp - last_comp : strlen(last_comp);
strncat(pathtocheck, last_comp, len);
memset(linkbuf, 0, sizeof(linkbuf));
- if ((link = (readlink(pathtocheck, linkbuf,
+ if ((link = (readlink(pathtocheck, linkbuf,
sizeof(linkbuf)) > 0))) {
if (++symlinkcount > MAXSYMLINKS) {
fprintf(stderr, "%s: %s\n", progname, strerror(ELOOP));
if (elast_comp)
strcpy(tmpbuf, elast_comp);
if (linkbuf[0] == DIR) {
- /*
- * If this is a symbolic link to an absolute path,
+ /*
+ * If this is a symbolic link to an absolute path,
* replace what we have by the absolute path.
*/
memset(path, 0, strlen(path));
memset(pathtocheck, 0, sizeof(pathtocheck));
}
else {
- /*
- * If this is a symbolic link to a relative path,
+ /*
+ * If this is a symbolic link to a relative path,
* replace only the last component with the link name.
*/
strncpy(last_comp, linkbuf, strlen(linkbuf) + 1);
int i;
struct hostent *hp;
struct in_addr in;
-
+
memset(outbuf, 0, sizeof(outbuf));
vio.out_size = sizeof(outbuf);
vio.in_size = 0;
vio.out = outbuf;
- dprintf("Getting list of hosts for %s\n", file);
+ afs_dprintf("Getting list of hosts for %s\n", file);
/* Don't worry about errors. */
if (!pioctl(file, VIOCWHEREIS, &vio, 1)) {
* If it is replicated on many servers, then none are included.
* This is not perfect, but the result is that people don't
* get subscribed to a lot of instances of FILSRV that they
- * probably won't need which reduces the instances of
+ * probably won't need which reduces the instances of
* people getting messages that don't apply to them.
*/
#ifndef ALLHOSTS
for (i = 0; phosts[i]; i++) {
if (hosts) {
in.s_addr = phosts[i];
- dprintf("Got host %s\n", inet_ntoa(in));
+ afs_dprintf("Got host %s\n", inet_ntoa(in));
ll_string(&hostlist, ll_s_add, (char *)inet_ntoa(in));
}
if (zsubs && (hp=gethostbyaddr((char *) &phosts[i],sizeof(long),AF_INET))) {
- dprintf("Got host %s\n", hp->h_name);
+ afs_dprintf("Got host %s\n", hp->h_name);
ll_string(&zsublist, ll_s_add, hp->h_name);
}
}
}
/*
- * This routine descends through a path to a directory, logging to
+ * This routine descends through a path to a directory, logging to
* every cell it encounters along the way.
*/
static int
/* Go on to the next level down the path */
while ((nextpath = next_path(NULL))) {
strcpy(pathtocheck, nextpath);
- dprintf("Checking directory %s\n", pathtocheck);
- /*
- * If this is an afs mountpoint, determine what cell from
- * the mountpoint name which is of the form
+ afs_dprintf("Checking directory %s\n", pathtocheck);
+ /*
+ * If this is an afs mountpoint, determine what cell from
+ * the mountpoint name which is of the form
* #cellname:volumename or %cellname:volumename.
*/
if (get_afs_mountpoint(pathtocheck, mountpoint, sizeof(mountpoint))) {
if (isdir(pathtocheck, &isdirectory) < 0) {
/*
* If we've logged and still can't stat, there's
- * a problem...
+ * a problem...
*/
- fprintf(stderr, "%s: stat(%s): %s\n", progname,
+ fprintf(stderr, "%s: stat(%s): %s\n", progname,
pathtocheck, strerror(errno));
return(AKLOG_BADPATH);
}
}
}
}
-
+
return(status);
}
progname = argv[0];
krb5_init_context(&context);
- initialize_ktc_error_table ();
+ initialize_KTC_error_table ();
+ initialize_U_error_table();
+ initialize_RXK_error_table();
+ initialize_ACFG_error_table();
+ initialize_PT_error_table();
afs_set_com_err_hook(redirect_errors);
/*
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-d") == 0)
dflag++;
- else if (strcmp(argv[i], "-noauth") == 0)
+ else if (strcmp(argv[i], "-noauth") == 0)
noauth++;
else if (strcmp(argv[i], "-zsubs") == 0)
zsubs++;
}
else
usage();
-
+
else if (argv[i][0] == '-')
usage();
else if (!pmode && !cmode) {
pmode++;
strcpy(path, argv[i]);
}
- else {
+ else {
cmode++;
strcpy(cell, argv[i]);
}
if ((new_cellinfo = copy_cellinfo(&cellinfo)))
ll_add_data(cur_node, new_cellinfo);
else {
- fprintf(stderr,
+ fprintf(stderr,
"%s: failure copying cellinfo.\n", progname);
exit(AKLOG_MISC);
}
struct passwd *pwd;
status = auth_to_cell(context, NULL, NULL, &linkedcell);
-
+
/* If this cell is linked to a DCE cell, and user requested -linked,
* get tokens for both. This is very useful when the AFS cell is
* linked to a DFS cell and this system does not also have DFS.
*/
if (!status && linked && linkedcell != NULL) {
- dprintf("Linked cell: %s\n", linkedcell);
+ afs_dprintf("Linked cell: %s\n", linkedcell);
status = auth_to_cell(context, linkedcell, NULL, NULL);
}
if (linkedcell) {
if ((stat(xlog_path, &sbuf) == 0) &&
((f = fopen(xlog_path, "r")) != NULL)) {
- dprintf("Reading %s for cells to authenticate to.\n",
+ afs_dprintf("Reading %s for cells to authenticate to.\n",
xlog_path);
while (fgets(fcell, 100, f) != NULL) {
fcell[strlen(fcell) - 1] = '\0';
- dprintf("Found cell %s in %s.\n", fcell, xlog_path);
+ afs_dprintf("Found cell %s in %s.\n", fcell, xlog_path);
auth_status = auth_to_cell(context, fcell, NULL, NULL);
if (status == AKLOG_SUCCESS)
somethingswrong++;
else {
if (linked && linkedcell != NULL) {
- dprintf("Linked cell: %s\n", linkedcell);
+ afs_dprintf("Linked cell: %s\n", linkedcell);
if ((status = auth_to_cell(context, linkedcell,
cellinfo.realm, NULL)))
somethingswrong++;
if ((status = auth_to_path(context, cur_node->data)))
somethingswrong++;
}
-
- /*
- * If only one thing was logged to, we'll return the status
+
+ /*
+ * If only one thing was logged to, we'll return the status
* of the single call. Otherwise, we'll return a generic
* something failed status.
*/
}
/* If we are keeping track of zephyr subscriptions, print them. */
- if (zsubs)
+ if (zsubs)
for (cur_node = zsublist.first; cur_node; cur_node = cur_node->next) {
printf("zsub: %s\n", cur_node->data);
}
if (lstat(path, &statbuf) < 0)
return (-1);
else {
- if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
+ if ((statbuf.st_mode & S_IFMT) == S_IFDIR)
*val = TRUE;
else
*val = FALSE;
return (0);
- }
+ }
}
static krb5_error_code
krb5_ticket ticket_reply[1];
krb5_enc_tkt_part enc_tkt_reply[1];
krb5_address address[30], *faddr[30];
-#endif
krb5_data * temp;
+#endif
int i;
static int any_enctype[] = {0};
*out_creds = 0;
enc_tkt_reply->times.starttime = starttime; /* krb524init needs this */
enc_tkt_reply->times.endtime = endtime;
#endif /* USING_HEIMDAL */
- /* NB: We will discard address for now--ignoring caddr field
+ /* NB: We will discard address for now--ignoring caddr field
in any case. MIT branch does what it always did. */
if (paddress && *paddress) {
krb5_kt_close(context, kt);
if (creds) krb5_free_creds(context, creds);
krb5_free_keyblock_contents(context, session_key);
-out:
return code;
#else
return -1;
krb5_error_code r;
static krb5_principal client_principal = 0;
- dprintf("Getting tickets: %s%s%s@%s\n", name,
+ afs_dprintf("Getting tickets: %s%s%s@%s\n", name,
(inst && inst[0]) ? "/" : "", inst ? inst : "", realm);
-
+
memset(&increds, 0, sizeof(increds));
/* ANL - instance may be ptr to a null string. Pass null then */
if ((r = krb5_build_principal(context, &increds.server,
(void *) NULL))) {
return r;
}
-
+
if (!_krb425_ccache) {
r = krb5_cc_default(context, &_krb425_ccache);
if (r)
return r;
}
-
+
increds.client = client_principal;
increds.times.endtime = 0;
/* Ask for DES since that is what V4 understands */
get_creds_enctype((&increds)) = ENCTYPE_DES_CBC_CRC;
-
+
if (keytab) {
int allowed_enctypes[] = {
ENCTYPE_DES_CBC_CRC, 0
creds /* out */);
} else {
r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds);
- }
+ }
return r;
}