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

Make GeoClue2 optional at runtime #656

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Lekensteyn
Copy link

Even if support for GeoClue2 was included at compile time, it could be
missing at runtime. Be sure to check that the service is really
installed.

Tested on Arch Linux without GeoClue2 installed (which results in a
fallback to manual mode) and with GeoClue2 installed (which results in
automatically starting GeoClue2 and using it).


Example output for unpatched redshift 1.12 on a system without GeoClue2:

$ redshift -c /dev/null
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Using method `randr'.
Waiting for initial location to become available...
<waits forever>

Example output for this patched version without GeoClue2:

$ src/redshift -c /dev/null
Trying location provider `geoclue2'...
GeoClue2 provider is not installed!
Failed to start provider geoclue2.
Trying next provider...
Trying location provider `manual'...
Latitude and longitude must be set.

Example output for this patched version with GeoClue2:

$ src/redshift -c /dev/null
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Waiting for current location to become available...
Location: 52.00 N, 4.00 E
Period: Daytime
Color temperature: 6500K
Brightness: 1.00

If location_geoclue2_init fails, state->thread and state->lock could be
uninitialized. Ensure that both are always set to avoid a crash.
Even if support for GeoClue2 was included at compile time, it could be
missing at runtime. Be sure to check that the service is really
installed.

Tested on Arch Linux without GeoClue2 installed (which results in a
fallback to manual mode) and with GeoClue2 installed (which results in
automatically starting GeoClue2 and using it).
@jonls jonls self-requested a review August 15, 2018 15:00
Copy link
Owner

@jonls jonls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I don't think this approach will work though, since if Redshift starts at login/boot the GeoClue DBus server may not be running so Redshift would fail to wait for it to become available (please correct me if I'm wrong but this is my understanding of how this would work). I understand that you'd like Redshift to fall back to the manual location if GeoClue for some reason is unresponsive. One solution that's been proposed is to immediate start out with a cached location value when Redshift starts up and then switch to a new location from GeoClue when it becomes available. I think this solution might work better and also solve the issue that you have. What do you think?

@ArchangeGabriel
Copy link

@jonls While the solution you mention is great for when GeoClue is used, here the case is about GeoClue not being available on the system.

For instance, the distro package can be compiled with GeoClue support, but have it as an optional dependency only. If someone decides they don’t want GeoClue and don’t install it, currently it does not work and they have to recompile without.

@jonls
Copy link
Owner

jonls commented Aug 24, 2018

@ArchangeGabriel Maybe in this case the best option for the user is to just set the location provider explicitly in the configuration file to manual? This seems like a reasonable solution if the user opts to not run GeoClue.

@ArchangeGabriel
Copy link

Sure. Let’s see if it suits @Lekensteyn. ;)

@Lekensteyn
Copy link
Author

Lekensteyn commented Aug 24, 2018

if Redshift starts at login/boot the GeoClue DBus server may not be running so Redshift would fail to wait for it to become available

If the daemon is not running, but the service files are available, it is supposed to be autostarted. That is what got tested in the above "with GeoClue2" scenario. I'll try to do another test with the GeoClue2 binaries deleted (but the service files installed) and see what happens.

Edit: renaming /usr/lib/geoclue results in failure to start the geoclue service. This makes redshift hang for 25 seconds and then it fallback to the manual provider (as desired):

[arch@builder src]$ time ./redshift -p
Trying location provider `geoclue2'...
GeoClue2 provider is not installed!
Failed to start provider geoclue2.
Trying next provider...
Trying location provider `manual'...
Latitude and longitude must be set.

real    0m25.083s
user    0m0.019s
sys     0m0.030s
# journalctl -af
Aug 25 01:34:27 builder dbus-daemon[2268]: [system] Activating via systemd: service name='org.freedesktop.GeoClue2' unit='geoclue.service' requested by ':1.24' (uid=1000 pid=2849 comm="./redshift -p ")
Aug 25 01:34:27 builder systemd[1]: Starting Location Lookup Service...
Aug 25 01:34:27 builder systemd[2852]: geoclue.service: Failed to execute command: No such file or directory
Aug 25 01:34:27 builder systemd[2852]: geoclue.service: Failed at step EXEC spawning /usr/lib/geoclue: No such file or directory
Aug 25 01:34:27 builder systemd[1]: geoclue.service: Main process exited, code=exited, status=203/EXEC
Aug 25 01:34:27 builder systemd[1]: geoclue.service: Failed with result 'exit-code'.
Aug 25 01:34:27 builder systemd[1]: Failed to start Location Lookup Service.
Aug 25 01:34:52 builder dbus-daemon[2268]: [system] Failed to activate service 'org.freedesktop.GeoClue2': timed out (service_start_timeout=25000ms)

One solution that's been proposed is to immediate start out with a cached location value when Redshift starts up and then switch to a new location from GeoClue when it becomes available.

That sounds like #36 but as @ArchangeGabriel mentioned I am trying to solve a different problem. I am trying to make GeoClue2 runtime optional.

I had some issues with lingering GeoClue2 agent processes on logout. While I could try to fix that, I realized that I have no need to the location service at all and for privacy reasons and to reduce the attack vector, removing GeoClue2 is desirable.

The original downstream proposal to make it optional is here: https://bugs.archlinux.org/task/59657. This patch tries to address a concern from that issue, namely the default behavior without the GeoClue2 package. Previously the user would not get any error (not even a suggestion to try changing the location provider to "manual"). After this patch it will warn about missing GeoClue2 and fallback to manual.

@jonls jonls self-assigned this Aug 27, 2018
@Lekensteyn
Copy link
Author

ping

@Lekensteyn
Copy link
Author

Ping, can this be merged or should something be changed?

@jonls
Copy link
Owner

jonls commented Oct 8, 2018

I'm assigned which means I'll take a look when I have time. No need to keep pinging 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants