|
Lines 2026-2035
create_filesystem_object(struct archive_
Link Here
|
| 2026 |
const char *linkname; |
2026 |
const char *linkname; |
| 2027 |
mode_t final_mode, mode; |
2027 |
mode_t final_mode, mode; |
| 2028 |
int r; |
2028 |
int r; |
| 2029 |
/* these for check_symlinks_fsobj */ |
|
|
| 2030 |
char *linkname_copy; /* non-const copy of linkname */ |
| 2031 |
struct archive_string error_string; |
| 2032 |
int error_number; |
| 2033 |
|
2029 |
|
| 2034 |
/* We identify hard/symlinks according to the link names. */ |
2030 |
/* We identify hard/symlinks according to the link names. */ |
| 2035 |
/* Since link(2) and symlink(2) don't handle modes, we're done here. */ |
2031 |
/* Since link(2) and symlink(2) don't handle modes, we're done here. */ |
|
Lines 2038-2064
create_filesystem_object(struct archive_
Link Here
|
| 2038 |
#if !HAVE_LINK |
2034 |
#if !HAVE_LINK |
| 2039 |
return (EPERM); |
2035 |
return (EPERM); |
| 2040 |
#else |
2036 |
#else |
| 2041 |
archive_string_init(&error_string); |
|
|
| 2042 |
linkname_copy = strdup(linkname); |
| 2043 |
if (linkname_copy == NULL) { |
| 2044 |
return (EPERM); |
| 2045 |
} |
| 2046 |
/* TODO: consider using the cleaned-up path as the link target? */ |
| 2047 |
r = cleanup_pathname_fsobj(linkname_copy, &error_number, &error_string, a->flags); |
| 2048 |
if (r != ARCHIVE_OK) { |
| 2049 |
archive_set_error(&a->archive, error_number, "%s", error_string.s); |
| 2050 |
free(linkname_copy); |
| 2051 |
/* EPERM is more appropriate than error_number for our callers */ |
| 2052 |
return (EPERM); |
| 2053 |
} |
| 2054 |
r = check_symlinks_fsobj(linkname_copy, &error_number, &error_string, a->flags); |
| 2055 |
if (r != ARCHIVE_OK) { |
| 2056 |
archive_set_error(&a->archive, error_number, "%s", error_string.s); |
| 2057 |
free(linkname_copy); |
| 2058 |
/* EPERM is more appropriate than error_number for our callers */ |
| 2059 |
return (EPERM); |
| 2060 |
} |
| 2061 |
free(linkname_copy); |
| 2062 |
r = link(linkname, a->name) ? errno : 0; |
2037 |
r = link(linkname, a->name) ? errno : 0; |
| 2063 |
/* |
2038 |
/* |
| 2064 |
* New cpio and pax formats allow hardlink entries |
2039 |
* New cpio and pax formats allow hardlink entries |