]> granicus.if.org Git - sudo/commitdiff
Always install plugins with a .so extension regardless of what
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 6 Mar 2013 22:08:10 +0000 (17:08 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 6 Mar 2013 22:08:10 +0000 (17:08 -0500)
extension the system uses for shared libraries.  That way the
group_plugin sudoers setting can be shared between heterogenous
systems.

configure
configure.in
plugins/group_file/Makefile.in
plugins/sample/Makefile.in
plugins/sudoers/Makefile.in
plugins/system_group/Makefile.in
src/load_plugins.c

index bb61d1bc7879bd85b8b259cdc93ce7ca79bd6821..c0ea373bd1b48d41feab26654cece8583e5b5e8b 100755 (executable)
--- a/configure
+++ b/configure
@@ -13675,18 +13675,18 @@ $as_echo_n "checking path to sudo_noexec.so... " >&6; }
 # Check whether --with-noexec was given.
 if test "${with_noexec+set}" = set; then :
   withval=$with_noexec; case $with_noexec in
-    yes)       with_noexec="$libexecdir/sudo/sudo_noexec$_shrext"
+    yes)       with_noexec="$libexecdir/sudo/sudo_noexec.so"
                ;;
     no)                ;;
     *)         ;;
 esac
 else
-  with_noexec="$libexecdir/sudo/sudo_noexec$_shrext"
+  with_noexec="$libexecdir/sudo/sudo_noexec.so"
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_noexec" >&5
 $as_echo "$with_noexec" >&6; }
-NOEXECFILE="sudo_noexec$_shrext"
+NOEXECFILE="sudo_noexec.so"
 NOEXECDIR="`echo $with_noexec|sed -e 's:^${\([^}]*\)}:$(\1):' -e 's:^\(.*\)/[^/]*:\1:'`"
 
 # Extract the first word of "uname", so it can be a program name with args.
@@ -21200,7 +21200,7 @@ EOF
 EOF
 
     cat >>confdefs.h <<EOF
-#define SUDOERS_PLUGIN "sudoers${SOEXT}"
+#define SUDOERS_PLUGIN "sudoers.so"
 EOF
 
     exec_prefix="$oexec_prefix"
index f07af5dfe3576a34d288a72bb1e88ff5950b02e9..e113bf5334bac955664305b46901f9a469287819 100644 (file)
@@ -1491,13 +1491,13 @@ fi
 AC_MSG_CHECKING(path to sudo_noexec.so)
 AC_ARG_WITH(noexec, [AS_HELP_STRING([--with-noexec[=PATH]], [fully qualified pathname of sudo_noexec.so])],
 [case $with_noexec in
-    yes)       with_noexec="$libexecdir/sudo/sudo_noexec$_shrext"
+    yes)       with_noexec="$libexecdir/sudo/sudo_noexec.so"
                ;;
     no)                ;;
     *)         ;;
-esac], [with_noexec="$libexecdir/sudo/sudo_noexec$_shrext"])
+esac], [with_noexec="$libexecdir/sudo/sudo_noexec.so"])
 AC_MSG_RESULT($with_noexec)
-NOEXECFILE="sudo_noexec$_shrext"
+NOEXECFILE="sudo_noexec.so"
 NOEXECDIR="`echo $with_noexec|sed -e 's:^${\([[^}]]*\)}:$(\1):' -e 's:^\(.*\)/[[^/]]*:\1:'`"
 
 dnl
@@ -3597,7 +3597,7 @@ if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then
        eval PLUGINDIR="$_PLUGINDIR"
     done
     SUDO_DEFINE_UNQUOTED(_PATH_SUDO_PLUGIN_DIR, "$PLUGINDIR/")
-    SUDO_DEFINE_UNQUOTED(SUDOERS_PLUGIN, "sudoers${SOEXT}")
+    SUDO_DEFINE_UNQUOTED(SUDOERS_PLUGIN, "sudoers.so")
     exec_prefix="$oexec_prefix"
 fi
 
