[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v3 11/12] LXC: controller: change the owner of /dev/pts and ptmx to the root of container



On Thu, May 23, 2013 at 12:06:55PM +0800, Gao feng wrote:
> This two files are created for container,
> the owner should be the root user of container.
> 
> Signed-off-by: Gao feng <gaofeng cn fujitsu com>
> ---
>  src/lxc/lxc_controller.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index b2ace20..7d27135 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -1506,8 +1506,15 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
>      char *opts = NULL;
>      char *devpts = NULL;
>      char *path = NULL;
> +    uid_t uid = (uid_t)-1;
> +    gid_t gid = (gid_t)-1;
>      int ret = -1;
>  
> +    if (ctrl->def->idmap.uidmap) {
> +        uid = ctrl->def->idmap.uidmap[0].target;
> +        gid = ctrl->def->idmap.gidmap[0].target;
> +    }
> +
>      VIR_DEBUG("Setting up private /dev/pts");
>  
>      mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager,
> @@ -1551,6 +1558,21 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
>          goto cleanup;
>      }
>  
> +    if (chown(ctrl->devptmx, uid, gid) < 0) {
> +        virReportSystemError(errno,
> +                             _("Failed to change the owner of"
> +                            "%s to %u:%u"),
> +                             path, uid, gid);
> +        goto cleanup;
> +    }
> +    if (chown(devpts, uid, gid) < 0) {
> +        virReportSystemError(errno,
> +                             _("Failed to change the owner of"
> +                             "%s to %u:%u"),
> +                             devpts, uid, gid);
> +        goto cleanup;
> +    }
> +
>      if (access(ctrl->devptmx, W_OK) < 0) {
>          if (virAsprintf(&path, "/%s/%s.dev/ptmx",
>                          LXC_STATE_DIR, ctrl->def->name)) {
> @@ -1564,8 +1586,16 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
>              virReportSystemError(errno,  _("Failed to make device %s"), path);
>              goto cleanup;
>          }
> +        if (chown(path, uid, gid) < 0) {
> +            virReportSystemError(errno,
> +                                 _("Failed to change the owner of"
> +                                 "%s to %u:%u"),
> +                                 path, uid, gid);
> +            goto 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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]