mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
qemuOpenFile: Don't force chown on NFS
If dynamic_ownership is off and we are creating a file on NFS we force chown. This will fail as chown/chmod are not supported on NFS. However, with no dynamic_ownership we are not required to do any chown.
This commit is contained in:
parent
d0eaf4b124
commit
b1256816ff
@ -2429,6 +2429,7 @@ qemuOpenFile(struct qemud_driver *driver, const char *path, int oflags,
|
|||||||
bool bypass_security = false;
|
bool bypass_security = false;
|
||||||
unsigned int vfoflags = 0;
|
unsigned int vfoflags = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
int path_shared = virStorageFileIsSharedFS(path);
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
gid_t gid = getgid();
|
gid_t gid = getgid();
|
||||||
|
|
||||||
@ -2437,7 +2438,12 @@ qemuOpenFile(struct qemud_driver *driver, const char *path, int oflags,
|
|||||||
* in the failure case */
|
* in the failure case */
|
||||||
if (oflags & O_CREAT) {
|
if (oflags & O_CREAT) {
|
||||||
need_unlink = true;
|
need_unlink = true;
|
||||||
|
|
||||||
|
/* Don't force chown on network-shared FS
|
||||||
|
* as it is likely to fail. */
|
||||||
|
if (path_shared <= 0 || driver->dynamicOwnership)
|
||||||
vfoflags |= VIR_FILE_OPEN_FORCE_OWNER;
|
vfoflags |= VIR_FILE_OPEN_FORCE_OWNER;
|
||||||
|
|
||||||
if (stat(path, &sb) == 0) {
|
if (stat(path, &sb) == 0) {
|
||||||
is_reg = !!S_ISREG(sb.st_mode);
|
is_reg = !!S_ISREG(sb.st_mode);
|
||||||
/* If the path is regular file which exists
|
/* If the path is regular file which exists
|
||||||
@ -2475,7 +2481,7 @@ qemuOpenFile(struct qemud_driver *driver, const char *path, int oflags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* On Linux we can also verify the FS-type of the directory. */
|
/* On Linux we can also verify the FS-type of the directory. */
|
||||||
switch (virStorageFileIsSharedFS(path)) {
|
switch (path_shared) {
|
||||||
case 1:
|
case 1:
|
||||||
/* it was on a network share, so we'll continue
|
/* it was on a network share, so we'll continue
|
||||||
* as outlined above
|
* as outlined above
|
||||||
|
Loading…
x
Reference in New Issue
Block a user