Merge lp:~brian.curtin/ubuntuone-client/930398-windows-is_root into lp:ubuntuone-client

Proposed by Brian Curtin on 2012-03-06
Status: Merged
Approved by: dobey on 2012-03-21
Approved revision: 1204
Merged at revision: 1214
Proposed branch: lp:~brian.curtin/ubuntuone-client/930398-windows-is_root
Merge into: lp:ubuntuone-client
Diff against target: 50 lines (+14/-2)
2 files modified
tests/platform/windows/test_os_helper.py (+8/-0)
ubuntuone/platform/windows/os_helper.py (+6/-2)
To merge this branch: bzr merge lp:~brian.curtin/ubuntuone-client/930398-windows-is_root
Reviewer Review Type Date Requested Status
dobey (community) Approve on 2012-03-21
Roberto Alsina (community) 2012-03-06 Approve on 2012-03-19
Review via email: mp+96224@code.launchpad.net

Commit Message

- Loosen the is_root check on Windows to allow Windows XP users, who commonly run with Administrator rights, to start U1 properly. (LP: #930398).

Description of the Change

When running on XP, which is almost always run from an Administrator account, always return False on is_root. On versions after XP, i.e., the versions 6.0 and greater (Vista/7), return the real status of whether or not the user is an Administrator.

This adds a test for the XP behavior, mocking platform.version() to produce an XP version string.

To post a comment you must log in.
Brian Curtin (brian.curtin) wrote :

While working on the installer, I've verified that this branch works on XP.

Roberto Alsina (ralsina) wrote :

Were all the cases of users reporting this on XP? If yes, then it's a +1 from me.

review: Needs Information
Brian Curtin (brian.curtin) wrote :

Last I heard, "most" of them were XP but a few were supposedly Win7. However, even if some are Win7, they would have to be explicitly running the app as admin in order for this to occur. It runs fine on my box until I start up a cmd with "Run as administrator", which we talked about before should not be allowed anyway.

I've tested this on my Win7 box and an XP VM and both behave properly. XP starts up fine, Win7 starts up fine, and Win7 explicitly running ubuntuone-syncdaemon as admin does gives the "do not run as root" error.

Roberto Alsina (ralsina) wrote :

Ok, let's merge it and then if users complain we give up and just return False.

review: Approve
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/windows/test_os_helper.py'
2--- tests/platform/windows/test_os_helper.py 2012-01-10 18:09:30 +0000
3+++ tests/platform/windows/test_os_helper.py 2012-03-06 19:12:19 +0000
4@@ -20,6 +20,7 @@
5 import os
6 import shutil
7 import sys
8+import platform
9
10 from twisted.internet import defer
11 from twisted.trial.unittest import TestCase
12@@ -478,3 +479,10 @@
13 self.patch(os_helper.shell, 'IsUserAnAdmin', lambda: expected)
14 actual = os_helper.is_root()
15 self.assertEqual(expected, actual)
16+
17+ def test_is_root_on_xp(self):
18+ """Test that os_helper.is_root always returns False on XP"""
19+ expected = False
20+ self.patch(platform, "version", "5.1.2600")
21+ actual = os_helper.is_root()
22+ self.assertEqual(expected, actual)
23
24=== modified file 'ubuntuone/platform/windows/os_helper.py'
25--- ubuntuone/platform/windows/os_helper.py 2012-01-10 18:09:30 +0000
26+++ ubuntuone/platform/windows/os_helper.py 2012-03-06 19:12:19 +0000
27@@ -23,6 +23,7 @@
28 import stat
29 import sys
30
31+from platform import version
32 from contextlib import contextmanager
33 from functools import wraps
34
35@@ -872,10 +873,13 @@
36
37 def is_root():
38 """Return if the user is running as root."""
39- # This solution works on Windows XP, Vista and 7
40+ # On Windows XP (v5.1), always return False. Nearly all users run with
41+ # Administrator access, so this would restrict too many users.
42+ # On Vista (v6.0) and 7 (v6.1), return the real Administrator value.
43 # The MSDN docs say this may go away in a later version, but look at what
44 # the alternative is: http://bit.ly/rXbIwc
45- return shell.IsUserAnAdmin()
46+ is_xp = version()[0] == "5"
47+ return False if is_xp else shell.IsUserAnAdmin()
48
49
50 @windowspath()

Subscribers

People subscribed via source and target branches