flowchartsman / deadman

A usb-based dead man's switch
133 stars 9 forks source link

Should check for necessary access #4

Open flowchartsman opened 9 years ago

flowchartsman commented 9 years ago

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.

omern1 commented 9 years ago

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.

flowchartsman commented 9 years ago

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.

omern1 commented 9 years ago

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

flowchartsman commented 9 years ago

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 notifications@github.com 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.

omern1 commented 9 years ago

Care to submit what? A manifest?

flowchartsman commented 9 years ago

Yes.

Sent from my iPhone

On May 9, 2015, at 1:26 AM, Nabeel Omer notifications@github.com wrote:

Care to submit what? A manifest?

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

omern1 commented 9 years ago

Sure.

omern1 commented 9 years ago
<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 :)

flowchartsman commented 9 years ago

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.

omern1 commented 9 years ago

Hahaha, Thanks.

omern1 commented 9 years ago

What's Up Andy, stopped all development?

flowchartsman commented 9 years ago

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

omern1 commented 9 years ago

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

flowchartsman commented 9 years ago

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.

omern1 commented 9 years ago

Have you updated the repository?

flowchartsman commented 9 years ago

You will receive an alert when I do.

omern1 commented 9 years ago

Something wrong?

flowchartsman commented 9 years ago

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.