Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0ad31c9
fix(storage): mask RCLONE_FLAGS values in the run log
tis24dev Nov 2, 2026
d72453a
fix(telegram): keep the bot server's answer out of the startup WARNING
tis24dev Nov 2, 2026
97b4adf
fix(storage): mask RCLONE_FLAGS values in every form they reach the log
tis24dev Nov 2, 2026
2dc0ce2
test(telegram): write the bidi rune of the startup test as an escape
tis24dev Nov 2, 2026
20241ef
fix(webhook): name the status, not the endpoint's answer, in failure …
tis24dev Nov 2, 2026
ed68c42
fix(upgrade): name GitHub's status, not its answer, in the upgrade error
tis24dev Nov 2, 2026
6ec4b39
fix(webhook): mask the URL's path, query and header values in the ans…
tis24dev Nov 2, 2026
b464991
fix(notify): keep the server's answer out of Telegram and Gotify errors
tis24dev Nov 2, 2026
e03cf93
fix(webhook): mask userinfo, escaped forms and header words in the an…
tis24dev Nov 2, 2026
55c8a1a
fix(webhook): mask the userinfo basic-auth form and bare query pairs …
tis24dev Nov 2, 2026
93c2967
fix(orchestrator): count the run log past a line longer than 1 MiB
tis24dev Nov 2, 2026
9dce359
fix(config): read "$$" in backup.env as a literal "$"
tis24dev Nov 2, 2026
26f9010
style(upgrade): use errors.AsType for the GitHub status error
tis24dev Nov 2, 2026
acc66ae
fix(storage): find a path's mount by device, so a symlinked destinati…
tis24dev Nov 3, 2026
62d5b52
fix(cli): refuse --dry-run with the modes that ignored it; --upgrade-…
tis24dev Nov 3, 2026
c96df24
fix(install): read the crontab back before removing the daemon on a s…
tis24dev Nov 3, 2026
6439cd8
fix(storage): set the mode of local cloud copies on a filesystem with…
tis24dev Nov 3, 2026
5cca77f
fix(storage): fail closed and refuse symlinks when setting local clou…
tis24dev Nov 3, 2026
c8025d5
fix(permissions): leave a disabled secondary alone in SET_BACKUP_PERM…
tis24dev Nov 3, 2026
9d5abcb
fix(security): neither create nor check the paths of a disabled secon…
tis24dev Nov 3, 2026
0afdc5e
fix(install): the permissions footer names the backup paths it skipped
tis24dev Nov 3, 2026
6127f5c
fix(support): a failed support email gets its own WARNING
tis24dev Nov 3, 2026
e165ccc
fix(email): count queued messages, not lines with an address
tis24dev Nov 3, 2026
64b7379
fix(email): read PBS user.cfg as section-config in the recipient fall…
tis24dev Nov 3, 2026
6c300a4
fix(cli): stop offering the removed proxmox-backup alias
tis24dev Nov 3, 2026
94bfd31
fix(upgrade): exit 130 on an interruption, 0 on an unanswered prompt,…
tis24dev Nov 3, 2026
ba3fd4f
fix(install): an incomplete post-install dry-run is no longer "no unu…
tis24dev Nov 3, 2026
3423786
fix(install): Ctrl+C on the TUI Healthchecks step aborts the install
tis24dev Nov 3, 2026
73537fd
fix(daemon): follow a symlinked backup.env in the daemon-mode writes
tis24dev Nov 3, 2026
0223d48
fix(cron): see an /etc cron line with an assignment in front of the c…
tis24dev Nov 3, 2026
9a6473b
fix(logging): mark lost run-log lines and count them in the exit code
tis24dev Nov 4, 2026
61425db
fix(config): default CLOUD_LOG_PATH to a relative path, like the backups
tis24dev Nov 4, 2026
d16e280
style(config): range over strings.SplitSeq in the template test
tis24dev Nov 4, 2026
c554c45
fix(decrypt): honour --log-level like backup and restore
tis24dev Nov 4, 2026
66efca8
fix(config): stop reading the Bash-era DISABLE_COLORS
tis24dev Nov 4, 2026
c5b363f
docs(daemon): say a personal script sees its name as /proc/self/fd/3
tis24dev Nov 4, 2026
9b777e0
fix(storage): classify CephFS as a network filesystem the ownership p…
tis24dev Nov 4, 2026
0f32add
fix(backup): skip dedup when the run's exclusions would drop its mani…
tis24dev Nov 4, 2026
c95ac3f
chore(whatsnew): add the 0.46.1 entry
tis24dev Nov 4, 2026
30826e8
feat(healthchecks): send an initial email for the monitoring portal
tis24dev Nov 13, 2026
f2732af
test(healthchecks): pin that the setup check keeps the relay's login_…
tis24dev Nov 13, 2026
8464d06
fix(healthchecks): send the initial email at daemon start too
tis24dev Nov 13, 2026
dd26778
fix(healthchecks): line-per-fact texts for the portal sign-in line an…
tis24dev Nov 13, 2026
f8faf9e
feat(install): ask the HC initial account email with the ProxSave HC …
tis24dev Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions cmd/proxsave/backup_env_symlink_write_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"

