manjaro / pacman-mirrors

This repo has been archived. Our code is now hosted at
https://gitlab.manjaro.org
GNU General Public License v3.0
25 stars 16 forks source link

wayland support #115

Closed fabiscafe closed 6 years ago

fabiscafe commented 6 years ago

pacman-mirrors "-i" option does not work on wayland, i think because root-owned windows are not allowed

If we run

sudo pacman-mirrors --geoip -i

we get

[1] 9719 segmentation fault sudo pacman-mirrors --geoip -i

if we use pkexec pacman-mirrors --geoip -i

It will start the CLI-interface

pacman-mirrors --version
Version 4.6

inxi -GSC
System:    Host: balder Kernel: 4.14.2-1-MANJARO x86_64 bits: 64 Desktop: Gnome 3.26.2 Distro: Manjaro Linux
CPU:       Quad core AMD A8-7600 Radeon R7 10 Compute Cores 4C+6G (-MCP-) cache: 8192 KB
           clock speeds: max: 3100 MHz 1: 1399 MHz 2: 1399 MHz 3: 1398 MHz 4: 1399 MHz
Graphics:  Card: Advanced Micro Devices [AMD/ATI] Tonga PRO [Radeon R9 285/380]
           Display Server: wayland (X.Org 1.19.5 ) drivers: amdgpu (unloaded: modesetting)
           Resolution: 1920x1080@59.96hz
           OpenGL: renderer: AMD Radeon R9 380 Series (AMD TONGA / DRM 3.23.0 / 4.15.0-1-MANJARO, LLVM 5.0.0)
           version: 4.5 Mesa 17.2.6
Huluti commented 6 years ago

Related with https://github.com/manjaro/packages-core/issues/97

fhdk commented 6 years ago

@Tids @Ste74 I have tried to implement the proposed changes from Stefanos gist.

I have placed a test package at https://www.uex.dk/public/pacman-mirrors

Will you test if this works for you on Wayland?

When I try to run pacman-mirrors with the proposed changes I get

/bin/bash: warning: shell level (1000) too high, resetting to 1

Have you a proposal to how I can work around that?

fabiscafe commented 6 years ago

Yep, same output:

LANG=C pacman-mirrors --geoip -i                         :(
localuser:root being added to access control list
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: retry: Resource temporarily unavailable
/usr/sbin/pacman-mirrors: fork: Resource temporarily unavailable
localuser:root being removed from access control list
access control enabled, only authorized clients can connect
SI:localuser:fabi

Now its completely broken. In /usr/bin/pacman-mirrors, line 3, you have to change the line to:

app="pm-launch $*"
fhdk commented 6 years ago

I have corrected to pm-launch - new pkg build

And it works as expected on a normal xfce install

fabiscafe commented 6 years ago

pacman-mirrors --geoip -i ^ works on wayland and will load the GTK interface

sudo pacman-mirrors --geoip -i ^ crashes with

No protocol specified
Unable to init server: Could not connect: Connection refused
No protocol specified
Unable to init server: Could not connect: Connection refused
/usr/bin/pacman-mirrors: line 30: 30973 Segmentation fault      (core dumped) ${app}

pkexec pacman-mirrors --geoip -i ^works and will start the CLI interface.


from what I understand, it is using the root-xorg as workaround to bypass wayland norootwindow-security-layer. For the long run it would maybe better to adopt a new structure for pacman-mirrors. where it runs completely as normal user, opens the dialog as normal user, creates the mirror list as normal user (in $XDG_CACHE_HOME) and only asks for root(via polkit) to move that mirrors list to /etc/*

fhdk commented 6 years ago

pacman-mirrors does a lot more than that

It seems that the problem only occurs when launching the GUI window.

pacman-mirrors checks the $DISPLAY variable to decide if showing GUI or CLI

Ste74 commented 6 years ago

So for me now work fine no ? Only we have to inform user to use simply pacman-mirrors without sudo or pkexec ..

OT: Now is good idea create a little gui to call via MSM .. do you think

fhdk commented 6 years ago

Only we have to inform user to use simply pacman-mirrors without sudo or pkexec ..

I am trying to get @Tids idea of using the XDG_CACHE_DIR which ultimately will result in pacman-mirrors when the final stage - file copy to their respective folders - is reached - which I agree is a better long term approach.

It would possibly also eliminate the need for the policy file as everything is refactored to run as the ordinary user.

fabiscafe commented 6 years ago

@fhdk you can also check for $XDG_SESSION_TYPE , wich would result in wayland on Gnome, KDE running as wayland compositors, x11 on X or is empty on TTY (and sudo -i). Because the $DISPLAY var is a bit strange to work with nowadays.

This would completely kill the X11 dependency without loss of functionality - you could even make the -i GUI option X11 only and fall back to shell for wayland and terminal until the "rootless" mode is implemented.

@Ste74 TBH I dont like the "hack" with pkexec, since it creates this unflexible behavior in pacman-mirrors

sudo pacman-mirrors --geoip -i
.: INFO Wayland sessions are not supported by the -i GTK Interface, fallback to CLI-mode in 2 secounds

or something like this

fhdk commented 6 years ago

cc7c52c33d671fbb0da91f5ff85abaa8f9b50046