#define GNU_COMPATIBLE /* Be more compatible with GNU getopt. */
+#ifdef REPLACE_GETOPT
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
-int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
+#else
+extern int opterr; /* if error message should be printed */
+extern int optind; /* index into parent argv vector */
+extern int optopt; /* character checked for validity */
+extern char *optarg; /* argument associated with option */
+#endif
+#if !defined(REPLACE_GETOPT) && !defined(HAVE_OPTRESET)
+int optreset; /* reset getopt */
+#endif
#define PRINT_ERROR ((opterr) && (*options != ':'))
/* Define to 1 if you use NRL OPIE. */
#undef HAVE_OPIE
+/* Define to 1 if you have the `optreset' symbol. */
+#undef HAVE_OPTRESET
+
/* Define to 1 if you use PAM authentication. */
#undef HAVE_PAM
fi
-ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"
-if test "x$ac_cv_func_getopt_long" = xyes; then :
- $as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" getopt_long.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
if test "x$ac_cv_func_memrchr" = xyes; then :
$as_echo "#define HAVE_MEMRCHR 1" >>confdefs.h
fi
+fi
+done
+
+for ac_func in getopt_long
+do :
+ ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"
+if test "x$ac_cv_func_getopt_long" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_GETOPT_LONG 1
+_ACEOF
+
+else
+ case " $LIBOBJS " in
+ *" getopt_long.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
+ ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for optreset" >&5
+$as_echo_n "checking for optreset... " >&6; }
+ if ${sudo_cv_optreset+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+extern int optreset; optreset = 1; return optreset;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ sudo_cv_optreset=yes
+else
+ sudo_cv_optreset=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+ if test "$sudo_cv_optreset" = "yes"; then
+ $as_echo "#define HAVE_OPTRESET 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_optreset" >&5
+$as_echo "$sudo_cv_optreset" >&6; }
+
fi
done
+
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }fnm_test"
])
SUDO_FUNC_ISBLANK
-AC_REPLACE_FUNCS(getopt_long memrchr memset_s pw_dup strlcpy strlcat)
+AC_REPLACE_FUNCS(memrchr memset_s pw_dup strlcpy strlcat)
AC_CHECK_FUNCS(nanosleep, [], [
# On Solaris, nanosleep is in librt
AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)])
])
+AC_CHECK_FUNCS(getopt_long, [], [AC_LIBOBJ(getopt_long)
+ AC_MSG_CHECKING([for optreset])
+ AC_CACHE_VAL(sudo_cv_optreset, [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern int optreset; optreset = 1; return optreset;]])], [sudo_cv_optreset=yes], [sudo_cv_optreset=no])])
+ if test "$sudo_cv_optreset" = "yes"; then
+ AC_DEFINE(HAVE_OPTRESET)
+ fi
+ AC_MSG_RESULT($sudo_cv_optreset)
+])
AC_CHECK_FUNCS(closefrom, [], [AC_LIBOBJ(closefrom)
AC_CHECK_DECL(F_CLOSEM, AC_DEFINE(HAVE_FCNTL_CLOSEM), [],
[ #include <limits.h>
AH_TEMPLATE(HAVE_LINUX_AUDIT, [Define to 1 to enable Linux audit support.])
AH_TEMPLATE(HAVE_SSSD, [Define to 1 to enable SSSD support.])
AH_TEMPLATE(HAVE_OPIE, [Define to 1 if you use NRL OPIE.])
+AH_TEMPLATE(HAVE_OPTRESET, [Define to 1 if you have the `optreset' symbol.])
AH_TEMPLATE(HAVE_PAM, [Define to 1 if you use PAM authentication.])
AH_TEMPLATE(HAVE_PAM_LOGIN, [Define to 1 if you use a specific PAM session for sudo -i.])
AH_TEMPLATE(HAVE_PROJECT_H, [Define to 1 if you have the <project.h> header file.])