RETURN(rc);
}
+
+static bool is_project_state_change(const struct lu_attr *oattr,
+ struct lu_attr *la)
+{
+ if (la->la_valid & LA_PROJID &&
+ oattr->la_projid != la->la_projid)
+ return true;
+
+ if ((la->la_valid & LA_FLAGS) &&
+ (la->la_flags & LUSTRE_PROJINHERIT_FL) !=
+ (oattr->la_flags & LUSTRE_PROJINHERIT_FL))
+ return true;
+
+ return false;
+}
+
/*
* This gives the same functionality as the code between
* sys_chmod and inode_setattr
*/
static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj,
const struct lu_attr *oattr, struct lu_attr *la,
- const unsigned long flags)
+ const struct md_attr *ma)
{
struct lu_ucred *uc;
int rc = 0;
+ const unsigned long flags = ma->ma_attr_flags;
+
ENTRY;
if (!la->la_valid)
if (uc == NULL)
RETURN(0);
+ if (is_project_state_change(oattr, la)) {
+ if (!md_capable(uc, CFS_CAP_SYS_RESOURCE) &&
+ !lustre_in_group_p(uc, ma->ma_enable_chprojid_gid) &&
+ !(ma->ma_enable_chprojid_gid == -1 &&
+ mdd_permission_internal(env, obj, oattr, MAY_WRITE)))
+ RETURN(-EPERM);
+ }
+
if (la->la_valid == LA_CTIME) {
if (!(flags & MDS_PERM_BYPASS))
/* This is only for set ctime when rename's source is
RETURN(rc);
*la_copy = ma->ma_attr;
- rc = mdd_fix_attr(env, mdd_obj, attr, la_copy, ma->ma_attr_flags);
+ rc = mdd_fix_attr(env, mdd_obj, attr, la_copy, ma);
if (rc)
RETURN(rc);