DECL_PIOCTL(PNewUuid);
DECL_PIOCTL(PPrecache);
DECL_PIOCTL(PGetPAG);
-#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV)
+#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX_ENV)
DECL_PIOCTL(PSetCachingThreshold);
#endif
static pioctlFunction OpioctlSw[] = {
PBogus, /* 0 */
PNFSNukeCreds, /* 1 -- nuke all creds for NFS client */
-#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV)
+#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX_ENV)
PSetCachingThreshold /* 2 -- get/set cache-bypass size threshold */
#else
PNoop /* 2 -- get/set cache-bypass size threshold */
return (code);
}
-#elif defined(AFS_LINUX22_ENV)
+#elif defined(AFS_LINUX_ENV)
struct afs_ioctl_sys {
unsigned int com;
unsigned long arg;
#if defined(AFS_NBSD50_ENV)
if ((fd = fd_getfile(SCARG(uap, fd))) == NULL)
return (EBADF);
-#elif defined(AFS_FBSD100_ENV)
+#elif defined(AFS_FBSD_ENV)
if ((uap->fd >= fdp->fd_nfiles)
|| ((fd = fdp->fd_ofiles[uap->fd].fde_file) == NULL))
return EBADF;
if (!ioctlDone) {
# if defined(AFS_FBSD_ENV)
-# if (__FreeBSD_version >= 900044)
return sys_ioctl(td, uap);
-# else
- return ioctl(td, uap);
-# endif
# elif defined(AFS_OBSD_ENV)
code = sys_ioctl(p, uap, retval);
# elif defined(AFS_NBSD_ENV)
#endif
/* macro to avoid adding any more #ifdef's to pioctl code. */
-#if defined(AFS_LINUX22_ENV) || defined(AFS_AIX41_ENV)
+#if defined(AFS_LINUX_ENV) || defined(AFS_AIX41_ENV)
#define PIOCTL_FREE_CRED() crfree(credp)
#else
#define PIOCTL_FREE_CRED()
#ifdef AFS_NEED_CLIENTCONTEXT
afs_ucred_t *tmpcred = NULL;
#endif
-#if defined(AFS_NEED_CLIENTCONTEXT) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_NEED_CLIENTCONTEXT) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
afs_ucred_t *foreigncreds = NULL;
#endif
afs_int32 code = 0;
#ifdef AFS_AIX41_ENV
struct ucred *credp = crref(); /* don't free until done! */
#endif
-#ifdef AFS_LINUX22_ENV
+#ifdef AFS_LINUX_ENV
cred_t *credp = crref(); /* don't free until done! */
struct dentry *dp;
#endif
}
if ((com & 0xff) == PSetClientContext) {
#ifdef AFS_NEED_CLIENTCONTEXT
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX_ENV)
code = HandleClientContext(&data, &com, &foreigncreds, credp);
#else
code = HandleClientContext(&data, &com, &foreigncreds, osi_curcred());
* like afs_osi_suser(cred) which, I think, is better since it
* generalizes and supports multi cred environments...
*/
-#if defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_LINUX_ENV)
tmpcred = credp;
credp = foreigncreds;
#elif defined(AFS_AIX41_ENV)
#endif
}
#endif /* AFS_NEED_CLIENTCONTEXT */
- if ((com & 0xff) == 15) {
+
+ /* VIOCPREFETCH */
+ if ((com & 0xff00) >> 8 == 'V' && (com & 0xff) == 15) {
/* special case prefetch so entire pathname eval occurs in helper process.
* otherwise, the pioctl call is essentially useless */
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
code =
Prefetch(path, &data, follow,
foreigncreds ? foreigncreds : credp);
lookupname(path, USR, follow, NULL, &vp,
foreigncreds ? foreigncreds : credp);
#else
-#ifdef AFS_LINUX22_ENV
+#ifdef AFS_LINUX_ENV
code = gop_lookupname_user(path, AFS_UIOUSER, follow, &dp);
if (!code)
vp = (struct vnode *)dp->d_inode;
#else
code = gop_lookupname_user(path, AFS_UIOUSER, follow, &vp);
-#endif /* AFS_LINUX22_ENV */
+#endif /* AFS_LINUX_ENV */
#endif /* AFS_AIX41_ENV */
AFS_GLOCK();
if (code) {
credp = OSI_GET_CURRENT_CRED();
code = afs_HandlePioctl(vp, com, &data, follow, &credp);
}
-#elif defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#elif defined(AFS_LINUX_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#elif defined(UKERNEL)
code = afs_HandlePioctl(vp, com, &data, follow,
set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
#elif defined(AFS_SGI_ENV)
OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
-#elif defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV)
+#elif defined(AFS_SUN5_ENV) || defined(AFS_LINUX_ENV)
credp = tmpcred; /* restore original credentials */
#else
osi_curcred() = tmpcred; /* restore original credentials */
}
#endif /* AFS_NEED_CLIENTCONTEXT */
if (vp) {
-#ifdef AFS_LINUX22_ENV
+#ifdef AFS_LINUX_ENV
/*
* Holding the global lock when calling dput can cause a deadlock
* when the kernel calls back into afs_dentry_iput
dput(dp);
AFS_GLOCK();
#else
-#if defined(AFS_FBSD80_ENV)
+#if defined(AFS_FBSD_ENV)
if (VOP_ISLOCKED(vp))
VOP_UNLOCK(vp, 0);
-#endif /* AFS_FBSD80_ENV */
+#endif /* AFS_FBSD_ENV */
AFS_RELE(vp); /* put vnode back */
#endif
}
}
+#if defined(AFS_LINUX_ENV)
+static_inline int
+_settok_setParentPag(afs_ucred_t **cred)
+{
+ afs_uint32 pag;
+ int code;
+ afs_ucred_t *old_cred = *cred;
+ code = setpag(cred, -1, &pag, 1);
+ if (code == 0) {
+ /* setpag() may have changed our credentials */
+ *cred = crref();
+ crfree(old_cred);
+ }
+ return code;
+}
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
static_inline int
-_settok_setParentPag(afs_ucred_t **cred) {
+_settok_setParentPag(afs_ucred_t **cred)
+{
afs_uint32 pag;
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
char procname[256];
osi_procname(procname, 256);
afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n",
MyPidxx2Pid(MyPidxx), procname);
return setpag(osi_curproc(), cred, -1, &pag, 1);
+}
#else
+static_inline int
+_settok_setParentPag(afs_ucred_t **cred)
+{
+ afs_uint32 pag;
return setpag(cred, -1, &pag, 1);
-#endif
}
+#endif
/*!
* VIOCSETTOK (3) - Set authentication tokens
}
/*!
+ * Lookup name in the directory associated with given vcache.
+ *
+ * \param[in] avc vcache associated with directory
+ * \param[in] areq request to be passed on
+ * \param[in] aname name to be searched
+ * \param[out] asys resolved name (replace @sys by system type)
+ * \param[out] afid fid associated with aname
+ *
+ * \return 0 on success; non-zero otherwise.
+ *
+ * \notes The caller must free asys->name (checking if asys->allocked == 1).
+ */
+static int
+afs_LookupName(struct vcache *avc, struct vrequest *areq, char *aname,
+ struct sysname_info *asys, struct VenusFid *afid)
+{
+ int code;
+ struct dcache *tdc;
+ afs_size_t offset, len;
+
+ memset(asys, 0, sizeof(*asys));
+ memset(afid, 0, sizeof(*afid));
+
+ if (!avc || !areq || !aname || !asys || !afid) {
+ afs_warn("afs: Internal error, bad args to afs_LookupName: %p, %p, %p, "
+ "%p, %p.\n", avc, areq, aname, asys, afid);
+ code = EIO;
+ goto done;
+ }
+
+ /* check if vcache is up to date */
+ code = afs_VerifyVCache(avc, areq);
+ if (code != 0) {
+ goto done;
+ }
+
+ /* must be a directory */
+ if (vType(avc) != VDIR) {
+ code = ENOTDIR;
+ goto done;
+ }
+
+ tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 1);
+ if (!tdc) {
+ code = EIO;
+ goto done;
+ }
+
+ /* if @sys is present, replace it by the machine's system type */
+ Check_AtSys(avc, aname, asys, areq);
+ ObtainReadLock(&tdc->lock);
+
+ do {
+ /*
+ * Lookup name in the appropriate directory. If name is not found, try
+ * again with the next sysname from the @sys list.
+ */
+ code = afs_dir_Lookup(tdc, asys->name, &afid->Fid);
+ } while (code == ENOENT && Next_AtSys(avc, areq, asys));
+
+ ReleaseReadLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ done:
+ return code;
+}
+
+/*!
* VIOC_AFS_STAT_MT_PT (29) - Stat mount point
*
* \ingroup pioctl
{
afs_int32 code;
struct vcache *tvc;
- struct dcache *tdc;
struct VenusFid tfid;
char *bufp;
char *name;
struct sysname_info sysState;
- afs_size_t offset, len;
AFS_STATCNT(PNewStatMount);
+ memset(&sysState, 0, sizeof(sysState));
+
if (!avc)
return EINVAL;
if (afs_pd_getStringPtr(ain, &name) != 0)
return EINVAL;
- code = afs_VerifyVCache(avc, areq);
- if (code)
- return code;
- if (vType(avc) != VDIR) {
- return ENOTDIR;
- }
- tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
- if (!tdc)
- return EIO;
- Check_AtSys(avc, name, &sysState, areq);
- ObtainReadLock(&tdc->lock);
- do {
- code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
- } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
- ReleaseReadLock(&tdc->lock);
- afs_PutDCache(tdc); /* we're done with the data */
- bufp = sysState.name;
+ code = afs_LookupName(avc, areq, name, &sysState, &tfid);
if (code) {
goto out;
}
+
+ bufp = sysState.name;
tfid.Cell = avc->f.fid.Cell;
tfid.Fid.Volume = avc->f.fid.Fid.Volume;
if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ tvc = afs_GetVCache(&tfid, areq);
}
if (!tvc) {
code = EIO;
afs_PutVCache(tvc);
out:
if (sysState.allocked)
- osi_FreeLargeSpace(bufp);
+ osi_FreeLargeSpace(sysState.name);
return code;
}
int i;
struct unixuser *tu = NULL;
+ if (iterator > afs_cellindex)
+ return NULL; /* no point in looking */
+
i = UHash(uid);
ObtainReadLock(&afs_xuser);
for (tu = afs_users[i]; tu; tu = tu->next) {
afs_int32 results[MAXGCSTATS];
afs_int32 flags;
struct dcache * tdc;
- int i, size;
+ int i;
AFS_STATCNT(PGetCacheSize);
tdc = afs_indexTable[i];
if (tdc){
+ afs_size_t size = tdc->validPos;
+
results[9]++;
- size = tdc->validPos;
if ( 0 <= size && size < (1<<12) ) results[10]++;
else if (size < (1<<14) ) results[11]++;
else if (size < (1<<16) ) results[12]++;
* This whole logic is bogus, because it relies on the newer command
* sending its 12th address as 0.
*/
- if ((afs_pd_remaining(ain) < AFS_MAXCELLHOSTS +3) * sizeof(afs_int32))
+ if (afs_pd_remaining(ain) < (AFS_MAXCELLHOSTS + 3) * sizeof(afs_int32))
return EINVAL;
newcell = afs_pd_where(ain) + (AFS_MAXCELLHOSTS + 3) * sizeof(afs_int32);
tfid.Cell = avc->f.fid.Cell;
tfid.Fid.Volume = avc->f.fid.Fid.Volume;
if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ tvc = afs_GetVCache(&tfid, areq);
}
if (!tvc) {
code = EIO;
return 0;
}
-static void
+static int
FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
{
afs_int32 i;
afs_int32 cell = 0;
afs_int32 volume = 0;
struct afs_q *tq, *uq;
+ int code = 0;
#ifdef AFS_DARWIN80_ENV
vnode_t vp;
#endif
continue;
}
#else
- AFS_FAST_HOLD(tvc);
+ if (osi_vnhold(tvc) != 0) {
+ continue;
+ }
#endif
ReleaseReadLock(&afs_xvcache);
ObtainWriteLock(&tvc->lock, 232);
continue; /* never had any data */
tdc = afs_GetValidDSlot(i);
if (!tdc) {
- continue;
+ code = EIO;
+ break;
}
if (tdc->refCount <= 1) { /* too high, in use by running sys call */
ReleaseReadLock(&tdc->tlock);
/* probably, a user is doing this, probably, because things are screwed up.
* maybe it's the dnlc's fault? */
osi_dnlc_purge();
+ return code;
}
/*!
if (!afs_resourceinit_flag) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
- FlushVolumeData(&avc->f.fid, *acred);
- return 0;
+ return FlushVolumeData(&avc->f.fid, *acred);
}
/*!
if (!afs_resourceinit_flag) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
- FlushVolumeData(NULL, *acred);
- return 0;
+ return FlushVolumeData(NULL, *acred);
}
/*!
#ifdef AFS_AIX51_ENV
newcred->cr_groupset.gs_union.un_groups[0] = g0;
newcred->cr_groupset.gs_union.un_groups[1] = g1;
-#elif defined(AFS_LINUX26_ENV)
+#elif defined(AFS_LINUX_ENV)
# ifdef AFS_PAG_ONEGROUP_ENV
afs_set_cr_group_info(newcred, groups_alloc(1)); /* nothing sets this */
l = (((g0-0x3f00) & 0x3fff) << 14) | ((g1-0x3f00) & 0x3fff);
GROUP_AT(afs_cr_group_info(newcred), 1) = g1;
# endif
#elif defined(AFS_SUN510_ENV)
+# ifdef AFS_PAG_ONEGROUP_ENV
+ gids[0] = afs_get_pag_from_groups(g0, g1);
+ crsetgroups(newcred, 1, gids);
+# else
gids[0] = g0;
gids[1] = g1;
crsetgroups(newcred, 2, gids);
+# endif /* !AFS_PAG_ONEGROUP_ENV */
#else
newcred->cr_groups[0] = g0;
newcred->cr_groups[1] = g1;
#endif
#ifdef AFS_AIX_ENV
newcred->cr_ngrps = 2;
-#elif !defined(AFS_LINUX26_ENV) && !defined(AFS_SUN510_ENV)
-# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_FBSD80_ENV)
+#elif !defined(AFS_LINUX_ENV) && !defined(AFS_SUN510_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX_ENV) || defined(AFS_FBSD_ENV)
newcred->cr_ngroups = 2;
# else
for (i = 2; i < NGROUPS; i++)
if (ainSize < sizeof(struct setspref))
return EINVAL;
-#if 0 /* num_servers is unsigned */
- if (sin->num_servers < 0)
- return EINVAL;
-#endif
if (sin->num_servers > AFS_MAX_INTERFACE_ADDR)
return ENOMEM;
{
afs_int32 code;
struct vcache *tvc;
- struct dcache *tdc;
struct VenusFid tfid;
char *bufp;
char *mount;
struct sysname_info sysState;
- afs_size_t offset, len;
AFS_STATCNT(PFlushMount);
+ memset(&sysState, 0, sizeof(sysState));
+
if (!avc)
return EINVAL;
if (afs_pd_getStringPtr(ain, &mount) != 0)
return EINVAL;
- code = afs_VerifyVCache(avc, areq);
- if (code)
- return code;
- if (vType(avc) != VDIR) {
- return ENOTDIR;
- }
- tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
- if (!tdc)
- return EIO;
- Check_AtSys(avc, mount, &sysState, areq);
- ObtainReadLock(&tdc->lock);
- do {
- code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
- } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
- ReleaseReadLock(&tdc->lock);
- afs_PutDCache(tdc); /* we're done with the data */
- bufp = sysState.name;
+ code = afs_LookupName(avc, areq, mount, &sysState, &tfid);
if (code) {
goto out;
}
+
+ bufp = sysState.name;
tfid.Cell = avc->f.fid.Cell;
tfid.Fid.Volume = avc->f.fid.Fid.Volume;
if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ tvc = afs_GetVCache(&tfid, areq);
}
if (!tvc) {
code = EIO;
afs_PutVCache(tvc);
out:
if (sysState.allocked)
- osi_FreeLargeSpace(bufp);
+ osi_FreeLargeSpace(sysState.name);
return code;
}
tfid.Fid.Vnode = Fid->Vnode;
tfid.Fid.Unique = Fid->Unique;
- tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ tvc = afs_GetVCache(&tfid, areq);
if (!tvc) {
afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, ICL_TYPE_POINTER, tvc,
ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &avc->f.fid);
tfid.Fid.Vnode = Fid->Vnode;
tfid.Fid.Unique = Fid->Unique;
- tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ tvc = afs_GetVCache(&tfid, areq);
afs_Trace3(afs_iclSetp, CM_TRACE_RESIDCMD, ICL_TYPE_POINTER, tvc,
ICL_TYPE_INT32, Inputs->command, ICL_TYPE_FID, &tfid);
if (!tvc)
return 0;
}
-#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX24_ENV)
+#if defined(AFS_CACHE_BYPASS) && defined(AFS_LINUX_ENV)
DECL_PIOCTL(PSetCachingThreshold)
{
DECL_PIOCTL(PCallBackAddr)
{
#ifndef UKERNEL
- afs_uint32 addr, code;
+ afs_uint32 code;
int srvAddrCount;
struct server *ts;
struct srvAddr *sa;
struct afs_conn *tc;
- afs_int32 i, j;
+ afs_int32 i, j, addr;
struct unixuser *tu;
struct srvAddr **addrs;
struct rx_connection *rxconn;
if (!afs_resourceinit_flag) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
if (afs_pd_getInt(ain, &addr) != 0)
if (!ts->cell) /* not really an active server, anyway, it must */
continue; /* have just been added by setsprefs */
+ if ((sa->sa_flags & SRVADDR_ISDOWN) == 0 && !afs_HaveCallBacksFrom(ts)) {
+ /* Server is up, and we have no active callbacks from it. */
+ continue;
+ }
+
/* get a connection, even if host is down; bumps conn ref count */
tu = afs_GetUser(areq->uid, ts->cell->cellNum, SHARED_LOCK);
tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu,
if (!tc)
continue;
- if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(ts)) {
- if (sa->sa_flags & SRVADDR_ISDOWN) {
- rx_SetConnDeadTime(rxconn, 3);
- }
+ if (sa->sa_flags & SRVADDR_ISDOWN) {
+ rx_SetConnDeadTime(rxconn, 3);
+ }
#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
+ AFS_GUNLOCK();
#endif /* RX_ENABLE_LOCKS */
- code = RXAFS_CallBackRxConnAddr(rxconn, &addr);
+ code = RXAFS_CallBackRxConnAddr(rxconn, &addr);
#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
+ AFS_GLOCK();
#endif /* RX_ENABLE_LOCKS */
- }
+
afs_PutConn(tc, rxconn, SHARED_LOCK); /* done with it now */
} /* Outer loop over addrs */
+ afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs));
#endif /* UKERNEL */
return 0;
}
}
if (tokenSet.flags & AFSTOKEN_EX_SETPAG) {
-#if defined(AFS_LINUX26_ENV)
- afs_ucred_t *old_cred = *acred;
-#endif
if (_settok_setParentPag(acred) == 0) {
-#if defined(AFS_LINUX26_ENV)
- /* setpag() may have changed our credentials */
- *acred = crref();
- crfree(old_cred);
-#endif
code = afs_CreateReq(&treq, *acred);
if (code) {
xdr_free((xdrproc_t) xdr_ktc_setTokenData, &tokenSet);
return code;
}
+/*!
+ * VIOC_GETTOK2 (7) - Return a user's nth token, or token for a cell by
+ * name.
+ *
+ * \ingroup pioctl
+ *
+ * \param[in] ain EITHER a string cellname
+ * OR an integer 'iterator' to specify the nth
+ * token.
+ *
+ * \param[out] aout XDR-encoded tokens from the user's tokenJar
+ *
+ * \retval EINVAL invalid input (bad integer, or invalid string)
+ * unable to extract token(s)
+ * \retval ENOMEM insufficient memory (returned from called routines)
+ * \retval EDOM (integer) request was out of bounds or the user has no tokens
+ * \retval ENOTCONN user found but has no valid token(s)
+ * \retval E2BIG token(s) do not fit in the output buffer
+ *
+ */
DECL_PIOCTL(PGetTokens2)
{
struct cell *cell = NULL;
char *cellName = NULL;
afs_int32 cellNum;
int code = 0;
+ int integer_in = 1; /* assume integer input */
time_t now;
XDR xdrs;
struct ktc_setTokenData tokenSet;
memset(&tokenSet, 0, sizeof(tokenSet));
/* No input data - return tokens for primary cell */
- /* 4 octets of data is an iterator count */
+ /* 4 octets of data is PROBABLY an iterator count */
/* Otherwise, treat as string & return tokens for that cell name */
if (afs_pd_remaining(ain) == sizeof(afs_int32)) {
- /* Integer iterator - return tokens for the n'th cell found for user */
+ char *scratch = afs_pd_where(ain);
+
+ if (scratch[3] == '\0' && strlen(scratch) == 3)
+ integer_in = 0;
+ } else {
+ integer_in = 0;
+ }
+
+ if (integer_in) {
+ /* The misleadingly-named getNthCell actually return the nth valid
+ * token found for the specified user; there can never be a gap
+ * in the ordinals at this level.
+ */
if (afs_pd_getInt(ain, &iterator) != 0)
return EINVAL;
tu = getNthCell(areq->uid, iterator);
return EACCES;
}
afs_PutUser(tu, SHARED_LOCK);
- } else if (!afs_osi_suser(acred)) {
+ } else if (!afs_osi_suser(*acred)) {
return EACCES;
}