Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On permission managed windows machines (eg. win7) rust generated binaries require administrator privileges to run #16455

Closed
brson opened this issue Aug 12, 2014 · 18 comments
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows

Comments

@brson
Copy link
Contributor

brson commented Aug 12, 2014

From http://discuss.rust-lang.org/t/prioritizing-windows-issues/319/2?u=brson

It appears that on permission managed windows machines (eg. win7) rust generated binaries require administrator privileges to run, even for trivial case applications like println!("Hello World"); these permissions must be accepted ("Run this as administrator") every time the application is launched.

I have no idea how this is typically managed in win programming, but having to accept "run this as administrator" every time you run cargo test or launch a binary is really tedious.

@brson
Copy link
Contributor Author

brson commented Aug 12, 2014

There may not be anything we can do about it since it seems this is just what happens when you build from cmd.exe: http://discuss.rust-lang.org/t/prioritizing-windows-issues/319/9?u=brson

@tbu-
Copy link
Contributor

tbu- commented Aug 15, 2014

V01D_EXE only says that this happens when you build a program from an elevated cmd.exe (or more generally, from an elevated process, I guess).

@retep998
Copy link
Member

I am able to build C++ programs from an elevated visual studio and then run them non-elevated just fine. So, it is definitely possible to fix this, it might just be mingw's fault instead of our fault.

@ghost
Copy link

ghost commented Aug 20, 2014

@brson
Well,

It appears that on permission managed windows machines (eg. win7) rust generated binaries require administrator privileges to run, even for trivial case applications like println!("Hello World"); these permissions must be accepted ("Run this as administrator") every time the application is launched.

I have no idea how this is typically managed in win programming, but having to accept "run this as administrator" every time you run cargo test or launch a binary is really tedious.

Under Windows 8/8.1 this is no problem as Windows generally adds permissions for Users as well.
But if these permissions are missing, then you need to always run as Administrator , or add these permissions at once.
See this pic.
Another thing that creates this problem is the UAC.

On permission managed windows machines , you generally cannot even compile without elevated permissions, and if you do that , then the Users permissions are missing.

It had happened to me on older windows as well. I have no idea how to fix it properly for RUST, but @retep998 it should not be a direct fault of mingw because I use MinGW with/without elevated permissions , and have no problem. The problem is of Windows. Visual Studio generates no problems as it is made specifically for windows so it takes care of everything.
There might be some other factors creating this problem , so you guys should ask someone experienced in windows stuff.

Hope this helps as I am also a windows user , and everyone of us wants Rust On Windows ASAP.

@retep998
Copy link
Member

This issue would most likely be solved once we provide proper support for manifests. rust-lang/rfcs#721

@vadimcn
Copy link
Contributor

vadimcn commented Feb 20, 2015

@V01D-exe, Is this a file permissions problem, i.e. only the file creator has rights to execute it?
If so, this is not a Rust issue and I would recommend closing this.

@ghost
Copy link

ghost commented Feb 22, 2015

@vadimcn
retep998 is right, and manifests should be able to fix this problems. [I am not sure but i think RequestedExecutionLevel is the fix.]
Generally it is a file permissions problem.

@vadimcn
Copy link
Contributor

vadimcn commented Feb 22, 2015

@V01D-exe, Would you mind describing your setup, so I could try to reproduce the problem locally? Have you tried adding a manifest to your executable?

@ghost
Copy link

ghost commented Feb 22, 2015

@vadimcn
I tried to create a user account with less privileges [standard user account] to provide a test case but my OS is giving some errors in loading it up.
So, I just used my admin user account , and then -

First -

a.rs

fn main() {
  print!("Hello World");
}

a.exe.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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>

Second - Compiled using rustc a.rs and got a.exe .

Third - Used mt.exe from Windows SDK to embed the manifest manually into the exe.

mt.exe  -manifest "a.exe.manifest" -outputresource:"a.exe";1

Fourth - From a non-elevated cmd, start a.exe . => a.exe automatically starts up in elevated cmd.
[Remember I am not on any permission managed windows machine, and I have admin access].

Fifth - Change level="requireAdministrator" to level="asInvoker" and redo third and fourth.
=> It starts up as a non-admin process.

NOTE : Since I have admin access on my PC, someone needs to check this in a permission managed machine, if it works or not.

PS: BTW, this problem was described by user shadowmint here, I don't have this issue since I am on windows 8 with admin access.

@bombless
Copy link
Contributor

So I notice that we don't even have a tracking issue for this.
#11207
#21352

See this comment #11207 (comment)

@vadimcn
Copy link
Contributor

vadimcn commented Feb 22, 2015

@V01D-exe: I assumed that you are experiencing this problem as well because of your comment here.
I thought the issue was that manifest-less rust executables do not run without elevation, but it seems nobody can repro this...

@bombless
Copy link
Contributor

We need to add proper manifest for Windows any way.

I am thinking about would it be possible that we take manifest as a crate in some way.
So we can add manifest infomation in Cargo.toml, and cargo can link the resource for us.

@bombless
Copy link
Contributor

cc @vadimcn

@vadimcn
Copy link
Contributor

vadimcn commented Feb 22, 2015

@bombless: perhaps so, but it is not clear at all that this particular issue is caused by the absent manifest.

@ghost
Copy link

ghost commented Feb 22, 2015

@vadimcn
I didn't have this problem with rust.It was just that a few years back, i had got the problem with mingw.

@ghost
Copy link

ghost commented Feb 23, 2015

@vadimcn Since no one is having this problem, i think this should be either closed down, or a reproduce tag should be added.

@steveklabnik
Copy link
Member

Triage: not aware of any specific movement on this front.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 21, 2017
@steveklabnik
Copy link
Member

Triage: not aware of any changes. Given that this is solved by proper manifests, and nobody has commented since 2015, i'm going to close this as a duplicate of rust-lang/rfcs#721

lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
minor: Remove Changelog: XXX title from Github release notes

Fixes rust-lang#16455
Closes rust-lang#17165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

7 participants