extern struct vfsmount *afs_cacheMnt;
#endif
extern struct super_block *afs_cacheSBp;
+#if defined(STRUCT_TASK_HAS_CRED)
+extern struct cred *cache_creds;
+#endif
#if defined(AFS_LINUX26_ENV)
void *
tip->i_flags |= MS_NOATIME; /* Disable updating access times. */
#if defined(STRUCT_TASK_HAS_CRED)
- filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
+ /* Use stashed credentials - prevent selinux/apparmor problems */
+ filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds);
#else
filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
#endif
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+#include <linux/cred.h>
+#endif
/* Exported variables */
struct osi_dev cacheDev; /*Cache device */
#if defined(AFS_XBSD_ENV)
static struct vnode *volumeVnode;
#endif
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+const struct cred *cache_creds;
+#endif
/* This is the kernel side of the dynamic vcache setting */
int afsd_dynamic_vcaches = 0; /* Enable dynamic-vcache support */
afs_cacheStats = astatSize;
afs_vcacheInit(astatSize);
afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+ /*
+ * Save current credentials for later access to disk cache files.
+ * If selinux, apparmor or other security modules are enabled,
+ * they might deny access to cache files if the userspace process
+ * is restricted. Save the credentials used at cache initialisation
+ * for later use when opening cache files.
+ */
+ cache_creds = get_current_cred();
+#endif
#ifdef AFS_64BIT_CLIENT
#ifdef AFS_VM_RDWR_ENV
afs_vmMappingEnd = AFS_CHUNKBASE(0x7fffffff);
memset((char *)&cacheDev, 0, sizeof(struct osi_dev));
osi_dnlc_shutdown();
}
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED)
+ put_cred(cache_creds);
+#endif
} /*shutdown_cache */