the caller to enforce permissions, with a new argument to push_ctxt.
/* simple.c */
struct obd_run_ctxt;
-void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new);
+struct obd_ucred;
+void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new,
+ struct obd_ucred *cred);
void pop_ctxt(struct obd_run_ctxt *saved);
struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode);
struct dentry *simple_mknod(struct dentry *dir, char *name, int mode);
struct vfsmount *e2_vfsmnt;
};
+struct obd_ucred {
+ __u32 ouc_fsuid;
+ __u32 ouc_fsgid;
+};
+
#define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
#define OBD_CTXT_DEBUG /* development-only debugging */
struct obd_run_ctxt {
struct vfsmount *pwdmnt;
struct dentry *pwd;
mm_segment_t fs;
+ __u32 fsuid;
+ __u32 fsgid;
#ifdef OBD_CTXT_DEBUG
__u32 magic;
#endif
};
+
#ifdef OBD_CTXT_DEBUG
#define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
#else
#endif
/* push / pop to root of obd store */
-void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new)
+void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new,
+ struct obd_ucred *uc)
{
//ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n");
ASSERT_CTXT_MAGIC(new->magic);
LASSERT(new->pwd);
LASSERT(new->pwdmnt);
+ save->fsuid = current->fsuid;
+ save->fsgid = current->fsgid;
+ if (uc) {
+ current->fsuid = uc->ouc_fsuid;
+ current->fsgid = uc->ouc_fsgid;
+ }
set_fs(new->fs);
set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
}
//printk("pc5");
mntput(saved->pwdmnt);
//printk("pc6\n");
+ current->fsuid = saved->fsuid;
+ current->fsgid = saved->fsgid;
}
/* utility to make a file */
struct lustre_handle lockh;
char *name;
int namelen, flags, lock_mode, rc = 0;
+ struct obd_ucred uc;
__u64 res_id[3] = {0, 0, 0};
ENTRY;
if (offset)
offset = 1;
- push_ctxt(&saved, &mds->mds_ctxt);
+ uc.ouc_fsuid = body->fsuid;
+ uc.ouc_fsgid = body->fsgid;
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
de = mds_fid2dentry(mds, &body->fid1, NULL);
if (IS_ERR(de)) {
LBUG();
struct dentry *de;
struct inode *inode;
struct mds_body *body;
+ struct obd_ucred uc;
int rc = 0, size[2] = {sizeof(*body)}, bufcount = 1;
ENTRY;
body = lustre_msg_buf(req->rq_reqmsg, offset);
- push_ctxt(&saved, &mds->mds_ctxt);
+ uc.ouc_fsuid = body->fsuid;
+ uc.ouc_fsgid = body->fsgid;
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
de = mds_fid2dentry(mds, &body->fid1, NULL);
if (IS_ERR(de)) {
req->rq_status = -ENOENT;
rc = mds_fs_set_md(mds, inode, handle, lmm);
if (!rc) {
struct obd_run_ctxt saved;
- push_ctxt(&saved, &mds->mds_ctxt);
+ struct obd_ucred uc;
+ uc.ouc_fsuid = body->fsuid;
+ uc.ouc_fsgid = body->fsgid;
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
rc = mds_update_last_rcvd(mds, handle, req);
pop_ctxt(&saved);
} else {
struct mds_body *body, *repbody;
struct obd_run_ctxt saved;
int rc, size = sizeof(*body);
+ struct obd_ucred uc;
ENTRY;
rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
}
body = lustre_msg_buf(req->rq_reqmsg, 0);
- push_ctxt(&saved, &mds->mds_ctxt);
+ uc.ouc_fsuid = body->fsuid;
+ uc.ouc_fsgid = body->fsgid;
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
de = mds_fid2dentry(mds, &body->fid1, &mnt);
if (IS_ERR(de))
GOTO(out_pop, rc = PTR_ERR(de));
/* This happens at the end when recovery is complete */
++mds->mds_mount_count;
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
rc = mds_update_server_data(mds);
pop_ctxt(&saved);
if (!mds->mds_sb)
RETURN(0);
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
mds_update_server_data(mds);
if (mds->mds_rcvd_filp) {
struct file *f;
int rc;
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
dentry = simple_mkdir(current->fs->pwd, "ROOT", 0755);
if (IS_ERR(dentry)) {
rc = PTR_ERR(dentry);
tgt_count = desc->ld_tgt_count;
lov_packdesc(desc);
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
f = filp_open("LOVDESC", O_CREAT|O_RDWR, 0644);
if (IS_ERR(f)) {
CERROR("Cannot open/create LOVDESC file\n");
struct file *f;
int rc;
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
f = filp_open("LOVDESC", O_RDONLY, 0644);
if (!f || IS_ERR(f)) {
CERROR("Cannot open LOVDESC file\n");
int rc;
int rc2;
- push_ctxt(&saved, &mds->mds_ctxt);
+ push_ctxt(&saved, &mds->mds_ctxt, NULL);
f = filp_open("LOVTGTS", O_RDONLY, 0644);
if (IS_ERR(f)) {
CERROR("Cannot open LOVTGTS file\n");
{
struct mds_obd *mds = mds_req2mds(req);
struct obd_run_ctxt saved;
+ struct obd_ucred uc;
int rc;
RETURN(rc);
}
- push_ctxt(&saved, &mds->mds_ctxt);
+ uc.ouc_fsuid = rec->ur_fsuid;
+ uc.ouc_fsgid = rec->ur_fsgid;
+
+ push_ctxt(&saved, &mds->mds_ctxt, &uc);
rc = reinters[rec->ur_opcode] (rec, offset, req);
pop_ctxt(&saved);
__u64 lastino = 2;
int mode = 0;
- push_ctxt(&saved, &filter->fo_ctxt);
+ push_ctxt(&saved, &filter->fo_ctxt, NULL);
dentry = simple_mkdir(current->fs->pwd, "O", 0700);
CDEBUG(D_INODE, "got/created O: %p\n", dentry);
if (IS_ERR(dentry)) {
struct file *file;
int mode;
- push_ctxt(&saved, &filter->fo_ctxt);
+ push_ctxt(&saved, &filter->fo_ctxt, NULL);
file = filp_open("D/status", O_RDWR | O_CREAT, 0700);
if (IS_ERR(file)) {
CERROR("OBD filter: cannot create status file\n");
}
filter_id(name, id, type);
- push_ctxt(&saved, &obddev->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obddev->u.filter.fo_ctxt, NULL);
file = filp_open(name, O_RDONLY | O_LARGEFILE, 0 /* type? */);
pop_ctxt(&saved);
lock_kernel();
if (iattr.ia_valid & ATTR_SIZE)
down(&inode->i_sem);
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
if (inode->i_op->setattr)
rc = inode->i_op->setattr(dentry, &iattr);
else
//filter_id(name, oa->o_id, oa->o_mode);
sprintf(name, LPU64, oa->o_id);
mode = (oa->o_mode & ~S_IFMT) | S_IFREG;
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
new = simple_mknod(filter->fo_dentry_O_mode[S_IFREG >> S_SHIFT], name,
mode);
pop_ctxt(&saved);
}
filter = &obd->u.filter;
- push_ctxt(&saved, &filter->fo_ctxt);
+ push_ctxt(&saved, &filter->fo_ctxt, NULL);
rc = vfs_unlink(dir_dentry->d_inode, object_dentry);
pop_ctxt(&saved);
}
sb = obd->u.filter.fo_sb;
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
pnum = 0; /* pnum indexes buf 0..num_pages */
file = filter_obj_open(obd, lsm->lsm_object_id, S_IFREG);
}
memset(res, 0, sizeof(*res) * niocount);
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
if (cmd & OBD_BRW_WRITE) {
*desc_private = filter_journal_start(&journal_save,
int i;
ENTRY;
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
journal_save = current->journal_info;
LASSERT(!journal_save);