Skip to content

Commit

Permalink
Frontend.XF.GTK: exit with one when user is 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:

```
update.go:85: cannot change mount namespace according to change mount (/snap/gtk-common-themes/1534/share/gtk2/Materia-compact /snap/geewallet/x1/data-dir/themes/Materia-compact none bind,ro 0 0): cannot write to "/snap/gtk-common-themes/1534/share/gtk2/Materia-compact" because it would affect the host in "/snap"
update.go:85: cannot change mount namespace according to change mount (/snap/gtk-common-themes/1534/share/gtk2/Materia-dark-compact /snap/geewallet/x1/data-dir/themes/Materia-dark-compact none bind,ro 0 0): cannot write to "/snap/gtk-common-themes/1534/share/gtk2/Materia-dark-compact" because it would affect the host in "/snap"
update.go:85: cannot change mount namespace according to change mount (/snap/gtk-common-themes/1534/share/gtk2/Yaru-MATE-dark /snap/geewallet/x1/data-dir/themes/Yaru-MATE-dark none bind,ro 0 0): cannot use "/snap/gtk-common-themes/1534/share/gtk2/Yaru-MATE-dark" as bind-mount source: not a directory
update.go:85: cannot change mount namespace according to change mount (/snap/gtk-common-themes/1534/share/gtk2/Yaru-MATE-light /snap/geewallet/x1/data-dir/themes/Yaru-MATE-light none bind,ro 0 0): cannot use "/snap/gtk-common-themes/1534/share/gtk2/Yaru-MATE-light" as bind-mount source: not a directory
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 27, 2024
1 parent 3114fc3 commit 156fa92
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 @@ -37,6 +37,10 @@ module Main =
[<EntryPoint>]
[<STAThread>]
let main argv =
if GWallet.Backend.Config.IsLinuxPlatform() && Environment.UserName = "root" then
Console.Error.WriteLine "Running as root user is not supported"
Environment.Exit 1

match argv.Length with
| 0 ->
NormalStartWithNoParameters()
Expand Down

0 comments on commit 156fa92

Please sign in to comment.