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

Build fails against samba 4.15.5 #348

Closed
dmulder opened this issue Feb 8, 2022 · 8 comments
Closed

Build fails against samba 4.15.5 #348

dmulder opened this issue Feb 8, 2022 · 8 comments
Assignees
Labels

Comments

@dmulder
Copy link
Contributor

dmulder commented Feb 8, 2022

[ 5s] /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c: In function 'ndr_pull_security_token':
[ 5s] /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c:1105:23: error: too few arguments to function 'ndr_get_array_size'
[ 5s] 1105 | size_sids_0 = ndr_get_array_size(ndr, &r->sids);
[ 5s] | ^~~~~~~~~~~~~~~~~~
[ 5s] In file included from /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.h:28,
[ 5s] from /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c:24:
[ 5s] /usr/include/samba-4.0/ndr.h:658:19: note: declared here
[ 5s] 658 | enum ndr_err_code ndr_get_array_size(struct ndr_pull *ndr, const void *p, uint32_t *size);
[ 5s] | ^~~~~~~~~~~~~~~~~~
[ 5s] /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c: In function 'ndr_pull_security_unix_token':
[ 5s] /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c:1182:25: error: too few arguments to function 'ndr_get_array_size'
[ 5s] 1182 | size_groups_0 = ndr_get_array_size(ndr, &r->groups);
[ 5s] | ^~~~~~~~~~~~~~~~~~
[ 5s] In file included from /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.h:28,
[ 5s] from /home/abuild/rpmbuild/BUILD/admc-0.9.0/src/adldap/samba/ndr_security.c:24:
[ 5s] /usr/include/samba-4.0/ndr.h:658:19: note: declared here
[ 5s] 658 | enum ndr_err_code ndr_get_array_size(struct ndr_pull *ndr, const void *p, uint32_t *size);
[ 5s] | ^~~~~~~~~~~~~~~~~~
[ 5s] make[2]: *** [src/adldap/CMakeFiles/adldap.dir/build.make:235: src/adldap/CMakeFiles/adldap.dir/samba/ndr_security.c.o] Error 1

You need to patch admc according to the samba ndr change in https://gitlab.com/samba-team/samba/-/commit/c35f4180a44eb3caecad0f2daab46574bc52be83

@dmulder
Copy link
Contributor Author

dmulder commented Feb 8, 2022

diff --git a/src/adldap/samba/ndr_security.c b/src/adldap/samba/ndr_security.c
index b7502b76..39cfe1ef 100644
--- a/src/adldap/samba/ndr_security.c
+++ b/src/adldap/samba/ndr_security.c
@@ -1102,7 +1102,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_security_token(struct ndr_pull *ndr, int ndr
         NDR_CHECK(ndr_pull_align(ndr, 8));
         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_sids));
         NDR_CHECK(ndr_pull_array_size(ndr, &r->sids));
-        size_sids_0 = ndr_get_array_size(ndr, &r->sids);
+        ndr_get_array_size(ndr, &r->sids, &size_sids_0);
         NDR_PULL_ALLOC_N(ndr, r->sids, size_sids_0);
         _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr);
         NDR_PULL_SET_MEM_CTX(ndr, r->sids, 0);
@@ -1179,7 +1179,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_security_unix_token(struct ndr_pull *ndr, in
         NDR_CHECK(ndr_pull_uid_t(ndr, NDR_SCALARS, &r->uid));
         NDR_CHECK(ndr_pull_gid_t(ndr, NDR_SCALARS, &r->gid));
         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ngroups));
-        size_groups_0 = ndr_get_array_size(ndr, &r->groups);
+        ndr_get_array_size(ndr, &r->groups, &size_groups_0);
         NDR_PULL_ALLOC_N(ndr, r->groups, size_groups_0);
         _mem_save_groups_0 = NDR_PULL_GET_MEM_CTX(ndr);
         NDR_PULL_SET_MEM_CTX(ndr, r->groups, 0);

@mastersin
Copy link
Member

mastersin commented Feb 8, 2022

It's looks like we could use pkg_check_modules for NDR library with NDR_VERSION variable to check API in compile time:

diff --git a/librpc/wscript_build b/librpc/wscript_build
index b82209b4299..59d6c31363d 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -361,11 +361,6 @@ bld.SAMBA_SUBSYSTEM('NDR_DRSBLOBS',
     header_path=[ ('gen_ndr*', 'gen_ndr'), ('ndr*', 'ndr')]
     )
 
