fails mysterious when runs as root (via sudo)

Bug #255674 reported by Michael Vogt
8
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.

Michael Vogt (mvo)
description: updated
Revision history for this message
Bryan McLellan (btm) wrote :

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.

Changed in ubuntu-vm-builder:
status: New → Confirmed
Revision history for this message
Bryan McLellan (btm) wrote :

@ Michael Vogt

> fails mysterious when runs as root (via sudo)

My failures were not mysterious though. They clearly printed the error: "Error creating directory ${DESTINATION}. Unable to proceed."

Can you confirm that you do get this error, and the reason for it being a mysterious error was that you expected to have the proper permissions since you were running u-v-b through sudo?

Revision history for this message
Michael Vogt (mvo) wrote :

I guess I should have clarified this a bit more, I found it mysterious in the sense that I ran the command with "sudo". So a error that a directory can not be created was a bit of a suprise.

Revision history for this message
MarianoAbsatz (el-baby) wrote :

Not counting the mysteriousness, I can confirm that I can't create a virtual machine on a root owned directory by doing the following:

sudo ubuntu-vm-builder kvm hardy --dest /var/kvm/my_vm01

I'd expect to be able to do this... or do I have to create a non-root user to be the owner of the VMs?

Revision history for this message
Nick Barcet (nijaba) wrote : Re: [Bug 255674] Re: fails mysterious when runs as root (via sudo)

MarianoAbsatz wrote:
> Not counting the mysteriousness, I can confirm that I can't create a
> virtual machine on a root owned directory by doing the following:
>
> sudo ubuntu-vm-builder kvm hardy --dest /var/kvm/my_vm01
>
> I'd expect to be able to do this... or do I have to create a non-root
> user to be the owner of the VMs?

No, you just need to give write capabilities to the for the enclosing
folder to the user you are creating it from, as it makes full sense for
the user creating the vm to be able to access it. Nothing prevents you
to use "sudo su" to start with so that the user that creates the vm is
effectively root.

  status invalid

Changed in ubuntu-vm-builder:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.