McdeSys: the backup errors in the catalog, German measured (t0282)

backup.c's 23 mcde_sys_fail calls are messages 22-38 of mcdesys.cat now:
cannot write, the backup disk mounted somewhere else, the six
administrator sentences (set up, change, switch, back up, look into,
restore), BorgBackup missing, password too short, choose a disk, bad numbers,
crontab/dtbackup missing, no disk set up, nothing to restore, cannot go to.
The German copy in programs/localized/de_DE.UTF-8/msg/mcdesys.msg uses the
same numbers; these texts are shown in System Settings (Xft), so they carry
proper umlauts.

Measured with a runner (setlocale + the public calls):
LANG=C: "Only the administrator can set up the backup.", "Only the
administrator can switch the backup.", "Only the administrator can restore
from the backups."; LANG=de_DE.UTF-8: "Nur der Administrator kann die
Sicherung einrichten.", "... die Sicherung umschalten.", "... aus den
Sicherungen wiederherstellen."
make mcde-linux MCDE_DIRS="install lib/McdeSys" and "install
programs/localized/C/msg" exit=0; "check lib/McdeSys": FAIL 0, exit=0;
MCDE_DIRS=plist: ok.
This commit is contained in:
lotherk committed 2026-11-16 10:52:58 +00:00
1 parent 7507b51850
commit dcee228451
4 files changed
+75 -38

No files matched your search

