fireice-uk / xmr-stak

Free Monero RandomX Miner and unified CryptoNight miner
GNU General Public License v3.0
4.05k stars 1.79k forks source link

xmr-stak requires administrator privileges on Windows 10 #150

Closed blacklion closed 6 years ago

blacklion commented 6 years ago

Each time I run new xmr-stak on Windows 10 it shows UAC window and ask for Administrator privileges. Previous (xmr-stak-cpu) version works without additional privileges. I have Large Page and memory lock allowed for my user account, so it is not a problem. It is very inconvenient, as I start xmr-stak at login and re-schedule it to IDLE priority. xmr-stak with elevated privileges can not be re-scheduled easily and UAC window on login is kinda suxx.

ClintOxx commented 6 years ago

From Fireice-uk on reddit

It depends. You can compile it not to ask (-DWIN_UAC=OFF) but it is needed for giving you rights to large pages (all systems, one off) and for large page allocation (Windows 7, all the time unless you set memory to slow).

blacklion commented 6 years ago

So, offical build is built with UAC and there are no way to make it command line option? It is pity :-(

ClintOxx commented 6 years ago

Yup not at the moment at least.

blacklion commented 6 years ago

Compilation documentation says «On Windows 10 it is only needed once to set up the account to use them.», but it asks every time.

ClintOxx commented 6 years ago

For now just compile it to get around this

psychocrypt commented 6 years ago

The problem is that it is not possible to pop up the UAC only once :-( As @Clintoxen wrote if you compile it by your own you can disable the UAC requirement.

blacklion commented 6 years ago

It is possible, if it is done in code, not by linker options / manifest. For example, FAR Manager (file manager) requests additional privileges only if it really needs them — for example, when you try to delete file which is not belong to you, not on startup.

But for now I'll build my own build, thank you!

psychocrypt commented 6 years ago

@fireice-uk Could you please have an eye to this issue.

aaronsace commented 6 years ago

I need the admin privileges removed as default.

Soon as this has been fixed then it can be included in MultiPoolMiner.

bagobones commented 6 years ago

I see this as a major security concern (the application downloads and exposes a web interface) and if your OS is up to date it is only a one time thing to set this or it can be done manually.

It might be better to make this an optional command line option on launch for legacy support in Windows 7 to do it on every run, and on new OS only as an optional prompt to set the memory permission for you if you want it.

fireice-uk commented 6 years ago

@blacklion If you know how to do it, please link. AFAIK elevation requires launching of a separate process.

aaronsace commented 6 years ago

Took some time but this script removes default admin rights from an exe file and doesn't require admin rights itself to run:

param([Parameter(Mandatory = $true)][String]$FullPath)
New-Item -Path "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" -Force | New-ItemProperty -Name $FullPath -Value "RunAsInvoker" -Force
fireice-uk commented 6 years ago

@aaronsace thanks! I think if the demand is large enough (which it looks like it will be) we will make a dedicated windows 10 build with UAC off.

bagobones commented 6 years ago

I would appreciate it, it would still be nice to have the setup run via a CLI option if the user has launched the app with elevated permissions manually.. Maybe a --setwinpermission or something.

blacklion commented 6 years ago

@fireice-uk Yes, you are right. I've studied FAR Manager code (it is Open source now) and found that it starts sub-process and communicate with it via named pipe to perform actions which require elevated privileges. Sorry.

anhphan commented 6 years ago

@fireice-uk Maybe we show follow the way notepad++ does. It's restart itselt under Administrator account when privileges is needed.

(Try use notepad++ to save hosts file, it's will ask to restart under Administrator account - If we accept it, UAC will prompt to start a program under Administrative right.)

bagobones commented 6 years ago

I decided to recompile to get rid of the UAC requirment so I could run the process under a non-privileged user, however the -WIN_UAC=OFF or -WIN_UAC=ON parameter had no effect on the compiled file, it always had the UAC flag

I ended up commenting out these lines in the CMakeLists.txt to get it to compile without UAC.

#if(WIN_UAC AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
#    set_property(TARGET xmr-stak PROPERTY LINK_FLAGS "/level='requireAdministrator' /uiAccess='false'")
#endif()

I suspect it has something to do with the COMPILER_ID but didn't bother to look into it as I simply wanted no UAC.

blacklion commented 6 years ago

@bagobones : it is cmake, so -DWIN_UAC=OFF / -DWIN_UAC=ON

bagobones commented 6 years ago

Thanks I don't build on windows normally.

psychocrypt commented 6 years ago

Info: I am working on a solution to have a runtime parameter for this.

thehockeyguy commented 6 years ago

This code `#if(WIN_UAC AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

set_property(TARGET xmr-stak PROPERTY LINK_FLAGS "/level='requireAdministrator' /uiAccess='false'")

endif()`

is not in the CmakeLists.txt ... how do I disable it for Windows 10?