fails mysterious when runs as root (via sudo)
Bug #255674 reported by
Michael Vogt
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-vm-builder (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: ubuntu-vm-builder
If I run ubuntu-vm-builder in intrepid as root (via sudo in some form) it fails if the current directory is not writable for the $SUDO_USER
This is because of:
set +e
if [ -n "${SUDO_USER}" ]; then
sudo -u "${SUDO_USER}" mkdir "${DESTINATION}"
else
mkdir "${DESTINATION}"
fi
If it wants to be clever, then it could be clever about this case as well, so something like:
if [ -n "${SUDO_USER}" ]; then
if ! sudo -u "${SUDO_USER}" mkdir "${DESTINATION}"; then
mkdir "${DESTINATION}"
fi
else
mkdir "${DESTINATION}"
fi
is probably more appropriate.
u-v-b assumes that the user can create files in the local directory in two places: when creating the directory and changing the permissions on the resulting files.
While this is probably the case most of the time when run without '-d', in an enterprise environment the images may be stored in a folder with restricted permissions.