xbps_purge_pkg: chdir to rootdir, check that REMOVE file exists and is executable.
This commit is contained in:
parent
243685507a
commit
2492d98d13
@ -171,24 +171,36 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
|
|||||||
/*
|
/*
|
||||||
* Execute the purge action in REMOVE script (if found).
|
* Execute the purge action in REMOVE script (if found).
|
||||||
*/
|
*/
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
|
if (chdir(xbps_get_rootdir()) == -1) {
|
||||||
|
rv = errno;
|
||||||
|
prop_object_release(dict);
|
||||||
|
xbps_error_printf("[purge] %s: cannot change to rootdir: %s.\n",
|
||||||
|
pkgname, strerror(rv));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
buf = xbps_xasprintf(".%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname);
|
buf = xbps_xasprintf(".%s/metadata/%s/REMOVE", XBPS_META_PATH, pkgname);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (access(buf, X_OK) == 0) {
|
||||||
|
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
|
||||||
|
|
||||||
if (xbps_file_exec(buf, "purge",
|
if (xbps_file_exec(buf, "purge",
|
||||||
pkgname, version, "no", NULL) != 0) {
|
pkgname, version, "no", NULL) != 0) {
|
||||||
free(buf);
|
free(buf);
|
||||||
if (errno && errno != ENOENT) {
|
if (errno && errno != ENOENT) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
xbps_error_printf("%s: purge action error in REMOVE "
|
xbps_error_printf("%s: purge action error in "
|
||||||
"script: %s\n", pkgname, strerror(errno));
|
"REMOVE script: %s\n", pkgname,
|
||||||
|
strerror(errno));
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
/*
|
/*
|
||||||
* Remove metadata dir and unregister package.
|
* Remove metadata dir and unregister package.
|
||||||
|
Loading…
Reference in New Issue
Block a user