RFR: 8337408: Use GetTempPath2 API instead of GetTempPath [v2]
Dhamoder Nalla
dhanalla at openjdk.org
Wed Sep 4 17:22:19 UTC 2024
On Wed, 21 Aug 2024 09:07:21 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
> Hi,
>
> From the linked doc: "When calling this function from a process running as SYSTEM it will return the path C:\Windows\SystemTemp, which is inaccessible to non-SYSTEM processes. For non-SYSTEM processes, GetTempPath2 will behave the same as GetTempPath."
>
> If SYSTEM and regular user processes have a different temp path, and we change temp as it's known to the attach api, they will have a different hsperfdata_username locations.
>
> Then does the attach api only find processes that are of the same category (SYSTEM vs non-SYSTEM)? e.g. "jps" for a user does not show SYSTEM processes?
>
> SYSTEM is not the "Administrator" user, so it's not going to be a very common problem, but if a Java process run as a SYSTEM then it could be an issue (is that possible?).
>
> And if Java can't be run as a SYSTEM task, then the doc states GetTempPath2 will behave the same as GetTempPath.
Thanks @kevinjwalls for reviewing this PR
The behavior has not changed; the old API GetTempPath also returns different temporary paths for SYSTEM and non-SYSTEM accounts, similar to the new API GetTempPath2.
For SYSTEM accounts:
GetTempPath: C:\WINDOWS\TEMP\
GetTempPath2: C:\WINDOWS\SystemTemp\
For non-SYSTEM accounts:
GetTempPath: C:\Users\\<user>\AppData\Local\Temp\
GetTempPath2: C:\Users\\<user>\AppData\Local\Temp\
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20600#issuecomment-2329598028
More information about the core-libs-dev
mailing list