Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sasldir and plugindir in Makefile.am #339

Closed
brong opened this issue Feb 15, 2011 · 11 comments · Fixed by #807
Closed

sasldir and plugindir in Makefile.am #339

brong opened this issue Feb 15, 2011 · 11 comments · Fixed by #807

Comments

@brong
Copy link
Member

brong commented Feb 15, 2011

From: Dilyan Palauzov
Bugzilla-Id: 3401
Version: 2.1.x
Owner: Ken Murchison

@brong
Copy link
Member Author

brong commented Feb 15, 2011

From: Dilyan Palauzov

cyrus-sasl-2.1.23/Makefile.am defines plugindir as $(prefix)/lib/sasl2, but it shall be defined as $(libdir)/sasl2 .

Likewise plugins/Makefile.am defines sasldir = $(prefix)/lib/sasl2, but it shall be $(libdir)/sasl2 .

Motivation: when building on 64bit, libdir is /usr/lib64, prefix is /usr and I want to install the plugins in /usr/lib64/sasl2 <=> $(libdir)/sasl2 != $(prefix)/lib/sasl2 .

@brong
Copy link
Member Author

brong commented Feb 15, 2011

From: Jeroen van Meeuwen (Kolab Systems)

I would actually say the plugins may need to go into /usr/libexec/, what do you think?

@brong
Copy link
Member Author

brong commented Feb 16, 2011

From: Dilyan Palauzov

About plugindir under /usr/libexec:

Keep in mind, that on mixed 32/64 bit systems you need distinct plugin binaries for 32 and 64 bit code, and the best way to manage this is with two different directories.

libexec is not mentioned in the Filesystem Hierarchy Standard.

I think libexec is just for executables that are not invoked by the users, the libsasl2 plugins are not executables.

That is why I consider libexec as supoptimal in this case.

Apart from this, http://cyrusimap.org/docs/cyrus-sasl/2.1.23/sysadmin.php#saslconf says that the sasl2 application configuration files are checked (only) in /usr/lib/sasl2 and does not mention /etc/sasl2 . According to the NEWS file bug #2796 as of cyrus sasl 2.1.22 the /etc/sasl2 directory is searched as well (and I think this is much better so, in order to avoid configuration files in /usr/lib/sasl2 or /usr/lib64/sasl2 , depending on the 32/64bits of the application).

@brong
Copy link
Member Author

brong commented Feb 16, 2011

From: Jeroen van Meeuwen (Kolab Systems)

