Re: [PATCH 4/7] Add libarchive helper functions for loader in unpack.c

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

 



> +void unpack_members(struct archive *a, char *dest) {
> +    int restore = 0;
> +    char prevcwd[PATH_MAX];
> +    struct archive_entry *e = NULL;
> +
> +    if (getcwd(prevcwd, PATH_MAX) == NULL)
> +        logMessage(ERROR, "unable to getcwd() (%s:%d): %m", __func__,
> +                                                            __LINE__);
> +    else
> +        restore = 1;
> +
> +    if (dest != NULL && access(dest, R_OK|W_OK|X_OK)) {
> +        if (g_mkdir_with_parents(dest, 0755) == -1)
> +            logMessage(ERROR, "unable to mkdir %s (%s:%d): %m",
> +                       dest, __func__, __LINE__);
> +    } else if (chdir(dest) == -1) {
> +        logMessage(ERROR, "unable to chdir %s (%s:%d): %m",
> +                   dest, __func__, __LINE__);
> +    }

If either of these things fail, you should return instead of blasting
the archive members into wherever the current directory may be.  Perhaps
unpack_members should return a value to indicate this.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux