Skip to content

Conversation

@wecharyu
Copy link
Contributor

What changes were proposed in this pull request?

Use filesystem's access() api to check permission.

Why are the changes needed?

The permission modes vary in different filesystems, we could not just check permissions based on the group mode.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Removed the supergroup test and add a new test in TestHdfsUtils.

mvn test -Dtest.groups= -Dtest=org.apache.hadoop.hive.metastore.utils.TestHdfsUtils -pl :hive-standalone-metastore-server

public class SecurityUtils {
private static final Logger LOG = LoggerFactory.getLogger(SecurityUtils.class);

public static UserGroupInformation getUGI() throws LoginException, IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LoginException would never be thrown, I consider to remove all uses of it in a new PR because it's not quite relative to current PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok

@wecharyu
Copy link
Contributor Author

@ayushtkn @deniskuzZ @zhangbutao could you help review this PR?

return null;
});
} catch (InterruptedException e) {
throw new IOException(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not throw AccessControlException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccessControlException will be thrown directly, and InterruptedException is usually not related to permission.

public class SecurityUtils {
private static final Logger LOG = LoggerFactory.getLogger(SecurityUtils.class);

public static UserGroupInformation getUGI() throws LoginException, IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok

return;
try {
ugi.doAs((PrivilegedExceptionAction<Void>) () -> {
fs.access(path, action);
Copy link
Contributor

@zhangbutao zhangbutao Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of hdfs filesystem, If user A belongs to the superuser group fs.getConf().get("dfs.permissions.supergroup", ""), then user A should have all permissions.
Can the fs.access(path, action) determine whether user A has all permissions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangbutao
Copy link
Contributor

LGTM

@wecharyu Please rebase to fix the conflicts.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 5, 2025

Copy link
Contributor

@zhangbutao zhangbutao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@zhangbutao zhangbutao merged commit 67bc120 into apache:master Sep 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants