Skip to content
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

8314094: java/lang/ProcessHandle/InfoTest.java fails on Windows when run as user with Administrator privileges #15222

Closed
wants to merge 3 commits into from

Conversation

RealCLanger
Copy link
Contributor

@RealCLanger RealCLanger commented Aug 10, 2023

On Windows, the test java/lang/ProcessHandle/InfoTest.java can fail when run as user that is member of the Administrators group. In that case new files are not owned by the user but instead by BUILTIN\ADMINISTRATORS. This breaks the assumptions of the test's whoami check. My suggestion is to cater for this case and don't fail the test but write a warning message to stdout that a whoami check is not correctly possible.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8314094: java/lang/ProcessHandle/InfoTest.java fails on Windows when run as user with Administrator privileges (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15222/head:pull/15222
$ git checkout pull/15222

Update a local copy of the PR:
$ git checkout pull/15222
$ git pull https://git.openjdk.org/jdk.git pull/15222/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15222

View PR using the GUI difftool:
$ git pr show -t 15222

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15222.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 10, 2023

👋 Welcome back clanger! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 10, 2023
@openjdk
Copy link

openjdk bot commented Aug 10, 2023

@RealCLanger The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Aug 10, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 10, 2023

Webrevs

Comment on lines 302 to 304
if (Platform.isWindows() && "BUILTIN\\Administrators".equals(whoami)) {
System.out.println("Test seems to be run as Administrator. " +
"Check for user correctness is not possible.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an alternative way to determine the expected username?
Perhaps by running a windows command or extracting it from the environment (System.getEnv("XX"))?

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 you might use System.getProperty("user.name"). But I am not sure about domain names of users on Windows.
I am also not sure why the user name is currently determined by creating a file - there might be a reason for this that is not obvious to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that ProcessHandle.info() returns DOMAIN/USERNAME on Windows but System.getProperty("user.name") only the USERNAME.
You can get DOMAIN and USERNAME on Windows by calling:
com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem();
String user = NTSystem.getName();
String domain = NTSystem.getDomain();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think using System.getProperty("user.name") is brittle as well. If we'd use com.sun.security.auth.module.NTSystem, we would introduce the dependency to another module - jdk.security.auth. Not sure, whether this is a good option.

Copy link
Contributor

Choose a reason for hiding this comment

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

The system environment has the domainname and the username.

String username = (System.getenv("USERDOMAIN") + "/" + System.getenv("USERNAME")).toLowerCase(Locale.ROOT);

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with the environment variables is, that jtreg only passes very few of them down to the testee process - USERDOMAIN and USERNAME are not part of these as far as I know.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, more overhead than value in the suggestion.
If its windows, strip off the domain (before "/") and compare.
If that doesn't work then just drop the username compare on windows.

Copy link
Contributor Author

@RealCLanger RealCLanger Sep 1, 2023

Choose a reason for hiding this comment

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

After verifying that System.getenv yields empty results for USERDOMAIN and USERNAME, I updated the change to use System.getProperty("user.name") in the Windows Administrators case. Let's see how testing goes.

Copy link
Member

@MBaesken MBaesken left a comment

Choose a reason for hiding this comment

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

Looks simple and solves our issue.

@openjdk
Copy link

openjdk bot commented Aug 24, 2023

@RealCLanger This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8314094: java/lang/ProcessHandle/InfoTest.java fails on Windows when run as user with Administrator privileges

Reviewed-by: mbaesken, azeller

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 26 new commits pushed to the master branch:

  • 0d52c82: 8310220: IGV: dump graph after each IGVN step at level 4
  • adfc1d6: 8313323: javac -g on a java file which uses unnamed variable leads to ClassFormatError when launching that class
  • 2dc930d: 8314997: Missing optimization opportunities due to missing try_clean_mem_phi() calls
  • ab12c5d: 8315549: CITime misreports code/total nmethod sizes
  • ba8d5c2: 8315582: Exclude compiler/codecache/CodeCacheFullCountTest.java with Xcomp
  • 75d4ac2: 8311775: [TEST] duplicate verifyHeapDump in several tests
  • 4f90aba: 8311585: Add JRadioButtonMenuItem to bug8031573.java
  • 2a11bc4: 8314837: 5 compiled/codecache tests ignore VM flags
  • 2f7c65e: 8303427: Fixpath confused if unix root contains "/jdk"
  • e9e0c56: 8314319: LogCompilation doesn't reset lateInlining when it encounters a failure.
  • ... and 16 more: https://git.openjdk.org/jdk/compare/c12ca885cc96b510c9ee2d54b520b7d4a98a0434...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 24, 2023
@RealCLanger
Copy link
Contributor Author

OK, the latest update seems to work. I'll integrate tomorrow, unless I hear concerns.

Copy link
Contributor

@ArnoZeller ArnoZeller left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@RealCLanger
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 5, 2023

Going to push as commit 69c9ec9.
Since your change was applied there have been 36 commits pushed to the master branch:

  • fe4f900: 8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty
  • 8bbebbb: 8315644: increase timeout of sun/security/tools/jarsigner/Warning.java
  • f292268: 8315454: Add a way to create an immutable snapshot of a BitSet
  • 9def453: 8314580: PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
  • 6c821f5: 8315545: C1: x86 cmove can use short branches
  • d7e4087: 8315369: [JVMCI] failure to attach to a libgraal isolate during shutdown should not be fatal
  • d1cabe4: 8315566: [JVMCI] deadlock in JVMCI startup when bad option specified
  • 94a74a0: 8315534: Incorrect warnings about implicit annotation processing
  • 84425a6: 8315452: Erroneous AST missing modifiers for partial input
  • 3094fd1: 8314662: jshell shows duplicated signatures of javap
  • ... and 26 more: https://git.openjdk.org/jdk/compare/c12ca885cc96b510c9ee2d54b520b7d4a98a0434...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 5, 2023
@openjdk openjdk bot closed this Sep 5, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 5, 2023
@openjdk
Copy link

openjdk bot commented Sep 5, 2023

@RealCLanger Pushed as commit 69c9ec9.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@RealCLanger RealCLanger deleted the JDK-8314094 branch September 5, 2023 08:31
Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

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

A bit late due to a US holiday. Looks good.

@RealCLanger
Copy link
Contributor Author

A bit late due to a US holiday. Looks good.

Thanks 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
4 participants