Checks for user running as root not working in Windows (design) #4601
Labels
distributed framework
enhancement
Enhancement or improvement to existing feature or request
v3.0.0
Issues and PRs related to version 3.0.0
Is your feature request related to a problem? Please describe.
Context: I am a committer at the JNA project and have been developing using JNA for 7 years.
The
Bootstrap
class prevents running OpenSearch as root via thedefinitelyRunningAsRoot()
method:OpenSearch/server/src/main/java/org/opensearch/bootstrap/Bootstrap.java
Lines 122 to 125 in c13b679
However, this check is failing on Windows by design... there's not even an attempt to check:
OpenSearch/server/src/main/java/org/opensearch/bootstrap/JNANatives.java
Lines 186 to 197 in c13b679
On macOS, if JNA is not available, we aren't sure: JNA Availability is determined here where an
UnsatisfiedLinkError
indicates failure to load the library. This will occur for two use case:This is potentially problematic because the JNA dependency for building
server
is still at 5.5.0.OpenSearch/buildSrc/version.properties
Lines 21 to 22 in 658f7a6
OpenSearch/server/build.gradle
Lines 134 to 135 in 6071824
However, it seems to work, possibly because the comment linked buildSrc directory seems to have 5.11.0, which may indicate that published "built" artifacts might work:
OpenSearch/buildSrc/build.gradle
Line 113 in bb47419
So I'm not clear where the 5.5 fits into the picture, but it could create problems.
Describe the solution you'd like
Upgrade both JNA dependency versions linked above to the current JNA release, 5.12.1.
Implement code to check whether the Windows version is running with elevated permissions by checking the current process's tokens for
TOKEN_ELEVATION
. I have implemented that code here.I am happy to submit both changes if this issue is received favorably.
Describe alternatives you've considered
Status quo,and document the lack of checks.
Additional context
Pro: I'm not clear what the reasoning is for prohibiting running as root on Linux, but assuming that's a good thing we should extend it to all operating systems.
Con: This has the potential to break workflows for customers currently using macOS 11.x+ or Windows with elevated permissions, who don't know that's a bad idea.
The text was updated successfully, but these errors were encountered: