2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Call gettext inside log_error et al instead of having the caller do it. This way we can display any messages to the user in their own locale but log in the sudoers local.

This commit is contained in:
Todd C. Miller
2012-11-08 15:37:44 -05:00
parent 595d3b2651
commit a0c53bd751
15 changed files with 167 additions and 121 deletions

View File

@@ -162,7 +162,7 @@ sudoers_policy_init(void *info, char * const envp[])
if (nss->open(nss) == 0 && nss->parse(nss) == 0) {
sources++;
if (nss->setdefs(nss) != 0)
log_error(NO_STDERR, _("problem with defaults entries"));
log_error(NO_STDERR, N_("problem with defaults entries"));
} else {
tq_remove(snl, nss);
}
@@ -196,7 +196,7 @@ sudoers_policy_init(void *info, char * const envp[])
set_runaspw(runas_user ? runas_user : def_runas_default);
if (!update_defaults(SETDEF_RUNAS))
log_error(NO_STDERR, _("problem with defaults entries"));
log_error(NO_STDERR, N_("problem with defaults entries"));
if (def_fqdn)
set_fqdn(); /* deferred until after sudoers is parsed */
@@ -333,7 +333,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
timestamp_uid = pw->pw_uid;
sudo_pw_delref(pw);
} else {
log_error(0, _("timestamp owner (%s): No such user"),
log_error(0, N_("timestamp owner (%s): No such user"),
def_timestampowner);
timestamp_uid = ROOT_UID;
}
@@ -595,7 +595,7 @@ init_vars(char * const envp[])
/* Need to make a fake struct passwd for the call to log_fatal(). */
sudo_user.pw = sudo_fakepwnamid(user_name, user_uid, user_gid);
log_fatal(0, _("unknown uid: %u"), (unsigned int) user_uid);
log_fatal(0, N_("unknown uid: %u"), (unsigned int) user_uid);
/* NOTREACHED */
}
}
@@ -694,7 +694,7 @@ set_cmnd(void)
user_base = user_cmnd;
if (!update_defaults(SETDEF_CMND))
log_error(NO_STDERR, _("problem with defaults entries"));
log_error(NO_STDERR, N_("problem with defaults entries"));
debug_return_int(rval);
}
@@ -729,10 +729,10 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
* the user with a reasonable error message (unlike the lexer).
*/
if ((fp = fopen(sudoers, "r")) == NULL) {
log_error(USE_ERRNO, _("unable to open %s"), sudoers);
log_error(USE_ERRNO, N_("unable to open %s"), sudoers);
} else {
if (sb.st_size != 0 && fgetc(fp) == EOF) {
log_error(USE_ERRNO, _("unable to read %s"),
log_error(USE_ERRNO, N_("unable to read %s"),
sudoers);
fclose(fp);
fp = NULL;
@@ -744,20 +744,20 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
}
break;
case SUDO_PATH_MISSING:
log_error(USE_ERRNO, _("unable to stat %s"), sudoers);
log_error(USE_ERRNO, N_("unable to stat %s"), sudoers);
break;
case SUDO_PATH_BAD_TYPE:
log_error(0, _("%s is not a regular file"), sudoers);
log_error(0, N_("%s is not a regular file"), sudoers);
break;
case SUDO_PATH_WRONG_OWNER:
log_error(0, _("%s is owned by uid %u, should be %u"),
log_error(0, N_("%s is owned by uid %u, should be %u"),
sudoers, (unsigned int) sb.st_uid, (unsigned int) sudoers_uid);
break;
case SUDO_PATH_WORLD_WRITABLE:
log_error(0, _("%s is world writable"), sudoers);
log_error(0, N_("%s is world writable"), sudoers);
break;
case SUDO_PATH_GROUP_WRITABLE:
log_error(0, _("%s is owned by gid %u, should be %u"),
log_error(0, N_("%s is owned by gid %u, should be %u"),
sudoers, (unsigned int) sb.st_gid, (unsigned int) sudoers_gid);
break;
default:
@@ -801,9 +801,9 @@ set_loginclass(struct passwd *pw)
* corrupted we want the admin to be able to use sudo to fix it.
*/
if (login_class)
log_fatal(errflags, _("unknown login class: %s"), login_class);
log_fatal(errflags, N_("unknown login class: %s"), login_class);
else
log_error(errflags, _("unknown login class: %s"), login_class);
log_error(errflags, N_("unknown login class: %s"), login_class);
def_use_loginclass = false;
}
login_close(lc);
@@ -835,7 +835,7 @@ set_fqdn(void)
hint.ai_family = PF_UNSPEC;
hint.ai_flags = AI_FQDN;
if (getaddrinfo(user_host, NULL, &hint, &res0) != 0) {
log_error(MSG_ONLY, _("unable to resolve host %s"), user_host);
log_error(MSG_ONLY, N_("unable to resolve host %s"), user_host);
} else {
if (user_shost != user_host)
efree(user_shost);
@@ -866,7 +866,7 @@ set_runaspw(const char *user)
runas_pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0);
} else {
if ((runas_pw = sudo_getpwnam(user)) == NULL)
log_fatal(NO_MAIL|MSG_ONLY, _("unknown user: %s"), user);
log_fatal(NO_MAIL|MSG_ONLY, N_("unknown user: %s"), user);
}
debug_return;
}
@@ -887,7 +887,7 @@ set_runasgr(const char *group)
runas_gr = sudo_fakegrnam(group);
} else {
if ((runas_gr = sudo_getgrnam(group)) == NULL)
log_fatal(NO_MAIL|MSG_ONLY, _("unknown group: %s"), group);
log_fatal(NO_MAIL|MSG_ONLY, N_("unknown group: %s"), group);
}
debug_return;
}