summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2022-10-31 12:47:23 +0200
committerAarni Koskela <akx@iki.fi>2022-10-31 13:24:28 +0200
commit03c8fae835c16d63fa5f4e3141074abb8bad3e83 (patch)
treec9ba1fb705051b355a336adb7f74108c21ad984c
parentc7d04e8cb7bd60ff305d8bc6df2ce8a3f92c0223 (diff)
downloadbabel-03c8fae835c16d63fa5f4e3141074abb8bad3e83.tar.gz
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).
-rw-r--r--babel/localtime/_unix.py24
1 files changed, 0 insertions, 24 deletions
diff --git a/babel/localtime/_unix.py b/babel/localtime/_unix.py
index 28b2533..3d1480e 100644
--- a/babel/localtime/_unix.py
+++ b/babel/localtime/_unix.py
@@ -1,10 +1,6 @@
import os
import re
-import sys
import pytz
-import subprocess
-
-_systemconfig_tz = re.compile(r'^Time Zone: (.*)$', re.MULTILINE)
def _tz_from_env(tzenv):
@@ -57,26 +53,6 @@ def _get_localzone(_root='/'):
except pytz.UnknownTimeZoneError:
pass
- # If we are on OS X now we are pretty sure that the rest of the
- # code will fail and just fall through until it hits the reading
- # of /etc/localtime and using it without name. At this point we
- # can invoke systemconfig which internally invokes ICU. ICU itself
- # does the same thing we do (readlink + compare file contents) but
- # since it knows where the zone files are that should be a bit
- # better than reimplementing the logic here.
- if sys.platform == 'darwin':
- c = subprocess.Popen(['systemsetup', '-gettimezone'],
- stdout=subprocess.PIPE)
- sys_result = c.communicate()[0]
- c.wait()
- tz_match = _systemconfig_tz.search(sys_result)
- if tz_match is not None:
- zone_name = tz_match.group(1)
- try:
- return pytz.timezone(zone_name)
- except pytz.UnknownTimeZoneError:
- pass
-
# Now look for distribution specific configuration files
# that contain the timezone name.
tzpath = os.path.join(_root, 'etc/timezone')