YANZ UPLOAD ANJG

#!/usr/local/cpanel/3rdparty/bin/perl # Copyright 2026 WebPros International, LLC # All rights reserved. # copyright@cpanel.net http://cpanel.net # This code is subject to the cPanel license. Unauthorized copying is prohibited. package scripts::comet_restorepkg_guard; use cPstrict; =encoding utf-8 =head1 NAME comet_restorepkg_guard - make a failed C restore actually fail the Comet job (CPANEL-55666) =head1 SYNOPSIS comet_restorepkg_guard --disable= --from-stdin --skipaccount --newuser [--comet-capture-domain-keys] The snapshot archive arrives on B STDIN, exactly as it arrived on C's before this guard was interposed. =head1 DESCRIPTION The C and C restore paths are Comet C (process) restores: the agent runs the item's C through C and pipes the snapshot to its STDIN. B STRUCTURALLY CANNOT REPORT AN EXTRACTION FAILURE.> It sets a transfer session up and then Cs C>, which tails the session's logs and always exits 0. So when the archive is the corrupted one CPANEL-55666's backup half produces, extraction dies with C, the transfer session records a C action in its C, and the process Comet is watching still exits 0. The plugin then logs C having restored nothing. The pre-existing net does not catch it either: C<_mysql_restore_quarantined> (CPANEL-54772) looks for the C directory C leaves behind when a per-database B fails. An archive that never EXTRACTED produces no dumps, so there is nothing to fail to import and nothing to quarantine. Absent data and failed data are different facts and only the second had a guard. C adds the missing one, in four steps: =over 4 =item 1. B The first two bytes of STDIN must be gzip magic, after up to C<$MAX_LEADING_WHITESPACE_BYTES> leading whitespace bytes (C<\n>, C<\r>, space, tab), which are skipped and never passed on (CPANEL-57691: core C can print blank lines ahead of the archive). If they are not (or STDIN is empty), C is B: the diagnostic names CPANEL-55666, echoes the leading bytes (they are the error text core printed into the backup stream) and exits non-zero. Refusing before dispatch is the whole point — a corrupted archive must not get as far as creating a session, let alone half-restoring an account. =item 2. B C is forked with a pipe as its STDIN; the two head bytes are written first and the remainder of our own STDIN is pumped after them, so the child sees a byte-identical archive. Its STDERR is inherited (the Comet job log keeps C's error rendering unchanged), and its STDOUT is captured to a regular temp FILE. A regular file is what makes this deadlock-free regardless of how much C writes before it drains STDIN — files never block, so there is no need for a second reader process or a C