index e6581c5d2c593451302a8692750e1a0fb61483f3..439b64b1556a869ca1cff8ca0e2cc9a0aa4c6e88 100644 (file)
@@ -119,10 +119,10 @@ install-includes:
 install-doc:
 
 install-plugin: install-dirs group_file.la
-       $(INSTALL) -b~ -m $(shlib_mode) .libs/group_file$(soext) $(DESTDIR)$(plugindir)
+       $(INSTALL) -b~ -m $(shlib_mode) .libs/group_file$(soext) $(DESTDIR)$(plugindir)/group_file.so
 
 uninstall:
-       -rm -f $(DESTDIR)$(plugindir)/group_file$(soext)
+       -rm -f $(DESTDIR)$(plugindir)/group_file.so
 
 check:
 
index 1117133c943373a1a8cf2c12d709f9f839c9085c..20cf3bc8d1082848f235e566f4921ada054995de 100644 (file)
@@ -118,10 +118,10 @@ install-includes:
 install-doc:
 
 install-plugin: install-dirs sample_plugin.la
-       $(INSTALL) -b~ -m $(shlib_mode) .libs/sample_plugin$(soext) $(DESTDIR)$(plugindir)
+       $(INSTALL) -b~ -m $(shlib_mode) .libs/sample_plugin$(soext) $(DESTDIR)$(plugindir)/sample_plugin.so
 
 uninstall:
-       -rm -f $(DESTDIR)$(plugindir)/sample_plugin$(soext)
+       -rm -f $(DESTDIR)$(plugindir)/sample_plugin.so
 
 check:
 
index 70baeb33436f0d65f820761ad62ef94a64eca837..5916cd56952a5c92aa4e4aabd882ddb33eb8a33c 100644 (file)
@@ -287,7 +287,7 @@ install-plugin: sudoers.la install-dirs
        if [ X"$(soext)" != X"" ]; then \
            test X"$$SUDO_PREINSTALL_CMD" != X"" && \
                $$SUDO_PREINSTALL_CMD .libs/sudoers$(soext); \
-           $(INSTALL) -b~ -O $(install_uid) -G $(install_gid) -m $(shlib_mode) .libs/sudoers$(soext) $(DESTDIR)$(plugindir); \
+           $(INSTALL) -b~ -O $(install_uid) -G $(install_gid) -m $(shlib_mode) .libs/sudoers$(soext) $(DESTDIR)$(plugindir)/sudoers.so; \
        fi
 
 install-sudoers: install-dirs
@@ -298,7 +298,7 @@ install-sudoers: install-dirs
                sudoers $(DESTDIR)$(sudoersdir)/sudoers
 
 uninstall:
-       -rm -f $(DESTDIR)$(plugindir)/sudoers$(soext)
+       -rm -f $(DESTDIR)$(plugindir)/sudoers.so
        -rm -f $(DESTDIR)$(replaydir)/sudoreplay
        -rm -f $(DESTDIR)$(visudodir)/visudo
        -cmp $(DESTDIR)$(sudoersdir)/sudoers $(srcdir)/sudoers >/dev/null && \
index aaac4bbca6e94a754210ff6931ae72dbec7f2f9c..91748de927157b8cb2c6fa1bb4f8eb10867abdb0 100644 (file)
@@ -119,10 +119,10 @@ install-includes:
 install-doc:
 
 install-plugin: install-dirs system_group.la
-       $(INSTALL) -b~ -m $(shlib_mode) .libs/system_group$(soext) $(DESTDIR)$(plugindir)
+       $(INSTALL) -b~ -m $(shlib_mode) .libs/system_group$(soext) $(DESTDIR)$(plugindir)/system_group.so
 
 uninstall:
-       -rm -f $(DESTDIR)$(plugindir)/system_group$(soext)
+       -rm -f $(DESTDIR)$(plugindir)/system_group.so
 
 check:
 
index 23f5b367017f91aef6b1e18e0652d9aaf706cfb7..3a4268fe5684d43a755ac2bf84bf0a18375650a0 100644 (file)
 # define RTLD_GLOBAL   0
 #endif
 
