xbps-bin(8): the 'check' target now handles symlinks correctly.
This commit is contained in:
parent
056f40da3f
commit
d59ad72ee4
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.18 (???):
|
xbps-0.18 (???):
|
||||||
|
|
||||||
|
* xbps-bin(8): the 'check' target now checks the target file in relative
|
||||||
|
symlinks, or multiple levels of symlinks.
|
||||||
|
|
||||||
* xbps-create(8): fixed an assertion that happened when resolving the
|
* xbps-create(8): fixed an assertion that happened when resolving the
|
||||||
target file of a symlink, which was unexistent because the real file was
|
target file of a symlink, which was unexistent because the real file was
|
||||||
provided by another pkg. In this case just keep the target file as is.
|
provided by another pkg. In this case just keep the target file as is.
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
@ -55,7 +56,7 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
|||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
prop_dictionary_t pkg_filesd = arg;
|
prop_dictionary_t pkg_filesd = arg;
|
||||||
const char *file, *tgt = NULL;
|
const char *file, *tgt = NULL;
|
||||||
char *path, buf[PATH_MAX];
|
char *path, *buf, *buf2, *buf3, *dname, *path_target;
|
||||||
bool broken = false, test_broken = false;
|
bool broken = false, test_broken = false;
|
||||||
|
|
||||||
(void)pkgdb_update;
|
(void)pkgdb_update;
|
||||||
@ -80,28 +81,37 @@ check_pkg_symlinks(struct xbps_handle *xhp,
|
|||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memset(&buf, 0, sizeof(buf));
|
if ((buf = realpath(path, NULL)) == NULL) {
|
||||||
if (realpath(path, buf) == NULL) {
|
|
||||||
xbps_error_printf("%s: broken symlink `%s': "
|
xbps_error_printf("%s: broken symlink `%s': "
|
||||||
"%s\n", pkgname, file, strerror(errno));
|
"%s\n", pkgname, file, strerror(errno));
|
||||||
test_broken = true;
|
test_broken = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (strncmp(tgt, "../", 3) == 0) {
|
||||||
free(path);
|
/* relative symlink target */
|
||||||
if (strcmp(xhp->rootdir, "/") &&
|
dname = dirname(path);
|
||||||
strstr(buf, xhp->rootdir))
|
buf2 = xbps_xasprintf("%s/%s", dname, tgt);
|
||||||
path = buf + strlen(xhp->rootdir);
|
assert(buf2);
|
||||||
else
|
buf3 = realpath(buf2, NULL);
|
||||||
path = buf;
|
assert(buf3);
|
||||||
|
free(buf2);
|
||||||
if (strcmp(path, tgt)) {
|
path_target = buf3;
|
||||||
|
} else {
|
||||||
|
path_target = buf;
|
||||||
|
}
|
||||||
|
if (strcmp(buf, path_target)) {
|
||||||
xbps_error_printf("%s: modified symlink `%s' "
|
xbps_error_printf("%s: modified symlink `%s' "
|
||||||
"points to: `%s' (shall be: `%s')\n",
|
"points to: `%s' (shall be: `%s')\n",
|
||||||
pkgname, file, path, tgt);
|
pkgname, file, buf, path_target);
|
||||||
test_broken = true;
|
test_broken = true;
|
||||||
}
|
}
|
||||||
path = NULL;
|
free(buf);
|
||||||
|
free(path);
|
||||||
|
if (buf3)
|
||||||
|
free(buf3);
|
||||||
|
|
||||||
|
path = buf = buf2 = buf3 = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user