Skip to content

STORM-4057 - Validate user with the id cmd #3640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions storm-server/src/main/java/org/apache/storm/utils/ServerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,17 @@ public static int getUserId(String user) {
cmdArgs.add("-u");
if (user != null && !user.isEmpty()) {
cmdArgs.add(user);
int exitCode = 0;
try {
exitCode = new ProcessBuilder(cmdArgs).start().waitFor();
} catch (Exception e) {
// Ignore
} finally {
if (exitCode != 0) {
LOG.debug("CMD: '{}' returned exit code of {}", String.join(" ", cmdArgs), exitCode);
cmdArgs.remove(user);
}
}
}
LOG.debug("CMD: {}", String.join(" ", cmdArgs));
ProcessBuilder pb = new ProcessBuilder(cmdArgs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Still need this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think so, yes. The first call is actually a test, if the user actually exist on the system (otherwise the parsing of the 2nd call would fail).

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 first call is a test. Whilst this code isn't optimal in terms of the number of OS calls being made, it keeps disruption to the current implementation to a minimum.

Expand Down
Loading