Skip to content

Commit

Permalink
Frontend.XF.GTK: different exitCode on root
Browse files Browse the repository at this point in the history
An error occurs when geewallet is run with root permissions,
thus it’s necessary to restrict users from running it as root:

```
mkdir: cannot create directory ‘/run/user/0’: Permission denied
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
realpath: '': No such file or directory
Authorization required, but no authorization protocol specified

(geewallet:5797): Gtk-WARNING **: 09:01:13.760: cannot open display: :0
```
  • Loading branch information
Mersho committed Feb 28, 2024
1 parent 3114fc3 commit b862202
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/GWallet.Backend/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ module Config =
let IsMacPlatform() =
RuntimeInformation.IsOSPlatform OSPlatform.OSX

let IsLinuxPlatform() =
RuntimeInformation.IsOSPlatform OSPlatform.Linux

let GetMonoVersion(): Option<Version> =
FSharpUtil.option {
// this gives None on MS.NET (e.g. UWP/WPF)
Expand Down
4 changes: 4 additions & 0 deletions src/GWallet.Frontend.XF.Gtk/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ module Main =
let main argv =
match argv.Length with
| 0 ->
if GWallet.Backend.Config.IsLinuxPlatform() && Environment.UserName = "root" then
Console.Error.WriteLine "Running the GTK GUI as root is not supported"
Environment.Exit 1

NormalStartWithNoParameters()
| 1 when argv.[0] = "--version" ->
Console.WriteLine (SPrintF1 "geewallet v%s" VersionHelper.CURRENT_VERSION)
Expand Down

0 comments on commit b862202

Please sign in to comment.