1. 12 10月, 2012 1 次提交
    • M
      selinux: Use raw contexts · 9674f2c6
      Martin Kletzander 提交于
      We are currently able to work only with non-translated SELinux
      contexts, but we are using functions that work with translated
      contexts throughout the code.  This patch swaps all SELinux context
      translation relative calls with their raw sisters to avoid parsing
      problems.
      
      The problems can be experienced with mcstrans for example.  The
      difference is that if you have translations enabled (yum install
      mcstrans; service mcstrans start), fgetfilecon_raw() will get you
      something like 'system_u:object_r:virt_image_t:s0', whereas
      fgetfilecon() will return 'system_u:object_r:virt_image_t:SystemLow'
      that we cannot parse.
      
      I was trying to confirm that the _raw variants were here since the dawn of
      time, but the only thing I see now is that it was imported together in
      the upstream repo [1] from svn, so before 2008.
      
      Thanks Laurent Bigonville for finding this out.
      
      [1] http://oss.tresys.com/git/selinux.git
      9674f2c6
  2. 11 10月, 2012 1 次提交
  3. 21 9月, 2012 2 次提交
  4. 21 8月, 2012 5 次提交
  5. 14 8月, 2012 3 次提交
  6. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  7. 21 7月, 2012 3 次提交
  8. 20 7月, 2012 1 次提交
  9. 24 5月, 2012 1 次提交
  10. 16 5月, 2012 5 次提交
  11. 27 3月, 2012 1 次提交
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  12. 04 2月, 2012 1 次提交
    • L
      qemu: eliminate "Ignoring open failure" when using root-squash NFS · c18a88ac
      Laine Stump 提交于
      This eliminates the warning message reported in:
      
       https://bugzilla.redhat.com/show_bug.cgi?id=624447
      
      It was caused by a failure to open an image file that is not
      accessible by root (the uid libvirtd is running as) because it's on a
      root-squash NFS share, owned by a different user, with permissions of
      660 (or maybe 600).
      
      The solution is to use virFileOpenAs() rather than open(). The
      codepath that generates the error is during qemuSetupDiskCGroup(), but
      the actual open() is in a lower-level generic function called from
      many places (virDomainDiskDefForeachPath), so some other pieces of the
      code were touched just to add dummy (or possibly useful) uid and gid
      arguments.
      
      Eliminating this warning message has the nice side effect that the
      requested operation may even succeed (which in this case isn't
      necessary, but shouldn't hurt anything either).
      c18a88ac
  13. 03 2月, 2012 1 次提交
    • D
      Add two new security label types · b170eb99
      Daniel P. Berrange 提交于
      Curently security labels can be of type 'dynamic' or 'static'.
      If no security label is given, then 'dynamic' is assumed. The
      current code takes advantage of this default, and avoids even
      saving <seclabel> elements with type='dynamic' to disk. This
      means if you temporarily change security driver, the guests
      can all still start.
      
      With the introduction of sVirt to LXC though, there needs to be
      a new default of 'none' to allow unconfined LXC containers.
      
      This patch introduces two new security label types
      
       - default:  the host configuration decides whether to run the
                   guest with type 'none' or 'dynamic' at guest start
       - none:     the guest will run unconfined by security policy
      
      The 'none' label type will obviously be undesirable for some
      deployments, so a new qemu.conf option allows a host admin to
      mandate confined guests. It is also possible to turn off default
      confinement
      
        security_default_confined = 1|0  (default == 1)
        security_require_confined = 1|0  (default == 0)
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Add new
        seclabel types
      * src/security/security_manager.c, src/security/security_manager.h:
        Set default sec label types
      * src/security/security_selinux.c: Handle 'none' seclabel type
      * src/qemu/qemu.conf, src/qemu/qemu_conf.c, src/qemu/qemu_conf.h,
        src/qemu/libvirtd_qemu.aug: New security config options
      * src/qemu/qemu_driver.c: Tell security driver about default
        config
      b170eb99
  14. 26 1月, 2012 1 次提交
    • D
      Introduce new API for generating random numbers · e95ef67b
      Daniel P. Berrange 提交于
      The old virRandom() API was not generating good random numbers.
      Replace it with a new API virRandomBits which instead of being
      told the upper limit, gets told the number of bits of randomness
      required.
      
      * src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
        and move virRandomInitialize
      * src/util/util.h, src/util/util.c: Delete virRandom and
        virRandomInitialize
      * src/libvirt.c, src/security/security_selinux.c,
        src/test/test_driver.c, src/util/iohelper.c: Update for
        changes from virRandom to virRandomBits
      * src/storage/storage_backend_iscsi.c: Remove bogus call
        to virRandomInitialize & convert to virRandomBits
      e95ef67b
  15. 11 1月, 2012 1 次提交
    • D
      Change security driver APIs to use virDomainDefPtr instead of virDomainObjPtr · 99be754a
      Daniel P. Berrange 提交于
      When sVirt is integrated with the LXC driver, it will be neccessary
      to invoke the security driver APIs using only a virDomainDefPtr
      since the lxc_container.c code has no virDomainObjPtr available.
      Aside from two functions which want obj->pid, every bit of the
      security driver code only touches obj->def. So we don't need to
      pass a virDomainObjPtr into the security drivers, a virDomainDefPtr
      is sufficient. Two functions also gain a 'pid_t pid' argument.
      
      * src/qemu/qemu_driver.c, src/qemu/qemu_hotplug.c,
        src/qemu/qemu_migration.c, src/qemu/qemu_process.c,
        src/security/security_apparmor.c,
        src/security/security_dac.c,
        src/security/security_driver.h,
        src/security/security_manager.c,
        src/security/security_manager.h,
        src/security/security_nop.c,
        src/security/security_selinux.c,
        src/security/security_stack.c: Change all security APIs to use a
        virDomainDefPtr instead of virDomainObjPtr
      99be754a
  16. 30 12月, 2011 1 次提交
    • E
      seclabel: honor device override in selinux · 904e05a2
      Eric Blake 提交于
      This wires up the XML changes in the previous patch to let SELinux
      labeling honor user overrides, as well as affecting the live XML
      configuration in one case where the user didn't specify anything
      in the offline XML.
      
      I noticed that the logs contained messages like this:
      
      2011-12-05 23:32:40.382+0000: 26569: warning : SELinuxRestoreSecurityFileLabel:533 : cannot lookup default selinux label for /nfs/libvirt/images/dom.img
      
      for all my domain images living on NFS.  But if we would just remember
      that on domain creation that we were unable to set a SELinux label (due to
      NFSv3 lacking labels, or NFSv4 not being configured to expose attributes),
      then we could avoid wasting the time trying to clear the label on
      domain shutdown.  This in turn is one less point of NFS failure,
      especially since there have been documented cases of virDomainDestroy
      hanging during an attempted operation on a failed NFS connection.
      
      * src/security/security_selinux.c (SELinuxSetFilecon): Move guts...
      (SELinuxSetFileconHelper): ...to new function.
      (SELinuxSetFileconOptional): New function.
      (SELinuxSetSecurityFileLabel): Honor override label, and remember
      if labeling failed.
      (SELinuxRestoreSecurityImageLabelInt): Skip relabeling based on
      override.
      904e05a2
  17. 12 12月, 2011 1 次提交
  18. 03 11月, 2011 1 次提交
    • D
      Allow multiple consoles per virtual guest · 0873b688
      Daniel P. Berrange 提交于
      While Xen only has a single paravirt console, UML, and
      QEMU both support multiple paravirt consoles. The LXC
      driver can also be trivially made to support multiple
      consoles. This patch extends the XML to allow multiple
      <console> elements in the XML. It also makes the UML
      and QEMU drivers support this config.
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Allow
        multiple <console> devices
      * src/lxc/lxc_driver.c, src/xen/xen_driver.c,
        src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c: Update for
        internal API changes
      * src/security/security_selinux.c, src/security/virt-aa-helper.c:
        Only label consoles that aren't a copy of the serial device
      * src/qemu/qemu_command.c, src/qemu/qemu_driver.c,
        src/qemu/qemu_process.c, src/uml/uml_conf.c,
        src/uml/uml_driver.c: Support multiple console devices
      * tests/qemuxml2xmltest.c, tests/qemuxml2argvtest.c: Extra
        tests for multiple virtio consoles. Set QEMU_CAPS_CHARDEV
        for all console /channel tests
      * tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.args,
        tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
        tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args: Update
        for correct chardev syntax
      * tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.args,
        tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml: New
        test file
      0873b688
  19. 28 9月, 2011 1 次提交
    • L
      security: properly chown/label bidirectional and unidirectional fifos · 46e8dc71
      Laine Stump 提交于
      This patch fixes the regression with using named pipes for qemu serial
      devices noted in:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=740478
      
      The problem was that, while new code in libvirt looks for a single
      bidirectional fifo of the name given in the config, then relabels that
      and continues without looking for / relabelling the two unidirectional
      fifos named ${name}.in and ${name}.out, qemu looks in the opposite
      order. So if the user had naively created all three fifos, libvirt
      would relabel the bidirectional fifo to allow qemu access, but qemu
      would attempt to use the two unidirectional fifos and fail (because it
      didn't have proper permissions/rights).
      
      This patch changes the order that libvirt looks for the fifos to match
      what qemu does - first it looks for the dual fifos, then it looks for
      the single bidirectional fifo. If it finds the dual unidirectional
      fifos first, it labels/chowns them and ignores any possible
      bidirectional fifo.
      
      (Note commit d37c6a3a (which first appeared in libvirt-0.9.2) added
      the code that checked for a bidirectional fifo. Prior to that commit,
      bidirectional fifos for serial devices didn't work because libvirt
      always required the ${name}.(in|out) fifos to exist, and qemu would
      always prefer those.
      46e8dc71
  20. 23 9月, 2011 1 次提交
  21. 09 9月, 2011 1 次提交
  22. 31 8月, 2011 1 次提交
    • D
      Remove bogus virSecurityManagerSetProcessFDLabel method · 18338388
      Daniel P. Berrange 提交于
      The virSecurityManagerSetProcessFDLabel method was introduced
      after a mis-understanding from a conversation about SELinux
      socket labelling. The virSecurityManagerSetSocketLabel method
      should have been used for all such scenarios.
      
      * src/security/security_apparmor.c, src/security/security_apparmor.c,
        src/security/security_driver.h, src/security/security_manager.c,
        src/security/security_manager.h, src/security/security_selinux.c,
        src/security/security_stack.c: Remove SetProcessFDLabel driver
      18338388
  23. 26 8月, 2011 2 次提交
    • J
      security: Introduce SetSocketLabel · 520d91f8
      Jiri Denemark 提交于
      This API labels all sockets created until ClearSocketLabel is called in
      a way that a vm can access them (i.e., they are labeled with svirt_t
      based label in SELinux).
      520d91f8
    • J
      security: Rename SetSocketLabel APIs to SetDaemonSocketLabel · 4c85d96f
      Jiri Denemark 提交于
      The APIs are designed to label a socket in a way that the libvirt daemon
      itself is able to access it (i.e., in SELinux the label is virtd_t based
      as opposed to svirt_* we use for labeling resources that need to be
      accessed by a vm). The new name reflects this.
      4c85d96f
  24. 22 7月, 2011 1 次提交
    • E
      build: rename files.h to virfile.h · 8e22e089
      Eric Blake 提交于
      In preparation for a future patch adding new virFile APIs.
      
      * src/util/files.h, src/util/files.c: Move...
      * src/util/virfile.h, src/util/virfile.c: ...here, and rename
      functions to virFile prefix.  Macro names are intentionally
      left alone.
      * *.c: All '#include "files.h"' uses changed.
      * src/Makefile.am (UTIL_SOURCES): Reflect rename.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
      * src/libvirt_private.syms: Likewise.
      * docs/hacking.html.in: Likewise.
      * HACKING: Regenerate.
      8e22e089
  25. 06 7月, 2011 1 次提交
    • D
      Fix default value of security label 'relabel' attribute · 693eac38
      Daniel P. Berrange 提交于
      When no <seclabel> is present in the XML, the virDomainSeclabelDef
      struct is left as all zeros. Unfortunately, this means it gets setup
      as type=dynamic, with relabel=no, which is an illegal combination.
      
      Change the 'bool relabel' attribute in virDomainSeclabelDef to
      the inverse 'bool norelabel' so that the default initialization
      is sensible
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h,
        src/security/security_apparmor.c, src/security/security_selinux.c:
        Replace 'relabel' with 'norelabel'
      693eac38
  26. 04 7月, 2011 1 次提交
    • D
      Allow for resource relabelling with static labels · 6321fd97
      Daniel P. Berrange 提交于
      Add a new attribute to the <seclabel> XML to allow resource
      relabelling to be enabled with static label usage.
      
        <seclabel model='selinux' type='static' relabel='yes'>
          <label>system_u:system_r:svirt_t:s0:c392,c662</label>
        </seclabel>
      
      * docs/schemas/domain.rng: Add relabel attribute
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Parse
        the 'relabel' attribute
      * src/qemu/qemu_process.c: Unconditionally clear out the
        'imagelabel' attribute
      * src/security/security_apparmor.c: Skip based on 'relabel'
        attribute instead of label type
      * src/security/security_selinux.c: Skip based on 'relabel'
        attribute instead of label type and fill in <imagelabel>
        attribute if relabel is enabled.
      6321fd97