virErrorInitialize() < 0)
goto error;
-#ifndef LIBVIRT_SETUID_RPC_CLIENT
- if (virIsSUID()) {
+ if (getuid() != geteuid() ||
+ getgid() != getegid()) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("libvirt.so is not safe to use from setuid programs"));
+ _("libvirt.so is not safe to use from setuid/setgid programs"));
goto error;
}
-#endif
virLogSetFromEnv();
if (name && name[0] == '\0')
name = NULL;
- if (!name && virIsSUID()) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("An explicit URI must be provided when setuid"));
- goto failed;
- }
-
/* Convert xen -> xen:///system for back compat */
if (name && STRCASEEQ(name, "xen"))
name = "xen:///system";
virHostHasIOMMU;
virIndexToDiskName;
virIsDevMapperDevice;
-virIsSUID;
virMemoryLimitIsSet;
virMemoryLimitTruncate;
virMemoryMaxValue;
transport = trans_unix;
}
- /*
- * We don't want to be executing external programs in setuid mode,
- * so this rules out 'ext' and 'ssh' transports. Exclude libssh
- * and tls too, since we're not confident the libraries are safe
- * for setuid usage. Just allow UNIX sockets, since that does
- * not require any external libraries or command execution
- */
- if (virIsSUID() &&
- transport != trans_unix) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Only Unix socket URI transport is allowed in setuid mode"));
- return VIR_DRV_OPEN_ERROR;
- }
-
-
/* Remote server defaults to "localhost" if not specified. */
if (conn->uri && conn->uri->port != 0) {
if (virAsprintf(&port, "%d", conn->uri->port) < 0)
* transport is listed, or transport is unix,
* and uid is unprivileged then auto-spawn a daemon.
*/
- if (!virIsSUID() &&
- !conn->uri->server &&
+ if (!conn->uri->server &&
(transport == NULL || STREQ(transport, "unix")) &&
(!autostart ||
STRNEQ(autostart, "0"))) {
if (geteuid() > 0) {
VIR_DEBUG("Auto-spawn user daemon instance");
rflags |= VIR_DRV_OPEN_REMOTE_USER;
- if (!virIsSUID() &&
- (!autostart ||
- STRNEQ(autostart, "0")))
+ if (!autostart ||
+ STRNEQ(autostart, "0"))
rflags |= VIR_DRV_OPEN_REMOTE_AUTOSTART;
}
}
size_t count = 0;
virLogPriority prio;
int dest;
- bool isSUID = virIsSUID();
VIR_DEBUG("output=%s", src);
goto cleanup;
}
- /* if running with setuid, only 'stderr' is allowed */
- if (isSUID && dest != VIR_LOG_TO_STDERR) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Running with SUID permits only destination of type "
- "'stderr'"));
- goto cleanup;
- }
-
switch ((virLogDestination) dest) {
case VIR_LOG_TO_STDERR:
ret = virLogNewOutputToStderr(prio);
return getenv(name); /* exempt from syntax-check */
}
-
-/**
- * virIsSUID:
- * Return a true value if running setuid. Does not
- * check for elevated capabilities bits.
- */
-bool virIsSUID(void)
-{
- return getuid() != geteuid();
-}
-
-
static time_t selfLastChanged;
time_t virGetSelfLastChanged(void)
const char *virGetEnvBlockSUID(const char *name);
const char *virGetEnvAllowSUID(const char *name);
-bool virIsSUID(void);
time_t virGetSelfLastChanged(void);