Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Laine Stump 90e4d681bc util: refactor virFileOpenAs
virFileOpenAs previously would only try opening a file as the current
user, or as a different user, but wouldn't try both methods in a
single call. This made it cumbersome to use as a replacement for
open(2). Additionally, it had a lot of historical baggage that led to
it being difficult to understand.

This patch refactors virFileOpenAs in the following ways:

* reorganize the code so that everything dealing with both the parent
  and child sides of the "fork+setuid+setgid+open" method are in a
  separate function. This makes the public function easier to understand.

* Allow a single call to virFileOpenAs() to first attempt the open as
  the current user, and if that fails to automatically re-try after
  doing fork+setuid (if deemed appropriate, i.e. errno indicates it
  would now be successful, and the file is on a networkFS). This makes
  it possible (in many, but possibly not all, cases) to drop-in
  virFileOpenAs() as a replacement for open(2).

  (NB: currently qemuOpenFile() calls virFileOpenAs() twice, once
  without forking, then again with forking. That unfortunately can't
  be changed without at least some discussion of the ramifications,
  because the requested file permissions are different in each case,
  which is something that a single call to virFileOpenAs() can't deal
  with.)

* Add a flag so that any fchown() of the file to a different uid:gid
  is explicitly requested when the function is called, rather than it
  being implied by the presence of the O_CREAT flag. This just makes
  for less subtle surprises to consumers. (Commit
  b1643dc15c added the check for O_CREAT
  before forcing ownership. This patch just makes that restriction
  more explicit.)

* If either the uid or gid is specified as "-1", virFileOpenAs will
  interpret this to mean "the current [gu]id".

All current consumers of virFileOpenAs should retain their present
behavior (after a few minor changes to their setup code and
arguments).
2012-02-03 16:47:39 -05:00
.gnulib@e9e8aba12a Update gnulib to fix mingw64 compilation errors 2012-02-01 17:37:45 -07:00
daemon build: clean up CPPFLAGS/INCLUDES usage 2012-02-03 10:36:02 -07:00
docs virterror.c: Fix several spelling mistakes 2012-02-03 11:32:51 -07:00
examples build: clean up CPPFLAGS/INCLUDES usage 2012-02-03 10:36:02 -07:00
gnulib build: update to latest gnulib 2012-01-12 15:47:54 -07:00
include qemu: new GRACEFUL flag for virDomainDestroy w/ QEMU support 2012-02-03 14:21:17 -05:00
m4 build: silence some compiler warnings from gnulib 2012-01-19 13:14:10 -07:00
po util: rename netlink.[ch] to virnetlink.[ch] 2012-02-03 15:27:40 -05:00
python Added missing memory reporting into python bindings 2012-02-03 10:48:32 -07:00
src util: refactor virFileOpenAs 2012-02-03 16:47:39 -05:00
tests build: expand rule to cover testsuite 2012-02-03 10:41:46 -07:00
tools virsh: add --graceful switch to destroy command 2012-02-03 14:50:14 -05:00
.dir-locals.el maint: let emacs avoid tabs in rng files 2011-08-13 08:56:26 -06:00
.gitignore build: fix missing include 2012-01-27 11:18:35 -07:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap maint: prune duplicate listings in AUTHORS 2012-02-03 09:56:45 -07:00
AUTHORS maint: prune duplicate listings in AUTHORS 2012-02-03 09:56:45 -07:00
autobuild.sh Disable python explicitly in mingw32 autobuild 2011-12-19 13:44:18 +00:00
autogen.sh build: allow for local gnulib diffs 2011-11-09 09:03:33 -07:00
bootstrap Update gnulib to fix mingw64 compilation errors 2012-02-01 17:37:45 -07:00
bootstrap.conf Replace hashing algorithm with murmurhash 2012-01-26 14:18:53 +00:00
cfg.mk python: use libvirt_util to avoid raw free 2012-02-03 10:41:47 -07:00
ChangeLog-old virterror.c: Fix several spelling mistakes 2012-02-03 11:32:51 -07:00
configure.ac storage: Support different wiping algorithms 2012-01-26 13:59:30 +01:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING Document STREQ_NULLABLE and STRNEQ_NULLABLE 2011-10-06 16:50:38 +02:00
libvirt.pc.in * libvirt.pc.in: applied patch from Daniel Berrange to fix --cflags 2006-03-24 13:18:12 +00:00
libvirt.spec.in Add a virt-host-validate command to sanity check HV config 2012-01-27 17:53:18 +00:00
Makefile.am maint: add missing copyright notices 2011-07-28 15:01:17 -06:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw32-libvirt.spec.in Add virt-host-validate.1 to Mingw32 RPM spec file list 2012-01-30 12:03:30 +00:00
README Correct typos in the documentation (Atsushi SAKAI) 2008-01-24 10:15:13 +00:00
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>