1. 21 1月, 2010 23 次提交
    • D
      Fix security driver calls in hotplug cleanup paths · 2df16576
      Daniel P. Berrange 提交于
      The hotplug code was not correctly invoking the security driver
      in error paths. If a hotplug attempt failed, the device would
      be left with VM permissions applied, rather than restored to the
      original permissions. Also, a CDROM media that is ejected was
      not restored to original permissions. Finally there was a bogus
      call to set hostdev permissions in the hostdev unplug code
      
      * qemu/qemu_driver.c: Fix security driver usage in hotplug/unplug
      2df16576
    • D
      Add missing call to re-attach host devices if VM startup fails · b2a2ba71
      Daniel P. Berrange 提交于
      If there is a problem with VM startup, PCI devices may be left
      assigned to pci-stub / pci-back. Adding a call to reattach
      host devices in the cleanup path is required.
      
      * qemu/qemu_driver.c: qemuDomainReAttachHostDevices() when
        VM startup fails
      b2a2ba71
    • D
      Switch QEMU driver over to use the DAC security driver · 3812c7b4
      Daniel P. Berrange 提交于
      Remove all the QEMU driver calls for setting file ownership and
      process uid/gid. Instead wire in the QEMU DAC security driver,
      stacking it ontop of the primary SELinux/AppArmour driver.
      
      * qemu/qemu_driver.c: Switch over to new DAC security driver
      3812c7b4
    • D
      Introduce a new DAC security driver for QEMU · 15f5eaa0
      Daniel P. Berrange 提交于
      This new security driver is responsible for managing UID/GID changes
      to the QEMU process, and any files/disks/devices assigned to it.
      
      * qemu/qemu_conf.h: Add flag for disabling automatic file permission
        changes
      * qemu/qemu_security_dac.h, qemu/qemu_security_dac.c: New DAC driver
        for QEMU guests
      * Makefile.am: Add new files
      15f5eaa0
    • D
      Introduce a stacked security driver impl for QEMU · 80fd73ca
      Daniel P. Berrange 提交于
      * qemu/qemu_conf.h: Add securityPrimaryDriver and
        securitySecondaryDriver fields to 'struct qemud_driver'
      * Makefile.am: Add new files
      * qemu/qemu_security_stacked.c, qemu/qemu_security_stacked.h: A
        simple stacked security driver
      80fd73ca
    • D
      Pull initial disk labelling out into libvirtd instead of exec hook · 08fd20b0
      Daniel P. Berrange 提交于
      Pulling the disk labelling code out of the exec hook, and into
      libvirtd will allow it to access shared state in the daemon. It
      will also make debugging & error reporting easier / more reliable.
      
      * qemu/qemu_driver.c: Move initial disk labelling calls up into
        libvirtd. Add cleanup of disk labels upon failure
      08fd20b0
    • D
      Fix leak of allocated security label · 9c48360b
      Daniel P. Berrange 提交于
      If a VM fails to start, we can't simply free the security label
      strings, we must call the domainReleaseSecurityLabel() method
      otherwise the reserved 'mcs' level will be leaked in SElinux
      
      * src/qemu/qemu_driver.c: Invoke domainReleaseSecurityLabel()
        when domain fails to start
      9c48360b
    • D
      Refactor setup & cleanup of security labels in security driver · 0c0e0d02
      Daniel P. Berrange 提交于
      The current security driver architecture has the following
      split of logic
      
       * domainGenSecurityLabel
      
          Allocate the unique label for the domain about to be started
      
       * domainGetSecurityLabel
      
          Retrieve the current live security label for a process
      
       * domainSetSecurityLabel
      
          Apply the previously allocated label to the current process
          Setup all disk image / device labelling
      
       * domainRestoreSecurityLabel
      
          Restore the original disk image / device labelling.
          Release the unique label for the domain
      
      The 'domainSetSecurityLabel' method is special because it runs
      in the context of the child process between the fork + exec.
      
      This is require in order to set the process label. It is not
      required in order to label disks/devices though. Having the
      disk labelling code run in the child process limits what it
      can do.
      
      In particularly libvirtd would like to remember the current
      disk image label, and only change shared image labels for the
      first VM to start. This requires use & update of global state
      in the libvirtd daemon, and thus cannot run in the child
      process context.
      
      The solution is to split domainSetSecurityLabel into two parts,
      one applies process label, and the other handles disk image
      labelling. At the same time domainRestoreSecurityLabel is
      similarly split, just so that it matches the style. Thus the
      previous 4 methods are replaced by the following 6 new methods
      
       * domainGenSecurityLabel
      
          Allocate the unique label for the domain about to be started
          No actual change here.
      
       * domainReleaseSecurityLabel
      
         Release the unique label for the domain
      
       * domainGetSecurityProcessLabel
      
         Retrieve the current live security label for a process
         Merely renamed for clarity.
      
       * domainSetSecurityProcessLabel
      
         Apply the previously allocated label to the current process
      
       * domainRestoreSecurityAllLabel
      
          Restore the original disk image / device labelling.
      
       * domainSetSecurityAllLabel
      
          Setup all disk image / device labelling
      
      The SELinux and AppArmour drivers are then updated to comply with
      this new spec. Notice that the AppArmour driver was actually a
      little different. It was creating its profile for the disk image
      and device labels in the 'domainGenSecurityLabel' method, where as
      the SELinux driver did it in 'domainSetSecurityLabel'. With the
      new method split, we can have consistency, with both drivers doing
      that in the domainSetSecurityAllLabel method.
      
      NB, the AppArmour changes here haven't been compiled so may not
      build.
      0c0e0d02
    • D
      Make security drivers responsible for checking dynamic vs static labelling · 81fbb4cb
      Daniel P. Berrange 提交于
      The QEMU driver is doing 90% of the calls to check for static vs
      dynamic labelling. Except it is forgetting todo so in many places,
      in particular hotplug is mistakenly assigning disk labels. Move
      all this logic into the security drivers themselves, so the HV
      drivers don't have to think about it.
      
      * src/security/security_driver.h: Add virDomainObjPtr parameter
        to virSecurityDomainRestoreHostdevLabel and to
        virSecurityDomainRestoreSavedStateLabel
      * src/security/security_selinux.c, src/security/security_apparmor.c:
        Add explicit checks for VIR_DOMAIN_SECLABEL_STATIC and skip all
        chcon() code in those cases
      * src/qemu/qemu_driver.c: Remove all checks for VIR_DOMAIN_SECLABEL_STATIC
        or VIR_DOMAIN_SECLABEL_DYNAMIC. Add missing checks for possibly NULL
        driver entry points.
      81fbb4cb
    • D
      Implement support for multi IQN · 6aabcb5b
      David Allan 提交于
      Allows the initiator to use a variety of IQNs rather than just the
      system IQN when creating iSCSI pools.
      * docs/schemas/storagepool.rng: extends the syntax with <iqn name="..."/>
      * src/conf/storage_conf.[ch]: read and stores the iqn name
      * src/storage/storage_backend_iscsi.[ch]: implement the IQN selection
        when detected
      6aabcb5b
    • J
      Let make fail when XHTML validation fails · 39d883bb
      Jiri Denemark 提交于
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      39d883bb
    • L
      Fix uses of virFileMakePath · 623bc48a
      Laine Stump 提交于
      * src/lxc/lxc_container.c src/lxc/lxc_controller.c src/lxc/lxc_driver.c
        src/network/bridge_driver.c src/qemu/qemu_driver.c
        src/uml/uml_driver.c: virFileMakePath returns 0 for success, or the
        value of errno on failure, so error checking should be to test
        if non-zero, not if lower than 0
      623bc48a
    • L
      Create storage pool directories with proper uid/gid/mode · 62927dd8
      Laine Stump 提交于
      Previously the uid/gid/mode in the xml was ignored when creating new
      storage pool directories. This commit attempts to honor the requested
      permissions, and spits out an error if it can't.
      
      Note that when creating the directory, the rest of the path leading up
      to the final element is created using current uid/gid/mode, and the
      final element gets the settings from xml. It is NOT an error for the
      directory to already exist; in this case, the perms for the existing
      directory are just set (if necessary).
      
      * src/storage/storage_backend_fs.c: update the virStorageBackendFileSystemBuild
        function to check the directory hierarchy separately then create the
        leaf directory with the right attributes
      62927dd8
    • L
      Create storage volumes directly with desired uid/gid · e1f27784
      Laine Stump 提交于
      In order to avoid problems trying to chown files that were created by
      root on a root-squashing nfs server, fork a new process that setuid's
      to the desired uid before creating the file. (It's only done this way
      if the pool containing the new volume is of type 'netfs', otherwise
      the old method of creating the file followed by chown() is used.)
      
      This changes the semantics of the "create_func" slightly - previously
      it was assumed that this function just created the file, then the
      caller would chown it to the desired uid. Now, create_func does both
      operations.
      
      There are multiple functions that can take on the role of create_func:
      
      createFileDir - previously called mkdir(), now calls virDirCreate().
      virStorageBackendCreateRaw - previously called open(),
                                   now calls virFileCreate().
      virStorageBackendCreateQemuImg - use virRunWithHook() to setuid/gid.
      virStorageBackendCreateQcowCreate - same.
      virStorageBackendCreateBlockFrom - preserve old behavior (but attempt
                                         chown when necessary even if not root)
      
      * src/storage/storage_backend.[ch] src/storage/storage_backend_disk.c
        src/storage/storage_backend_fs.c src/storage/storage_backend_logical.c
        src/storage/storage_driver.c: change the create_func implementations,
        also propagate the pool information to be able to detect NETFS ones.
      e1f27784
    • L
      New utility functions virFileCreate and virDirCreate · 98f6f381
      Laine Stump 提交于
      These functions create a new file or directory with the given
      uid/gid. If the flag VIR_FILE_CREATE_AS_UID is given, they do this by
      forking a new process, calling setuid/setgid in the new process, and
      then creating the file. This is better than simply calling open then
      fchown, because in the latter case, a root-squashing nfs server would
      create the new file as user nobody, then refuse to allow fchown.
      
      If VIR_FILE_CREATE_AS_UID is not specified, the simpler tactic of
      creating the file/dir, then chowning is is used. This gives better
      results in cases where the parent directory isn't on a root-squashing
      NFS server, but doesn't give permission for the specified uid/gid to
      create files. (Note that if the fork/setuid method fails to create the
      file due to access privileges, the parent process will make a second
      attempt using this simpler method.)
      
      If the bit VIR_FILE_CREATE_ALLOW_EXIST is set in the flags, an
      existing file/directory will not cause an error; in this case, the
      function will simply set the permissions of the file/directory to
      those requested. If VIR_FILE_CREATE_ALLOW_EXIST is not specified, an
      existing file/directory is considered (and reported as) an error.
      
      Return from both of these functions is 0 on success, or the value of
      errno if there was a failure.
      
      * src/util/util.[ch]: add the 2 new util functions
      98f6f381
    • L
      Add virRunWithHook util function · d2259ada
      Laine Stump 提交于
      * src/util/util.[ch]: similar to virExecWithHook, but waits for child to
        exit. Useful for doing things like setuid after the fork but before the
        exec.
      d2259ada
    • M
      Unset copied environment variables in qemuxml2argvtest · 1671b647
      Matthias Bolte 提交于
      The test expected all environment variables copied in qemudBuildCommandLine
      to have known values. So all of them have to be either set to a known value
      or be unset. SDL_VIDEODRIVER and QEMU_AUDIO_DRV are not handled at all but
      should be handled. Unset both, otherwise the test will fail if they are set
      in the testing environment.
      
      * src/qemu/qemu_conf.c: add a comment about copied environment variables
        and qemuxml2argvtest
      * tests/qemuxml2argvtest.c: unset SDL_VIDEODRIVER and QEMU_AUDIO_DRV
      1671b647
    • M
      qemu: Don't allocate zero bytes · aef96949
      Matthias Bolte 提交于
      aef96949
    • J
      clean-up: remove unnecessary closedir call · 21c84e00
      Jim Meyering 提交于
      * src/node_device/node_device_linux_sysfs.c (get_virtual_functions_linux):
      Remove unnecessary closedir.  Spotted by Dave Allan.
      21c84e00
    • J
      node_device_linux_sysfs.c: avoid opendir/fd leak on error path · 2355fce3
      Jim Meyering 提交于
      * src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux):
      Don't leak a DIR buffer and file descriptor on error path.
      2355fce3
    • J
      domain_conf.c: avoid a leak and the need for "cleanup:" block · 1825c655
      Jim Meyering 提交于
      * src/conf/domain_conf.c (virDomainChrDefFormat): Plug a leak on
      an error path, and at the same time, eliminate the need for a
      "cleanup:" block.  Before, the "return -1" after the switch
      would leak an "addr" string.  Now, by reversing the port,addr-
      getting blocks we can free "addr" immediately and skip the goto.
      1825c655
    • D
      Make all bitfields unsigned ints to avoid unexpected values in casts · 50b6c95d
      Daniel P. Berrange 提交于
      The 'int virInterfaceIsActive()' method was directly returning the
      value of the 'int active:1' bitfield in virIntefaceDefPtr. A bitfield
      with a signed integer, will hold the values 0 and -1, not 0 and +1
      as might be expected. This meant that virInterfaceIsActive() was
      always returning -1 when the interface was active, not +1 & thus all
      callers thought an error had occurred. To protect against this kind
      of mistake again, change all bitfields to be unsigned ints
      
      * daemon/libvirtd.h, src/conf/domain_conf.h, src/conf/interface_conf.h,
        src/conf/network_conf.h: Change bitfields to unsigned int.
      50b6c95d
    • D
      Fix QEMU driver custom domain status XML extensions · ed00e45d
      Daniel P. Berrange 提交于
      Invoking the virConnectGetCapabilities() method causes the QEMU
      driver to rebuild its internal capabilities object. Unfortunately
      it was forgetting to register the custom domain status XML hooks
      again.
      
      To avoid this kind of error in the future, the code which builds
      capabilities is refactored into one single method, which can be
      called from all locations, ensuring reliable rebuilds.
      
      * src/qemu/qemu_driver.c: Fix rebuilding of capabilities XML and
        guarentee it is always consistent
      ed00e45d
  2. 20 1月, 2010 13 次提交
  3. 19 1月, 2010 4 次提交