build dir being left in the library path of the installed executable.
Instead, we remove the "lt-" prefix from the program name in
initprogname() so that the regress test output is unaffected by
libtool's binary wrapper.
/* Define to 1 if you have the `setkeycreatecon' function. */
#undef HAVE_SETKEYCREATECON
+/* Define to 1 if you have the `setprogname' function. */
+#undef HAVE_SETPROGNAME
+
/* Define to 1 if you have the `setresuid' function. */
#undef HAVE_SETRESUID
cat >>confdefs.h <<_ACEOF
#define HAVE_GETPROGNAME 1
_ACEOF
+ for ac_func in setprogname
+do :
+ ac_fn_c_check_func "$LINENO" "setprogname" "ac_cv_func_setprogname"
+if test "x$ac_cv_func_setprogname" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SETPROGNAME 1
+_ACEOF
+
+fi
+done
else
dnl
dnl Check for getprogname() or __progname
dnl
-AC_CHECK_FUNCS(getprogname, , [
+AC_CHECK_FUNCS(getprogname, [AC_CHECK_FUNCS(setprogname)], [
AC_MSG_CHECKING([for __progname])
AC_CACHE_VAL(sudo_cv___progname, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *__progname; (void)puts(__progname);]])], [sudo_cv___progname=yes], [sudo_cv___progname=no])])
# define killpg(s) kill(-(s))
#endif
-/*
- * If we lack getprogname(), emulate with __progname if possible.
- * Otherwise, add a prototype for use with our own getprogname.c.
- */
-#ifndef HAVE_GETPROGNAME
-# ifdef HAVE___PROGNAME
-extern const char *__progname;
-# define getprogname() (__progname)
-# else
-__dso_public const char *getprogname(void);
-# endif /* HAVE___PROGNAME */
-#endif /* !HAVE_GETPROGNAME */
-
/*
* Declare errno if errno.h doesn't do it for us.
*/
# undef inet_pton
# define inet_pton(_a, _b, _c) sudo_inet_pton((_a), (_b), (_c))
#endif /* HAVE_INET_PTON */
+#ifndef HAVE_GETPROGNAME
+__dso_public const char *sudo_getprogname(void);
+# undef getprogname
+# define getprogname() sudo_getprogname()
+#endif /* HAVE_GETPROGNAME */
#endif /* _SUDO_MISSING_H */
#include "missing.h"
#include "sudo_util.h"
-#if defined(HAVE_GETPROGNAME) || defined(HAVE___PROGNAME)
+#if defined(HAVE_GETPROGNAME)
-/* STUB */
void
initprogname(const char *name)
{
+# ifdef HAVE_SETPROGNAME
+ /* Check for libtool prefix and strip it if present. */
+ name = getprogname();
+ if (name[0] == 'l' && name[1] == 't' && name[2] == '-' && name[3] != '\0')
+ setprogname(name + 3);
+# endif
+ return;
+}
+
+#elif defined(HAVE___PROGNAME)
+
+extern const char *__progname;
+static const char *progname = "";
+
+void
+initprogname(const char *name)
+{
+ /* Check for libtool prefix and strip it if present. */
+ if (__progname[0] == 'l' && __progname[1] == 't' && __progname[2] == '-' &&
+ __progname[3] != '\0')
+ progname = __progname + 3;
+ else
+ progname = __progname;
return;
}
if (rc != -1 || errno == EOVERFLOW) {
strlcpy(ucomm, pstat.pst_ucomm, sizeof(ucomm));
progname = ucomm;
- return;
+ goto done;
}
#elif defined(HAVE_PROCFS_H) || defined(HAVE_SYS_PROCFS_H)
/* XXX - configure check for psinfo.pr_fname */
if (nread == (ssize_t)sizeof(psinfo)) {
strlcpy(ucomm, psinfo.pr_fname, sizeof(ucomm));
progname = ucomm;
- return;
+ goto done;
}
}
#endif /* HAVE_PSTAT_GETPROC */
base = name;
}
progname = base;
+
+done:
+ if (progname[0] == 'l' && progname[1] == 't' && progname[2] == '-' &&
+ progname[3] != '\0')
+ progname += 3;
}
+#endif /* !HAVE_GETPROGNAME && !HAVE___PROGNAME */
+#if !defined(HAVE_GETPROGNAME)
const char *
-getprogname(void)
+sudo_getprogname(void)
{
return progname;
}
-
-#endif /* !HAVE_GETPROGNAME && !HAVE___PROGNAME */
+#endif /* !HAVE_GETPROGNAME */
aix_restoreauthdb
aix_setauthdb
closefrom_fallback
-getprogname
initprogname
isblank
sudo_asprintf
sudo_getline
sudo_getopt_long
sudo_getopt_long_only
+sudo_getprogname
sudo_glob
sudo_globfree
sudo_inet_pton
$(LIBTOOL) @LT_STATIC@ --mode=link $(CC) $(LDFLAGS) $(LT_LDFLAGS) -o $@ $(SUDOERS_OBJS) libparsesudoers.la $(SUDOERS_LIBS) -module -avoid-version -rpath $(plugindir) -shrext .so
visudo: libparsesudoers.la $(VISUDO_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(VISUDO_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) libparsesudoers.la $(LIBS) $(VISUDO_LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(VISUDO_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) libparsesudoers.la $(LIBS) $(VISUDO_LIBS)
sudoreplay: timestr.lo $(REPLAY_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(REPLAY_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) timestr.lo $(LIBS) $(REPLAY_LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(REPLAY_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) timestr.lo $(LIBS) $(REPLAY_LIBS)
testsudoers: libparsesudoers.la $(TEST_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(TEST_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) libparsesudoers.la $(LIBS) $(TESTSUDOERS_LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(TEST_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) libparsesudoers.la $(LIBS) $(TESTSUDOERS_LIBS)
check_addr: $(CHECK_ADDR_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_ADDR_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) $(NET_LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_ADDR_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) $(NET_LIBS)
check_base64: $(CHECK_BASE64_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_BASE64_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_BASE64_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS)
check_digest: $(CHECK_DIGEST_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_DIGEST_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) @LIBMD@ -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_DIGEST_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) @LIBMD@
check_fill: $(CHECK_FILL_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_FILL_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_FILL_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS)
check_iolog_path: $(CHECK_IOLOG_PATH_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_IOLOG_PATH_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_IOLOG_PATH_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS)
# We need to link check_symbols with -lpthread on HP-UX since LDAP uses threads
check_symbols: $(CHECK_SYMBOLS_OBJS) $(LT_LIBS)
fi
check_wrap: $(CHECK_WRAP_OBJS) $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_WRAP_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS) -no-fast-install
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_WRAP_OBJS) $(LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(LIBS)
GENERATED = gram.h gram.c toke.c def_data.c def_data.h getdate.c