+23 -38
View File
@@ -111,7 +111,7 @@ WriteConf(const McdeSysBackup *b)
FILE *fp = fopen(CONF ".new", "w");
if (fp == NULL)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", CONF);
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_WRITE, "Cannot write %s."), CONF);
fprintf(fp, "# MCDE backup (System Settings, Backup)\ndisk=%s\nrepo=%s\n"
"enabled=%d\n# kept: a number, -1 for every one\nkeep_hourly=%d\n"
"keep_daily=%d\nkeep_weekly=%d\nkeep_monthly=%d\n"
@@ -119,7 +119,7 @@ WriteConf(const McdeSysBackup *b)
"min_free=%d\n", b->disk, b->repo, b->enabled, b->keepHourly,
b->keepDaily, b->keepWeekly, b->keepMonthly, b->minFree);
if (fclose(fp) != 0 || rename(CONF ".new", CONF) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", CONF);
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_WRITE, "Cannot write %s."), CONF);
return MCDE_SYS_OK;
}
@@ -143,8 +143,7 @@ Ready(McdeSysBackup *b)
if (mcde_sys_disk_mount(b->disk, where, sizeof where) != MCDE_SYS_OK)
return MCDE_SYS_EFAIL;
if (strncmp(b->repo, where, strlen(where)) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "The backup disk is mounted "
"on %s, not where the backups are (%s).", where, b->repo);
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_WRONG_DISK, "The backup disk is mounted on %s, not where the backups are (%s)."), where, b->repo);
return MCDE_SYS_OK;
}
@@ -158,15 +157,12 @@ mcde_sys_backup_setup(const char *partition, const char *passphrase)
int fd;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can set up the backup.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_SETUP, "Only the administrator can set up the backup."));
if (borg == NULL)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "BorgBackup is not "
"installed.");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_BAK_NO_BORG, "BorgBackup is not installed."));
if (passphrase == NULL || strlen(passphrase) < 8 ||
strchr(passphrase, '\n') != NULL)
return mcde_sys_fail(MCDE_SYS_EINVAL, "The password needs 8 "
"characters or more.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_PASSWORD, "The password needs 8 characters or more."));
if (mcde_sys_disk_mount(partition, where, sizeof where) != MCDE_SYS_OK)
return MCDE_SYS_EFAIL;
if (mcde_sys_hostname_get(host, sizeof host) != MCDE_SYS_OK)
@@ -178,10 +174,10 @@ mcde_sys_backup_setup(const char *partition, const char *passphrase)
/* the passphrase for the hourly runs: root alone reads it */
if ((fd = open(PASS ".new", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 ||
(fp = fdopen(fd, "w")) == NULL)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", PASS);
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_WRITE, "Cannot write %s."), PASS);
fprintf(fp, "%s\n", passphrase);
if (fclose(fp) != 0 || rename(PASS ".new", PASS) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", PASS);
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_WRITE, "Cannot write %s."), PASS);
{
char *argv[] = { "/usr/bin/env", PASSCMD, (char *) borg,
"init", "--encryption", "repokey-blake2", b.repo, NULL };
@@ -207,16 +203,13 @@ mcde_sys_backup_policy(const McdeSysBackup *p)
McdeSysBackup b;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can change the backup.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_CHANGE, "Only the administrator can change the backup."));
(void) mcde_sys_backup_get(&b);
if (!b.configured)
return mcde_sys_fail(MCDE_SYS_EINVAL, "Choose a backup disk "
"first.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_NO_DISK_CHOOSE, "Choose a backup disk first."));
if (p->minFree < 1 || p->minFree > 90 || p->keepHourly < -1 ||
p->keepDaily < -1 || p->keepWeekly < -1 || p->keepMonthly < -1)
return mcde_sys_fail(MCDE_SYS_EINVAL, "Those numbers cannot "
"be used.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_BAD_NUMBERS, "Those numbers cannot be used."));
b.keepHourly = p->keepHourly;
b.keepDaily = p->keepDaily;
b.keepWeekly = p->keepWeekly;
@@ -278,16 +271,14 @@ mcde_sys_backup_enable(int on)
int skip = 0;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can switch the backup.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_SWITCH, "Only the administrator can switch the backup."));
(void) mcde_sys_backup_get(&b);
if (on && !b.configured)
return mcde_sys_fail(MCDE_SYS_EINVAL, "Choose a backup disk "
"first.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_NO_DISK_CHOOSE, "Choose a backup disk first."));
if (ct == NULL)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "crontab is not there.");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_BAK_NO_CRONTAB, "crontab is not there."));
if (on && db == NULL)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "dtbackup is not there.");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_BAK_NO_DTBACKUP, "dtbackup is not there."));
/* root's crontab with the MCDE lines replaced (crontab(1) -l, -) */
{
char *argv[] = { (char *) ct, "-l", NULL };
@@ -334,15 +325,12 @@ mcde_sys_backup_run(char *log, size_t len)
log[0] = '\0';
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can back up the system.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_RUN, "Only the administrator can back up the system."));
(void) mcde_sys_backup_get(&b);
if (!b.configured)
return mcde_sys_fail(MCDE_SYS_EINVAL, "No backup disk is set "
"up.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_NO_DISK, "No backup disk is set up."));
if (borg == NULL)
return mcde_sys_fail(MCDE_SYS_ENOTSUP, "BorgBackup is not "
"installed.");
return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_BAK_NO_BORG, "BorgBackup is not installed."));
if (Ready(&b) != MCDE_SYS_OK) {
WriteState(mcde_sys_error());
return MCDE_SYS_EFAIL;
@@ -412,8 +400,7 @@ mcde_sys_backup_archives(McdeSysBackupArchive *a, size_t max)
if (!b.configured || borg == NULL)
return 0;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can look into the backups.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_LOOK, "Only the administrator can look into the backups."));
if (Ready(&b) != MCDE_SYS_OK)
return -1;
{
@@ -453,15 +440,13 @@ mcde_sys_backup_restore(const char *archive, const char *path,
int r;
if (geteuid() != 0)
return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator "
"can restore from the backups.");
return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_BAK_EPERM_RESTORE, "Only the administrator can restore from the backups."));
if (archive == NULL || path == NULL || path[0] != '/' ||
dest == NULL || dest[0] != '/' || strstr(archive, "::") != NULL)
return mcde_sys_fail(MCDE_SYS_EINVAL, "Nothing to restore.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_NOTHING, "Nothing to restore."));
(void) mcde_sys_backup_get(&b);
if (!b.configured || borg == NULL)
return mcde_sys_fail(MCDE_SYS_EINVAL, "No backup disk is set "
"up.");
return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_BAK_NO_DISK, "No backup disk is set up."));
if (Ready(&b) != MCDE_SYS_OK)
return MCDE_SYS_EFAIL;
snprintf(what, sizeof what, "%s::%s", b.repo, archive);
@@ -470,7 +455,7 @@ mcde_sys_backup_restore(const char *archive, const char *path,
snprintf(where, sizeof where, "%s", dest);
(void) mkdir(where, 0700);
if (getcwd(cwd, sizeof cwd) == NULL || chdir(where) != 0)
return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot go to %s: %s.",
return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_BAK_CD, "Cannot go to %s: %s."),
where, strerror(errno));
{
char *argv[] = { "/usr/bin/env", PASSCMD, (char *) borg,
+17
View File
@@ -25,3 +25,20 @@ $set 1
19 %s:// cannot be connected to here yet.
20 No folder.
21 No umount.
22 Cannot write %s.
23 The backup disk is mounted on %s, not where the backups are (%s).
24 Only the administrator can set up the backup.
25 Only the administrator can change the backup.
26 Only the administrator can switch the backup.
27 Only the administrator can back up the system.
28 Only the administrator can look into the backups.
29 Only the administrator can restore from the backups.
30 BorgBackup is not installed.
31 The password needs 8 characters or more.
32 Choose a backup disk first.
33 Those numbers cannot be used.
34 crontab is not there.
35 dtbackup is not there.
36 No backup disk is set up.
37 Nothing to restore.
38 Cannot go to %s: %s.
+18
View File
@@ -38,6 +38,24 @@ int mcde_sys_fail(int status, const char *fmt, ...);
#define MSG_NET_SCHEME 19
#define MSG_NET_NO_FOLDER 20
#define MSG_NET_NO_UMOUNT 21
/* backup.c: the backup disk, the password, borg and the administrator */
#define MSG_BAK_WRITE 22
#define MSG_BAK_WRONG_DISK 23
#define MSG_BAK_EPERM_SETUP 24
#define MSG_BAK_EPERM_CHANGE 25
#define MSG_BAK_EPERM_SWITCH 26
#define MSG_BAK_EPERM_RUN 27
#define MSG_BAK_EPERM_LOOK 28
#define MSG_BAK_EPERM_RESTORE 29
#define MSG_BAK_NO_BORG 30
#define MSG_BAK_PASSWORD 31
#define MSG_BAK_NO_DISK_CHOOSE 32
#define MSG_BAK_BAD_NUMBERS 33
#define MSG_BAK_NO_CRONTAB 34
#define MSG_BAK_NO_DTBACKUP 35
#define MSG_BAK_NO_DISK 36
#define MSG_BAK_NOTHING 37
#define MSG_BAK_CD 38
const char *mcde_sys_msg(int n, const char *text);
/* run ARGV (an absolute path first) and wait; MCDE_SYS_OK on exit status 0 */
@@ -23,3 +23,20 @@ $set 1
19 %s:// kann hier noch nicht verbunden werden.
20 Kein Ordner.
21 Kein umount.
22 %s kann nicht geschrieben werden.
23 Die Sicherungsplatte ist auf %s eingehängt, nicht dort, wo die Sicherungen liegen (%s).
24 Nur der Administrator kann die Sicherung einrichten.
25 Nur der Administrator kann die Sicherung ändern.
26 Nur der Administrator kann die Sicherung umschalten.
27 Nur der Administrator kann den Rechner sichern.
28 Nur der Administrator kann in die Sicherungen sehen.
29 Nur der Administrator kann aus den Sicherungen wiederherstellen.
30 BorgBackup ist nicht installiert.
31 Das Passwort braucht 8 Zeichen oder mehr.
32 Wähle zuerst eine Sicherungsplatte.
33 Diese Zahlen sind nicht verwendbar.
34 crontab ist nicht vorhanden.
35 dtbackup ist nicht vorhanden.
36 Es ist keine Sicherungsplatte eingerichtet.
37 Nichts wiederherzustellen.
38 %s kann nicht geöffnet werden: %s.