deadman icon indicating copy to clipboard operation
deadman copied to clipboard

Should check for necessary access

Open flowchartsman opened this issue 9 years ago • 18 comments

In keeping with the zero-surprises mode of thinking, deadman should detect, at startup, whether or not it is capable of shutting down. On *nix systems, this means checking whether or not it has superuser access. On windows, further research is required.

flowchartsman avatar May 06 '15 00:05 flowchartsman

on windows, every thing will be resolved by using the win32 api because it has functions for all of the things that are issues here.

omern1 avatar May 08 '15 05:05 omern1

In order to figure out exactly which calls to make, I'll need to not only know which DLLs are involved, but also the permission names/UUIDs and such that are involved. If you can point me in the right direction of finding out if a given user has shutdown privileges, it would be much appreciated. All I know as of now is that the local security policy of a windows box can restrict it. As to how to check... not there yet.

flowchartsman avatar May 08 '15 08:05 flowchartsman

A better idea would be to force the application to run only with administrative privileges by embedding a manifest.

omern1 avatar May 08 '15 09:05 omern1

Good idea. Maybe using this: http://github.com/akavel/rsrc

Care to submit one?

Sent from my iPhone

On May 8, 2015, at 5:35 AM, Nabeel Omer [email protected] wrote:

A better idea would be to force the application to run only with administrative privileges by embedding a manifest.

— Reply to this email directly or view it on GitHub.

flowchartsman avatar May 09 '15 01:05 flowchartsman

Care to submit what? A manifest?

omern1 avatar May 09 '15 05:05 omern1

Yes.

Sent from my iPhone

On May 9, 2015, at 1:26 AM, Nabeel Omer [email protected] wrote:

Care to submit what? A manifest?

— Reply to this email directly or view it on GitHub.

flowchartsman avatar May 09 '15 14:05 flowchartsman

Sure.

omern1 avatar May 09 '15 16:05 omern1

<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='requireAdministrator' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

This is a manifest that will force the user to provide administrator credentials and the application will run elevated. Its 100% correct and working (I know that for certain because I copied it from one of my own applications). PS. I believe, now I am a contributor :)

omern1 avatar May 09 '15 16:05 omern1

I'll test and make sure that the tool I've got embeds the necessary manifest, and that it works. If all goes well, what you can do if you want to get on the contributors list is the following:

  1. Fork the repo.
  2. make a directory assets/windows
  3. place this file there with a suitable filename like require_admin.xml
  4. check it in with a decent commit message
  5. issue a pull request.

Then, my friend, you'll be listed as a contributor.

flowchartsman avatar May 09 '15 16:05 flowchartsman

Hahaha, Thanks.

omern1 avatar May 09 '15 16:05 omern1

What's Up Andy, stopped all development?

omern1 avatar May 11 '15 16:05 omern1

Nope. Working on an event-based branch to remove the need for polling.

flowchartsman avatar May 11 '15 17:05 flowchartsman

That is a tough job. Especially in windows. You need a message only window. Anyways, did you try the manifest?

omern1 avatar May 11 '15 18:05 omern1

I actually completed it with a callout to powershell and System.Management.WqlEventQuery and System.Management.ManagementEventWatcher. It's unpolished at the moment, but it works. All Win32_PnPEntitys seem to show up on add and remove. No, I have not yet tried the manifest. I will try and get to it tonight.

flowchartsman avatar May 11 '15 22:05 flowchartsman

Have you updated the repository?

omern1 avatar May 12 '15 09:05 omern1

You will receive an alert when I do.

flowchartsman avatar May 12 '15 15:05 flowchartsman

Something wrong?

omern1 avatar May 12 '15 16:05 omern1

Unix checks still outstanding. This appears to work for Windows. I also gave it a more meaningful name. You also didn't create an assets directory like I asked, but I think it will be okay in the base directory with the new name.

flowchartsman avatar May 12 '15 16:05 flowchartsman