[libvirt] [PATCH v3 09/12] LXC: controller: change the owner of /dev to the root user of container

Daniel P. Berrange berrange at redhat.com
Tue Jun 4 13:50:01 UTC 2013


On Thu, May 23, 2013 at 12:06:53PM +0800, Gao feng wrote:
> container will create /dev/pts directory in /dev.
> the owner of /dev should be the root user of container.
> 
> Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
> ---
>  src/lxc/lxc_controller.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index 4660f25..f892ce3 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -1191,6 +1191,13 @@ virLXCControllerSetupDev(virLXCControllerPtr ctrl)
>      char *opts = NULL;
>      char *dev = NULL;
>      int ret = -1;
> +    uid_t uid = (uid_t)-1;
> +    gid_t gid = (gid_t)-1;
> +
> +    if (ctrl->def->idmap.uidmap) {
> +        uid = ctrl->def->idmap.uidmap[0].target;
> +        gid = ctrl->def->idmap.gidmap[0].target;
> +    }
>  
>      VIR_DEBUG("Setting up /dev/ for container");
>  
> @@ -1231,6 +1238,13 @@ virLXCControllerSetupDev(virLXCControllerPtr ctrl)
>          goto cleanup;
>      }
>  
> +    if (chown(dev, uid, gid) < 0) {
> +        virReportSystemError(errno,
> +                             _("Failed to change owner of %s to %d:%d"),
> +                             dev, uid, gid);
> +        goto cleanup;
> +    }
> +
>      ret = 0;
>  
>  cleanup:

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list