]> xenbits.xensource.com Git - libvirt.git/commitdiff
remote: drop code for migrating config files from pre-XDG dir layout
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 19 Jun 2019 13:25:52 +0000 (14:25 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 21 Jun 2019 11:59:06 +0000 (12:59 +0100)
The unprivileged libvirtd daemon switched to use the XDG dir layout in
the 0.9.13 release, and included code for moving config files from the
old location. The chances of someone upgrading libvirt from <= 0.9.12
directly to libvirt >= 5.5.0 is close enough to zero that we can
reasonably drop the back compat code.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/remote/remote_daemon.c

index c3782971f1261f59fa1131caa6b6e77a9b161cc9..c1544ba914ef008cf2e9f21ab51867e9c8473df9 100644 (file)
@@ -845,79 +845,6 @@ static int daemonStateInit(virNetDaemonPtr dmn)
     return 0;
 }
 
-static int migrateProfile(void)
-{
-    char *old_base = NULL;
-    char *updated = NULL;
-    char *home = NULL;
-    char *xdg_dir = NULL;
-    char *config_dir = NULL;
-    const char *config_home;
-    int ret = -1;
-    mode_t old_umask;
-
-    VIR_DEBUG("Checking if user profile needs migrating");
-
-    if (!(home = virGetUserDirectory()))
-        goto cleanup;
-
-    if (virAsprintf(&old_base, "%s/.libvirt", home) < 0)
-        goto cleanup;
-
-    /* if the new directory is there or the old one is not: do nothing */
-    if (!(config_dir = virGetUserConfigDirectory()))
-        goto cleanup;
-
-    if (!virFileIsDir(old_base) || virFileExists(config_dir)) {
-        VIR_DEBUG("No old profile in '%s' / "
-                  "new profile directory already present '%s'",
-                  old_base, config_dir);
-        ret = 0;
-        goto cleanup;
-    }
-
-    /* test if we already attempted to migrate first */
-    if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0)
-        goto cleanup;
-    if (virFileExists(updated))
-        goto cleanup;
-
-    config_home = virGetEnvBlockSUID("XDG_CONFIG_HOME");
-    if (config_home && config_home[0] != '\0') {
-        if (VIR_STRDUP(xdg_dir, config_home) < 0)
-            goto cleanup;
-    } else {
-        if (virAsprintf(&xdg_dir, "%s/.config", home) < 0)
-            goto cleanup;
-    }
-
-    old_umask = umask(077);
-    if (virFileMakePath(xdg_dir) < 0) {
-        umask(old_umask);
-        goto cleanup;
-    }
-    umask(old_umask);
-
-    if (rename(old_base, config_dir) < 0) {
-        int fd = creat(updated, 0600);
-        VIR_FORCE_CLOSE(fd);
-        VIR_ERROR(_("Unable to migrate %s to %s"), old_base, config_dir);
-        goto cleanup;
-    }
-
-    VIR_DEBUG("Profile migrated from %s to %s", old_base, config_dir);
-    ret = 0;
-
- cleanup:
-    VIR_FREE(home);
-    VIR_FREE(old_base);
-    VIR_FREE(xdg_dir);
-    VIR_FREE(config_dir);
-    VIR_FREE(updated);
-
-    return ret;
-}
-
 static int
 daemonSetupHostUUID(const struct daemonConfig *config)
 {
@@ -1162,12 +1089,6 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
-    if (!privileged &&
-        migrateProfile() < 0) {
-        VIR_ERROR(_("Exiting due to failure to migrate profile"));
-        exit(EXIT_FAILURE);
-    }
-
     if (daemonSetupHostUUID(config) < 0) {
         VIR_ERROR(_("Can't setup host uuid"));
         exit(EXIT_FAILURE);