(In reply to comment #2)
> About plugindir under /usr/libexec:
>
> Keep in mind, that on mixed 32/64 bit systems you need distinct plugin binaries
> for 32 and 64 bit code, and the best way to manage this is with two different
> directories.
>

Just like with {,/usr}/{,s}bin/, a mixed architecture system on a single / shared root filesystem is cumbersome at best. /usr/sbin for example is not to be shared between a x86_64 and ppc64 simultaneously either (think GFS(2) over iSCSI, or NFS root filesystem). Likewise, the 32/64 bit doesn't pose a problem for plugins being located in /usr/libexec/.

Should the plugins be moved, I suppose one would want to avoid moving them to another libdir and pay dynamic linker overhead whereas the plugins are dlopen()'ed (iirc).

@brong
Copy link
Member Author

brong commented Mar 24, 2016

Attachment-Id: 1567
From: Jan Parcel
Type: text/plain
File: sasldir-fix-dist.patch

Patch to allow multiarch placement of plugins, based on distrib bundle

@brong
Copy link
Member Author

brong commented Mar 24, 2016

From: Jan Parcel

In the distributed 2.1.26, I was having trouble configuring plugindir and
sasldir. Unlike the comments in README.andrew, I could find no way to set
sasldir, and it had initially looked like plugindir meant something
different, because it seemed to be hard-coded to be $(PREFIX)/lib/sasl2 and
would complain if it wasn't.

On Solaris systems, the install path and search path are different. For
installing, a 32-bit library goes into $(PREFIX)/usr/lib, and the 64-bit goes
into $(PREFIX/usr/lib/$(MACH64), but for searching we do NOT append the
$(MACH64).

So I had to patch configure.in to create a --with-sasldir option, and
patch Makefile.am to make the complaints match the realities of searching,
and patch plugins/Makefile.am to not hardcode sasldir.

I have attached my patch, which is NOT a code patch from your viewpoint, but
it shows what I did, as an example.

If the fixes that are decided upon allow our library design to be configurable
with configure options, then I don't need to file a bug, I'll just wait for a
fix
in a future update.

@dilyanpalauzov
Copy link

dilyanpalauzov commented Apr 23, 2017

sasl installs the plugins in $prefix/lib/sasl2, which defaults to /usr/local/lib/sasl2, but looks for them in $plugindir, which defaults to /usr/lib/sasl2 . So "./configure && make install" does not work.

This patch:

  • ensures a usable system after "./configure && make install", in particular it abolishes the possibility to install plugins in one directory and load them from another;
  • installs the plugins by default in $(libdir)/sasl2;
  • looks for configuration files by default in the directory, where plugins are installed, as de jure it has always been, and in ${sysconfdir}/sasl2 instead of /etc/sasl2;
  • updates ./configure --help accordingly; and
  • fixes two compiler warnings.
--- a/Makefile.am
+++ b/Makefile.am
@@ -83,24 +83,6 @@ dist-hook:
        (cd $(distdir)/plugins && sh makeinit.sh)
 
 framedir = /Library/Frameworks/SASL2.framework
-install-exec-local: $(INSTALLOSX)
-       @if test "$(plugindir)" != "$(prefix)/lib/sasl2"; then \
-         echo "********************************************************"; \
-         echo "* WARNING:"; \
-         echo "* Plugins are being installed into $(prefix)/lib/sasl2,"; \
-         echo "* but the library will look for them in $(plugindir)."; \
-         echo "* You need to make sure that the plugins will eventually"; \
-         echo "* be in $(plugindir) -- the easiest way is to make a"; \
-         echo "* symbolic link from $(plugindir) to $(prefix)/lib/sasl2,"; \
-         echo "* but this may not be appropriate for your site, so this"; \
-         echo "* installation procedure won't do it for you."; \
-         echo "*"; \
-          echo "* If you don't want to do this for some reason, you can"; \
-          echo "* set the location where the library will look for plugins"; \
-         echo "* by setting the environment variable SASL_PATH to the path"; \
-         echo "* the library should use."; \
-         echo "********************************************************"; \
-       fi
 install-exec-local-osx:
        $(mkinstalldirs) $(framedir)/Versions/A/Headers
        $(mkinstalldirs) $(framedir)/Versions/A/Resources
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1121,17 +1121,15 @@ AC_SUBST(SASL_STATIC_OBJS)
 AC_SUBST(SASL_STATIC_LIBS)
 
 AC_ARG_WITH(plugindir, [  --with-plugindir=DIR    set the directory where plugins will
-                          be found [[/usr/lib/sasl2]] ],
+                          be found [[LIBDIR/sasl2]] ],
   plugindir=$withval,
-  plugindir=/usr/lib/sasl2)
-AC_DEFINE_UNQUOTED(PLUGINDIR, "$plugindir", [Runtime plugin location])
+  plugindir='${libdir}'/sasl2)
 AC_SUBST(plugindir)
 
 AC_ARG_WITH(configdir, [   --with-configdir=DIR    set the directory where config files will
-                          be found [/usr/lib/sasl2] ],
+                          be found [PLUGINDIR:SYSCONFDIR/sasl2] ],
   configdir=$withval,
-  configdir=$plugindir:/etc/sasl2)
-AC_DEFINE_UNQUOTED(CONFIGDIR, "$configdir", [Runtime config file location])
+  configdir='${plugindir}:${sysconfdir}/sasl2')
 AC_SUBST(configdir)
 
 dnl look for rc4 libraries. we accept the CMU one or one from openSSL
diff --git a/lib/Makefile.am b/lib/Makefile.am
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -45,7 +45,7 @@
 # CURRENT:REVISION:AGE
 sasl_version = 3:0:0
 
-AM_CPPFLAGS=-DLIBSASL_EXPORTS=1 -I$(top_srcdir)/include -I$(top_srcdir)/plugins -I$(top_builddir)/include -I$(top_srcdir)/sasldb
+AM_CPPFLAGS=-DLIBSASL_EXPORTS=1 -I$(top_srcdir)/include -I$(top_srcdir)/plugins -I$(top_builddir)/include -I$(top_srcdir)/sasldb -DCONFIGDIR='"${configdir}"' -DPLUGINDIR='"${plugindir}"'
 
 EXTRA_DIST = windlopen.c dlopen.c staticopen.h NTMakefile
 EXTRA_LIBRARIES = libsasl2.a
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -63,8 +63,8 @@ plugindir = @plugindir@
 
 common_sources = plugin_common.c plugin_common.h
 
-sasldir = $(prefix)/lib/sasl2
-sasl_LTLIBRARIES = @SASL_MECHS@
+
+plugin_LTLIBRARIES = @SASL_MECHS@
 EXTRA_LTLIBRARIES = libplain.la libanonymous.la libkerberos4.la libcrammd5.la \
        libgs2.la libgssapiv2.la libdigestmd5.la liblogin.la libsrp.la libotp.la \
        libscram.la libntlm.la libpassdss.la libsasldb.la libsql.la libldapdb.la
diff --git a/sample/Makefile.am b/sample/Makefile.am
--- a/sample/Makefile.am
+++ b/sample/Makefile.am
@@ -42,7 +42,7 @@
 #
 ################################################################
 
-AM_CPPFLAGS=-I$(top_srcdir)/include
+AM_CPPFLAGS=-I$(top_srcdir)/include -DPLUGINDIR='"${plugindir}"'
 
 noinst_PROGRAMS = client server
 EXTRA_PROGRAMS = sample-client sample-server
