Do not allow callers to pass a NULL cred to afs_CreateReq. This
avoids setting the uid of zero in the vrequest when no cred is
passed. Update callers to pass afs_osi_credp for an anonymous cred
when no cred is available.
Thanks to Andrew Deason for pointing out afs_osi_credp should be
used.
Reviewed-on: http://gerrit.openafs.org/11336
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: D Brashear <shadow@your-file-system.com>
(cherry picked from commit
b7f1763652fb932ca5bd3f3351a48df11e58f2dc)
Change-Id: I0a7f17a05decdd0a9ef1ff72d7bf73153db95bed
Reviewed-on: http://gerrit.openafs.org/11365
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
* for osi_AllocSmallSpace() and osi_FreeSmallSpace().
*
* \param[out] avpp address of the vrequest pointer
- * \param[in] acred user credentials to setup the vrequest; may be NULL
+ * \param[in] acred user credentials to setup the vrequest
+ * afs_osi_credp should be used for anonymous connections
* \return 0 on success
*/
int
if (afs_shuttingdown) {
return EIO;
}
- if (!avpp) {
+ if (!avpp || !acred) {
return EINVAL;
}
treq = osi_AllocSmallSpace(sizeof(struct vrequest));
if (!treq) {
return ENOMEM;
}
- if (!acred) {
- memset(treq, 0, sizeof(struct vrequest));
- } else {
- code = afs_InitReq(treq, acred);
- if (code != 0) {
- osi_FreeSmallSpace(treq);
- return code;
- }
+ code = afs_InitReq(treq, acred);
+ if (code != 0) {
+ osi_FreeSmallSpace(treq);
+ return code;
}
*avpp = treq;
return 0;
code = ENOENT;
} else if (ret == 0) {
/* didn't find an entry. */
- code = afs_CreateReq(&treq, NULL);
+ code = afs_CreateReq(&treq, afs_osi_credp);
if (code == 0) {
*avcpp = afs_GetVCache(&vfid, treq, NULL, NULL);
afs_DestroyReq(treq);
XSTATS_DECLS;
AFS_STATCNT(afs_FlushActiveVcaches);
- code = afs_CreateReq(&treq, NULL);
+ code = afs_CreateReq(&treq, afs_osi_credp);
if (code) {
afs_warn("unable to alloc treq\n");
return;