Imported Upstream version 1.8.2
[debian/sudo] / src / sudo_edit.c
index 0be9d31fdfa1b41852427f911041d0a56d888068..0a4d511f80f2f91aa4f7ac251dd0ac9f5793ecf7 100644 (file)
@@ -64,12 +64,12 @@ switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)
        if (seteuid(ROOT_UID) != 0)
            error(1, "seteuid(ROOT_UID)");
     }
+    if (setegid(egid) != 0)
+       error(1, "setegid(%d)", (int)egid);
     if (ngroups != -1) {
-       if (setgroups(ngroups, groups) != 0)
+       if (sudo_setgroups(ngroups, groups) != 0)
            error(1, "setgroups");
     }
-    if (setegid(egid) != 0)
-       error(1, "setegid(%d)", (int)egid);
     if (euid != ROOT_UID) {
        if (seteuid(euid) != 0)
            error(1, "seteuid(%d)", (int)euid);
@@ -105,7 +105,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 to uid to root (%u)", ROOT_UID);
+       warning(_("unable to change uid to root (%u)"), ROOT_UID);
        return 1;
     }
 
@@ -137,7 +137,7 @@ sudo_edit(struct command_details *command_details)
            editor_argc++;
     }
     if (nfiles == 0) {
-       warningx("plugin error: missing file list for sudoedit");
+       warningx(_("plugin error: missing file list for sudoedit"));
        return 1;
     }
 
@@ -169,7 +169,7 @@ sudo_edit(struct command_details *command_details)
            if (rc)
                warning("%s", files[i]);
            else
-               warningx("%s: not a regular file", files[i]);
+               warningx(_("%s: not a regular file"), files[i]);
            if (ofd != -1)
                close(ofd);
            continue;
@@ -203,7 +203,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(_("%s: short write"), tf[j].tfile);
                    goto cleanup;
                }
            }
@@ -277,8 +277,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(_("%s: not a regular file"), tf[i].tfile);
+           warningx(_("%s left unmodified"), tf[i].ofile);
            if (tfd != -1)
                close(tfd);
            continue;
@@ -291,7 +291,7 @@ sudo_edit(struct command_details *command_details)
             */
            timevalsub(&tv1, &tv2);
            if (timevalisset(&tv2)) {
-               warningx("%s unchanged", tf[i].ofile);
+               warningx(_("%s unchanged"), tf[i].ofile);
                unlink(tf[i].tfile);
                close(tfd);
                continue;
@@ -303,8 +303,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(_("unable to write to %s"), tf[i].ofile);
+           warningx(_("contents of edit session left in %s"), tf[i].tfile);
            close(tfd);
            continue;
        }
@@ -313,7 +313,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(_("%s: short write"), tf[i].ofile);
                break;
            }
        }
@@ -321,11 +321,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(_("unable to read temporary file"));
+           warningx(_("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(_("unable to write to %s"), tf[i].ofile);
+           warningx(_("contents of edit session left in %s"), tf[i].tfile);
        }
        close(ofd);
     }