mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 18:08:23 +00:00
Execute cvtsudoers if the user runs "visudo -x" but also emit a
warning.
This commit is contained in:
parent
63321f19a9
commit
7e5e1f6a6d
@ -130,6 +130,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct sudoersfile *sp;
|
struct sudoersfile *sp;
|
||||||
char *editor, **editor_argv;
|
char *editor, **editor_argv;
|
||||||
|
const char *export_path = NULL;
|
||||||
int ch, oldlocale, editor_argc, exitcode = 0;
|
int ch, oldlocale, editor_argc, exitcode = 0;
|
||||||
bool quiet, strict, oldperms;
|
bool quiet, strict, oldperms;
|
||||||
debug_decl(main, SUDOERS_DEBUG_MAIN)
|
debug_decl(main, SUDOERS_DEBUG_MAIN)
|
||||||
@ -197,9 +198,8 @@ main(int argc, char *argv[])
|
|||||||
quiet = true; /* quiet mode */
|
quiet = true; /* quiet mode */
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
/* XXX - make more concise */
|
export_path = optarg;
|
||||||
sudo_warnx(U_("conversion of sudoers to JSON format has moved to the cvtsudoers utility"));
|
break;
|
||||||
usage(1);
|
|
||||||
default:
|
default:
|
||||||
usage(1);
|
usage(1);
|
||||||
}
|
}
|
||||||
@ -208,6 +208,15 @@ main(int argc, char *argv[])
|
|||||||
if (argc - optind != 0)
|
if (argc - optind != 0)
|
||||||
usage(1);
|
usage(1);
|
||||||
|
|
||||||
|
if (export_path != NULL) {
|
||||||
|
/* Backwards compatibility for the time being. */
|
||||||
|
sudo_warnx(U_("the -x option will be removed in a future release"));
|
||||||
|
sudo_warnx(U_("please consider using the cvtsudoers utility instead"));
|
||||||
|
execlp("cvtsudoers", "cvtsudoers", "-f", "json", "-o", export_path,
|
||||||
|
sudoers_file, (char *)0);
|
||||||
|
sudo_fatal(U_("unable to execute %s"), "cvtsudoers");
|
||||||
|
}
|
||||||
|
|
||||||
/* Mock up a fake sudo_user struct. */
|
/* Mock up a fake sudo_user struct. */
|
||||||
user_cmnd = user_base = "";
|
user_cmnd = user_base = "";
|
||||||
if (geteuid() == 0) {
|
if (geteuid() == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user