]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
libafs: do not allow NULL creds for afs_CreateReq
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 28 Jul 2014 21:27:40 +0000 (17:27 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 13 Aug 2014 15:27:33 +0000 (11:27 -0400)
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>
src/afs/afs_osi_pag.c
src/afs/afs_osi_vget.c
src/afs/afs_vcache.c

index ea16fe706672a18ebaef980095bd2b46888d8080..afbb1cf0844a40a0c9cebfe63a43765a13da806a 100644 (file)
@@ -497,7 +497,8 @@ afs_InitReq(struct vrequest *av, afs_ucred_t *acred)
  *       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
@@ -509,21 +510,17 @@ afs_CreateReq(struct vrequest **avpp, afs_ucred_t *acred)
     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;
index 822ab08118eb93a04ba8552a99f4bf5eaa02dd5f..5fd36bff62765a4267ce9e38cbba7766f5528d0e 100644 (file)
@@ -60,7 +60,7 @@ afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp)
        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);
index bcaf8d2a6c9c173f84a421c0589c5ee6eac7d405..179c57247fa2c57b31ab512b57de4e78ce97b9b2 100644 (file)
@@ -1002,7 +1002,7 @@ afs_FlushActiveVcaches(afs_int32 doflocks)
     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;