Re: [PATCH] Use XDG Base Directories instead of storing in home directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 01, 2012 at 09:50:31AM -0400, William Jon McCann wrote:
> +static int migrateProfile(void)
> +{
> +    char *old_base = NULL;
> +    char *updated = NULL;
> +    char *home = NULL;
> +    char *xdg_dir = NULL;
> +    char *config_dir = NULL;
> +    int ret = -1;
> +    mode_t old_umask;
> +
> +    if (!(home = virGetUserDirectory(geteuid())))
> +        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(geteuid())))
> +        goto cleanup;
> +
> +    if (!virFileIsDir(old_base) || virFileExists(config_dir)) {
> +        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;
> +    }
> +
> +    xdg_dir = strdup(getenv("XDG_CONFIG_HOME"));

Opps, segv-tastic - you can't pass a NULL string to strdup().

Bugs aside, I think this patch gets my vote.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]