"github.com/tis24dev/proxsave/internal/logging"
"github.com/tis24dev/proxsave/internal/types"
)

// A configs/backup.env that is an absolute or escaping symlink was refused by the
// daemon-mode writes ("path escapes from parent") while the loader followed it: the
// switch to the daemon removed the cron line and recorded nothing. The write now
// follows the link to its target, and the link stays a link.
func TestSetBackupEnvKeysFollowsASymlinkedConfig(t *testing.T) {
for _, tc := range []struct {
name string
link func(target, configs string) string
}{
{"absolute link outside", func(target, _ string) string { return target }},
{"relative link escaping", func(target, configs string) string {
rel, _ := filepath.Rel(configs, target)
return rel
}},
} {
t.Run(tc.name, func(t *testing.T) {
root := t.TempDir()
target := filepath.Join(root, "etc", "proxsave", "backup.env")
configs := filepath.Join(root, "base", "configs")
for _, d := range []string{filepath.Dir(target), configs} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatal(err)
}
}
if err := os.WriteFile(target, []byte("SCHEDULER_MODE=cron\n"), 0o600); err != nil {
t.Fatal(err)
}
link := filepath.Join(configs, "backup.env")
if err := os.Symlink(tc.link(target, configs), link); err != nil {
t.Fatal(err)
}
if err := setBackupEnvKeys(link, map[string]string{"SCHEDULER_MODE": "daemon"}); err != nil {
t.Fatalf("setBackupEnvKeys: %v", err)
}
data, err := os.ReadFile(target)
if err != nil || !strings.Contains(string(data), "SCHEDULER_MODE=daemon") {
t.Fatalf("target = %q (%v), want SCHEDULER_MODE=daemon", data, err)
}
if fi, err := os.Lstat(link); err != nil || fi.Mode()&os.ModeSymlink == 0 {
t.Fatalf("the link was replaced: %v %v", fi.Mode(), err)
}
})
}
}

