net rpc shutdown - how to poweroff

Willi Mann newsletters at wm1.at
Mon Dec 30 00:05:00 GMT 2002


Hi Andrew!

The existing net rpc shutdown function doesn't seem to be able to do a 
power off. It seems to be an implementation of the 
initiateSystemShutdown API-call, which is used in many freeware 
closed-source shutdown applications. I've played around with the flags 
in the current Samba-implementation with the following result:
If one of the first 8 bits is set to 1 the machine reboots.
The second 8 bits mark the forced shutdown but I haven't verified that 
it makes a difference to non-forced shutdowns.

There is a way for a working remote power off. The WMI-framework 
provides a function called win32shutdown. This function is also used by 
the Management Console-Shutdown. It offers nearly all flags which are 
available in the ExitWindowsEx-function. It is completely different to 
the net rpc shutdown. I've modified a VBscript-example provided in the 
WMI-SDK to get the shortest possible shutdown-session and sniffed it. 
There are about 100 packets on the wire (incl. authentication, SYNs, 
RSTs, etc.) I'll try to work out more about that in the next few days.

My biggest problem is that I'm not familiar enough with the SAMBA source 
code and the SMB/RPC-calls and this is my first attempt to work on a 
network program.

Willi Mann



Andrew Bartlett wrote:

>On Tue, 2002-12-17 at 06:37, Willi Mann wrote:
>  
>
>>Thanks for your fast answer but that's not the problem.
>>
>>rpc shutdown with windows2000 offers you four possibilities what you 
>>want to do:
>>-logoff current user
>>-shutdown (which really shuts down w2k but doesn't power off)
>>-reboot
>>-power off (if supported) (which does what I want)
>>
>>and three methods how to deal with applications, which block the process:
>>-never
>>-when no reaction
>>-always
>>
>>Window: my computer > administration > properties > extended > shutdown
>>
>>The windows api also knows these different methods (look for 
>>exitwindowsex on m$dn).
>>
>>My problem is that remote shutdown from windows 2000 machines (german) 
>>only works if the remote machine is in the same domain. The samba net 
>>rpc shutdown command doesn't depend on that detail. However, it doesn't 
>>solve my problem because I want to power off the machines to avoid disk 
>>damage (8 hours but not more for "class C" drives says an Austrian IBM 
>>branch) but that command doesn't offer you that different ways shutdown 
>>methods.
>>    
>>
>
>Grab a sniffer, and figure out what Win2k does that Samba does not do. 
>Then see if you can come out with a patch - there just might be a few
>more flags in there we didn't know about.  
>
>Andrew Bartlett
>
>  
>





More information about the samba-technical mailing list