When creating a new file, sudoedit will now check that the file's
parent directory exists before running the editor.
This commit is contained in:
3
NEWS
3
NEWS
@@ -83,6 +83,9 @@ What's new in Sudo 1.8.15
|
||||
to the group plugin. Previously, unknown system groups were
|
||||
always passed to the group plugin.
|
||||
|
||||
* When creating a new file, sudoedit will now check that the file's
|
||||
parent directory exists before running the editor.
|
||||
|
||||
What's new in Sudo 1.8.14p3
|
||||
|
||||
* Fixed a bug introduced in sudo 1.8.14p2 that prevented sudo
|
||||
|
@@ -387,8 +387,21 @@ sudo_edit_create_tfiles(struct command_details *command_details,
|
||||
ofd = sudo_edit_open(files[i], O_RDONLY, 0644, command_details->flags);
|
||||
if (ofd != -1 || errno == ENOENT) {
|
||||
if (ofd == -1) {
|
||||
memset(&sb, 0, sizeof(sb)); /* new file */
|
||||
rc = 0;
|
||||
/* New file, verify parent dir exists unless in cwd. */
|
||||
char *slash = strrchr(files[i], '/');
|
||||
if (slash != NULL && slash != files[i]) {
|
||||
int serrno = errno;
|
||||
*slash = '\0';
|
||||
if (stat(files[i], &sb) == 0 && S_ISDIR(sb.st_mode)) {
|
||||
memset(&sb, 0, sizeof(sb));
|
||||
rc = 0;
|
||||
}
|
||||
*slash = '/';
|
||||
errno = serrno;
|
||||
} else {
|
||||
memset(&sb, 0, sizeof(sb));
|
||||
rc = 0;
|
||||
}
|
||||
} else {
|
||||
rc = fstat(ofd, &sb);
|
||||
}
|
||||
|
Reference in New Issue
Block a user