1

I have ASP.NET MVC3 application that runs on IIS. One of controllers actions starting the process "cmd /C git clone some-repo".

I need to make sure that child process running under the user that already have git being setup. I use application pool with Identity == My Accout (admin + git is works).

The processes starting up ok, but it hangs up. I think that because of wrong identity which runs it.

Does anyone have experiece with starting up processes under IIS, have you seen something similar? What is the way to debug such issues?

Alexander Beletsky
  • 19,453
  • 9
  • 63
  • 86

2 Answers2

1

What I suspect is happening...

On a per-user basis, you need to accept the public key of a remote SSH service. Your process is likely hung waiting for someone to accept the public key via keyboard input.

In a console application, the user is you and you have already accepted it. As w3wp, the key has not been accepted - waiting forever for it to be accepted.

You have a couple of options.

  1. If you control the identity of the AppPool of w3wc, you can login as that user, and permanently accept it yourself. You can use tools like PsExec to run a process as System or Network service as well.

  2. Use a different overload of Process.Start to start it as a different user that has already accepted the public key.

vcsjones
  • 138,677
  • 31
  • 291
  • 286
  • good answer.. I assume that it have to run under my user, that already accepted keys. moreover it worked before. smth is happend as soon I got Win7 SP1 – Alexander Beletsky Sep 24 '11 at 15:07
  • I've checked, it is INDEED ssh.exe process that hangs out. I'm now tring just run ssh -T git@github.com - no success. Any tips to diagnose the problem ? – Alexander Beletsky Sep 26 '11 at 18:13
  • you are right about ssh.exe I did a little more analisys.. please take a look http://stackoverflow.com/questions/7666423/iis-7-5-with-process-idenity-set-to-user-has-wrong-userprofile – Alexander Beletsky Oct 05 '11 at 19:24
1

I think that your other question's solution works for this too.

After setting impersonation to my username like this

<identity impersonate="true" password="o1j2813n" userName="obrad" />

I have tried running processes from System.Diagnostics.Process.Start from mvc action and they appear under my username in windows task manager, so I think that this answer will be helpfull.

EDIT

The other part of problem - git not working is caused by wrong way to give git command. I have made some experiments and found a way how to clone a git repo from controller action:

System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Git\bin\git.exe", "clone git://github.com/goranobradovic/go.DB.JournalingBase.git " + @"C:\Users\obrad\Desktop\temp");

This command clones repo from git://github.com/goranobradovic/go.DB.JournalingBase.git to temp folder on my desktop.

Community
  • 1
  • 1
Goran Obradovic
  • 8,951
  • 9
  • 50
  • 79