microsoft / p4vfs

Microsoft Virtual File System for Perforce
MIT License
272 stars 13 forks source link

P4VFS does not respect P4TICKETS specified in a P4CONFIG file #52

Closed jtomori closed 1 day ago

jtomori commented 3 weeks ago

Hello, based on my testing it seems like the P4VFS service is not respecting P4TICKETS's value, which is specified in a P4CONFIG file specific to a workspace.

For example, I am able to run p4 sync without a password prompt in a workspace directory (it's picking up P4TICKETS correctly, can be verified with p4 set), but p4vfs sync shows a dialog asking me for a password (entering it saves the ticket into my home folder). A temporary workaround is to specify P4TICKETS as a system-wide environment variable, but that is not ideal as I'd prefer to control its value on a per-workspace basis.

Best, Juraj

jessk-msft commented 3 weeks ago

Hi Juraj, Thanks a lot for reporting this problem. I don't think that we've ever tried specifying P4TICKETS within a P4CONFIG file for p4vfs. I have reproduced the bug as you describe. In my case:

set P4CONFIG=C:\temp\p4config.txt

Then C:\temp\p4config.txt contains:

P4TICKETS=C:\Temp\p4tickets.txt

Then delete the default %USERPROFILE%\p4tickets.txt file.

When I run p4.exe sync //... I get a login prompt and see that ticket is saved to C:\Temp\p4tickets.txt Then when I run p4vfs.exe sync //... I get a login prompt and see that ticket is saved to %USERPROFILE%\p4tickets.txt

Seems like exactly what you describe. We'll fix this and repost here.

jtomori commented 2 weeks ago

Thank you for looking into it, I appreciate that.

jtomori commented 1 week ago

Hello, I'd like to ask you if you could advise a temporary workaround for specifying P4VFS-specific P4TICKETS configuration.

I've tried setting a P4VFS.Service-specific environment variable (as explained here and confirmed with Process Explorer), but that doesn't seem to have any effect on P4VFS' behavior.

The only thing that works reliably is to set P4TICKETS as a user/system environment variable, but I'd like to avoid that as that affects P4 as well.

A partially working workaround is to specify P4TICKETS in the command line's environment, which works when running e.g. p4vfs sync -t, but hydration of virtual files then doesn't work.

Best, Juraj

jessk-msft commented 1 week ago

Hi Juraj,

That's a clever idea with P4VFS.Service-specific environment variable, but I can see why it wouldn't work due to how the service is trying to use the impersonated process environment.

This really seems like a bug in P4VFS, and I don't know of another way (besides what you mention, and p4 set registry) to override the service environment. It's the intension for the service to use the environment of the impersonating process or calling process. Doesn't seem to be working in this case. I'll take a closer look ... and write a test.

Regards -Jess

jessk-msft commented 1 week ago

There's a new branch dev/p4config-fixes with an addition to test UnitTestCommon.EnvironmentConfigTest to reproduce this issue (currently failing). I'm expecting a small change to the DepotClient code to fix this.

jessk-msft commented 1 week ago

This should be fixed in release v1.28.2.0 Release Notes v1.28.2.0

jtomori commented 1 day ago

Hello, thank you for the update, it has fixed the issue.