Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Issue 2949253002: Try 'sudo chmod' in make_tree_deleteable() as last effort (Closed)

Created:
3 years, 6 months ago by M-A Ruel
Modified:
3 years, 6 months ago
Reviewers:
Vadim Sh.
CC:
chromium-reviews, infra-reviews+luci-py_chromium.org, dgarrett, dnj
Target Ref:
refs/heads/master
Project:
luci-py
Visibility:
Public.

Description

Try 'sudo chmod' in make_tree_deleteable() as last effort - Some tasks on Swarming may create root owned files on passwordless sudoer account. This CL makes rmtree() try running 'sudo chmod' on linux in case the current account happens to be passwordless sudoer. If it fails once, do not try again. - Make rmtree() usable even if fix_encoding() wasn't called so the test case above can be used. Because correctly testing this code requires passwordless sudo, it has to be manually tested. The 3 manual test cases to confirm the code works as expected: 1) Verify make_tree_deleteable() works with passwordless sudo: mkdir -p x/y && sudo chown -R root:root x && sudo chmod -R a-rwX x sudo ls -la x x/y python -c 'import os; from utils import file_path; \ file_path.make_tree_deleteable(os.path.abspath(u"x"))' ls -la x x/y rm -rf x Expected: x and x/y are fully deletable without sudo in the last rm -rf. 2) Verify rmtree() works with passwordless sudo: mkdir -p x/y && sudo chown -R root:root x && sudo chmod -R a-rwX x sudo ls -la x x/y python -c 'import os; from utils import file_path; \ file_path.rmtree(os.path.abspath(u"x"))' ls -la x Expected: x and x/y were removed A logging warning was printed 3) Verify that a sudo password prompt fails the rmtree(): mkdir -p x/y && sudo chown -R root:root x && sudo chmod -R a-rwX x sudo ls -la x x/y sudo -K python -c 'import os; from utils import file_path; \ file_path.rmtree(os.path.abspath(u"x"))' ls -la x Expected: removal failed R=vadimsh@chromium.org BUG=723809 Review-Url: https://codereview.chromium.org/2949253002 Committed: https://github.com/luci/luci-py/commit/274f6429d25c5243eb8043afff854f884b20cf18

Patch Set 1 : . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -4 lines) Patch
M client/utils/file_path.py View 5 chunks +28 lines, -4 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 19 (15 generated)
M-A Ruel
3 years, 6 months ago (2017-06-22 15:59:24 UTC) #12
Vadim Sh.
lgtm
3 years, 6 months ago (2017-06-22 17:03:06 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2949253002/60001
3 years, 6 months ago (2017-06-22 17:19:38 UTC) #16
commit-bot: I haz the power
3 years, 6 months ago (2017-06-22 17:22:33 UTC) #19
Message was sent while issue was closed.
Committed patchset #1 (id:60001) as
https://github.com/luci/luci-py/commit/274f6429d25c5243eb8043afff854f884b20cf18

Powered by Google App Engine
This is Rietveld 408576698