Skip to content
This repository was archived by the owner on Sep 14, 2026. It is now read-only.

Fix expire phase failing on snapshots without owner write bit - #1

Merged
abkrim merged 1 commit into
masterfrom
fix/expire-perms-uw
May 11, 2026
Merged

abkrim merged 1 commit into
masterfrom
fix/expire-perms-uw

Conversation

@abkrim

@abkrim abkrim commented May 11, 2026

Copy link
Copy Markdown

Summary

fn_expire_backup invocaba fn_rm_dir directamente sin sanear permisos. Cuando un snapshot envejece y contiene ficheros/dirs sin u+w (típico de ISPConfig .php-fcgi-starter 0500, web1/ 0550, o /etc/ssl/private/ 0700), rm -rf falla con Permission denied y aborta todo el backup.

Caso real detectado en stor01-ovh (user kvm476):

```
rm: cannot remove '.../2026-01-19-124749/var/www/php-fcgi-scripts/web1/.php-fcgi-starter': Permission denied
```

Changes

  1. fn_fix_permissions — filtro ampliado de -perm 0111/-perm 000 a ! -perm -u=w. Captura cualquier dir/file donde el propietario carece de write (0400, 0500, 0550, 0700, 0710...). Ramas SUDO colapsadas en un único \$sudo_cmd.
  2. fn_expire_backup — llama a fn_fix_permissions sobre el snapshot antes de fn_rm_dir, condicionado a destino local (la función no usa fn_run_cmd, no es SSH-aware).

Test plan

  • Tests bats nuevos en tests/06_expire_perms.bats
  • Suite completa local: 56/56 OK
  • CI green en GitHub Actions

Storages afectados (propagación tras merge)

  • stor01-ovh (user kvm476)
  • localstor-indiva (user indiva)
  • stor01avanzait (user avanzait)

🤖 Generated with Claude Code

fn_expire_backup called fn_rm_dir directly without ever sanitizing
permissions. When a snapshot aged into expiration containing files
or directories without u+w (typical of ISPConfig .php-fcgi-starter at
0500, web1/ at 0550, or /etc/ssl/private/ at 0700), `rm -rf` failed
with "Permission denied" and the entire backup run aborted.

Real-world trigger on stor01-ovh, user kvm476:
  rm: cannot remove '.../2026-01-19-124749/var/www/php-fcgi-scripts/
  web1/.php-fcgi-starter': Permission denied

Two changes:

1. fn_fix_permissions: widen the find filter from the narrow
   `-perm 0111` / `-perm 000` to `! -perm -u=w`. This catches every
   dir/file where the owner lacks write, including 0400, 0500, 0550,
   0700, 0710 — all common in /var/www, /root, /etc/ssl/private.
   Also collapse the duplicated SUDO branches into a single $sudo_cmd
   prefix.

2. fn_expire_backup: invoke fn_fix_permissions on the snapshot before
   fn_rm_dir, guarded so it only runs on local destinations (the find
   in fn_fix_permissions does not go through fn_run_cmd / SSH).

Added tests/06_expire_perms.bats with two regression cases:
- ISPConfig-style 0500 file inside 0550 dir
- 0400 private key inside 0700 dir

All 56 bats tests pass.
@abkrim
abkrim merged commit cfc803c into master May 11, 2026
4 checks passed
@abkrim
abkrim deleted the fix/expire-perms-uw branch May 11, 2026 10:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant