Fightin_Foo
3rd December 2007 15:05 UTC
Username and Password
I am trying to write an installer for a service, and I would like the service to be installed under the current user and not the system user. I've seen several plugins that handle services, and they need to username and password of the account to install the service to. Is there a way to get a user's username and password?
ClayDowling
3rd December 2007 16:29 UTC
nsDialogs would be a good place to start. I wrote my first custom screen last week and fell completely in love with it. Much easier to use than the old InstallOptions.
You'll need to verify that the username and password are valid before you accept them, which you should do on the Leave function of your custom page.
Fightin_Foo
3rd December 2007 16:38 UTC
I was hoping for a way of just getting them and not prompting the user. Is there a way to just look them up with some system call or registry entry?
Anders
3rd December 2007 16:42 UTC
username:
System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"
DetailPrint "User name - $0"
to get the password you would probably have to bruteforce the SAM database lol
ClayDowling
3rd December 2007 16:43 UTC
Not particularly. For one, the installing user probably isn't the one who will be running the service. Having a service run as a user with Administrative privileges is a really bad idea, because any flaw in your program will allow an attacker to smash the stack in your program and run their own code on the machine with administrator rights.
There's a system account with privileges less than an administrator that is a common choice, but I don't know the details of using it. The absolute safest option is to create your own user and run the service as that user. That user has extremely restricted privileges, so that even if miscreants hijack your service they'll be fairly restricted in what they can do.
Fightin_Foo
4th December 2007 14:18 UTC
Thanks for all the info everybody.