Why are some subfolders under C:\Windows\System32\config\systemprofile not found for a Command Line build step?

In particular, I'm trying to run Leiningen.

Under the C:\Windows\System32\config\systemprofile folder is a folder .lein and in that folder are two folders profiles.d and self-installs.

Here's the contents of the Command Line Custom Script:

echo Contents of C:\Windows\system32\config\systemprofile\.lein
dir "C:\Windows\system32\config\systemprofile\.lein"
echo Contents of C:\Windows\system32\config\systemprofile\.lein\self-installs
dir "C:\Windows\system32\config\systemprofile\.lein\self-installs"
lein with-profile +teamcity do clean, test, uberjar

The last line is the actual line I want to run; the other lines are to demonstrate what I think is the problem.

Here's the build log for the above script:

[14:13:32][Step 1/1] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script914836795769205572.cmd
[14:13:32][Step 1/1] in directory: C:\TeamCity\buildAgent\work\5772168e0f9479b6
[14:13:32][Step 1/1] Contents of C:\Windows\system32\config\systemprofile\.lein
[14:13:32][Step 1/1] Volume in drive C has no label.
[14:13:32][Step 1/1] Volume Serial Number is 340A-E0D8
[14:13:32][Step 1/1]
[14:13:32][Step 1/1] Directory of C:\Windows\system32\config\systemprofile\.lein
[14:13:32][Step 1/1] File Not Found
[14:13:32][Step 1/1]
[14:13:32][Step 1/1] 06/03/2014  11:05 AM    <DIR>          .
[14:13:32][Step 1/1] 06/03/2014  11:05 AM    <DIR>          ..
[14:13:32][Step 1/1] 0 File(s)              0 bytes
[14:13:32][Step 1/1] 2 Dir(s)  40,491,573,248 bytes free
[14:13:32][Step 1/1] Contents of C:\Windows\system32\config\systemprofile\.lein\self-installs
[14:13:32][Step 1/1] Volume in drive C has no label.
[14:13:32][Step 1/1] Volume Serial Number is 340A-E0D8
[14:13:32][Step 1/1]
[14:13:32][Step 1/1] Directory of C:\Windows\system32\config\systemprofile\.lein
[14:13:32][Step 1/1]
[14:13:32][Step 1/1]
[14:13:32][Step 1/1] C:\Windows\system32\config\systemprofile\.lein\self-installs\leiningen-2.3.4-standalone.jar can not be found.
[14:13:32][Step 1/1] You can try running "lein self-install"
[14:13:32][Step 1/1] or change LEIN_JAR environment variable
[14:13:32][Step 1/1] or edit lein.bat to set appropriate LEIN_JAR path.
[14:13:32][Step 1/1]
[14:13:32][Step 1/1] Process exited with code 0


[I think the strange order (i.e. the oddly placed line "File Not Found" might be due to how PsExec outputs to the standard and error output handles.]

I also tried including the following in the Command Line Custom Script:

echo whoami
whoami


The relevant build log output:

[13:03:29][Step 1/1] whoami
[13:03:29][Step 1/1] nt authority\system


What's strange is that if I access the Windows command shell with the following command (entered in Command Prompt), I can list the .lein subfolders and run the lein ... command fine (and see its output):


psexec -s \\localhost cmd
...


I tried executing the commands in the build step via psexec and they seem to work, but unfortunately the build log shows only the last line of the output of psexec and the +teamcity portion of the lein ... command is intended to produce output that TeamCity recognizes, e.g. something like the following (which is copied from the output when I run the lein ... command directly from Command Prompt):

##teamcity[testFailed name='a-test' message=':expected (= 0 1)|n:actual (not (=
0 1))']


The server is running Windows Server 2008 Datacenter [version 6.0.6002]; TeamCity Professional 8.0.6 (build 27767).
5 comments
Comment actions Permalink

Why do you think TeamCity is to blame here? TeamCity just starts your command, nothing more. Usually problems like this are caused by windows service limitations or incorrect permissions. Here is a list of things to check if build misbehaves under TeamCity: http://confluence.jetbrains.com/display/TCD8/Common+Problems#CommonProblems-BuildfailsorbehavesdifferentlyinTeamCitybutnotlocally

0
Comment actions Permalink

Why do you think Windows services are limited? Both of the TeamCity services are running under 'LocalSystem' (aka "NT AUTHORITY\SYSTEM"), and I even included evidence that the command was being executed as that user in my post.

Microsoft's documentation about the LocalSytem account states:

One advantage of running under the LocalSystem account is that the service has complete unrestricted access to local resources.

If I examine the Windows (filesystem) Security settings of the two folders I mentioned in my original post, I see that "SYSTEM" (i.e. LocalSystem) has "Full Control" permissions granted. That matches the evidence obtained by running psexec that the account does indeed have access to those folders, including listing them in their parent folder.

I haven't been able to find any info about how a service running under this account could be limited – the info I have found instead describes the security risks involved because the account has no effective limitations.

Additional evidence that the issue pertains to TeamCity is that I am able to run the exact same command without issue using another build program, on the same computer, and for which the corresponding service is running under the same account ("Local System").

And ... you were right anyways; it's not TeamCity's fault!

I was able to resolve the issue by copying the two folders under the folder C:\Windows\SysWOW64\config\systemprofile – instead of C:\Windows\System32\config\systemprofile.

0
Comment actions Permalink

The issue seems to be that the TeamCity service, when running under 'LocalSystem' on a 64-bit version of Windows, is effectively accessing the system profile folder C:\Windows\SysWOW64\config\systemprofile instead of C:\Windows\System32\config\systemprofile.

0
Comment actions Permalink

Thank you for additional details. Seems this workaround covers your case: http://youtrack.jetbrains.com/issue/TW-25671#comment=27-438215

0

Please sign in to leave a comment.