Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Check the packge locking status at various crucial junctures and throw a spanner in the works if a locked package would be modified at all.
Matthew Seaman committed 13 years ago
commit d964370f45082c6e7c6afd710e040db26081083e
parent a97f0c7
2 files changed +28 -1
modified libpkg/pkg_delete.c
@@ -44,6 +44,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags)
	struct pkg_dep	*rdep = NULL;
	int		 ret;
	bool		 handle_rc = false;
+
	bool		 locked;
	const char	*origin;

	assert(pkg != NULL);
@@ -74,6 +75,13 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags)
	else
		pkg_emit_deinstall_begin(pkg);

+
	/* If the package is locked */
+
	pkg_get(pkg, PKG_LOCKED, &locked);
+
	if (locked) {
+
		pkg_emit_locked(pkg);
+
		return (EPKG_LOCKED);
+
	}
+

	/* If there are dependencies */
	if (pkg_rdeps(pkg, &rdep) == EPKG_OK) {
		pkg_emit_required(pkg, flags & PKG_DELETE_FORCE);
modified libpkg/pkg_jobs.c
@@ -169,7 +169,7 @@ pkg_jobs_install(struct pkg_jobs *j)

	while (pkg_jobs(j, &p) == EPKG_OK) {
		const char *pkgorigin, *pkgrepopath, *newversion, *origin;
-
		bool automatic;
+
		bool automatic, locked;
		flags = 0;

		pkg_get(p, PKG_ORIGIN, &pkgorigin, PKG_REPOPATH, &pkgrepopath,
@@ -180,6 +180,15 @@ pkg_jobs_install(struct pkg_jobs *j)
			it = pkgdb_query(j->db, pkgorigin, MATCH_EXACT);
			if (it != NULL) {
				if (pkgdb_it_next(it, &pkg, lflags) == EPKG_OK) {
+
					pkg_get(pkg, PKG_LOCKED, &locked);
+
					if (locked) {
+
						pkg_emit_locked(pkg);
+
						pkgdb_it_free(it);
+
						retcode = EPKG_LOCKED;
+
						pkgdb_transaction_rollback(j->db->sqlite, "upgrade");
+
						goto cleanup; /* Bail out */
+
					}
+

					STAILQ_INSERT_TAIL(&pkg_queue, pkg, next);
					pkg_script_run(pkg,
					    PKG_SCRIPT_PRE_DEINSTALL);
@@ -204,6 +213,16 @@ pkg_jobs_install(struct pkg_jobs *j)
		if (it != NULL) {
			pkg = NULL;
			while (pkgdb_it_next(it, &pkg, lflags) == EPKG_OK) {
+

+
				pkg_get(pkg, PKG_LOCKED, &locked);
+
				if (locked) {
+
					pkg_emit_locked(pkg);
+
					pkgdb_it_free(it);
+
					retcode = EPKG_LOCKED;
+
					pkgdb_transaction_rollback(j->db->sqlite, "upgrade");
+
					goto cleanup; /* Bail out */
+
				}
+

				STAILQ_INSERT_TAIL(&pkg_queue, pkg, next);
				pkg_script_run(pkg, PKG_SCRIPT_PRE_DEINSTALL);
				pkg_get(pkg, PKG_ORIGIN, &origin);