mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-09-28 09:45:00 +03:00
Compare commits
9 Commits
v6.8.0
...
v1.2.19-ma
Author | SHA1 | Date | |
---|---|---|---|
|
7d3b95b038 | ||
|
4e16e7a3fc | ||
|
38d5c57b9a | ||
|
69548d2004 | ||
|
10d659cc9b | ||
|
3606f62fab | ||
|
e0025d2967 | ||
|
8b1d84e640 | ||
|
3468542f06 |
@@ -1077,9 +1077,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
|
|||||||
* previously by virDomainSave() or virDomainSaveFlags().
|
* previously by virDomainSave() or virDomainSaveFlags().
|
||||||
*
|
*
|
||||||
* No security-sensitive data will be included unless @flags contains
|
* No security-sensitive data will be included unless @flags contains
|
||||||
* VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
|
* VIR_DOMAIN_XML_SECURE.
|
||||||
* connections. For this API, @flags should not contain either
|
|
||||||
* VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU.
|
|
||||||
*
|
*
|
||||||
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
|
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
|
||||||
* error. The caller must free() the returned value.
|
* error. The caller must free() the returned value.
|
||||||
@@ -1095,12 +1093,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
|
|||||||
|
|
||||||
virCheckConnectReturn(conn, NULL);
|
virCheckConnectReturn(conn, NULL);
|
||||||
virCheckNonNullArgGoto(file, error);
|
virCheckNonNullArgGoto(file, error);
|
||||||
|
virCheckReadOnlyGoto(conn->flags, error);
|
||||||
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
||||||
_("virDomainSaveImageGetXMLDesc with secure flag"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn->driver->domainSaveImageGetXMLDesc) {
|
if (conn->driver->domainSaveImageGetXMLDesc) {
|
||||||
char *ret;
|
char *ret;
|
||||||
@@ -11124,6 +11117,7 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|||||||
virResetLastError();
|
virResetLastError();
|
||||||
|
|
||||||
virCheckConnectReturn(conn, NULL);
|
virCheckConnectReturn(conn, NULL);
|
||||||
|
virCheckReadOnlyGoto(conn->flags, error);
|
||||||
|
|
||||||
if (conn->driver->connectGetDomainCapabilities) {
|
if (conn->driver->connectGetDomainCapabilities) {
|
||||||
char *ret;
|
char *ret;
|
||||||
|
@@ -1462,6 +1462,7 @@ virFileSanitizePath;
|
|||||||
virFileSkipRoot;
|
virFileSkipRoot;
|
||||||
virFileStripSuffix;
|
virFileStripSuffix;
|
||||||
virFileTouch;
|
virFileTouch;
|
||||||
|
virFileUnlink;
|
||||||
virFileUnlock;
|
virFileUnlock;
|
||||||
virFileUpdatePerm;
|
virFileUpdatePerm;
|
||||||
virFileWaitForDevices;
|
virFileWaitForDevices;
|
||||||
|
@@ -6878,7 +6878,7 @@ qemuDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *path,
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainSaveImageGetXMLDescEnsureACL(conn, def, flags) < 0)
|
if (virDomainSaveImageGetXMLDescEnsureACL(conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = qemuDomainDefFormatXML(driver, def, flags);
|
ret = qemuDomainDefFormatXML(driver, def, flags);
|
||||||
|
@@ -4028,6 +4028,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
char expire_time [64];
|
char expire_time [64];
|
||||||
const char *connected = NULL;
|
const char *connected = NULL;
|
||||||
|
const char *password;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
@@ -4035,16 +4036,14 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
password = auth->passwd ? auth->passwd : defaultPasswd;
|
||||||
|
|
||||||
if (auth->connected)
|
if (auth->connected)
|
||||||
connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
ret = qemuMonitorSetPassword(priv->mon,
|
ret = qemuMonitorSetPassword(priv->mon, type, password, connected);
|
||||||
type,
|
|
||||||
auth->passwd ? auth->passwd : defaultPasswd,
|
|
||||||
connected);
|
|
||||||
|
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
if (type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
||||||
@@ -4052,14 +4051,15 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
_("Graphics password only supported for VNC"));
|
_("Graphics password only supported for VNC"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
ret = qemuMonitorSetVNCPassword(priv->mon,
|
ret = qemuMonitorSetVNCPassword(priv->mon, password);
|
||||||
auth->passwd ? auth->passwd : defaultPasswd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto end_job;
|
goto end_job;
|
||||||
|
|
||||||
if (auth->expires) {
|
if (password[0] == '\0') {
|
||||||
|
snprintf(expire_time, sizeof(expire_time), "now");
|
||||||
|
} else if (auth->expires) {
|
||||||
time_t lifetime = auth->validTo - now;
|
time_t lifetime = auth->validTo - now;
|
||||||
if (lifetime <= 0)
|
if (lifetime <= 0)
|
||||||
snprintf(expire_time, sizeof(expire_time), "now");
|
snprintf(expire_time, sizeof(expire_time), "now");
|
||||||
|
@@ -546,10 +546,6 @@ remoteClientCloseFunc(virNetClientPtr client ATTRIBUTE_UNUSED,
|
|||||||
cbdata->freeCallback = NULL;
|
cbdata->freeCallback = NULL;
|
||||||
}
|
}
|
||||||
virObjectUnlock(cbdata);
|
virObjectUnlock(cbdata);
|
||||||
|
|
||||||
/* free the connection reference that comes along with the callback
|
|
||||||
* registration */
|
|
||||||
virObjectUnref(cbdata->conn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helper macro to ease extraction of arguments from the URI */
|
/* helper macro to ease extraction of arguments from the URI */
|
||||||
|
@@ -4907,8 +4907,7 @@ enum remote_procedure {
|
|||||||
/**
|
/**
|
||||||
* @generate: both
|
* @generate: both
|
||||||
* @priority: high
|
* @priority: high
|
||||||
* @acl: domain:read
|
* @acl: domain:write
|
||||||
* @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
|
|
||||||
*/
|
*/
|
||||||
REMOTE_PROC_DOMAIN_SAVE_IMAGE_GET_XML_DESC = 235,
|
REMOTE_PROC_DOMAIN_SAVE_IMAGE_GET_XML_DESC = 235,
|
||||||
|
|
||||||
|
@@ -486,6 +486,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
int operation_flags;
|
int operation_flags;
|
||||||
bool reflink_copy = false;
|
bool reflink_copy = false;
|
||||||
|
mode_t open_mode = VIR_STORAGE_DEFAULT_VOL_PERM_MODE;
|
||||||
|
|
||||||
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
|
||||||
VIR_STORAGE_VOL_CREATE_REFLINK,
|
VIR_STORAGE_VOL_CREATE_REFLINK,
|
||||||
@@ -518,11 +519,12 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (pool->def->type == VIR_STORAGE_POOL_NETFS)
|
if (pool->def->type == VIR_STORAGE_POOL_NETFS)
|
||||||
operation_flags |= VIR_FILE_OPEN_FORK;
|
operation_flags |= VIR_FILE_OPEN_FORK;
|
||||||
|
|
||||||
|
if (vol->target.perms->mode != (mode_t) -1)
|
||||||
|
open_mode = vol->target.perms->mode;
|
||||||
|
|
||||||
if ((fd = virFileOpenAs(vol->target.path,
|
if ((fd = virFileOpenAs(vol->target.path,
|
||||||
O_RDWR | O_CREAT | O_EXCL,
|
O_RDWR | O_CREAT | O_EXCL,
|
||||||
(vol->target.perms->mode ?
|
open_mode,
|
||||||
VIR_STORAGE_DEFAULT_VOL_PERM_MODE :
|
|
||||||
vol->target.perms->mode),
|
|
||||||
vol->target.perms->uid,
|
vol->target.perms->uid,
|
||||||
vol->target.perms->gid,
|
vol->target.perms->gid,
|
||||||
operation_flags)) < 0) {
|
operation_flags)) < 0) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_backend_fs.c: storage backend for FS and directory handling
|
* storage_backend_fs.c: storage backend for FS and directory handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2014 Red Hat, Inc.
|
* Copyright (C) 2007-2015 Red Hat, Inc.
|
||||||
* Copyright (C) 2007-2008 Daniel P. Berrange
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@@ -1057,6 +1057,14 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
else
|
else
|
||||||
vol->type = VIR_STORAGE_VOL_FILE;
|
vol->type = VIR_STORAGE_VOL_FILE;
|
||||||
|
|
||||||
|
/* Volumes within a directory pools are not recursive; do not
|
||||||
|
* allow escape to ../ or a subdir */
|
||||||
|
if (strchr(vol->name, '/')) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("volume name '%s' cannot contain '/'"), vol->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
VIR_FREE(vol->target.path);
|
VIR_FREE(vol->target.path);
|
||||||
if (virAsprintf(&vol->target.path, "%s/%s",
|
if (virAsprintf(&vol->target.path, "%s/%s",
|
||||||
pool->def->target.path,
|
pool->def->target.path,
|
||||||
@@ -1203,7 +1211,8 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
switch ((virStorageVolType) vol->type) {
|
switch ((virStorageVolType) vol->type) {
|
||||||
case VIR_STORAGE_VOL_FILE:
|
case VIR_STORAGE_VOL_FILE:
|
||||||
if (unlink(vol->target.path) < 0) {
|
if (virFileUnlink(vol->target.path, vol->target.perms->uid,
|
||||||
|
vol->target.perms->gid) < 0) {
|
||||||
/* Silently ignore failures where the vol has already gone away */
|
/* Silently ignore failures where the vol has already gone away */
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
|
@@ -1867,8 +1867,12 @@ storageVolCreateXML(virStoragePoolPtr obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (backend->refreshVol &&
|
if (backend->refreshVol &&
|
||||||
backend->refreshVol(obj->conn, pool, voldef) < 0)
|
backend->refreshVol(obj->conn, pool, voldef) < 0) {
|
||||||
|
storageVolDeleteInternal(volobj, backend, pool, voldef,
|
||||||
|
0, false);
|
||||||
|
voldef = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update pool metadata ignoring the disk backend since
|
/* Update pool metadata ignoring the disk backend since
|
||||||
* it updates the pool values.
|
* it updates the pool values.
|
||||||
|
@@ -2306,6 +2306,112 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* virFileUnlink:
|
||||||
|
* @path: file to unlink
|
||||||
|
* @uid: uid that was used to create the file (not required)
|
||||||
|
* @gid: gid that was used to create the file (not required)
|
||||||
|
*
|
||||||
|
* If a file/volume was created in an NFS root-squash environment,
|
||||||
|
* then we must 'unlink' the file in the same environment. Unlike
|
||||||
|
* the virFileOpenAs[Forked] and virDirCreate[NoFork], this code
|
||||||
|
* takes no extra flags and does not bother with EACCES failures
|
||||||
|
* from the child.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virFileUnlink(const char *path,
|
||||||
|
uid_t uid,
|
||||||
|
gid_t gid)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
int waitret;
|
||||||
|
int status, ret = 0;
|
||||||
|
gid_t *groups;
|
||||||
|
int ngroups;
|
||||||
|
|
||||||
|
/* If not running as root or if a non explicit uid/gid was being used for
|
||||||
|
* the file/volume, then use unlink directly
|
||||||
|
*/
|
||||||
|
if ((geteuid() != 0) ||
|
||||||
|
((uid == (uid_t) -1) && (gid == (gid_t) -1)))
|
||||||
|
return unlink(path);
|
||||||
|
|
||||||
|
/* Otherwise, we have to deal with the NFS root-squash craziness
|
||||||
|
* to run under the uid/gid that created the volume in order to
|
||||||
|
* perform the unlink of the volume.
|
||||||
|
*/
|
||||||
|
if (uid == (uid_t) -1)
|
||||||
|
uid = geteuid();
|
||||||
|
if (gid == (gid_t) -1)
|
||||||
|
gid = getegid();
|
||||||
|
|
||||||
|
ngroups = virGetGroupList(uid, gid, &groups);
|
||||||
|
if (ngroups < 0)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
pid = virFork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
ret = -errno;
|
||||||
|
VIR_FREE(groups);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid) { /* parent */
|
||||||
|
/* wait for child to complete, and retrieve its exit code */
|
||||||
|
VIR_FREE(groups);
|
||||||
|
|
||||||
|
while ((waitret = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
|
||||||
|
if (waitret == -1) {
|
||||||
|
ret = -errno;
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("failed to wait for child unlinking '%s'"),
|
||||||
|
path);
|
||||||
|
goto parenterror;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If waitpid succeeded, but if the child exited abnormally or
|
||||||
|
* reported non-zero status, report failure
|
||||||
|
*/
|
||||||
|
if (!WIFEXITED(status) || (WEXITSTATUS(status)) != 0) {
|
||||||
|
char *msg = virProcessTranslateStatus(status);
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("child failed to unlink '%s': %s"),
|
||||||
|
path, msg);
|
||||||
|
VIR_FREE(msg);
|
||||||
|
if (WIFEXITED(status))
|
||||||
|
ret = -WEXITSTATUS(status);
|
||||||
|
else
|
||||||
|
ret = -EACCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
parenterror:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* child */
|
||||||
|
|
||||||
|
/* set desired uid/gid, then attempt to unlink the file */
|
||||||
|
if (virSetUIDGID(uid, gid, groups, ngroups) < 0) {
|
||||||
|
ret = errno;
|
||||||
|
goto childerror;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlink(path) < 0) {
|
||||||
|
ret = errno;
|
||||||
|
goto childerror;
|
||||||
|
}
|
||||||
|
|
||||||
|
childerror:
|
||||||
|
if ((ret & 0xff) != ret) {
|
||||||
|
VIR_WARN("unable to pass desired return value %d", ret);
|
||||||
|
ret = 0xff;
|
||||||
|
}
|
||||||
|
_exit(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* return -errno on failure, or 0 on success */
|
/* return -errno on failure, or 0 on success */
|
||||||
static int
|
static int
|
||||||
virDirCreateNoFork(const char *path,
|
virDirCreateNoFork(const char *path,
|
||||||
|
@@ -219,6 +219,7 @@ int virFileOpenAs(const char *path, int openflags, mode_t mode,
|
|||||||
uid_t uid, gid_t gid,
|
uid_t uid, gid_t gid,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
int virFileUnlink(const char *path, uid_t uid, gid_t gid);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
VIR_DIR_CREATE_NONE = 0,
|
VIR_DIR_CREATE_NONE = 0,
|
||||||
|
@@ -2552,8 +2552,8 @@ vshReadlineInit(vshControl *ctl)
|
|||||||
char *name_capitalized = NULL;
|
char *name_capitalized = NULL;
|
||||||
int max_history = 500;
|
int max_history = 500;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
char *histsize_env = NULL;
|
||||||
const char *histsize_str = NULL;
|
const char *histsize_str = NULL;
|
||||||
const char *histsize_env = NULL;
|
|
||||||
const char *strings[] = {
|
const char *strings[] = {
|
||||||
name_capitalized,
|
name_capitalized,
|
||||||
"HISTSIZE",
|
"HISTSIZE",
|
||||||
@@ -2613,6 +2613,7 @@ vshReadlineInit(vshControl *ctl)
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(userdir);
|
VIR_FREE(userdir);
|
||||||
VIR_FREE(name_capitalized);
|
VIR_FREE(name_capitalized);
|
||||||
|
VIR_FREE(histsize_env);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user