Translate help / usage strings.

This commit is contained in:
Todd C. Miller
2011-05-19 16:07:14 -04:00
parent d2384297a0
commit 67cc4ff025
6 changed files with 107 additions and 84 deletions

View File

@@ -1546,7 +1546,10 @@ sudo_ldap_display_entry_long(LDAP *ld, LDAPMessage *entry, struct lbuf *lbuf)
/* extract the dn, only show the first rdn */ /* extract the dn, only show the first rdn */
rdn = sudo_ldap_get_first_rdn(ld, entry); rdn = sudo_ldap_get_first_rdn(ld, entry);
lbuf_append(lbuf, "\nLDAP Role: ", rdn ? rdn : "UNKNOWN", "\n", NULL); if (rdn != NULL)
lbuf_append(lbuf, _("\nLDAP Role: "), rdn, "\n", NULL);
else
lbuf_append(lbuf, _("\nLDAP Role: UNKNOWN\n"), NULL);
if (rdn) if (rdn)
ldap_memfree(rdn); ldap_memfree(rdn);

View File

@@ -371,9 +371,9 @@ sudo_file_display_priv_long(struct passwd *pw, struct userspec *us,
tags.nopasswd = UNSPEC; tags.nopasswd = UNSPEC;
tags.log_input = UNSPEC; tags.log_input = UNSPEC;
tags.log_output = UNSPEC; tags.log_output = UNSPEC;
lbuf_append(lbuf, "\nSudoers entry:\n", NULL); lbuf_append(lbuf, _("\nSudoers entry:\n"), NULL);
tq_foreach_fwd(&priv->cmndlist, cs) { tq_foreach_fwd(&priv->cmndlist, cs) {
lbuf_append(lbuf, " RunAsUsers: ", NULL); lbuf_append(lbuf, " ", _("RunAsUsers: "), NULL);
if (!tq_empty(&cs->runasuserlist)) { if (!tq_empty(&cs->runasuserlist)) {
tq_foreach_fwd(&cs->runasuserlist, m) { tq_foreach_fwd(&cs->runasuserlist, m) {
if (m != tq_first(&cs->runasuserlist)) if (m != tq_first(&cs->runasuserlist))
@@ -388,7 +388,7 @@ sudo_file_display_priv_long(struct passwd *pw, struct userspec *us,
} }
lbuf_append(lbuf, "\n", NULL); lbuf_append(lbuf, "\n", NULL);
if (!tq_empty(&cs->runasgrouplist)) { if (!tq_empty(&cs->runasgrouplist)) {
lbuf_append(lbuf, " RunAsGroups: ", NULL); lbuf_append(lbuf, " ", _("RunAsGroups: "), NULL);
tq_foreach_fwd(&cs->runasgrouplist, m) { tq_foreach_fwd(&cs->runasgrouplist, m) {
if (m != tq_first(&cs->runasgrouplist)) if (m != tq_first(&cs->runasgrouplist))
lbuf_append(lbuf, ", ", NULL); lbuf_append(lbuf, ", ", NULL);
@@ -397,7 +397,7 @@ sudo_file_display_priv_long(struct passwd *pw, struct userspec *us,
} }
lbuf_append(lbuf, "\n", NULL); lbuf_append(lbuf, "\n", NULL);
} }
lbuf_append(lbuf, " Commands:\n\t", NULL); lbuf_append(lbuf, " ", _("Commands:\n\t"), NULL);
sudo_file_append_cmnd(cs, &tags, lbuf); sudo_file_append_cmnd(cs, &tags, lbuf);
lbuf_append(lbuf, "\n", NULL); lbuf_append(lbuf, "\n", NULL);
nfound++; nfound++;

View File

@@ -263,8 +263,8 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
lbuf_init(&privs, output, 4, NULL, sudo_user.cols); lbuf_init(&privs, output, 4, NULL, sudo_user.cols);
/* Display defaults from all sources. */ /* Display defaults from all sources. */
lbuf_append(&defs, "Matching Defaults entries for ", pw->pw_name, lbuf_append(&defs, _("Matching Defaults entries for "), pw->pw_name,
" on this host:\n", NULL); _(" on this host:\n"), NULL);
count = 0; count = 0;
tq_foreach_fwd(snl, nss) { tq_foreach_fwd(snl, nss) {
count += nss->display_defaults(nss, pw, &defs); count += nss->display_defaults(nss, pw, &defs);
@@ -276,8 +276,8 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
/* Display Runas and Cmnd-specific defaults from all sources. */ /* Display Runas and Cmnd-specific defaults from all sources. */
olen = defs.len; olen = defs.len;
lbuf_append(&defs, "Runas and Command-specific defaults for ", pw->pw_name, lbuf_append(&defs, _("Runas and Command-specific defaults for "),
":\n", NULL); pw->pw_name, ":\n", NULL);
count = 0; count = 0;
tq_foreach_fwd(snl, nss) { tq_foreach_fwd(snl, nss) {
count += nss->display_bound_defaults(nss, pw, &defs); count += nss->display_bound_defaults(nss, pw, &defs);
@@ -288,8 +288,8 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
defs.len = olen; defs.len = olen;
/* Display privileges from all sources. */ /* Display privileges from all sources. */
lbuf_append(&privs, "User ", pw->pw_name, lbuf_append(&privs, _("User "), pw->pw_name,
" may run the following commands on this host:\n", NULL); _(" may run the following commands on this host:\n"), NULL);
count = 0; count = 0;
tq_foreach_fwd(snl, nss) { tq_foreach_fwd(snl, nss) {
count += nss->display_privs(nss, pw, &privs); count += nss->display_privs(nss, pw, &privs);
@@ -298,7 +298,7 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
lbuf_print(&defs); lbuf_print(&defs);
lbuf_print(&privs); lbuf_print(&privs);
} else { } else {
printf("User %s is not allowed to run sudo on %s.\n", pw->pw_name, printf(_("User %s is not allowed to run sudo on %s.\n"), pw->pw_name,
user_shost); user_shost);
} }

View File

@@ -288,7 +288,7 @@ main(int argc, char *argv[])
errorx(1, _("invalid speed factor: %s"), optarg); errorx(1, _("invalid speed factor: %s"), optarg);
break; break;
case 'V': case 'V':
(void) printf("%s version %s\n", getprogname(), PACKAGE_VERSION); (void) printf(_("%s version %s\n"), getprogname(), PACKAGE_VERSION);
exit(0); exit(0);
default: default:
usage(1); usage(1);
@@ -345,7 +345,7 @@ main(int argc, char *argv[])
getline(&cp, &len, lfile) == -1) { getline(&cp, &len, lfile) == -1) {
errorx(1, _("invalid log file %s"), path); errorx(1, _("invalid log file %s"), path);
} }
printf("Replaying sudo session: %s", cp); printf(_("Replaying sudo session: %s"), cp);
free(cp); free(cp);
fclose(lfile); fclose(lfile);
@@ -939,10 +939,10 @@ static void
usage(int fatal) usage(int fatal)
{ {
fprintf(fatal ? stderr : stdout, fprintf(fatal ? stderr : stdout,
"usage: %s [-h] [-d directory] [-m max_wait] [-s speed_factor] ID\n", _("usage: %s [-h] [-d directory] [-m max_wait] [-s speed_factor] ID\n"),
getprogname()); getprogname());
fprintf(fatal ? stderr : stdout, fprintf(fatal ? stderr : stdout,
"usage: %s [-h] [-d directory] -l [search expression]\n", _("usage: %s [-h] [-d directory] -l [search expression]\n"),
getprogname()); getprogname());
if (fatal) if (fatal)
exit(1); exit(1);
@@ -951,16 +951,16 @@ usage(int fatal)
static void static void
help(void) help(void)
{ {
(void) printf("%s - replay sudo session logs\n\n", getprogname()); (void) printf(_("%s - replay sudo session logs\n\n"), getprogname());
usage(0); usage(0);
(void) puts("\nOptions:"); (void) puts(_("\nOptions:\n"
(void) puts(" -d directory specify directory for session logs"); " -d directory specify directory for session logs\n"
(void) puts(" -f filter specify which I/O type to display"); " -f filter specify which I/O type to display\n"
(void) puts(" -h display help message and exit"); " -h display help message and exit\n"
(void) puts(" -l [expression] list available session IDs that match expression"); " -l [expression] list available session IDs that match expression\n"
(void) puts(" -m max_wait max number of seconds to wait between events"); " -m max_wait max number of seconds to wait between events\n"
(void) puts(" -s speed_factor speed up or slow down output"); " -s speed_factor speed up or slow down output\n"
(void) puts(" -V display version information and exit"); " -V display version information and exit"));
exit(0); exit(0);
} }

View File

@@ -176,8 +176,8 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) { while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) {
switch (ch) { switch (ch) {
case 'V': case 'V':
(void) printf("%s version %s\n", getprogname(), PACKAGE_VERSION); (void) printf(_("%s version %s\n"), getprogname(), PACKAGE_VERSION);
(void) printf("%s grammar version %d\n", getprogname(), SUDOERS_GRAMMAR_VERSION); (void) printf(_("%s grammar version %d\n"), getprogname(), SUDOERS_GRAMMAR_VERSION);
exit(0); exit(0);
case 'c': case 'c':
checkonly++; /* check mode */ checkonly++; /* check mode */
@@ -240,7 +240,7 @@ main(int argc, char *argv[])
if (!sp->doedit) if (!sp->doedit)
continue; continue;
if (sp != tq_first(&sudoerslist)) { if (sp != tq_first(&sudoerslist)) {
printf("press return to edit %s: ", sp->path); printf(_("press return to edit %s: "), sp->path);
while ((ch = getchar()) != EOF && ch != '\n') while ((ch = getchar()) != EOF && ch != '\n')
continue; continue;
} }
@@ -472,7 +472,7 @@ reparse_sudoers(char *editor, char *args, int strict, int quiet)
/* If any new #include directives were added, edit them too. */ /* If any new #include directives were added, edit them too. */
for (sp = last->next; sp != NULL; sp = sp->next) { for (sp = last->next; sp != NULL; sp = sp->next) {
printf("press return to edit %s: ", sp->path); printf(_("press return to edit %s: "), sp->path);
while ((ch = getchar()) != EOF && ch != '\n') while ((ch = getchar()) != EOF && ch != '\n')
continue; continue;
edit_sudoers(sp, editor, args, errorlineno); edit_sudoers(sp, editor, args, errorlineno);
@@ -619,7 +619,7 @@ whatnow(void)
int choice, c; int choice, c;
for (;;) { for (;;) {
(void) fputs("What now? ", stdout); (void) fputs(_("What now? "), stdout);
choice = getchar(); choice = getchar();
for (c = choice; c != '\n' && c != EOF;) for (c = choice; c != '\n' && c != EOF;)
c = getchar(); c = getchar();
@@ -633,10 +633,10 @@ whatnow(void)
case 'Q': case 'Q':
return choice; return choice;
default: default:
(void) puts("Options are:"); (void) puts(_("Options are:\n"
(void) puts(" (e)dit sudoers file again"); " (e)dit sudoers file again\n"
(void) puts(" e(x)it without saving changes to sudoers file"); " e(x)it without saving changes to sudoers file\n"
(void) puts(" (Q)uit and save changes to sudoers file (DANGER!)\n"); " (Q)uit and save changes to sudoers file (DANGER!)\n"));
} }
} }
} }
@@ -720,12 +720,12 @@ check_syntax(char *sudoers_path, int quiet, int strict)
if (!quiet) { if (!quiet) {
if (parse_error) { if (parse_error) {
if (errorlineno != -1) if (errorlineno != -1)
(void) printf("parse error in %s near line %d\n", errorfile, (void) printf(_("parse error in %s near line %d\n"),
errorlineno); errorfile, errorlineno);
else else
(void) printf("parse error in %s\n", errorfile); (void) printf(_("parse error in %s\n"), errorfile);
} else { } else {
(void) printf("%s: parsed OK\n", sudoers_path); (void) printf(_("%s: parsed OK\n"), sudoers_path);
} }
} }
/* Check mode and owner in strict mode. */ /* Check mode and owner in strict mode. */
@@ -738,14 +738,15 @@ check_syntax(char *sudoers_path, int quiet, int strict)
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) { if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
error = TRUE; error = TRUE;
if (!quiet) { if (!quiet) {
fprintf(stderr, "%s: wrong owner (uid, gid) should be (%d, %d)\n", fprintf(stderr,
_("%s: wrong owner (uid, gid) should be (%d, %d)\n"),
sudoers_path, SUDOERS_UID, SUDOERS_GID); sudoers_path, SUDOERS_UID, SUDOERS_GID);
} }
} }
if ((sb.st_mode & 07777) != SUDOERS_MODE) { if ((sb.st_mode & 07777) != SUDOERS_MODE) {
error = TRUE; error = TRUE;
if (!quiet) { if (!quiet) {
fprintf(stderr, "%s: bad permissions, should be mode 0%o\n", fprintf(stderr, _("%s: bad permissions, should be mode 0%o\n"),
sudoers_path, SUDOERS_MODE); sudoers_path, SUDOERS_MODE);
} }
} }
@@ -1186,15 +1187,15 @@ usage(int fatal)
static void static void
help(void) help(void)
{ {
(void) printf("%s - safely edit the sudoers file\n\n", getprogname()); (void) printf(_("%s - safely edit the sudoers file\n\n"), getprogname());
usage(0); usage(0);
(void) puts("\nOptions:"); (void) puts(_("\nOptions:\n"
(void) puts(" -c check-only mode"); " -c check-only mode\n"
(void) puts(" -f sudoers specify sudoers file location"); " -f sudoers specify sudoers file location\n"
(void) puts(" -h display help message and exit"); " -h display help message and exit\n"
(void) puts(" -q less verbose (quiet) syntax error messages"); " -q less verbose (quiet) syntax error messages\n"
(void) puts(" -s strict syntax checking"); " -s strict syntax checking\n"
(void) puts(" -V display version information and exit"); " -V display version information and exit"));
exit(0); exit(0);
} }

View File

@@ -512,81 +512,100 @@ help(void)
lbuf_init(&lbuf, usage_out, indent, NULL, user_details.ts_cols); lbuf_init(&lbuf, usage_out, indent, NULL, user_details.ts_cols);
if (strcmp(pname, "sudoedit") == 0) if (strcmp(pname, "sudoedit") == 0)
lbuf_append(&lbuf, pname, " - edit files as another user\n\n", NULL); lbuf_append(&lbuf, pname, _(" - edit files as another user\n\n"), NULL);
else else
lbuf_append(&lbuf, pname, " - execute a command as another user\n\n", NULL); lbuf_append(&lbuf, pname, _(" - execute a command as another user\n\n"), NULL);
lbuf_print(&lbuf); lbuf_print(&lbuf);
usage(0); usage(0);
lbuf_append(&lbuf, "\nOptions:\n", NULL); lbuf_append(&lbuf, _("\nOptions:\n"), NULL);
#ifdef HAVE_BSD_AUTH_H #ifdef HAVE_BSD_AUTH_H
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -A use helper program for password prompting\n", NULL); " -A ",
_("use helper program for password prompting\n"), NULL);
#endif #endif
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -a type use specified BSD authentication type\n", NULL); " -a type ",
_("use specified BSD authentication type\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -b run command in the background\n", NULL); " -b ",
_("run command in the background\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -C fd close all file descriptors >= fd\n", NULL); " -C fd ",
_("close all file descriptors >= fd\n"), NULL);
#ifdef HAVE_LOGIN_CAP_H #ifdef HAVE_LOGIN_CAP_H
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -c class run command with specified login class\n", NULL); " -c class ",
_("run command with specified login class\n"), NULL);
#endif #endif
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -E preserve user environment when executing command\n", " -E ",
NULL); _("preserve user environment when executing command\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -e edit files instead of running a command\n", NULL); " -e ",
_("edit files instead of running a command\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -g group execute command as the specified group\n", NULL); " -g group ",
_("execute command as the specified group\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -H set HOME variable to target user's home dir.\n", " -H ",
NULL); _("set HOME variable to target user's home dir.\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -h display help message and exit\n", NULL); " -h ",
_("display help message and exit\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -i [command] run a login shell as target user\n", NULL); " -i [command] ",
_("run a login shell as target user\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -K remove timestamp file completely\n", NULL); " -K ",
_("remove timestamp file completely\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -k invalidate timestamp file\n", NULL); " -k ",
_("invalidate timestamp file\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -l[l] command list user's available commands\n", NULL); " -l[l] command ",
_("list user's available commands\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -n non-interactive mode, will not prompt user\n", NULL); " -n ",
_("non-interactive mode, will not prompt user\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -P preserve group vector instead of setting to target's\n", " -P ",
NULL); _("preserve group vector instead of setting to target's\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -p prompt use specified password prompt\n", NULL); " -p prompt ",
_("use specified password prompt\n"), NULL);
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -r role create SELinux security context with specified role\n", " -r role ",
NULL); _("create SELinux security context with specified role\n"), NULL);
#endif #endif
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -S read password from standard input\n", NULL); " -S ",
_("read password from standard input\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -s [command] run a shell as target user\n", NULL); " -s [command] ",
_("run a shell as target user\n"), NULL);
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -t type create SELinux security context with specified role\n", " -t type ",
NULL); _("create SELinux security context with specified role\n"), NULL);
#endif #endif
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -U user when listing, list specified user's privileges\n", " -U user ",
NULL); _("when listing, list specified user's privileges\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -u user run command (or edit file) as specified user\n", NULL); " -u user ",
_("run command (or edit file) as specified user\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -V display version information and exit\n", NULL); " -V ",
_("display version information and exit\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -v update user's timestamp without running a command\n", " -v ",
NULL); _("update user's timestamp without running a command\n"), NULL);
lbuf_append(&lbuf, lbuf_append(&lbuf,
" -- stop processing command line arguments\n", NULL); " -- ",
_("stop processing command line arguments\n"), NULL);
lbuf_print(&lbuf); lbuf_print(&lbuf);
lbuf_destroy(&lbuf); lbuf_destroy(&lbuf);
exit(0); exit(0);