version 1.1.1.4, 2013/10/14 07:56:35
|
version 1.1.1.5, 2014/06/15 16:12:55
|
Line 45
|
Line 45
|
#include <signal.h> |
#include <signal.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#if TIME_WITH_SYS_TIME | #ifdef TIME_WITH_SYS_TIME |
# include <time.h> |
# include <time.h> |
#endif |
#endif |
|
|
Line 107 sudo_edit(struct command_details *command_details)
|
Line 107 sudo_edit(struct command_details *command_details)
|
* We will change the euid as needed below. |
* We will change the euid as needed below. |
*/ |
*/ |
if (setuid(ROOT_UID) != 0) { |
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; |
goto cleanup; |
} |
} |
|
|
Line 139 sudo_edit(struct command_details *command_details)
|
Line 139 sudo_edit(struct command_details *command_details)
|
editor_argc++; |
editor_argc++; |
} |
} |
if (nfiles == 0) { |
if (nfiles == 0) { |
warningx(_("plugin error: missing file list for sudoedit")); | warningx(U_("plugin error: missing file list for sudoedit")); |
goto cleanup; |
goto cleanup; |
} |
} |
|
|
Line 167 sudo_edit(struct command_details *command_details)
|
Line 167 sudo_edit(struct command_details *command_details)
|
if (rc) |
if (rc) |
warning("%s", files[i]); |
warning("%s", files[i]); |
else |
else |
warningx(_("%s: not a regular file"), files[i]); | warningx(U_("%s: not a regular file"), files[i]); |
if (ofd != -1) |
if (ofd != -1) |
close(ofd); |
close(ofd); |
continue; |
continue; |
Line 201 sudo_edit(struct command_details *command_details)
|
Line 201 sudo_edit(struct command_details *command_details)
|
if (nwritten == -1) |
if (nwritten == -1) |
warning("%s", tf[j].tfile); |
warning("%s", tf[j].tfile); |
else |
else |
warningx(_("%s: short write"), tf[j].tfile); | warningx(U_("%s: short write"), tf[j].tfile); |
goto cleanup; |
goto cleanup; |
} |
} |
} |
} |
Line 267 sudo_edit(struct command_details *command_details)
|
Line 267 sudo_edit(struct command_details *command_details)
|
if (rc) |
if (rc) |
warning("%s", tf[i].tfile); |
warning("%s", tf[i].tfile); |
else |
else |
warningx(_("%s: not a regular file"), tf[i].tfile); | warningx(U_("%s: not a regular file"), tf[i].tfile); |
warningx(_("%s left unmodified"), tf[i].ofile); | warningx(U_("%s left unmodified"), tf[i].ofile); |
if (tfd != -1) |
if (tfd != -1) |
close(tfd); |
close(tfd); |
continue; |
continue; |
} |
} |
mtim_get(&sb, &tv); |
mtim_get(&sb, &tv); |
if (tf[i].osize == sb.st_size && timevalcmp(&tf[i].omtim, &tv, ==)) { | if (tf[i].osize == sb.st_size && sudo_timevalcmp(&tf[i].omtim, &tv, ==)) { |
/* |
/* |
* If mtime and size match but the user spent no measurable |
* If mtime and size match but the user spent no measurable |
* time in the editor we can't tell if the file was changed. |
* time in the editor we can't tell if the file was changed. |
*/ |
*/ |
timevalsub(&tv1, &tv2); | if (sudo_timevalcmp(&tv1, &tv2, !=)) { |
if (timevalisset(&tv2)) { | warningx(U_("%s unchanged"), tf[i].ofile); |
warningx(_("%s unchanged"), tf[i].ofile); | |
unlink(tf[i].tfile); |
unlink(tf[i].tfile); |
close(tfd); |
close(tfd); |
continue; |
continue; |
Line 293 sudo_edit(struct command_details *command_details)
|
Line 292 sudo_edit(struct command_details *command_details)
|
switch_user(ROOT_UID, user_details.egid, |
switch_user(ROOT_UID, user_details.egid, |
user_details.ngroups, user_details.groups); |
user_details.ngroups, user_details.groups); |
if (ofd == -1) { |
if (ofd == -1) { |
warning(_("unable to write to %s"), tf[i].ofile); | warning(U_("unable to write to %s"), tf[i].ofile); |
warningx(_("contents of edit session left in %s"), tf[i].tfile); | warningx(U_("contents of edit session left in %s"), tf[i].tfile); |
close(tfd); |
close(tfd); |
continue; |
continue; |
} |
} |
Line 303 sudo_edit(struct command_details *command_details)
|
Line 302 sudo_edit(struct command_details *command_details)
|
if (nwritten == -1) |
if (nwritten == -1) |
warning("%s", tf[i].ofile); |
warning("%s", tf[i].ofile); |
else |
else |
warningx(_("%s: short write"), tf[i].ofile); | warningx(U_("%s: short write"), tf[i].ofile); |
break; |
break; |
} |
} |
} |
} |
Line 311 sudo_edit(struct command_details *command_details)
|
Line 310 sudo_edit(struct command_details *command_details)
|
/* success, got EOF */ |
/* success, got EOF */ |
unlink(tf[i].tfile); |
unlink(tf[i].tfile); |
} else if (nread < 0) { |
} else if (nread < 0) { |
warning(_("unable to read temporary file")); | warning(U_("unable to read temporary file")); |
warningx(_("contents of edit session left in %s"), tf[i].tfile); | warningx(U_("contents of edit session left in %s"), tf[i].tfile); |
} else { |
} else { |
warning(_("unable to write to %s"), tf[i].ofile); | warning(U_("unable to write to %s"), tf[i].ofile); |
warningx(_("contents of edit session left in %s"), tf[i].tfile); | warningx(U_("contents of edit session left in %s"), tf[i].tfile); |
} |
} |
close(ofd); |
close(ofd); |
} |
} |