use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AlluxioFuseFileSystemTest method chownWithoutValidUid.
@Test
public void chownWithoutValidUid() throws Exception {
String userName = System.getProperty("user.name");
long uid = AlluxioFuseFileSystem.ID_NOT_SET_VALUE;
long gid = AlluxioFuseUtils.getGid(userName);
mFuseFs.chown("/foo/bar", uid, gid);
String groupName = AlluxioFuseUtils.getGroupName(userName);
AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
SetAttributePOptions options = SetAttributePOptions.newBuilder().setGroup(groupName).build();
verify(mFileSystem).setAttribute(expectedPath, options);
uid = AlluxioFuseFileSystem.ID_NOT_SET_VALUE_UNSIGNED;
mFuseFs.chown("/foo/bar", uid, gid);
verify(mFileSystem, times(2)).setAttribute(expectedPath, options);
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AlluxioJniFuseFileSystemTest method chownWithoutValidUid.
@Test
public void chownWithoutValidUid() throws Exception {
String userName = System.getProperty("user.name");
long uid = AlluxioFuseUtils.ID_NOT_SET_VALUE;
long gid = AlluxioFuseUtils.getGid(userName);
mFuseFs.chown("/foo/bar", uid, gid);
String groupName = AlluxioFuseUtils.getGroupName(userName);
AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
SetAttributePOptions options = SetAttributePOptions.newBuilder().setGroup(groupName).build();
verify(mFileSystem).setAttribute(expectedPath, options);
uid = AlluxioFuseUtils.ID_NOT_SET_VALUE_UNSIGNED;
mFuseFs.chown("/foo/bar", uid, gid);
verify(mFileSystem, times(2)).setAttribute(expectedPath, options);
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class AlluxioJniFuseFileSystemTest method chmod.
@Test
public void chmod() throws Exception {
long mode = 123;
mFuseFs.chmod("/foo/bar", mode);
AlluxioURI expectedPath = BASE_EXPECTED_URI.join("/foo/bar");
SetAttributePOptions options = SetAttributePOptions.newBuilder().setMode(new Mode((short) mode).toProto()).build();
verify(mFileSystem).setAttribute(expectedPath, options);
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class SystemUserGroupAuthPolicy method setUserGroupIfNeeded.
@Override
public void setUserGroupIfNeeded(AlluxioURI uri) throws Exception {
FuseContext fc = mFuseFileSystem.getContext();
if (!mIsUserGroupTranslation) {
return;
}
long uid = fc.uid.get();
long gid = fc.gid.get();
if (uid == AlluxioFuseUtils.ID_NOT_SET_VALUE || uid == AlluxioFuseUtils.ID_NOT_SET_VALUE_UNSIGNED || gid == AlluxioFuseUtils.ID_NOT_SET_VALUE || gid == AlluxioFuseUtils.ID_NOT_SET_VALUE_UNSIGNED) {
// cannot get valid uid or gid
return;
}
if (uid == AlluxioFuseUtils.DEFAULT_UID && gid == AlluxioFuseUtils.DEFAULT_GID) {
// no need to set attribute
return;
}
String groupName = gid != AlluxioFuseUtils.DEFAULT_GID ? mGroupnameCache.get(gid) : AlluxioFuseUtils.DEFAULT_GROUP_NAME;
String userName = uid != AlluxioFuseUtils.DEFAULT_UID ? mUsernameCache.get(uid) : AlluxioFuseUtils.DEFAULT_USER_NAME;
if (userName.isEmpty() || groupName.isEmpty()) {
// cannot get valid user name and group name
return;
}
SetAttributePOptions attributeOptions = SetAttributePOptions.newBuilder().setGroup(groupName).setOwner(userName).build();
LOG.debug("Set attributes of path {} to {}", uri, attributeOptions);
mFileSystem.setAttribute(uri, attributeOptions);
}
use of alluxio.grpc.SetAttributePOptions in project alluxio by Alluxio.
the class CustomAuthPolicy method setUserGroupIfNeeded.
@Override
public void setUserGroupIfNeeded(AlluxioURI uri) throws Exception {
if (StringUtils.isEmpty(mUname) || StringUtils.isEmpty(mGname)) {
return;
}
SetAttributePOptions attributeOptions = SetAttributePOptions.newBuilder().setGroup(mGname).setOwner(mUname).build();
mFileSystem.setAttribute(uri, attributeOptions);
LOG.debug("Set attributes of path {} to {}", uri, attributeOptions);
}
Aggregations