• 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
storage_driver.c 51.9 KB