-bld.SAMBA_SUBSYSTEM('NDR_ODJ',
-    source='gen_ndr/ndr_ODJ.c ndr/ndr_ODJ.c',
-    public_deps='NDR_LSA NDR_NETLOGON NDR_SECURITY',
-    deps='ndr')
-
 bld.SAMBA_SUBSYSTEM('NDR_KRB5PAC',
                     source='',
                     deps='ndr-krb5pac')
@@ -654,7 +649,7 @@ bld.SAMBA_LIBRARY('ndr',
     public_deps='samba-errors talloc samba-util util_str_hex',
     public_headers='gen_ndr/misc.h gen_ndr/ndr_misc.h ndr/libndr.h:ndr.h',
     header_path= [('*gen_ndr*', 'gen_ndr')],
-    vnum='2.0.0',
+    vnum='1.0.1',
     abi_directory='ABI',
     abi_match='!ndr_table_* ndr_* GUID_* _ndr_pull_error* _ndr_push_error*',
     )

@dmulder
Copy link
Contributor Author

dmulder commented Feb 9, 2022

I'm also seeing these build failures:

[ 32%] Linking CXX executable ../../admc
../../libadldap.so: error: undefined reference to 'rep_memset_s'
../../libadldap.so: error: undefined reference to 'ndr_size_security_descriptor'
../../libadldap.so: error: undefined reference to 'ndr_pull_dom_sid'
../../libadldap.so: error: undefined reference to 'ndr_pull_security_ace'
../../libadldap.so: error: undefined reference to 'ndr_size_security_acl'
../../libadldap.so: error: undefined reference to 'ndr_push_dom_sid'
../../libadldap.so: error: undefined reference to 'ndr_size_security_ace'
../../libadldap.so: error: undefined reference to 'ndr_print_dom_sid'
collect2: error: ld returned 1 exit status
make[2]: *** [src/admc/CMakeFiles/admc.dir/build.make:2258: admc] Error 1
make[1]: *** [CMakeFiles/Makefile2:343: src/admc/CMakeFiles/admc.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I wonder if this is related?

@Kvel2D Kvel2D self-assigned this Feb 10, 2022
@Kvel2D Kvel2D added the adldap label Feb 10, 2022
@Kvel2D
Copy link
Collaborator

Kvel2D commented Feb 10, 2022

Ok, will need to first get version of samba during compile time, then set some flag SAMBA_VERSION_ABOVE_X, push it to config.h, then load into code and use #ifdef to make code compatible to both versions above and below the problematic version.

I'm also seeing these build failures:

[ 32%] Linking CXX executable ../../admc
../../libadldap.so: error: undefined reference to 'rep_memset_s'
../../libadldap.so: error: undefined reference to 'ndr_size_security_descriptor'
../../libadldap.so: error: undefined reference to 'ndr_pull_dom_sid'
../../libadldap.so: error: undefined reference to 'ndr_pull_security_ace'
../../libadldap.so: error: undefined reference to 'ndr_size_security_acl'
../../libadldap.so: error: undefined reference to 'ndr_push_dom_sid'
../../libadldap.so: error: undefined reference to 'ndr_size_security_ace'
../../libadldap.so: error: undefined reference to 'ndr_print_dom_sid'
collect2: error: ld returned 1 exit status
make[2]: *** [src/admc/CMakeFiles/admc.dir/build.make:2258: admc] Error 1
make[1]: *** [CMakeFiles/Makefile2:343: src/admc/CMakeFiles/admc.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I wonder if this is related?

Probably, yes. ndr_security fails to compile due to changed samba f-n signatures, and ndr_security contains ndr_size_security_descriptor and so on.

@dmulder
Copy link
Contributor Author

dmulder commented Feb 10, 2022

I managed to get it to build/run with my ndr patch, plus specifying -DCMAKE_SHARED_LINKER_FLAGS=-undefined to ignore the undefined failiures.

@dmulder dmulder closed this as completed Feb 28, 2022
@Kvel2D
Copy link
Collaborator

Kvel2D commented Mar 1, 2022

@dmulder I've been on a vacation, so wasn't able to work on this. Does this still need attention?

@Kvel2D
Copy link
Collaborator

Kvel2D commented Mar 23, 2022

Need to solve this since ALT is upgrading samba to 4.15.

@Kvel2D Kvel2D reopened this Mar 23, 2022
@Kvel2D
Copy link
Collaborator

Kvel2D commented Apr 1, 2022

Fixed by 9fa2f3a
This has been pushed to version 0.8.3 and will be available in 0.9.0.

@Kvel2D Kvel2D closed this as completed Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants