sudo with application that uses launchpadlib creates ~/.launchpadlib with root owner

Bug #1828208 reported by Dan Streetman on 2019-05-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
Undecided
Dan Streetman

Bug Description

[impact]

and application that uses launchpadlib to login to LP, and is run as root (with sudo), will cause launchpadlib to also be run as root. It will then create the $HOME/.launchpadlib directory and cache files with root ownership, but in the non-root user's $HOME directory, since sudo does not do a full login and change the env.

The root-owned ~/.launchpadlib and/or root-owned files under that directory will then cause later failures with other applications that also use launchpadlib, but are not run as root, since launchpadlib will try to update the files, but can't since it is not root.

[test case]

ubuntu@test:~$ ls -lad .launchpadlib
ls: cannot access '.launchpadlib': No such file or directory

ubuntu@test:~$ sudo python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from launchpadlib.launchpad import Launchpad
>>> lp = Launchpad.login_with('sudo-test', service_root='production', version='devel')
The authorization page:
 (https://launchpad.net/+authorize-token?oauth_token=mB9NB4ndzLVswfRHPjHZ&allow_permission=DESKTOP_INTEGRATION)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
>>>

ubuntu@test:~$ ls -lad .launchpadlib
drwx------ 3 root root 4096 May 8 10:13 .launchpadlib

[regression potential]

TBD

[other info]

I am updating software-properties to use launchpadlib in bug 645404, and the primary use case there is the 'add-apt-repository' script which must be run as root.

NOTE: I think this would be better fixed by bug 1556302, so depending on that bug, this could be marked as a duplicate (if it's fixed). If that bug is not fixed, this very likely will need some workaround, if/when add-apt-repository is updated to use launchpadlib, since add-apt-repository is always run as root.

Dan Streetman (ddstreet) on 2019-05-09
Changed in launchpadlib:
assignee: nobody → Dan Streetman (ddstreet)
status: New → In Progress
Dan Streetman (ddstreet) on 2019-05-14
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers