Merge ~vorlon/utah/+git/utah:check-access-not-owner into utah:master

Proposed by Steve Langasek
Status: Merged
Approved by: Paride Legovini
Approved revision: 9316fc1f0f31dc3025f496e24a80837c16f3e6d2
Merged at revision: 9316fc1f0f31dc3025f496e24a80837c16f3e6d2
Proposed branch: ~vorlon/utah/+git/utah:check-access-not-owner
Merge into: utah:master
Diff against target: 63 lines (+8/-9)
3 files modified
debian/changelog (+2/-0)
examples/run_utah_tests.py (+2/-2)
utah/group.py (+4/-7)
Reviewer Review Type Date Requested Status
Paride Legovini Approve
Review via email: mp+375316@code.launchpad.net

Commit message

Pet peeve: don't make me log back into my desktop after installing your software.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :
Revision history for this message
Paride Legovini (paride) wrote :

Should we use config.logpath instead of hardcoding /var/log/utah?

Revision history for this message
Steve Langasek (vorlon) wrote :

On Fri, Nov 08, 2019 at 03:19:09PM -0000, Paride Legovini wrote:
> Should we use config.logpath instead of hardcoding /var/log/utah?

Yes, I think we should, thanks. Pushed that change.

Revision history for this message
Paride Legovini (paride) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 29d86ac..532cab7 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -9,6 +9,8 @@ utah (0.19) UNRELEASED; urgency=medium
6 * Drop dependency on libvirt-bin; it's a transitional package and none of
7 the binaries included in the xenial version of the package are
8 referenced at all in the utah source.
9+ * Don't check membership in a utah group when what we actually care about
10+ is /var/log/utah being writable by the current user.
11
12 -- Paride Legovini <paride.legovini@canonical.com> Thu, 11 Jul 2019 11:20:10 +0200
13
14diff --git a/examples/run_utah_tests.py b/examples/run_utah_tests.py
15index 9677e70..489cb2e 100755
16--- a/examples/run_utah_tests.py
17+++ b/examples/run_utah_tests.py
18@@ -27,7 +27,7 @@ import utah
19 from utah.cleanup import cleanup
20 from utah.config import config
21 from utah.exceptions import UTAHException
22-from utah.group import check_user_group, print_group_error_message
23+from utah.group import check_user_writable, print_group_error_message
24 from utah.iso import ISO
25 from utah.parser import get_parser, parse_args # NOQA
26 from utah.provisioning.ssh import ProvisionedMachine
27@@ -109,7 +109,7 @@ def run_utah_tests(argv=None):
28 except SystemExit:
29 sys.exit(ReturnCodes.CMD_PARSING_ERROR)
30
31- if not check_user_group():
32+ if not check_user_writable():
33 print_group_error_message(__file__)
34 return ReturnCodes.GROUP_ERROR
35
36diff --git a/utah/group.py b/utah/group.py
37index a482c2a..f035c6e 100644
38--- a/utah/group.py
39+++ b/utah/group.py
40@@ -24,19 +24,16 @@ import getpass
41 from utah.config import config
42
43
44-def check_user_group(group=config.group):
45- """Return whether the user is a member of the given group."""
46- user_gids = os.getgroups()
47- gid = grp.getgrnam(group).gr_gid
48-
49- return gid in user_gids
50+def check_user_writable(path=config.logpath):
51+ """Return whether the user has write access to the given path."""
52+ return os.access(path, os.W_OK)
53
54
55 def print_group_error_message(script):
56 """Print error message to stderr to be used by scripts."""
57 argv = list(sys.argv)
58 argv[0] = os.path.abspath(script)
59- message = ["Error: you are not in the utah group.",
60+ message = ["Error: you do not have write access to /var/log/utah.",
61 ("If you believe you have properly configured "
62 "your user account for UTAH use, try:"),
63 ' sudo usermod -a -G utah {}'.format(getpass.getuser()),

Subscribers

People subscribed via source and target branches