Add warning_gettext() wrapper function that changes to the user locale,

then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
This commit is contained in:
Todd C. Miller
2013-11-18 08:59:57 -07:00
parent 99b7351de0
commit 96eb2c4f8f
50 changed files with 445 additions and 492 deletions

View File

@@ -107,7 +107,7 @@ sudo_edit(struct command_details *command_details)
* We will change the euid as needed below.
*/
if (setuid(ROOT_UID) != 0) {
warning(_("unable to change uid to root (%u)"), ROOT_UID);
warning(U_("unable to change uid to root (%u)"), ROOT_UID);
goto cleanup;
}
@@ -139,7 +139,7 @@ sudo_edit(struct command_details *command_details)
editor_argc++;
}
if (nfiles == 0) {
warningx(_("plugin error: missing file list for sudoedit"));
warningx(U_("plugin error: missing file list for sudoedit"));
goto cleanup;
}
@@ -167,7 +167,7 @@ sudo_edit(struct command_details *command_details)
if (rc)
warning("%s", files[i]);
else
warningx(_("%s: not a regular file"), files[i]);
warningx(U_("%s: not a regular file"), files[i]);
if (ofd != -1)
close(ofd);
continue;
@@ -201,7 +201,7 @@ sudo_edit(struct command_details *command_details)
if (nwritten == -1)
warning("%s", tf[j].tfile);
else
warningx(_("%s: short write"), tf[j].tfile);
warningx(U_("%s: short write"), tf[j].tfile);
goto cleanup;
}
}
@@ -267,8 +267,8 @@ sudo_edit(struct command_details *command_details)
if (rc)
warning("%s", tf[i].tfile);
else
warningx(_("%s: not a regular file"), tf[i].tfile);
warningx(_("%s left unmodified"), tf[i].ofile);
warningx(U_("%s: not a regular file"), tf[i].tfile);
warningx(U_("%s left unmodified"), tf[i].ofile);
if (tfd != -1)
close(tfd);
continue;
@@ -281,7 +281,7 @@ sudo_edit(struct command_details *command_details)
*/
timevalsub(&tv1, &tv2);
if (timevalisset(&tv2)) {
warningx(_("%s unchanged"), tf[i].ofile);
warningx(U_("%s unchanged"), tf[i].ofile);
unlink(tf[i].tfile);
close(tfd);
continue;
@@ -293,8 +293,8 @@ sudo_edit(struct command_details *command_details)
switch_user(ROOT_UID, user_details.egid,
user_details.ngroups, user_details.groups);
if (ofd == -1) {
warning(_("unable to write to %s"), tf[i].ofile);
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to write to %s"), tf[i].ofile);
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
close(tfd);
continue;
}
@@ -303,7 +303,7 @@ sudo_edit(struct command_details *command_details)
if (nwritten == -1)
warning("%s", tf[i].ofile);
else
warningx(_("%s: short write"), tf[i].ofile);
warningx(U_("%s: short write"), tf[i].ofile);
break;
}
}
@@ -311,11 +311,11 @@ sudo_edit(struct command_details *command_details)
/* success, got EOF */
unlink(tf[i].tfile);
} else if (nread < 0) {
warning(_("unable to read temporary file"));
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to read temporary file"));
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
} else {
warning(_("unable to write to %s"), tf[i].ofile);
warningx(_("contents of edit session left in %s"), tf[i].tfile);
warning(U_("unable to write to %s"), tf[i].ofile);
warningx(U_("contents of edit session left in %s"), tf[i].tfile);
}
close(ofd);
}