// The adoption that cannot read backup.env logged only DEBUG while the cron line was
// removed anyway; it is now the WARNING a failed write already gets.
func TestScheduleAdoptionWarnsWhenBackupEnvCannotBeRead(t *testing.T) {
var out bytes.Buffer
bootstrap := logging.NewBootstrapLogger()
bootstrap.SetConsoleQuiet(true)
mirror := logging.New(types.LogLevelDebug, false)
mirror.SetOutput(&out)
bootstrap.SetMirrorLogger(mirror)
adoptSchedulerTimeForDaemon(filepath.Join(t.TempDir(), "missing", "backup.env"), []string{"30 21 * * * /usr/local/bin/proxsave"}, bootstrap)
log := out.String()
for _, want := range []string{"Backup schedule: not adopted from cron entry", "backup.env could not be read"} {
if !strings.Contains(log, want) {
t.Fatalf("missing %q; log:\n%s", want, log)
}
}
}
2 changes: 1 addition & 1 deletion cmd/proxsave/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ensureConfigExists(path string, logger configStatusLogger) error {

// No automatic migration or template creation: require explicit user action.
logger.Warning("Configuration file not found: %s", path)
logger.Warning("Run 'proxsave --install' (alias: proxmox-backup --install) to create a new configuration")
logger.Warning("Run 'proxsave --install' to create a new configuration")
return fmt.Errorf("configuration file is required to continue")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/proxsave/config_integrity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestTheDebugBlockExplainsEveryDecisionItMade(t *testing.T) {
// which write form won, since the two resolve in opposite ways
fmt.Sprintf("CUSTOM_BACKUP_PATHS assigned on lines %d, %d; line %d wins (block form: it replaces everything before it)", customPathLines[0], customPathLines[1], customPathLines[1]),
// the template's own two halves, so the counts above can be reconstructed
"template assigns 191 variables and documents",
"template assigns 192 variables and documents",
} {
if !strings.Contains(logged, want) {
t.Fatalf("missing %q in:\n%s", want, logged)
Expand Down
15 changes: 5 additions & 10 deletions cmd/proxsave/cron_indirect_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2076,8 +2076,9 @@ func resolveSystemCronPath(path string) string {
// MM HH DOM MON DOW USER COMMAND -> field 7 is the command
// @daily USER COMMAND -> field 3 is the command
//
// Comments and environment assignments are rejected exactly as in the user format, so
// a line like "MAILTO=root" is never mistaken for a command.
// Comments and environment assignment lines are rejected exactly as in the user format,
// so a line like "MAILTO=root" is never mistaken for a command, and an assignment in front
// of the command is stepped over as there (cronCommandWordAt).
func systemCronCommandToken(line string) string {
trimmed := strings.TrimSpace(line)
if trimmed == "" || strings.HasPrefix(trimmed, "#") {
Expand All @@ -2088,15 +2089,9 @@ func systemCronCommandToken(line string) string {
return ""
}
if strings.HasPrefix(fields[0], "@") {
if len(fields) >= 3 {
return fields[2]
}
return ""
}
if len(fields) <= 6 {
return ""
return cronCommandWordAt(fields, 2)
}
return fields[6]
return cronCommandWordAt(fields, 6)
}

// warnIndirectProxsaveCronOnDaemonInstall reports, without touching anything, every
Expand Down
24 changes: 21 additions & 3 deletions cmd/proxsave/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ type daemon struct {
notifyWant *notifyPolicy
notifyApplied *notifyPolicy
notifyPolls uint64 // config polls that reached the relay; guarded by mu
// initialEmailWant is HEALTHCHECK_ACCOUNT_INITIAL_EMAIL as last read by refreshNotifyPolicy
// (nil: d.cfg's). initialEmailDone is the address the relay gave a final answer for
// (applied or rejected): it is not sent again while the variable holds it. Both guarded by mu.
initialEmailWant *string
initialEmailDone string
// pollMu makes the daemon send one /api/healthcheck/config poll at a time (pollCentralized
// holds it across the request and its resends). The relay provisions under a per-server
// lock it does not wait on: a second poll that arrives while the first is provisioning
Expand Down Expand Up @@ -2113,7 +2118,9 @@ func (d *daemon) buildReporter(ctx context.Context) *health.Reporter {
// centralized
p := d.pollCentralized(ctx, "", "")
d.afterFailedPoll(p)
return d.reporterFromPoll(p, false)
r := d.reporterFromPoll(p, false)
d.logInitialEmailOutcome(p)
return r
}

// afterFailedPoll clears the relay secret a poll was refused with. A DEFINITIVE rejection means
Expand Down Expand Up @@ -2200,6 +2207,9 @@ type configPoll struct {
secret string // the exact secret sent, the comparand of a rejected-secret clear
frequency cron.Frequency // the schedule frequency sent
notify notifyPolicy // the notify policy whose ack cfg carries
// initialEmailSent says the poll carried HEALTHCHECK_ACCOUNT_INITIAL_EMAIL; cfg then holds the
// relay's answer in AccountInitialEmail. The address itself is never kept here.
initialEmailSent bool
}

// relaySecret is the relay secret on disk or, when there is none yet, one from a THROTTLED,
Expand Down Expand Up @@ -2245,20 +2255,28 @@ func (d *daemon) pollCentralizedTo(ctx context.Context, logger *logging.Logger,
// checks back to daily on a poll with channels and no frequency.
want := d.wantedNotifyPolicy()
freq := d.wantedFrequency()
// The portal's initial email rides the start poll and the poll before each run, the two that
// report it (logInitialEmailOutcome); the schedule negotiation's polls do not carry it.
initialEmail := ""
if op != "schedule" {
initialEmail = d.wantedInitialEmail()
}
fetch := func(want notifyPolicy) (health.CentralizedConfig, int, error) {
plog := health.PollLog{}
if op != "" {
plog = health.PollLog{Logger: logger, Operation: op, Prefix: prefix,
URLDetail: fmt.Sprintf("frequency=%s notify_on=%s channels=%s", freq, want.notifyOn, want.channelList())}
}
return health.FetchCentralizedConfigPoll(ctx, nil, d.cfg.ServerAPIHost, d.cfg.ServerID, secret,
want.channels, want.notifyOn, string(freq), plog)
want.channels, want.notifyOn, string(freq), initialEmail, plog)
}
cfg, status, err := fetch(want)
p := configPoll{sent: true, status: status, cfg: cfg, err: err, secret: secret, frequency: freq, notify: want}
p := configPoll{sent: true, status: status, cfg: cfg, err: err, secret: secret, frequency: freq, notify: want,
initialEmailSent: initialEmail != ""}
if err != nil {
return p
}
d.recordInitialEmailAck(initialEmail, p.cfg.AccountInitialEmail)
// A poll that sent a policy no longer wanted may have reached the relay after a newer one
// and put the old policy back there: send the wanted one again, so the relay's last word is
// always the policy wanted now. Every answer is recorded, the last resend's included: the
Expand Down
104 changes: 104 additions & 0 deletions cmd/proxsave/daemon_initial_email.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package main

import (
"strings"

"github.com/tis24dev/proxsave/internal/config"
"github.com/tis24dev/proxsave/internal/health"
"github.com/tis24dev/proxsave/internal/logging"
"github.com/tis24dev/proxsave/internal/ui/theme"
)

// The initial email of the monitoring portal (issue 347). HEALTHCHECK_ACCOUNT_INITIAL_EMAIL is sent
// to the relay on the start poll and on the poll before each scheduled run, until the relay gives
// a final answer for that address (applied or rejected); a different address is sent again. The
// relay mails a confirmation link; the click moves this server's project into the account of the
// address. The address is never logged.

// wantedInitialEmail is the address the next poll sends: "" when none is set, healthchecks is not
// centralized, or the relay already answered for good about this address.
func (d *daemon) wantedInitialEmail() string {
if d.cfg == nil || !d.cfg.HealthcheckEnabled || d.cfg.HealthcheckMode != config.HealthcheckModeCentralized {
return ""
}
d.mu.Lock()
defer d.mu.Unlock()
want := d.cfg.HealthcheckAccountInitialEmail
if d.initialEmailWant != nil {
want = *d.initialEmailWant
}
want = strings.TrimSpace(want)
if want == "" || want == d.initialEmailDone {
return ""
}
return want
}

// recordInitialEmailAck keeps a final answer for sent, so that address is not sent again.
func (d *daemon) recordInitialEmailAck(sent string, ack *health.AccountInitialEmailAck) {
if sent == "" || !ack.Final() {
return
}
d.mu.Lock()
d.initialEmailDone = sent
d.mu.Unlock()
}

// setInitialEmailWant records the address as backup.env holds it now (refreshNotifyPolicy).
func (d *daemon) setInitialEmailWant(value string) {
d.mu.Lock()
d.initialEmailWant = &value
d.mu.Unlock()
}

// logInitialEmailOutcome is the "Applying monitoring portal email..." block of a poll that sent
// the address: DEBUG evidence, then the outcome. Nothing visible when the poll failed or the relay
// did not answer about it (an older relay): the next poll sends it again.
func (d *daemon) logInitialEmailOutcome(p configPoll) {
if !p.initialEmailSent {
return
}
logger := logging.GetDefaultLogger()
logging.DebugStep(logger, "initial email", "read HEALTHCHECK_ACCOUNT_INITIAL_EMAIL set=true source=%s", d.cfg.ConfigPath)
if p.err != nil {
logging.DebugStep(logger, "initial email", "no answer %s", pollFailure(p))
return
}
ack := p.cfg.AccountInitialEmail
if ack == nil {
logging.DebugStep(logger, "initial email", "ack missing")
return
}
logging.DebugStep(logger, "initial email", "ack state=%s reason=%s", ack.State, ack.Reason)
logging.Info("Applying monitoring portal email...")
switch ack.State {
case "applied":
logging.Info("%s Monitoring portal email: applied", theme.SymbolSuccess)
case "rejected":
if why := initialEmailRejection(ack.Reason); why != "" {
logging.Info(" %s", why)
}
logging.Warning("%s Monitoring portal email: not applied", theme.SymbolWarning)
default:
if ack.Reason == "limit" {
logging.Info(" Daily mail limit reached, retried at the next run")
} else {
logging.Info(" Waiting for the confirmation link sent by mail")
}
logging.Info("%s Monitoring portal email: not applied", theme.SymbolWarning)
}
}

// initialEmailRejection is the operator's reason for a rejected address; "" for a reason this
// client does not know (the DEBUG line above has it).
func initialEmailRejection(reason string) string {
switch reason {
case "invalid":
return "Not a usable email address"
case "reserved":
return "An address of the ProxSave HC Server"
case "unconfirmed":
return "3 confirmation mails expired; set another address"
}
return ""
}
Loading
Loading