[sudo-workers] visudo edit wrong file
Todd C. Miller
Todd.Miller at courtesan.com
Tue Sep 15 09:27:33 MDT 2015
Confirmed. This bug was introduced in 1.8.14 with the refactoring
of the editing code. The patch below will work around the issue.
For sudo 1.8.15 I'm going to rearrange things a bit to make this
unnecessary.
- todd
diff -r 2b3efe0a91f2 plugins/sudoers/visudo.c
--- a/plugins/sudoers/visudo.c Thu Sep 10 16:44:57 2015 -0600
+++ b/plugins/sudoers/visudo.c Tue Sep 15 09:26:35 2015 -0600
@@ -465,14 +465,15 @@
lineno = -1;
/*
- * We pre-allocated 2 extra spaces for "+n filename" in argv.
+ * The last 3 slots in the editor argv are: "-- +1 sudoers"
* Replace those placeholders with the real values.
*/
- ac = editor_argc - 2;
+ ac = editor_argc - 3;
if (lineno > 0) {
(void)snprintf(linestr, sizeof(linestr), "+%d", lineno);
editor_argv[ac++] = linestr;
}
+ editor_argv[ac++] = "--";
editor_argv[ac++] = sp->tpath;
editor_argv[ac++] = NULL;
More information about the sudo-workers
mailing list