I am working on a cross-platform project with C # / soap and php for Windows and Linux.
The idea is that when the user clicks a button on the web interface, he sends a request for soap, which will stop the server.
This works fine on Windows, but it doesnβt work on Linux, I see no reason why not, as when I run the shutdown command manually on the server, it works fine.
Below is the code I'm using
public bool shutdownServer() { Process process = new Process(); if (CommonTasks.getOperatingSystem() == CommonTasks.OperatingSystemType.Windows) { process.StartInfo.FileName = "shutdown"; process.StartInfo.Arguments = "-s -t 0"; } else if (CommonTasks.getOperatingSystem() == CommonTasks.OperatingSystemType.Linux) { process.StartInfo.FileName = "shutdown"; process.StartInfo.Arguments = "-h now"; } else { return false; } library.logging(classDetails + MethodInfo.GetCurrentMethod().Name, string.Format("Shutting down with the following {0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments)); process.Start(); return true; }
I see no reason why the linux partition will not perform shutdown, but the Windows version is working fine. What am I doing wrong.
Just to be clear, I'm trying to disconnect the whole server, not the application.
Thanks for any help you can provide.
* UPDATE * Thanks for your suggestions, I think I'm somewhere. I found out that mono works under wwwrun using the janis method.
I added wwwrun: www group to / etc / groups using wwwrun:x:0 , I'm not sure if this bit is correct or not, I don't know why: x: 0.
I added %wheel ALL = (ALL) NOPASSWD: /sbin/shutdown to the sudoers file and restarted apache.
When I start the soap service to perform a shutdown, I get the following error in /var/log/messages
Aug 3 23:28:01 dev-server sudo: pam_unix2 (sudo: auth): conversation failed Aug 3 23:20:27 dev-server sudo: wwwrun: pam_authenticate: Talk error; TTY = unknown; PWD = /; USER = root; COMMAND = / sbin / shutdown -h now
I do not know where to go from here now, sorry if I ask a little question about noob, I am pretty new to soap / linux / mono.
UPDATE 2 Just learned something else, it works on Windows only if the browser is running on a local PC that is shutting down. I tried redirecting the output from the command to see if it returns an error and nothing happens, so I canβt understand why it fails.
UPDATE 3 I just found out something else, I have two computers with a PC, a laptop and a desktop, both Windows 7 x64 and a desktop browser. I can make a soap request to turn off the laptop and vice versa, however, the problem I encountered is related to Windows Server and Linux, even local ones in the Windows browser, will not allow me to close using the soap request. I can make the Windows server allow me to shutdown through a soap request, local and remote browser, and how can I fix a problem with Linux.
UPDATE 4 Just fixed the problem with Windows, I needed to add an IIS user account as an administrator so that she could perform shutdown, so now I just have a problem with Linux.