• D
    tools: split virt-login-shell into two binaries · 4feeb2d9
    Daniel P. Berrangé 提交于
    The virt-login-shell binary is a setuid program that takes
    no arguments. When invoked it looks at the invoking uid,
    resolves it to a username, and finds an LXC guest with the
    same name. It then starts the guest and runs the shell in
    side the namespaces of the container.
    
    Given this set of tasks the virt-login-shell binary needs
    to connect to libvirtd, make various other libvirt API calls.
    This is a problem for setuid binaries as various libraries
    that libvirt.so links to are not safe. For example, they have
    constructor functions which execute an unknown amount of code
    that can be influenced by env variables.
    
    For this reason virt-login-shell doesn't use libvirt.so,
    but instead links to a custom, cut down, set of source files
    sufficient to be a local client only.
    
    This introduces a problem for integrating glib2 into libvirt
    though, as once integrated, there would be no way to build
    virt-login-shell without an external dependancy on glib2 and
    this is definitely not setuid safe.
    
    To resolve this problem, we split the virt-login-shell binary
    into two parts. The first part is setuid and does almost
    nothing. It simply records the original uid+gid, and then
    invokes the virt-login-shell-helper binary. Crucially when
    it does this it completes scrubs all environment variables.
    It is thus safe for virt-login-shell-helper to link to the
    normal libvirt.so. Any things that constructor functions
    do cannot be influenced by user control env vars or cli
    args.
    Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
    Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
    4feeb2d9
.gitignore 3.9 KB