static const char * virAdmGetDefaultURI(virConfPtr conf) { virConfValuePtr value = NULL; const char *uristr = NULL; uristr = virGetEnvAllowSUID("LIBVIRT_ADMIN_DEFAULT_URI"); if (uristr && *uristr) { VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", uristr); } else if ((value = virConfGetValue(conf, "admin_uri_default"))) { if (value->type != VIR_CONF_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Expected a string for 'admin_uri_default' config " "parameter")); return NULL; } VIR_DEBUG("Using config file uri '%s'", value->str); uristr = value->str; } else { /* Since we can't probe connecting via any hypervisor driver as libvirt * does, if no explicit URI was given and neither the environment * variable, nor the configuration parameter had previously been set, * we set the default admin server URI to 'libvirtd://system'. */ uristr = "libvirtd:///system"; } return uristr; }
static int virAdmGetDefaultURI(virConfPtr conf, char **uristr) { const char *defname = virGetEnvAllowSUID("LIBVIRT_ADMIN_DEFAULT_URI"); if (defname && *defname) { if (VIR_STRDUP(*uristr, defname) < 0) return -1; VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr); } else { if (virConfGetValueString(conf, "admin_uri_default", uristr) < 0) return -1; if (*uristr) { VIR_DEBUG("Using config file uri '%s'", *uristr); } else { /* Since we can't probe connecting via any hypervisor driver as libvirt * does, if no explicit URI was given and neither the environment * variable, nor the configuration parameter had previously been set, * we set the default admin server URI to 'libvirtd://system'. */ if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0) return -1; } } return 0; }