enter_chroot: try to avoid sudo when deleting sync pid file

The sync pid file is created without using sudo which means we should be
able to delete it without using sudo.  By default, run `rm` directly and
if it fails, fall back to sudo like we historically have.

BUG=None
TEST=`cros_sdk --enter true`; see pid file deleted

Change-Id: I26d898f6d594eb9ea4652335468345dd11303122
Reviewed-on: http://gerrit.chromium.org/gerrit/8644
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Mike Frysinger 2011-09-28 11:53:56 -04:00 committed by Gerrit
parent 0c80dfb97d
commit 470be99f4f

View File

@ -418,8 +418,9 @@ function teardown_env {
# starting the syncer process when this occurs by deleting the
# PID file.
kill $(<"${SYNCERPIDFILE}") && \
sudo rm -f "${SYNCERPIDFILE}" || \
debug "Unable to clean up syncer process.";
{ rm -f "${SYNCERPIDFILE}" 2>/dev/null || \
sudo rm -f "${SYNCERPIDFILE}" ; } ||
debug "Unable to clean up syncer process.";
debug "Unmounting chroot environment."
safe_umount_tree "${MOUNTED_PATH}/"