diff --git a/utils/Makefile.am b/utils/Makefile.am
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -89,7 +89,7 @@ libsfsasl2_la_SOURCES =
 libsfsasl2_la_LIBADD = sfsasl.lo
 libsfsasl2_la_LDFLAGS = -version-info 1:0:0 -export-dynamic -rpath $(libdir)
 
-AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include @SASL_DB_INC@
+AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include @SASL_DB_INC@ -DPLUGINDIR='"${plugindir}"'
 EXTRA_DIST = saslpasswd2.8 sasldblistusers2.8 pluginviewer.8 sfsasl.h sfsasl.c smtptest.c testsuite.c pluginviewer.c NTMakefile
 
 sfsasl.lo: sfsasl.c

diff --git a/plugins/gssapi.c b/plugins/gssapi.c
--- a/plugins/gssapi.c
+++ b/plugins/gssapi.c
@@ -652,11 +652,12 @@ static void gssapi_common_mech_free(void *global_context __attribute__((unused))
  * flags negotiated by GSSAPI to determine If confidentiality or integrity are
  * used. These flags are stored in text->qop transalated as layers by the
  * caller */
-static int gssapi_spnego_ssf(context_t *text, const sasl_utils_t *utils,
+static int gssapi_spnego_ssf(context_t *text,
+                            const sasl_utils_t *utils __attribute__((unused)),
                              sasl_security_properties_t *props,
                              sasl_out_params_t *oparams)
 {
-    OM_uint32 maj_stat = 0, min_stat = 0;
+    OM_uint32 __attribute__((unused)) maj_stat = 0, min_stat = 0;
     OM_uint32 max_input;
 
     if (text->qop & LAYER_CONFIDENTIALITY) {

@dilyanpalauzov
Copy link

In fact, when utils/pluginviewer.c:getpath() is called, the context parameter is always set, so PLUGINDIR built in libsasl2 is always used. Likewise for sample/sample-client.c. No need for PLUGINDIR in utils/Makefile.am:

--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -89,7 +89,7 @@ libsfsasl2_la_SOURCES =
 libsfsasl2_la_LIBADD = sfsasl.lo
 libsfsasl2_la_LDFLAGS = -version-info 1:0:0 -export-dynamic -rpath $(libdir)
 
-AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include @SASL_DB_INC@ -DPLUGINDIR='"${plugindir}"'
+AM_CPPFLAGS=-I$(top_srcdir)/include -I$(top_builddir)/include @SASL_DB_INC@
 EXTRA_DIST = saslpasswd2.8 sasldblistusers2.8 pluginviewer.8 sfsasl.h sfsasl.c smtptest.c testsuite.c pluginviewer.c NTMakefile
 
 sfsasl.lo: sfsasl.c
diff --git a/utils/pluginviewer.c b/utils/pluginviewer.c
--- a/utils/pluginviewer.c
+++ b/utils/pluginviewer.c
@@ -193,12 +193,7 @@ getpath(void *context,
     if (! path) {
         return SASL_BADPARAM;
     }
-
-    if (searchpath) {
-        *path = searchpath;
-    } else {
-        *path = PLUGINDIR;
-    }
+    *path = searchpath;
 
     return SASL_OK;
 }
diff --git a/sample/sample-client.c b/sample/sample-client.c
--- a/sample/sample-client.c
+++ b/sample/sample-client.c
@@ -197,11 +197,7 @@ getpath(void *context,
   if (! path)
     return SASL_BADPARAM;
 
-  if (searchpath) {
-      *path = searchpath;
-  } else {
-      *path = PLUGINDIR;
-  }
+  *path = searchpath;
 
   return SASL_OK;
 }

@quanah quanah added this to the 2.2.0 milestone Apr 19, 2022
@quanah quanah assigned quanah and hyc and unassigned ksmurchison and quanah Aug 24, 2023
@hyc
Copy link
Contributor

hyc commented Aug 31, 2023

@dilyanpalauzov the patches look ok to me but I think we need a DCO from you.

@quanah
Copy link
Contributor

quanah commented Aug 31, 2023

Best to open this as a PR w/ the commit sign off to meet the DCO requirements.

hyc added a commit to hyc/cyrus-sasl that referenced this issue Sep 18, 2023
Closes cyrusimap#339

Most of the changes mentioned there were already committed in cyrusimap#528
This commit just removes some unused references to PLUGINDIR.

Signed-off-by: Howard Chu <hyc@symas.com>
@hyc hyc mentioned this issue Sep 18, 2023
@hyc
Copy link
Contributor

hyc commented Sep 18, 2023

The only relevant parts remaining were all deletions so I guess there's nothing creative to deal with.

quanah pushed a commit that referenced this issue Sep 19, 2023
Closes #339

Most of the changes mentioned there were already committed in #528
This commit just removes some unused references to PLUGINDIR.

Signed-off-by: Howard Chu <hyc@symas.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants