diff --git a/INSTALL b/INSTALL index 1a763fe14..515147915 100644 --- a/INSTALL +++ b/INSTALL @@ -424,9 +424,11 @@ Operating system-specific options: Disable use of the setresuid() function for operating systems where it is broken (none currently known). - --enable-admin-flag - Enable the creation of an Ubuntu-style admin flag file - the first time sudo is run. + --enable-admin-flag[=PATH] + Enable the creation of an Ubuntu-style admin flag file the + first time sudo is run. If PATH is not specified, the + default value is: + ~/.sudo_as_admin_successful --enable-devsearch=PATH Set a system-specific search path of directories to look in diff --git a/config.h.in b/config.h.in index 7e66d29fb..3dbc35468 100644 --- a/config.h.in +++ b/config.h.in @@ -1231,10 +1231,6 @@ /* Define to 1 if the `unsetenv' function returns void instead of `int'. */ #undef UNSETENV_VOID -/* Define to 1 if you want to create ~/.sudo_as_admin_successful if the user - is in the admin group the first time they run sudo. */ -#undef USE_ADMIN_FLAG - /* Define to 1 if you want to insult the user for entering an incorrect password. */ #undef USE_INSULTS diff --git a/configure b/configure index 6a293a818..26a3c6c62 100755 --- a/configure +++ b/configure @@ -1718,7 +1718,8 @@ Optional Features: instead of the default C compiler. --disable-leaks Prevent some harmless memory leaks. --disable-poll Use select() instead of poll(). - --enable-admin-flag Whether to create a Ubuntu-style admin flag file + --enable-admin-flag[=PATH] + Whether to create a Ubuntu-style admin flag file --disable-nls Disable natural language support using gettext --disable-rpath Disable passing of -Rpath to the linker --enable-static-sudoers Build the sudoers policy module as part of the sudo @@ -6989,12 +6990,16 @@ fi if test ${enable_admin_flag+y} then : enableval=$enable_admin_flag; case "$enableval" in - yes) printf "%s\n" "#define USE_ADMIN_FLAG 1" >>confdefs.h + yes) cat >>confdefs.h <&5 -printf "%s\n" "$as_me: WARNING: Ignoring unknown argument to --enable-admin-flag: $enableval" >&2;} + *) cat >>confdefs.h <= ssizeof(flagfile)) + if ((flagfile = strdup(def_admin_flag)) == NULL) { + sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); + debug_return_int(-1); + } + if (!expand_tilde(&flagfile, user_name)) { + free(flagfile); debug_return_int(false); + } /* Create admin flag file if it doesn't already exist. */ if (set_perms(PERM_USER)) { @@ -1111,13 +1119,14 @@ create_admin_success_flag(void) if (!restore_perms()) ret = -1; } + free(flagfile); debug_return_int(ret); } -#else /* !USE_ADMIN_FLAG */ +#else /* !_PATH_SUDO_ADMIN_FLAG */ int create_admin_success_flag(void) { /* STUB */ return true; } -#endif /* USE_ADMIN_FLAG */ +#endif /* _PATH_SUDO_ADMIN_FLAG */