Skip to content

Commit 3c80f06

Browse files
committed
lib: don't allow xbps self-update to bypass integrity checks
This reverts 83ade39. In the past, self-updates mandated that only xbps and its dependencies can be updated if an xbps update is avaliable. As updating dependencies may break their depndents, xbps used XBPS_FLAG_FORCE_REMOVE_REVDEPS in order to bypass integrety checks when using xbps-install -u xbps. This can result in circumstances where the the system is rendered inoperable due to missing or mismatched dependencies of core system packages (e.g. PAM). Remove the auto-update mechanism until a better designed system can be implemented.
1 parent 1aa8f0c commit 3c80f06

File tree

5 files changed

+4
-371
lines changed

5 files changed

+4
-371
lines changed

lib/transaction_ops.c

Lines changed: 1 addition & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -222,80 +222,6 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
222222
return 0;
223223
}
224224

225-
/*
226-
* Returns 1 if there's an update, 0 if none or -1 on error.
227-
*/
228-
static int
229-
xbps_autoupdate(struct xbps_handle *xhp)
230-
{
231-
xbps_array_t rdeps;
232-
xbps_dictionary_t pkgd;
233-
const char *pkgver = NULL, *pkgname = NULL;
234-
int rv;
235-
236-
/*
237-
* Check if there's a new update for XBPS before starting
238-
* another transaction.
239-
*/
240-
if (((pkgd = xbps_pkgdb_get_pkg(xhp, "xbps")) == NULL) &&
241-
((pkgd = xbps_pkgdb_get_virtualpkg(xhp, "xbps")) == NULL))
242-
return 0;
243-
244-
if (!xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver)) {
245-
return EINVAL;
246-
}
247-
if (!xbps_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname)) {
248-
return EINVAL;
249-
}
250-
251-
rv = trans_find_pkg(xhp, pkgname, false);
252-
253-
xbps_dbg_printf("%s: trans_find_pkg xbps: %d\n", __func__, rv);
254-
255-
if (rv == 0) {
256-
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
257-
return 0;
258-
}
259-
/* a new xbps version is available, check its revdeps */
260-
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, "xbps");
261-
for (unsigned int i = 0; i < xbps_array_count(rdeps); i++) {
262-
const char *curpkgver = NULL;
263-
char curpkgn[XBPS_NAME_SIZE] = {0};
264-
265-
xbps_array_get_cstring_nocopy(rdeps, i, &curpkgver);
266-
xbps_dbg_printf("%s: processing revdep %s\n", __func__, curpkgver);
267-
268-
if (!xbps_pkg_name(curpkgn, sizeof(curpkgn), curpkgver)) {
269-
abort();
270-
}
271-
rv = trans_find_pkg(xhp, curpkgn, false);
272-
xbps_dbg_printf("%s: trans_find_pkg revdep %s: %d\n", __func__, curpkgver, rv);
273-
if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV)
274-
return -1;
275-
}
276-
/*
277-
* Set XBPS_FLAG_FORCE_REMOVE_REVDEPS to ignore broken
278-
* reverse dependencies in xbps_transaction_prepare().
279-
*
280-
* This won't skip revdeps of the xbps pkg, rather other
281-
* packages in rootdir that could be broken indirectly.
282-
*
283-
* A sysup transaction after updating xbps should fix them
284-
* again.
285-
*/
286-
xhp->flags |= XBPS_FLAG_FORCE_REMOVE_REVDEPS;
287-
return 1;
288-
} else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
289-
/* no update */
290-
return 0;
291-
} else {
292-
/* error */
293-
return -1;
294-
}
295-
296-
return 0;
297-
}
298-
299225
int
300226
xbps_transaction_update_packages(struct xbps_handle *xhp)
301227
{
@@ -305,17 +231,8 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
305231
bool newpkg_found = false;
306232
int rv = 0;
307233

308-
rv = xbps_autoupdate(xhp);
309-
switch (rv) {
310-
case 1:
311-
/* xbps needs to be updated, don't allow any other update */
312-
return EBUSY;
313-
case -1:
314-
/* error */
234+
if (xbps_pkgdb_init(xhp) != 0)
315235
return EINVAL;
316-
default:
317-
break;
318-
}
319236

320237
iter = xbps_dictionary_iterator(xhp->pkgdb);
321238
assert(iter);
@@ -355,22 +272,6 @@ xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg, bool force
355272
xbps_array_t rdeps;
356273
int rv;
357274

358-
rv = xbps_autoupdate(xhp);
359-
xbps_dbg_printf("%s: xbps_autoupdate %d\n", __func__, rv);
360-
switch (rv) {
361-
case 1:
362-
/* xbps needs to be updated, only allow xbps to be updated */
363-
if (strcmp(pkg, "xbps"))
364-
return EBUSY;
365-
return 0;
366-
case -1:
367-
/* error */
368-
return EINVAL;
369-
default:
370-
/* no update */
371-
break;
372-
}
373-
374275
/* update its reverse dependencies */
375276
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
376277
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
@@ -406,21 +307,6 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool forc
406307
xbps_array_t rdeps;
407308
int rv;
408309

409-
rv = xbps_autoupdate(xhp);
410-
switch (rv) {
411-
case 1:
412-
/* xbps needs to be updated, only allow xbps to be updated */
413-
if (strcmp(pkg, "xbps"))
414-
return EBUSY;
415-
return 0;
416-
case -1:
417-
/* error */
418-
return EINVAL;
419-
default:
420-
/* no update */
421-
break;
422-
}
423-
424310
/* update its reverse dependencies */
425311
rdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkg);
426312
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {

tests/xbps/libxbps/shell/Kyuafile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ atf_test_program{name="preserve_files_test"}
2020
atf_test_program{name="update_shlibs_test"}
2121
atf_test_program{name="update_hold_test"}
2222
atf_test_program{name="update_repolock_test"}
23-
atf_test_program{name="update_itself_test"}
2423
atf_test_program{name="cyclic_deps_test"}
2524
atf_test_program{name="conflicts_test"}
2625
atf_test_program{name="hold_test"}

tests/xbps/libxbps/shell/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TESTSHELL+= replace_test installmode_test obsoletefiles_test
77
TESTSHELL+= issue31_test scripts_test incorrect_deps_test
88
TESTSHELL+= vpkg_test install_test preserve_files_test configure_test
99
TESTSHELL+= update_shlibs_test update_hold_test update_repolock_test
10-
TESTSHELL+= cyclic_deps_test conflicts_test update_itself_test
10+
TESTSHELL+= cyclic_deps_test conflicts_test
1111
TESTSHELL+= hold_test ignore_test preserve_test repo_test
1212
TESTSHELL+= noextract_files_test orphans_test transaction_check_revdeps_test
1313
EXTRA_FILES = Kyuafile

tests/xbps/libxbps/shell/install_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ update_xbps_body() {
484484
cd ..
485485
xbps-rindex -d -a repo/*.xbps
486486
atf_check_equal $? 0
487-
out=$(xbps-install -r root --repository=repo -yun)
487+
out=$(xbps-install -r root --repository=repo -yun xbps)
488488
set -- $out
489489
exp="$1 $2 $3 $4"
490490
atf_check_equal "$exp" "xbps-1.1_1 update noarch $(readlink -f repo)"
@@ -537,7 +537,7 @@ update_xbps_virtual_body() {
537537
cd ..
538538
xbps-rindex -d -a repo/*.xbps
539539
atf_check_equal $? 0
540-
out=$(xbps-install -r root --repository=repo -yun)
540+
out=$(xbps-install -r root --repository=repo -yun xbps-git)
541541
set -- $out
542542
exp="$1 $2 $3 $4"
543543
atf_check_equal "$exp" "xbps-git-1.1_1 update noarch $(readlink -f repo)"

0 commit comments

Comments
 (0)