Skip to content

Commit 03c8fae

Browse files
committed
Remove determining time zone via systemsetup on macOS
According to https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/comment-page-1/ the `systemsetup` command has required superuser privileges since macOS 10.8.5 (which has been EOL for over 6 years at the time of writing). We shouldn't expect to use a codepath that requires a helper tool that requires su in any regular use; IOW, _if_ a Babel user had ever reached this path without having been superuser, it would have failed anyway on any currently supported version of macOS. Closes #895 (supersedes it).
1 parent c7d04e8 commit 03c8fae

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

babel/localtime/_unix.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import os
22
import re
3-
import sys
43
import pytz
5-
import subprocess
6-
7-
_systemconfig_tz = re.compile(r'^Time Zone: (.*)$', re.MULTILINE)
84

95

106
def _tz_from_env(tzenv):
@@ -57,26 +53,6 @@ def _get_localzone(_root='/'):
5753
except pytz.UnknownTimeZoneError:
5854
pass
5955

60-
# If we are on OS X now we are pretty sure that the rest of the
61-
# code will fail and just fall through until it hits the reading
62-
# of /etc/localtime and using it without name. At this point we
63-
# can invoke systemconfig which internally invokes ICU. ICU itself
64-
# does the same thing we do (readlink + compare file contents) but
65-
# since it knows where the zone files are that should be a bit
66-
# better than reimplementing the logic here.
67-
if sys.platform == 'darwin':
68-
c = subprocess.Popen(['systemsetup', '-gettimezone'],
69-
stdout=subprocess.PIPE)
70-
sys_result = c.communicate()[0]
71-
c.wait()
72-
tz_match = _systemconfig_tz.search(sys_result)
73-
if tz_match is not None:
74-
zone_name = tz_match.group(1)
75-
try:
76-
return pytz.timezone(zone_name)
77-
except pytz.UnknownTimeZoneError:
78-
pass
79-
8056
# Now look for distribution specific configuration files
8157
# that contain the timezone name.
8258
tzpath = os.path.join(_root, 'etc/timezone')

0 commit comments

Comments
 (0)