-/*
- * Load the plugin specified by "info".
- */
-static bool
-sudo_load_plugin(struct plugin_container *policy_plugin,
-    struct plugin_container_list *io_plugins, struct plugin_info *info)
+static int
+sudo_stat_plugin(struct plugin_info *info, char *fullpath,
+    size_t pathsize, struct stat *sb)
 {
-    struct plugin_container *container;
-    struct generic_plugin *plugin;
-    struct stat sb;
-    void *handle;
-    char path[PATH_MAX];
-    bool rval = false;
-    int status;
-    debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
+    int status = -1;
+    debug_decl(sudo_stat_plugin, SUDO_DEBUG_PLUGIN)
 
     if (info->path[0] == '/') {
-       if (strlcpy(path, info->path, sizeof(path)) >= sizeof(path)) {
+       if (strlcpy(fullpath, info->path, pathsize) >= pathsize) {
            warningx(_("error in %s, line %d while loading plugin `%s'"),
                _PATH_SUDO_CONF, info->lineno, info->symbol_name);
            warningx(_("%s: %s"), info->path, strerror(ENAMETOOLONG));
            goto done;
        }
-       status = stat(path, &sb);
+       status = stat(fullpath, sb);
     } else {
-       if (snprintf(path, sizeof(path), "%s%s", _PATH_SUDO_PLUGIN_DIR,
-           info->path) >= sizeof(path)) {
+       if (snprintf(fullpath, pathsize, "%s%s", _PATH_SUDO_PLUGIN_DIR,
+           info->path) >= pathsize) {
            warningx(_("error in %s, line %d while loading plugin `%s'"),
                _PATH_SUDO_CONF, info->lineno, info->symbol_name);
            warningx(_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
@@ -87,17 +78,61 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
            goto done;
        }
        /* Try parent dir for compatibility with old plugindir default. */
-       if ((status = stat(path, &sb)) != 0) {
-           char *cp = strrchr(path, '/');
-           if (cp > path + 4 && cp[-5] == '/' && cp[-4] == 's' &&
+       if ((status = stat(fullpath, sb)) != 0) {
+           char *cp = strrchr(fullpath, '/');
+           if (cp > fullpath + 4 && cp[-5] == '/' && cp[-4] == 's' &&
                cp[-3] == 'u' && cp[-2] == 'd' && cp[-1] == 'o') {
                int serrno = errno;
-               strlcpy(cp - 4, info->path, sizeof(path) - (cp - 4 - path));
-               if ((status = stat(path, &sb)) != 0)
+               strlcpy(cp - 4, info->path, pathsize - (cp - 4 - fullpath));
+               if ((status = stat(fullpath, sb)) != 0)
+                   errno = serrno;
+           }
+       }
+#ifdef __hpux__
+       /* Try .sl instead of .so on HP-UX for backwards compatibility. */
+       if (status != 0) {
+           size_t len = strlen(info->path);
+           if (len >= 3 && info->path[len - 3] == '.' &&
+               info->path[len - 2] == 's' && info->path[len - 1] == 'o') {
+               const char *sopath = info->path;
+               char *slpath = estrdup(info->path);
+               int serrno = errno;
+
+               slpath[len - 1] = 'l';
+               info->path = slpath;
+               status = sudo_stat_plugin(info, fullpath, pathsize, sb);
+               if (status == 0) {
+                   efree((void *)sopath);
+               } else {
+                   efree(slpath);
+                   info->path = sopath;
                    errno = serrno;
+               }
            }
        }
+#endif
     }
+done:
+    debug_return_int(status);
+}
+
+/*
+ * Load the plugin specified by "info".
+ */
+static bool
+sudo_load_plugin(struct plugin_container *policy_plugin,
+    struct plugin_container_list *io_plugins, struct plugin_info *info)
+{
+    struct plugin_container *container;
+    struct generic_plugin *plugin;
+    struct stat sb;
+    void *handle;
+    char path[PATH_MAX];
+    bool rval = false;
+    int status;
+    debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
+
+    status = sudo_stat_plugin(info, path, sizeof(path), &sb);
     if (status != 0) {
        warningx(_("error in %s, line %d while loading plugin `%s'"),
            _PATH_SUDO_CONF, info->lineno, info->symbol_name);