[SSSD] having trouble linking with libsamba-security (but only sometimes)

Günther Deschner gdeschne at redhat.com
Fri Apr 4 10:40:43 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Yassir,

linking a private library is not a good idea in general.

You could use well documented and public calls
ConvertSidToStringSid() and ConvertStringSidToSid() from netapi for
example.

See:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa376399%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa376402%28v=vs.85%29.aspx

or netapi.h for their usage and examples.

Guenther

On 03/04/14 20:47, Yassir Elley wrote:
> Hi all,
> 
> I have been using a samba function (string_to_sid) in my gpo code
> and have had no trouble so far compiling and linking my
> libsss_ad.so gpo code.
> 
> I simply needed to apply the following patches, which includes
> having to declare the string_to_sid function before it is used in
> the file. --- /dev/null +++ b/src/providers/ad/ad_gpo.c @@  @@ + +
> bool string_to_sid(struct dom_sid *sidout, const char *sidstr); + 
> --- a/Makefile.am +++ b/Makefile.am @@  @@ libsss_ad_la_SOURCES =
> \ src/providers/ad/ad_access.h \ +    src/providers/ad/ad_gpo.c \ +
> src/providers/ad/ad_gpo.h \ src/providers/ad/ad_opts.h \
> 
> 
> However, now that I'm creating a gpo unit test (using the same
> string_to_sid function), the linker fails with the following
> message: /usr/bin/ld: src/tests/cmocka/ad_gpo_tests-test_ad_gpo.o:
> undefined reference to symbol 'string_to_sid@@SAMBA_4.1.5' 
> /usr/bin/ld: note: 'string_to_sid@@SAMBA_4.1.5' is defined in DSO
> /usr/lib64/samba/libsamba-security.so so try adding it to the
> linker command line /usr/lib64/samba/libsamba-security.so: could
> not read symbols: Invalid operation
> 
> I applied the following patches to get ad_gpo_test.c, which allowed
> me to compile successfully, but the link failed with the above
> message. --- a/Makefile.am +++ b/Makefile.am @@  @@ if HAVE_CMOCKA 
> ad_access_filter_tests \ +        ad_gpo_tests \ ad_common_tests \ 
> @@  @@ ad_access_filter_tests_LDADD = \ +ad_gpo_tests_SOURCES = \ +
> $(sssd_be_SOURCES) \ +    src/util/sss_ldap.c \ +
> src/util/sss_krb5.c \ +    src/util/find_uid.c \ +
> src/util/user_info_msg.c \ +    src/providers/ad/ad_common.c \ +
> src/tests/cmocka/test_ad_gpo.c +ad_gpo_tests_CFLAGS = \ +
> $(AM_CFLAGS) \ +    $(SYSTEMD_LOGIN_CFLAGS) \ +
> $(NDR_NBT_CFLAGS) \ +    -DUNIT_TESTING +ad_gpo_tests_LDADD = \ +
> $(PAM_LIBS) \ +    $(CMOCKA_LIBS) \ +    $(SSSD_LIBS) \ +
> $(CARES_LIBS) \ +    $(KRB5_LIBS) \ +    $(SSSD_INTERNAL_LTLIBS) \ 
> +    $(SYSTEMD_LOGIN_LIBS) \ +    $(NDR_NBT_LIBS) \ +
> libsss_ldap_common.la \ +    libsss_idmap.la \ +
> libsss_krb5_common.la \ +    libsss_ad.la \ +
> libsss_test_common.la + ad_common_tests_SOURCES = \
> 
> If I apply the following patch, I am able to compile and link
> successfully!!: --- a/Makefile.am +++ b/Makefile.am @@ -1625,7
> +1625,10 @@ ad_gpo_tests_CFLAGS = \ $(SYSTEMD_LOGIN_CFLAGS) \ 
> $(NDR_NBT_CFLAGS) \ -DUNIT_TESTING +ad_gpo_tests_LDFLAGS = \ +
> -rpath $(libdir)/samba ad_gpo_tests_LDADD = \ +
> $(libdir)/samba/libsamba-security.so \ $(PAM_LIBS) \ $(CMOCKA_LIBS)
> \
> 
> I am confused by a few things: * Why do we need to explicitly add
> libsamba-security.so (and -rpath) to the linker line for the gpo
> tests, but not for libsss_ad.so * The patch that allows the
> gpo_tests to link/compile might not be portable b/c it assumes that
> libsamba-security.so is in $(libdir)/samba for all distributions.
> Is that a valid assumption? * One of the issues seems to be that
> the linker only looks in $(libdir) and $(libdir)/sssd, which is why
> adding the rpath works. Is this really the first time that we are
> using a library not in $(libdir) or $(libdir)/sssd. In other words,
> I would have expected this to have happened before (i.e. linking
> against a library not in the default locations). * Presumably, the
> libsss_ad.so gpo code links successfully because it is pulling in a
> library (which is internally pulling in libsamba-security), but I'm
> not sure which library that is. Any ideas? * Is there a better
> solution for getting the gpo tests to link?
> 
> Thanks, Yassir.
> 


- -- 
Günther Deschner                    GPG-ID: 8EE11688
Red Hat                         gdeschner at redhat.com
Samba Team                              gd at samba.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlM+jB4ACgkQSOk3aI7hFogz3wCfVz/PxiTeMSnPy7AQ8FfnUWwl
kcMAniuX6mDalMt/+tcQEW4uIs1b4GEQ
=hiW6
-----END PGP SIGNATURE-----



More information about the sssd-devel mailing list