=== Applying patches on top of PostgreSQL commit ID e42f1d0f1be811511e305bba44b29b08073a705d === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Aug 22 02:12:23 UTC 2026 On branch cf/6909 nothing to commit, working tree clean === using 'git am' to apply patch ./v1-0001-Tighten-ACL-check-in-repack_is_permitted_for_rela.patch === Applying: Tighten ACL check in repack_is_permitted_for_relation() Using index info to reconstruct a base tree... M src/backend/commands/repack.c Falling back to patching base and 3-way merge... Auto-merging src/backend/commands/repack.c CONFLICT (content): Merge conflict in src/backend/commands/repack.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Tighten ACL check in repack_is_permitted_for_relation() When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v1-0001-Tighten-ACL-check-in-repack_is_permitted_for_rela.patch === patching file src/backend/commands/repack.c Hunk #1 FAILED at 172. Hunk #2 FAILED at 724. Hunk #3 FAILED at 2198. Hunk #4 FAILED at 2235. Hunk #5 FAILED at 2304. Hunk #6 FAILED at 2321. Hunk #7 FAILED at 2338. 7 out of 7 hunks FAILED -- saving rejects to file src/backend/commands/repack.c.rej Removing src/backend/commands/repack.c.rej === using 'git apply' to apply patch ./v1-0001-Tighten-ACL-check-in-repack_is_permitted_for_rela.patch === Applied patch to 'src/backend/commands/repack.c' with conflicts. U src/backend/commands/repack.c diff --cc src/backend/commands/repack.c index 477c86b2ba6,b09be65da3b..00000000000 --- a/src/backend/commands/repack.c +++ b/src/backend/commands/repack.c @@@ -169,12 -169,11 +169,17 @@@ static void copy_table_data(Relation Ne MultiXactId *pCutoffMulti); static List *get_tables_to_repack(RepackCommand cmd, bool usingindex, MemoryContext permcxt); -static List *get_tables_to_repack_partitioned(RepackCommand cmd, - Oid relid, bool rel_is_index, +static List *get_tables_to_repack_partitioned(RepackStmt *stmt, + Relation rel, MemoryContext permcxt); ++<<<<<<< ours +static bool repack_is_permitted_for_relation(RepackCommand cmd, + Oid relid, Oid userid, + bool already_locked); ++======= + static bool repack_is_permitted_for_relation(RepackCommand cmd, Oid relid, + Oid userid, bool missing_ok); ++>>>>>>> theirs static void apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt); static void apply_concurrent_insert(Relation rel, TupleTableSlot *slot, @@@ -682,7 -724,7 +687,11 @@@ cluster_rel_recheck(RepackCommand cmd, Assert(CheckRelationLockedByMe(OldHeap, lmode, false)); /* Check that the user still has privileges for the relation */ ++<<<<<<< ours + if (!repack_is_permitted_for_relation(cmd, tableOid, userid, true)) ++======= + if (!repack_is_permitted_for_relation(cmd, tableOid, userid, false)) ++>>>>>>> theirs { relation_close(OldHeap, lmode); return false; @@@ -2156,7 -2198,7 +2165,11 @@@ get_tables_to_repack(RepackCommand cmd /* noisily skip rels which the user can't process */ if (!repack_is_permitted_for_relation(cmd, index->indrelid, ++<<<<<<< ours + GetUserId(), false)) ++======= + GetUserId(), true)) ++>>>>>>> theirs continue; /* Use a permanent memory context for the result list */ @@@ -2193,7 -2235,7 +2206,11 @@@ /* noisily skip rels which the user can't process */ if (!repack_is_permitted_for_relation(cmd, class->oid, ++<<<<<<< ours + GetUserId(), false)) ++======= + GetUserId(), true)) ++>>>>>>> theirs continue; /* Use a permanent memory context for the result list */ @@@ -2321,8 -2304,7 +2338,12 @@@ get_tables_to_repack_partitioned(Repack * leaf partition despite having them on the partitioned table. Skip * if so. */ ++<<<<<<< ours + if (!repack_is_permitted_for_relation(stmt->command, table_oid, + GetUserId(), false)) ++======= + if (!repack_is_permitted_for_relation(cmd, table_oid, GetUserId(), true)) ++>>>>>>> theirs continue; /* Use a permanent memory context for the result list */ @@@ -2342,36 -2321,38 +2363,67 @@@ /* ++<<<<<<< ours + * Return whether userid has privileges to execute REPACK/CLUSTER on relid. + * + * The relation may already be locked by caller, in which case it cannot + * possibly go missing; otherwise it may have been removed recently. If + * it's been removed, silently return false. If the relation exists but + * the user doesn't have the required privs, emit a WARNING and return false. + * + * Otherwise the relation exists and user has required perms, so return true. + */ +static bool +repack_is_permitted_for_relation(RepackCommand cmd, Oid relid, Oid userid, + bool already_locked) ++======= + * Check whether the passed-in user has privileges to execute REPACK on the + * relation. + * + * missing_ok should be passed only by callers that hold no lock on the + * relation, where a concurrent drop is possible and fine to skip. A caller + * that holds a lock must not pass it: there a missing relation would indicate + * a bug and should error out rather than be silently skipped. + * + * If the relation does exist but the user doesn't have the required + * privileges, emit a WARNING and return false to let the caller + * decide what to do with this relation. + */ + static bool + repack_is_permitted_for_relation(RepackCommand cmd, Oid relid, Oid userid, + bool missing_ok) ++>>>>>>> theirs { bool is_missing = false; AclResult result; char *relname; Assert(cmd == REPACK_COMMAND_CLUSTER || cmd == REPACK_COMMAND_REPACK); + Assert(!already_locked || + CheckRelationOidLockedByMe(relid, AccessShareLock, true)); ++<<<<<<< ours + result = pg_class_aclcheck_ext(relid, userid, ACL_MAINTAIN, &is_missing); + + /* + * If the relation was concurrently dropped, nothing to do. This is only + * reachable when the caller doesn't already have a lock on the relation. + */ + if (is_missing) + { + Assert(!already_locked); ++======= + result = pg_class_aclcheck_ext(relid, userid, ACL_MAINTAIN, + missing_ok ? &is_missing : NULL); + + /* + * If the relation was concurrently dropped, nothing to do. Note that this + * is only reachable when the caller specified missing_ok. + */ + if (is_missing) + { + Assert(missing_ok); ++>>>>>>> theirs return false; }