diff --git a/lib/McdeSys/mcdesys.msg b/lib/McdeSys/mcdesys.msg index cfe16c81..f8d85ca1 100644 --- a/lib/McdeSys/mcdesys.msg +++ b/lib/McdeSys/mcdesys.msg @@ -146,3 +146,46 @@ $set 1 141 Cannot read /proc/net/dev: %s. 142 Cannot read /proc/diskstats: %s. 143 Cannot read the kernel's event socket: %s. +144 %s did not start. +145 Cannot count the processes: %s. +146 Cannot list the processes: %s. +147 Cannot make a new ntp.conf: %s. +148 Cannot read %s. +149 Cannot read %s: %s. +150 Cannot replace ntp.conf: %s. +151 Cannot write /etc/myname: %s. +152 Cannot write beside %s. +153 Cannot write ntp.conf. +154 Changing the touchpad needs the administrator. +155 DRVGETEVENT: %s. +156 No PKG_PATH. +157 No salt for the password. +158 No update source is set (%s). +159 Only the administrator can look for Wi-Fi networks while none is joined. +160 Only the administrator can renew the lease: click the lock first. +161 Secure virtual memory needs the administrator. +162 The computers on the network cannot be looked for: mdnsd does not run (mdnsd=YES in rc.conf). +163 The list of processes changes too fast. +164 The mixer has no outputs.master. +165 The network name or the password cannot be used (a password has 8 to 63 characters, no quotes). +166 The password cannot be hashed. +167 The server is not installed (%s). +168 The system does not say whether memory is encrypted in swap. +169 The system tells no CPU times: %s. +170 The system tells no disk counters: %s. +171 The system tells no interfaces: %s. +172 The system tells no memory: %s. +173 The system tells no number of processors. +174 The touchpad setting %s could not be written (%s). +175 The update source does not answer: %s +176 The update source is not allowed: it must be a directory, file:/// or https:// (%s). +177 There is no Bluetooth controller. +178 There is no place for the state. +179 There is no place for the value. +180 This system has no cgd(4) configuration (%s). +181 This system has no npf(7) (/sbin/npfctl). +182 This system has no touchpad settings. +183 Too many settings. +184 dhcpcd did not renew the lease of %s. +185 dhcpcd did not start (/etc/rc.d/dhcpcd start). +186 sysctl(8) did not take vm.swap_encrypt. diff --git a/lib/McdeSys/netbsd.c b/lib/McdeSys/netbsd.c index 60f04196..357a9d38 100644 --- a/lib/McdeSys/netbsd.c +++ b/lib/McdeSys/netbsd.c @@ -123,7 +123,7 @@ mcde_sys_power(McdeSysPower what) case MCDE_POWER_SHUTDOWN: return mcde_sys_run(halt); } - return mcde_sys_fail(MCDE_SYS_EINVAL, "Unknown power action."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_LX_POWER_ACTION, "Unknown power action.")); } /* ---- network: an interface that answers SIOCG80211NWID is Wi-Fi, and the @@ -175,8 +175,7 @@ mcde_sys_mixer_get(int *percent, int *muted) if (mcde_sys_capture_limited(v, out, sizeof out, MCDE_SYS_STATUS_SECONDS) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "The mixer has no " - "outputs.master."); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_MIXER_NO_MASTER, "The mixer has no outputs.master.")); *percent = (atoi(out) * 100 + 127) / 255; /* "l,r": the left */ *muted = mcde_sys_capture_limited(m, out, sizeof out, MCDE_SYS_STATUS_SECONDS) == MCDE_SYS_OK && @@ -234,8 +233,7 @@ mcde_sys_bluetooth_power(int on) (void) mcde_sys_bluetooth(&bt); if (!bt.present) - return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no Bluetooth " - "controller."); + return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_NB_NO_BLUETOOTH, "There is no Bluetooth controller.")); argv[1] = bt.name; argv[2] = on ? "up" : "down"; return mcde_sys_run(argv); @@ -317,13 +315,10 @@ SysctlWriteInt(const char *name, int v) if (sysctlbyname(name, NULL, NULL, &v, sizeof v) == 0) return MCDE_SYS_OK; if (errno == EPERM || errno == EACCES) - return mcde_sys_fail(MCDE_SYS_EPERM, "Changing the touchpad " - "needs the administrator."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NB_TOUCHPAD_EPERM, "Changing the touchpad needs the administrator.")); if (errno == ENOENT) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no " - "touchpad settings."); - return mcde_sys_fail(MCDE_SYS_EFAIL, "The touchpad setting %s could " - "not be written (%s).", name, strerror(errno)); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_NO_TOUCHPAD, "This system has no touchpad settings.")); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_TOUCHPAD_FAIL, "The touchpad setting %s could not be written (%s)."), name, strerror(errno)); } int @@ -335,8 +330,7 @@ mcde_sys_touchpad_get(McdeSysTouchpad *t) return MCDE_SYS_EINVAL; if (!SysctlReadInt("hw.synaptics.tap_to_click", &tap) || !SysctlReadInt("hw.synaptics.two_fingers_emulation", &fingers)) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no " - "touchpad settings."); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_NO_TOUCHPAD, "This system has no touchpad settings.")); (void) SysctlReadInt("hw.synaptics.vert_scroll_percent", &vert); (void) SysctlReadInt("hw.synaptics.horizontal_scroll_percent", &horiz); @@ -506,8 +500,7 @@ mcde_sys_wifi_scan(const char *ifname, McdeSysWifi *nets, size_t max) /* ifconfig -v IF list scan: "SSID BSSID CHAN RATE S:N INT CAPS", * the SSID padded; the interface must be up (root) */ if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can look for Wi-Fi networks while none is joined."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NB_WIFI_SCAN_EPERM, "Only the administrator can look for Wi-Fi networks while none is joined.")); argv[0] = ifconfigp; argv[1] = (char *) ifname; argv[2] = "up"; @@ -566,11 +559,11 @@ KeySet(const char *file, const char *var, const char *value) int fd, done = 0; if (stat(file, &st) != 0 || (from = fopen(file, "r")) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s.", file); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_READ, "Cannot read %s."), file); (void)snprintf(tmp, sizeof tmp, "%s.mcdeXXXXXX", file); if ((fd = mkstemp(tmp)) < 0 || (to = fdopen(fd, "w")) == NULL) { fclose(from); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write beside %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_WRITE_BESIDE, "Cannot write beside %s."), file); } while (fgets(line, sizeof line, from) != NULL) { @@ -588,7 +581,7 @@ KeySet(const char *file, const char *var, const char *value) if (fchmod(fd, st.st_mode & 07777) != 0 || fclose(to) != 0 || rename(tmp, file) != 0) { unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", file); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), file); } return MCDE_SYS_OK; } @@ -611,15 +604,12 @@ mcde_sys_wifi_join(const char *ifname, const char *ssid, char *argv[4]; if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can join a Wi-Fi network."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_LX_WIFI_EPERM, "Only the administrator can join a Wi-Fi network.")); if (!mcde_sys_wifi_config_ok(ifname, ssid, passphrase)) - return mcde_sys_fail(MCDE_SYS_EINVAL, "The network name or the " - "password cannot be used (a password has 8 to 63 " - "characters, no quotes)."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NB_WIFI_BAD, "The network name or the password cannot be used (a password has 8 to 63 characters, no quotes).")); fresh = stat(WPA_CONF, &st) != 0; if ((fp = fopen(WPA_CONF, "a")) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), WPA_CONF); (void) fchmod(fileno(fp), 0600); /* the example's head (share/examples/wpa_supplicant): wpa_cli for @@ -635,7 +625,7 @@ mcde_sys_wifi_join(const char *ifname, const char *ssid, fprintf(fp, "\tkey_mgmt=NONE\n"); fprintf(fp, "\tscan_ssid=1\n}\n"); if (fclose(fp) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), WPA_CONF); /* sysinst's lines (net.c:1203-1209) */ snprintf(flags, sizeof flags, @@ -911,7 +901,7 @@ ReplaceBlock(const char *file, const char *ifname, const char *block) if (stat(file, &st) == 0) mode = st.st_mode & 07777; if ((fd = mkstemp(tmp)) < 0 || (to = fdopen(fd, "w")) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write beside %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_WRITE_BESIDE, "Cannot write beside %s."), file); if ((from = fopen(file, "r")) != NULL) { while (fgets(line, sizeof line, from) != NULL) { @@ -932,7 +922,7 @@ ReplaceBlock(const char *file, const char *ifname, const char *block) fprintf(to, "%s%s%s", begin, block, end); if (fchmod(fd, mode) != 0 || fclose(to) != 0 || rename(tmp, file) != 0) { unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", file); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), file); } return MCDE_SYS_OK; } @@ -950,7 +940,7 @@ StripIfconfig(const char *ifname, int *removed) snprintf(path, sizeof path, "/etc/ifconfig.%s", ifname); snprintf(tmp, sizeof tmp, "%s.mcdeXXXXXX", path); if ((fd = mkstemp(tmp)) < 0 || (to = fdopen(fd, "w")) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write beside %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_WRITE_BESIDE, "Cannot write beside %s."), path); if ((from = fopen(path, "r")) != NULL) { while (fgets(line, sizeof line, from) != NULL) { @@ -974,7 +964,7 @@ StripIfconfig(const char *ifname, int *removed) fputs("up\n", to); if (fchmod(fd, 0644) != 0 || fclose(to) != 0 || rename(tmp, path) != 0) { unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", path); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), path); } return MCDE_SYS_OK; } @@ -1029,7 +1019,7 @@ mcde_sys_net_configure_backend(const char *ifname, const McdeSysNetConfig *c) } #undef ADD if (at >= sizeof block) - return mcde_sys_fail(MCDE_SYS_EINVAL, "Too many settings."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NB_TOO_MANY, "Too many settings.")); /* "interface IF" alone says nothing: no block then */ if (strchr(strchr(block, '\n') + 1, '\n') == NULL) block[0] = '\0'; @@ -1070,8 +1060,7 @@ mcde_sys_net_configure_backend(const char *ifname, const McdeSysNetConfig *c) return mcde_sys_net_renew(ifname); argv[1] = "start"; if (mcde_sys_run(argv) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_EFAIL, "dhcpcd did not start " - "(/etc/rc.d/dhcpcd start)."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_DHCP_START, "dhcpcd did not start (/etc/rc.d/dhcpcd start).")); return MCDE_SYS_OK; } @@ -1081,14 +1070,11 @@ mcde_sys_net_renew(const char *ifname) char *argv[] = { dhcpcdp, "-n", (char *) ifname, NULL }; if (!mcde_sys_net_ifname_ok(ifname)) - return mcde_sys_fail(MCDE_SYS_EINVAL, "There is no network " - "card of that name."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_LX_NO_CARD, "There is no network card of that name.")); if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can renew the lease: click the lock first."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NB_RENEW_EPERM, "Only the administrator can renew the lease: click the lock first.")); if (mcde_sys_run(argv) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_EFAIL, "dhcpcd did not renew the " - "lease of %s.", ifname); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_DHCP_RENEW, "dhcpcd did not renew the lease of %s."), ifname); return MCDE_SYS_OK; } @@ -1116,17 +1102,14 @@ mcde_sys_user_set_password(const char *login, const char *password) char *argv[] = { usermod, "-p", NULL, NULL, NULL }; if (getpwnam(login) == NULL) - return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no account " - "\"%s\".", login); + return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_USR_NOT_FOUND, "There is no account \"%s\"."), login); if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can set a password: unlock first."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_LX_PW_EPERM, "Only the administrator can set a password: unlock first.")); if (pw_gensalt(salt, sizeof salt, "argon2id", NULL) != 0 && pw_gensalt(salt, sizeof salt, "blowfish", "10") != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "No salt for the password."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_SALT, "No salt for the password.")); if ((hash = crypt(password, salt)) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The password cannot be " - "hashed."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_HASH_FAIL, "The password cannot be hashed.")); argv[2] = hash; argv[3] = (char *) login; return mcde_sys_run(argv); @@ -1146,11 +1129,11 @@ RemoveFromGroup(const char *login, const char *group) int fd, changed = 0; if (stat(_PATH_GROUP, &st) != 0 || (from = fopen(_PATH_GROUP, "r")) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_READ, "Cannot read %s."), _PATH_GROUP); if ((fd = mkstemp(tmp)) < 0 || (to = fdopen(fd, "w")) == NULL) { fclose(from); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write beside %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_WRITE_BESIDE, "Cannot write beside %s."), _PATH_GROUP); } while (fgets(line, sizeof line, from) != NULL) { @@ -1188,7 +1171,7 @@ RemoveFromGroup(const char *login, const char *group) fchown(fd, st.st_uid, st.st_gid) != 0 || fclose(to) != 0 || rename(tmp, _PATH_GROUP) != 0) { unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_SHR_WRITE, "Cannot write %s."), _PATH_GROUP); } (void) changed; @@ -1201,11 +1184,9 @@ mcde_sys_user_set_admin(const char *login, int admin) char *argv[] = { usermod, "-G", "wheel", NULL, NULL }; if (getpwnam(login) == NULL) - return mcde_sys_fail(MCDE_SYS_ENOENT, "There is no account " - "\"%s\".", login); + return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_USR_NOT_FOUND, "There is no account \"%s\"."), login); if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can change that: unlock first."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_LX_CHANGE_EPERM, "Only the administrator can change that: unlock first.")); if (!admin) return RemoveFromGroup(login, "wheel"); if (mcde_sys_user_is_admin(login)) @@ -1267,8 +1248,7 @@ mcde_sys_update_check(McdeSysUpdate *u) } snprintf(url, sizeof url, "%s/RELEASE", u->source); if (mcde_sys_capture(argv, out, sizeof out) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The update source does " - "not answer: %s", u->source); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_SOURCE_NO_ANSWER, "The update source does not answer: %s"), u->source); /* "Makronix 0.99.10 NAME/amd64 (based on NetBSD ...)" */ if ((e = strchr(out, '\n')) != NULL) *e = '\0'; @@ -1299,25 +1279,21 @@ mcde_sys_update_apply(void) int n = 0, r; if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator can " - "update the computer: unlock first."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_LX_UPDATE_EPERM, "Only the administrator can update the computer: unlock first.")); if (!UpdateSource(url, sizeof url)) - return mcde_sys_fail(MCDE_SYS_ENOENT, "No update source is set " - "(%s).", updateConf); + return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_NB_NO_SOURCE, "No update source is set (%s)."), updateConf); /* sysupgrade unpacks the sets as root and checks nothing, pkg_add * -uu trusts the packages it is given: only a source nobody on the * way can change (t0078, docs/reference/update-verification.txt) */ if (!mcde_sys_update_source_ok(url)) - return mcde_sys_fail(MCDE_SYS_EINVAL, "The update source is " - "not allowed: it must be a directory, file:/// or https:// " - "(%s).", updateConf); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NB_SOURCE_BAD, "The update source is not allowed: it must be a directory, file:/// or https:// (%s)."), updateConf); if ((r = mcde_sys_run(sysupgrade)) != MCDE_SYS_OK) return r; /* the installed packages, by name ("vim-9.2.1202 comment" -> vim), * updated from the packages of the release: pkg_add -uu */ snprintf(pkgpath, sizeof pkgpath, "%s/packages/All", url); if (setenv("PKG_PATH", pkgpath, 1) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "No PKG_PATH."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_PKGPATH, "No PKG_PATH.")); if ((r = mcde_sys_capture(pkginfo, out, sizeof out)) != MCDE_SYS_OK) return r; argv[n++] = "/usr/sbin/pkg_add"; @@ -1406,31 +1382,28 @@ mcde_sys_processes_backend(McdeSysProcess **out, size_t *n) mib[5] = 0; if (sysctl(mib, 6, NULL, &size, NULL, 0) != 0) { free(kp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot count the " - "processes: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_PROC_COUNT, "Cannot count the processes: %s."), strerror(errno)); } size += 16 * sizeof *kp; /* processes that start meanwhile */ free(kp); if ((kp = malloc(size)) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); mib[5] = (int) (size / sizeof *kp); if (sysctl(mib, 6, kp, &size, NULL, 0) == 0) break; if (errno != ENOMEM) { free(kp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot list the " - "processes: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_PROC_LIST, "Cannot list the processes: %s."), strerror(errno)); } } if (tries == 5) { free(kp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "The list of processes " - "changes too fast."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_PROC_FAST, "The list of processes changes too fast.")); } cnt = size / sizeof *kp; if ((v = malloc((cnt > 0 ? cnt : 1) * sizeof *v)) == NULL) { free(kp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); } for (i = 0; i < cnt; i++) { const struct kinfo_proc2 *k = &kp[i]; @@ -1501,10 +1474,8 @@ mcde_sys_file_comment_get_backend(const char *path, char *buf, size_t len) if (errno == ENOATTR) return MCDE_SYS_OK; if (errno == ENOTSUP || errno == EOPNOTSUPP) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This file system " - "keeps no comments."); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read the comment: " - "%s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_LX_NO_COMMENTS, "This file system keeps no comments.")); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_LX_COMMENT_READ, "Cannot read the comment: %s."), strerror(errno)); } buf[n] = '\0'; return MCDE_SYS_OK; @@ -1517,17 +1488,14 @@ mcde_sys_file_comment_set_backend(const char *path, const char *text) if (extattr_delete_file(path, EXTATTR_NAMESPACE_USER, "mcde.comment") != 0 && errno != ENOATTR && errno != ENOTSUP) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot remove the " - "comment: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_LX_COMMENT_REMOVE, "Cannot remove the comment: %s."), strerror(errno)); return MCDE_SYS_OK; } if (extattr_set_file(path, EXTATTR_NAMESPACE_USER, "mcde.comment", text, strlen(text)) < 0) { if (errno == ENOTSUP || errno == EOPNOTSUPP) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This file system " - "keeps no comments."); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write the comment: " - "%s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_LX_NO_COMMENTS, "This file system keeps no comments.")); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_LX_COMMENT_WRITE, "Cannot write the comment: %s."), strerror(errno)); } return MCDE_SYS_OK; } @@ -1540,7 +1508,7 @@ mcde_sys_file_locked_get_backend(const char *path, int *locked) *locked = 0; if (stat(path, &st) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s: %s.", path, + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_READ2, "Cannot read %s: %s."), path, strerror(errno)); *locked = (st.st_flags & UF_IMMUTABLE) != 0; return MCDE_SYS_OK; @@ -1552,12 +1520,14 @@ mcde_sys_file_locked_set_backend(const char *path, int locked) struct stat st; if (stat(path, &st) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot read %s: %s.", path, + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_READ2, "Cannot read %s: %s."), path, strerror(errno)); if (chflags(path, locked ? (st.st_flags | UF_IMMUTABLE) : (st.st_flags & ~UF_IMMUTABLE)) != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Cannot %s the lock: %s.", - locked ? "set" : "clear", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EPERM, locked ? + mcde_sys_msg(MSG_LX_LOCK_SET, "Cannot set the lock: %s.") : + mcde_sys_msg(MSG_LX_LOCK_CLEAR, "Cannot clear the lock: %s."), + strerror(errno)); return MCDE_SYS_OK; } @@ -1569,8 +1539,7 @@ mcde_sys_hostname_set_backend(const char *name) char *argv[3]; if ((fp = fopen("/etc/myname", "w")) == NULL) - return mcde_sys_fail(MCDE_SYS_EPERM, "Cannot write /etc/myname: " - "%s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NB_MYNAME, "Cannot write /etc/myname: %s."), strerror(errno)); fprintf(fp, "%s\n", name); fclose(fp); argv[0] = (char *) "/bin/hostname"; @@ -1641,12 +1610,11 @@ NtpConfSet(const char *server) if ((in = fopen(NTP_CONF, "r")) == NULL) in = NULL; if ((fd = mkstemp(tmp)) < 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot make a new ntp.conf: " - "%s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NTP_TMP, "Cannot make a new ntp.conf: %s."), strerror(errno)); if ((out = fdopen(fd, "w")) == NULL) { close(fd); unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot write ntp.conf."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NTP_WRITE, "Cannot write ntp.conf.")); } if (in != NULL) { while (fgets(line, sizeof line, in) != NULL) { @@ -1668,8 +1636,7 @@ NtpConfSet(const char *server) if (fclose(out) != 0 || chmod(tmp, 0644) != 0 || rename(tmp, NTP_CONF) != 0) { unlink(tmp); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Cannot replace ntp.conf: " - "%s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NTP_REPLACE, "Cannot replace ntp.conf: %s."), strerror(errno)); } (void) have; return MCDE_SYS_OK; @@ -1766,7 +1733,7 @@ mcde_sys_service_state(McdeSysShareService s, McdeSysServiceState *st) memset(st, 0, sizeof *st); if ((int) s < 0 || s >= MCDE_SHARE_COUNT) - return mcde_sys_fail(MCDE_SYS_EINVAL, "No such service."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_LX_NO_SERVICE, "No such service.")); st->installed = access(services[s].binary, X_OK) == 0; if (!st->installed) return MCDE_SYS_OK; @@ -1788,13 +1755,11 @@ mcde_sys_service_set(McdeSysShareService s, int on) int i, r = MCDE_SYS_OK; if ((int) s < 0 || s >= MCDE_SHARE_COUNT) - return mcde_sys_fail(MCDE_SYS_EINVAL, "No such service."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_LX_NO_SERVICE, "No such service.")); if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Only the administrator " - "can switch a service."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_LX_SERVICE_EPERM, "Only the administrator can switch a service.")); if (access(services[s].binary, X_OK) != 0) - return mcde_sys_fail(MCDE_SYS_ENOENT, "The server is not " - "installed (%s).", services[s].binary); + return mcde_sys_fail(MCDE_SYS_ENOENT, mcde_sys_msg(MSG_NB_SERVER_MISSING, "The server is not installed (%s)."), services[s].binary); for (i = 0; i < 5 && services[s].vars[i] != NULL; i++) { /* rpcbind: on with NFS, left as it is when NFS goes off */ if (!on && strcmp(services[s].vars[i], "rpcbind") == 0) @@ -1818,8 +1783,7 @@ mcde_sys_service_set(McdeSysShareService s, int on) MCDE_SYS_OK && RcScript(services[s].scripts[i], "start") != MCDE_SYS_OK) - r = mcde_sys_fail(MCDE_SYS_EFAIL, "%s did not " - "start.", services[s].scripts[i]); + r = mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_DID_NOT_START, "%s did not start."), services[s].scripts[i]); } } else { for (i = 4; i >= 0; i--) @@ -1960,9 +1924,7 @@ mcde_sys_net_browse(McdeSysNetHost *hosts, size_t max, int timeout_ms) } if (started == 0) { browse = NULL; - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "The computers on the " - "network cannot be looked for: mdnsd does not run " - "(mdnsd=YES in rc.conf)."); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_NO_MDNSD, "The computers on the network cannot be looked for: mdnsd does not run (mdnsd=YES in rc.conf).")); } gettimeofday(&end, NULL); end.tv_sec += timeout_ms / 1000; @@ -2032,15 +1994,13 @@ mcde_sys_swap_encrypt_get(int *on) char buf[32], *argv[4]; if (on == NULL) - return mcde_sys_fail(MCDE_SYS_EINVAL, "There is no place for the " - "value."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NB_NO_VALUE_ROOM, "There is no place for the value.")); argv[0] = (char *) "/sbin/sysctl"; argv[1] = (char *) "-n"; argv[2] = (char *) "vm.swap_encrypt"; argv[3] = NULL; if (mcde_sys_capture(argv, buf, sizeof buf) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "The system does not say " - "whether memory is encrypted in swap."); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_SWAP_UNKNOWN, "The system does not say whether memory is encrypted in swap.")); *on = atoi(buf) != 0; return MCDE_SYS_OK; } @@ -2051,16 +2011,14 @@ mcde_sys_swap_encrypt_set(int on) char val[32], *argv[4]; if (geteuid() != 0) - return mcde_sys_fail(MCDE_SYS_EPERM, "Secure virtual memory " - "needs the administrator."); + return mcde_sys_fail(MCDE_SYS_EPERM, mcde_sys_msg(MSG_NB_SWAP_EPERM, "Secure virtual memory needs the administrator.")); (void)snprintf(val, sizeof val, "vm.swap_encrypt=%d", on ? 1 : 0); argv[0] = (char *) "/sbin/sysctl"; argv[1] = (char *) "-w"; argv[2] = val; argv[3] = NULL; if (mcde_sys_run(argv) != MCDE_SYS_OK) - return mcde_sys_fail(MCDE_SYS_EFAIL, "sysctl(8) did not take " - "vm.swap_encrypt."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_SWAP_SYSCTL, "sysctl(8) did not take vm.swap_encrypt.")); /* and after the next start: /etc/sysctl.conf */ return KeySet(SYSCTL_CONF, "vm.swap_encrypt", on ? "1" : "0"); } @@ -2073,8 +2031,7 @@ mcde_sys_cgd_volumes(char (*vols)[MCDE_SYS_CGD_ENTRY_LEN], size_t max) int n = 0; if (fp == NULL) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no " - "cgd(4) configuration (%s).", CGD_CONF); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_NO_CGD, "This system has no cgd(4) configuration (%s)."), CGD_CONF); while (vols != NULL && n < (int)max && fgets(line, sizeof line, fp) != NULL) { char *p = line; @@ -2097,11 +2054,9 @@ mcde_sys_firewall_get(int *on, char *conf, size_t len) char v[32]; if (on == NULL || conf == NULL) - return mcde_sys_fail(MCDE_SYS_EINVAL, "There is no place for " - "the state."); + return mcde_sys_fail(MCDE_SYS_EINVAL, mcde_sys_msg(MSG_NB_NO_STATE_ROOM, "There is no place for the state.")); if (access("/sbin/npfctl", X_OK) != 0) - return mcde_sys_fail(MCDE_SYS_ENOTSUP, "This system has no " - "npf(7) (/sbin/npfctl)."); + return mcde_sys_fail(MCDE_SYS_ENOTSUP, mcde_sys_msg(MSG_NB_NO_NPF, "This system has no npf(7) (/sbin/npfctl).")); (void)snprintf(conf, len, "%s", NPF_CONF); /* rc.conf's npf=YES starts it at boot (rc.d/npf reads it) */ *on = RcConfGet("npf", v, sizeof v) && strcasecmp(v, "YES") == 0; @@ -2127,13 +2082,12 @@ mcde_sys_cpu_times_backend(McdeSysCpu **out, size_t *n) mib[0] = CTL_HW; mib[1] = HW_NCPU; if (sysctl(mib, 2, &ncpu, &len, NULL, 0) != 0 || ncpu < 1) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no " - "number of processors."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_NCPU, "The system tells no number of processors.")); len = (size_t) ncpu * CPUSTATES * sizeof(uint64_t); if ((t = malloc(len)) == NULL || (v = calloc((size_t) ncpu, sizeof *v)) == NULL) { free(t); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); } mib[0] = CTL_KERN; mib[1] = KERN_CP_TIME; @@ -2141,8 +2095,7 @@ mcde_sys_cpu_times_backend(McdeSysCpu **out, size_t *n) len != (size_t) ncpu * CPUSTATES * sizeof(uint64_t)) { free(t); free(v); - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no CPU " - "times: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_CPUTIMES, "The system tells no CPU times: %s."), strerror(errno)); } for (i = 0; i < ncpu; i++) { v[i].user = t[i * CPUSTATES + CP_USER]; @@ -2168,8 +2121,7 @@ mcde_sys_memory_backend(McdeSysMemory *m) mib[0] = CTL_VM; mib[1] = VM_UVMEXP2; if (sysctl(mib, 2, &u, &len, NULL, 0) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no " - "memory: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_MEMORY, "The system tells no memory: %s."), strerror(errno)); ps = (unsigned long long) u.pagesize; m->total = (unsigned long long) u.npages * ps; m->free = (unsigned long long) u.free * ps; @@ -2195,8 +2147,7 @@ mcde_sys_net_io_backend(McdeSysNetIo **out, size_t *n) size_t cnt = 0, cap = 0; if (getifaddrs(&ifap) != 0) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no " - "interfaces: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_IFACES, "The system tells no interfaces: %s."), strerror(errno)); for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { const struct if_data *d; @@ -2209,8 +2160,7 @@ mcde_sys_net_io_backend(McdeSysNetIo **out, size_t *n) if ((nv = realloc(v, cap * sizeof *v)) == NULL) { free(v); freeifaddrs(ifap); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of " - "memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); } v = nv; } @@ -2240,23 +2190,21 @@ mcde_sys_disk_io_backend(McdeSysDiskIo **out, size_t *n) mib[1] = HW_IOSTATS; mib[2] = sizeof(struct io_sysctl); if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1) - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no disk " - "counters: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_DISKCOUNTERS, "The system tells no disk counters: %s."), strerror(errno)); if (size == 0) return MCDE_SYS_OK; /* a drive may arrive between the two calls: room for a few more */ size += 4 * sizeof(struct io_sysctl); if ((drives = malloc(size)) == NULL) - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); if (sysctl(mib, 3, drives, &size, NULL, 0) == -1) { free(drives); - return mcde_sys_fail(MCDE_SYS_EFAIL, "The system tells no disk " - "counters: %s.", strerror(errno)); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_NO_DISKCOUNTERS, "The system tells no disk counters: %s."), strerror(errno)); } count = size / sizeof(struct io_sysctl); if ((v = calloc(count != 0 ? count : 1, sizeof *v)) == NULL) { free(drives); - return mcde_sys_fail(MCDE_SYS_EFAIL, "Out of memory."); + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NO_MEMORY, "Out of memory.")); } for (i = 0; i < count; i++) { if (drives[i].type != IOSTAT_DISK) @@ -2288,7 +2236,7 @@ mcde_sys_disk_event_read_backend(int fd, char *buf, size_t len) if (prop_dictionary_recv_ioctl(fd, DRVGETEVENT, &ev) != 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) return 0; - return mcde_sys_fail(MCDE_SYS_EFAIL, "DRVGETEVENT: %s.", + return mcde_sys_fail(MCDE_SYS_EFAIL, mcde_sys_msg(MSG_NB_DRVGETEVENT, "DRVGETEVENT: %s."), strerror(errno)); } (void) prop_dictionary_get_string(ev, "event", &event); diff --git a/lib/McdeSys/private.h b/lib/McdeSys/private.h index f21d4c0a..81e65fbc 100644 --- a/lib/McdeSys/private.h +++ b/lib/McdeSys/private.h @@ -170,6 +170,50 @@ int mcde_sys_fail(int status, const char *fmt, ...); #define MSG_LX_NETDEV_READ 141 #define MSG_LX_DISKSTATS_READ 142 #define MSG_LX_EVENT_READ 143 +/* netbsd.c: the NetBSD backend's sentences */ +#define MSG_NB_DID_NOT_START 144 +#define MSG_NB_PROC_COUNT 145 +#define MSG_NB_PROC_LIST 146 +#define MSG_NB_NTP_TMP 147 +#define MSG_NB_READ 148 +#define MSG_NB_READ2 149 +#define MSG_NB_NTP_REPLACE 150 +#define MSG_NB_MYNAME 151 +#define MSG_NB_WRITE_BESIDE 152 +#define MSG_NB_NTP_WRITE 153 +#define MSG_NB_TOUCHPAD_EPERM 154 +#define MSG_NB_DRVGETEVENT 155 +#define MSG_NB_NO_PKGPATH 156 +#define MSG_NB_NO_SALT 157 +#define MSG_NB_NO_SOURCE 158 +#define MSG_NB_WIFI_SCAN_EPERM 159 +#define MSG_NB_RENEW_EPERM 160 +#define MSG_NB_SWAP_EPERM 161 +#define MSG_NB_NO_MDNSD 162 +#define MSG_NB_PROC_FAST 163 +#define MSG_NB_MIXER_NO_MASTER 164 +#define MSG_NB_WIFI_BAD 165 +#define MSG_NB_HASH_FAIL 166 +#define MSG_NB_SERVER_MISSING 167 +#define MSG_NB_SWAP_UNKNOWN 168 +#define MSG_NB_NO_CPUTIMES 169 +#define MSG_NB_NO_DISKCOUNTERS 170 +#define MSG_NB_NO_IFACES 171 +#define MSG_NB_NO_MEMORY 172 +#define MSG_NB_NO_NCPU 173 +#define MSG_NB_TOUCHPAD_FAIL 174 +#define MSG_NB_SOURCE_NO_ANSWER 175 +#define MSG_NB_SOURCE_BAD 176 +#define MSG_NB_NO_BLUETOOTH 177 +#define MSG_NB_NO_STATE_ROOM 178 +#define MSG_NB_NO_VALUE_ROOM 179 +#define MSG_NB_NO_CGD 180 +#define MSG_NB_NO_NPF 181 +#define MSG_NB_NO_TOUCHPAD 182 +#define MSG_NB_TOO_MANY 183 +#define MSG_NB_DHCP_RENEW 184 +#define MSG_NB_DHCP_START 185 +#define MSG_NB_SWAP_SYSCTL 186 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 */ diff --git a/programs/localized/de_DE.UTF-8/msg/mcdesys.msg b/programs/localized/de_DE.UTF-8/msg/mcdesys.msg index fed42a37..34113751 100644 --- a/programs/localized/de_DE.UTF-8/msg/mcdesys.msg +++ b/programs/localized/de_DE.UTF-8/msg/mcdesys.msg @@ -144,3 +144,46 @@ $set 1 141 /proc/net/dev kann nicht gelesen werden: %s. 142 /proc/diskstats kann nicht gelesen werden: %s. 143 Der Ereignis-Socket des Kernels kann nicht gelesen werden: %s. +144 %s wurde nicht gestartet. +145 Die Prozesse können nicht gezählt werden: %s. +146 Die Prozesse können nicht aufgelistet werden: %s. +147 Eine neue ntp.conf kann nicht erzeugt werden: %s. +148 %s kann nicht gelesen werden. +149 %s kann nicht gelesen werden: %s. +150 ntp.conf kann nicht ersetzt werden: %s. +151 /etc/myname kann nicht geschrieben werden: %s. +152 Neben %s kann nicht geschrieben werden. +153 ntp.conf kann nicht geschrieben werden. +154 Das Touchpad zu ändern braucht den Administrator. +155 DRVGETEVENT: %s. +156 Kein PKG_PATH. +157 Kein Salt für das Passwort. +158 Es ist keine Update-Quelle eingerichtet (%s). +159 Nur der Administrator kann nach WLANs suchen, solange keins verbunden ist. +160 Nur der Administrator kann die Lease erneuern: zuerst entsperren. +161 Verschlüsselter Auslagerungsspeicher braucht den Administrator. +162 Die Rechner im Netz können nicht gesucht werden: mdnsd läuft nicht (mdnsd=YES in rc.conf). +163 Die Prozessliste ändert sich zu schnell. +164 Der Mixer hat kein outputs.master. +165 Netzwerkname oder Passwort sind nicht verwendbar (ein Passwort hat 8 bis 63 Zeichen, keine Anführungszeichen). +166 Das Passwort kann nicht gehasht werden. +167 Der Server ist nicht installiert (%s). +168 Das System sagt nicht, ob der Auslagerungsspeicher verschlüsselt ist. +169 Das System nennt keine CPU-Zeiten: %s. +170 Das System nennt keine Plattenzähler: %s. +171 Das System nennt keine Schnittstellen: %s. +172 Das System nennt keinen Speicher: %s. +173 Das System nennt keine Prozessorzahl. +174 Die Touchpad-Einstellung %s konnte nicht geschrieben werden (%s). +175 Die Update-Quelle antwortet nicht: %s +176 Die Update-Quelle ist nicht erlaubt: ein Verzeichnis, file:/// oder https:// (%s). +177 Es gibt keinen Bluetooth-Controller. +178 Kein Platz für den Zustand. +179 Kein Platz für den Wert. +180 Dieses System hat keine cgd(4)-Konfiguration (%s). +181 Dieses System hat kein npf(7) (/sbin/npfctl). +182 Dieses System hat keine Touchpad-Einstellungen. +183 Zu viele Einstellungen. +184 dhcpcd hat die Lease von %s nicht erneuert. +185 dhcpcd wurde nicht gestartet (/etc/rc.d/dhcpcd start). +186 sysctl(8) hat vm.swap_encrypt nicht angenommen.