]> granicus.if.org Git - python/commit
Fix #9333. Expose os.symlink on Windows only when usable.
authorBrian Curtin <brian.curtin@gmail.com>
Thu, 2 Dec 2010 18:29:18 +0000 (18:29 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Thu, 2 Dec 2010 18:29:18 +0000 (18:29 +0000)
commit52173d4959a1c1e961efab2522e4ba8a22a3c7c6
treea89463de7c0db84aa60ef25bc05caf8837e2cc33
parent02524629f39bb70f4ea00ab8e64d694e08719227
Fix #9333. Expose os.symlink on Windows only when usable.

In order to create symlinks on Windows, SeCreateSymbolicLinkPrivilege
is an account privilege that is required to be held by the user. Not only
must the privilege be enabled for the account, the activated privileges for
the currently running application must be adjusted to enable the requested
privilege.

Rather than exposing an additional function to be called prior to the user's
first os.symlink call, we handle the AdjustTokenPrivileges Windows API call
internally and only expose os.symlink when the privilege escalation was
successful.

Due to the change of only exposing os.symlink when it's available, we can
go back to the original test skipping methods of checking via `hasattr`.
12 files changed:
Doc/library/os.rst
Lib/test/support.py
Lib/test/test_glob.py
Lib/test/test_httpservers.py
Lib/test/test_os.py
Lib/test/test_platform.py
Lib/test/test_posixpath.py
Lib/test/test_shutil.py
Lib/test/test_sysconfig.py
Lib/test/test_tarfile.py
Misc/NEWS
Modules/posixmodule.c