Dear Samba-experts:
we migrated from Samba 3.6 to 4.18 and everything works well.
But there are two problems where I need some expert-help:
We are using a daemon that is running on our AD-server. It accepts
connections from remote machines and changes the passwords of
certain users. Calling system("smbpasswd") from within that daemon
would be too slow so the daemon calls local_password_change().
I therefor compile that daemon within the Samba source-tree.
Since its function is simular to smbpasswd I duplicated
source3/utils/smbpasswd.c into source3/utils/smbscardd.c,
replaced main() and removed all unneccessary routines.
I then duplicated the smbpasswd-rules in Makefile as well so
calling make would create the daemon.
Samba4 uses a new build system, so I added source3/utils/smbscardd.c
and replaced
bld.SAMBA3_BINARY('smbpasswd',
???????????????? source='smbpasswd.c',
???????????????? deps='''
???????????????? talloc
???????????????? smbconf
???????????????? pdb
???????????????? PASSWD_UTIL
???????????????? PASSCHANGE
???????????????? cmdline_contexts
???????????????? ''')
by
bld.SAMBA3_BINARY('smbpasswd',
???????????????? source='smbpasswd.c',
???????????????? deps='''
???????????????? talloc
???????????????? smbconf
???????????????? pdb
???????????????? PASSWD_UTIL
???????????????? PASSCHANGE
???????????????? cmdline_contexts
???????????????? ''')
bld.SAMBA3_BINARY('smbscardd',
???????????????? source='smbscardd.c',
???????????????? deps='''
???????????????? talloc
???????????????? smbconf
???????????????? pdb
???????????????? PASSWD_UTIL
???????????????? PASSCHANGE
???????????????? cmdline_contexts
???????????????? ''')
Unfortunately this does not work. smbscardd.c compiles, but
it won't link since it needs one more library, i.e. -lcrypto
I therefor did
PYTHONHASHSEED=1 WAF_MAKE=1 ./buildtools/bin/waf -v build
to see what's going on.
The last message is:
Build failed
?-> task in 'smbscardd' failed with exit status 1:
??????? {task 140216595759840: cprogram
smbscardd.c.12.o,passchange.c.107.o,passwd_util.c.1.o,init_samr.c.141.o,cli_samr.c.126.o,init_lsa.c.140.o
-> smbscardd}
['/usr/bin/gcc', '-Wl,--as-needed',
'source3/utils/smbscardd.c.12.o',
'source3/libsmb/passchange.c.107.o',
'source3/utils/passwd_util.c.1.o',
'source3/rpc_client/init_samr.c.141.o',
'source3/rpc_client/cli_samr.c.126.o',
'source3/rpc_client/init_lsa.c.140.o',
'-o/var/tmp/samba-4.19.0/bin/default/source3/utils/smbscardd',
'-Wl,-rpath,/var/tmp/samba-4.19.0/bin/shared',
'-Wl,-rpath,/var/tmp/samba-4.19.0/bin/shared/private',
'-Wl,-Bstatic',
'-Wl,-Bdynamic',
'-L/var/tmp/samba-4.19.0/bin/default/source4/cluster',
'-L/var/tmp/samba-4.19.0/bin/default/source4/lib/messaging',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/nbt',
'-L/var/tmp/samba-4.19.0/bin/default/source4/lib/socket',
'-L/var/tmp/samba-4.19.0/bin/default/auth',
'-L/var/tmp/samba-4.19.0/bin/default/source4/libcli/ldap',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/dns',
'-L/var/tmp/samba-4.19.0/bin/default/lib/ldb',
'-L/var/tmp/samba-4.19.0/bin/default/source4/auth/kerberos',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/cldap',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/smb',
'-L/var/tmp/samba-4.19.0/bin/default/lib/addns',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/ldap',
'-L/var/tmp/samba-4.19.0/bin/default/source4/lib/events',
'-L/var/tmp/samba-4.19.0/bin/default/lib/tdb_wrap',
'-L/var/tmp/samba-4.19.0/bin/default/third_party/heimdal_build',
'-L/var/tmp/samba-4.19.0/bin/default/source4/dsdb',
'-L/var/tmp/samba-4.19.0/bin/default/libds/common',
'-L/var/tmp/samba-4.19.0/bin/default/lib/tdb',
'-L/var/tmp/samba-4.19.0/bin/default/lib/ldb-samba',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/registry',
'-L/var/tmp/samba-4.19.0/bin/default/auth/gensec',
'-L/var/tmp/samba-4.19.0/bin/default/source4/librpc',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/named_pipe_auth',
'-L/var/tmp/samba-4.19.0/bin/default/lib/param',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/auth',
'-L/var/tmp/samba-4.19.0/bin/default/nsswitch/libwbclient',
'-L/var/tmp/samba-4.19.0/bin/default/auth/credentials',
'-L/var/tmp/samba-4.19.0/bin/default/lib',
'-L/var/tmp/samba-4.19.0/bin/default/lib/socket',
'-L/var/tmp/samba-4.19.0/bin/default/lib/messaging',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/security',
'-L/var/tmp/samba-4.19.0/bin/default/lib/replace',
'-L/var/tmp/samba-4.19.0/bin/default/lib/dbwrap',
'-L/var/tmp/samba-4.19.0/bin/default/lib/tevent',
'-L/var/tmp/samba-4.19.0/bin/default/lib/krb5_wrap',
'-L/var/tmp/samba-4.19.0/bin/default/lib/util',
'-L/var/tmp/samba-4.19.0/bin/default/lib/talloc',
'-L/var/tmp/samba-4.19.0/bin/default/librpc',
'-L/var/tmp/samba-4.19.0/bin/default/source3',
'-L/var/tmp/samba-4.19.0/bin/default/libcli/util',
'-L/usr/local/lib',
'-L/usr/local/lib', '-lsamba-errors',
'-lcmdline-contexts-samba4',
'-lmsrpc3-samba4', '-lsmbconf', '-lsamba-passdb',
'-ldcerpc-samba-samba4', '-ltalloc-samba4',
'-lsamba-util',
'-lkrb5samba-samba4', '-lsamba-debug-samba4', '-lndr',
'-lmessages-util-samba4', '-lsamba3-util-samba4',
'-ltevent-samba4',
'-ldbwrap-samba4', '-lsys-rw-samba4',
'-lserver-id-db-samba4',
'-lreplace-samba4', '-lsamba-security-samba4',
'-ltalloc-report-printf-samba4', '-liov-buf-samba4',
'-lsocket-blocking-samba4', '-lmessages-dgm-samba4',
'-linterfaces-samba4', '-lsamba-sockets-samba4',
'-lCHARSET3-samba4',
'-ltevent-util', '-lsamba-cluster-support-samba4',
'-lutil-tdb-samba4',
'-ldcerpc-binding', '-llibsmb-samba4',
'-lsamba-credentials',
'-lgse-samba4', '-lndr-samba-samba4', '-lwbclient',
'-lcliauth-samba4',
'-lsamba-hostconfig', '-lnpa-tstream-samba4',
'-lndr-nbt',
'-lndr-standard', '-lndr-samba4', '-lgensec-samba4',
'-lutil-reg-samba4', '-lsmbd-shim-samba4',
'-lsmbldaphelper-samba4',
'-lsamba-modules-samba4', '-lldbsamba-samba4',
'-ltdb-samba4',
'-lsecrets3-samba4', '-lsmbldap',
'-lflag-mapping-samba4',
'-lsamdb-common-samba4', '-lsamdb', '-lgenrand-samba4',
'-lutil-setid-samba4', '-ltime-basic-samba4',
'-lasn1-samba4',
'-lkrb5-samba4', '-lgssapi-samba4', '-lcom-err-samba4',
'-ltdb-wrap-samba4', '-lmsghdr-samba4',
'-levents-samba4',
'-lcli-ldap-common-samba4', '-lasn1util-samba4',
'-laddns-samba4',
'-lcli-smb-common-samba4', '-lcli-cldap-samba4',
'-lauthkrb5-samba4',
'-lldb-samba4', '-lstable-sort-samba4', '-lndr-krb5pac',
'-lserver-role-samba4', '-lroken-samba4',
'-lheimbase-samba4',
'-lhx509-samba4', '-lwind-samba4', '-lhcrypto-samba4',
'-lclidns-samba4', '-lsmb-transport-samba4',
'-lcli-ldap-samba4',
'-lcommon-auth-samba4', '-lnetif-samba4',
'-lcli-nbt-samba4',
'-lMESSAGING-SEND-samba4', '-lcluster-samba4',
'-ljansson', '-lutil',
'-lresolv', '-licuuc', '-licudata', '-licui18n',
'-lldap', '-llber',
'-lz', '-ldl', '-lgnutls', '-lpthread',
'-pie', '-Wl,-z,relro,-z,now',
'-Wl,-no-undefined', '-Wl,--export-dynamic']
I tried hard to understand the waf build system and find out how
to add -lcrypto to the compile statement of smbscardd.
Since I did not find a way to do so, I manually compiled the daemon with:
cd bin/default
gcc -Wl,--as-needed \
??? source3/utils/smbscardd.c.12.o source3/libsmb/passchange.c.107.o
source3/utils/passwd_util.c.1.o \
??? source3/rpc_client/init_samr.c.141.o
source3/rpc_client/cli_samr.c.126.o source3/rpc_client/init_lsa.c.140.o \
??? -o source3/utils/smbscardd \
??? -Wl,-rpath,/var/tmp/samba-4.19.0/bin/shared \
??? -Wl,-rpath,/var/tmp/samba-4.19.0/bin/shared/private \
??? -Wl,-Bstatic -Wl,-Bdynamic \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/cluster \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/lib/messaging \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/nbt \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/lib/socket \
??? -L/var/tmp/samba-4.19.0/bin/default/auth \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/libcli/ldap \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/dns \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/ldb \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/auth/kerberos \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/cldap \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/smb \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/addns \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/ldap \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/lib/events \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/tdb_wrap \
??? -L/var/tmp/samba-4.19.0/bin/default/third_party/heimdal_build \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/dsdb \
??? -L/var/tmp/samba-4.19.0/bin/default/libds/common \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/tdb \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/ldb-samba \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/registry \
??? -L/var/tmp/samba-4.19.0/bin/default/auth/gensec \
??? -L/var/tmp/samba-4.19.0/bin/default/source4/librpc \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/named_pipe_auth \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/param \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/auth \
??? -L/var/tmp/samba-4.19.0/bin/default/nsswitch/libwbclient \
??? -L/var/tmp/samba-4.19.0/bin/default/auth/credentials \
??? -L/var/tmp/samba-4.19.0/bin/default/lib \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/socket \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/messaging \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/security \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/replace \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/dbwrap \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/tevent \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/krb5_wrap \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/util \
??? -L/var/tmp/samba-4.19.0/bin/default/lib/talloc \
??? -L/var/tmp/samba-4.19.0/bin/default/librpc \
??? -L/var/tmp/samba-4.19.0/bin/default/source3 \
??? -L/var/tmp/samba-4.19.0/bin/default/libcli/util \
??? -L/usr/local/lib \
??? -lsamba-errors -lcmdline-contexts-samba4 -lmsrpc3-samba4 -lsmbconf
-lsamba-passdb \
??? -ldcerpc-samba-samba4 -ltalloc-samba4 -lsamba-util
-lkrb5samba-samba4 -lsamba-debug-samba4 \
??? -lndr -lmessages-util-samba4 -lsamba3-util-samba4 -ltevent-samba4
-ldbwrap-samba4 \
??? -lsys-rw-samba4 -lserver-id-db-samba4 -lreplace-samba4
-lsamba-security-samba4 \
??? -ltalloc-report-printf-samba4 -liov-buf-samba4
-lsocket-blocking-samba4 -lmessages-dgm-samba4 \
??? -linterfaces-samba4 -lsamba-sockets-samba4 -lCHARSET3-samba4
-ltevent-util \
??? -lsamba-cluster-support-samba4 -lutil-tdb-samba4 -ldcerpc-binding
-llibsmb-samba4 \
??? -lsamba-credentials -lgse-samba4 -lndr-samba-samba4 -lwbclient
-lcliauth-samba4 \
??? -lsamba-hostconfig -lnpa-tstream-samba4 -lndr-nbt -lndr-standard
-lndr-samba4 -lgensec-samba4 \
??? -lutil-reg-samba4 -lsmbd-shim-samba4 -lsmbldaphelper-samba4
-lsamba-modules-samba4 \
??? -lldbsamba-samba4 -ltdb-samba4 -lsecrets3-samba4 -lsmbldap
-lflag-mapping-samba4 \
??? -lsamdb-common-samba4 -lsamdb -lgenrand-samba4 -lutil-setid-samba4
-ltime-basic-samba4 \
??? -lasn1-samba4 -lkrb5-samba4 -lgssapi-samba4 -lcom-err-samba4
-ltdb-wrap-samba4 -lmsghdr-samba4 \
??? -levents-samba4 -lcli-ldap-common-samba4 -lasn1util-samba4
-laddns-samba4 -lcli-smb-common-samba4 \
??? -lcli-cldap-samba4 -lauthkrb5-samba4 -lldb-samba4
-lstable-sort-samba4 -lndr-krb5pac \
??? -lserver-role-samba4 -lroken-samba4 -lheimbase-samba4
-lhx509-samba4 -lwind-samba4 \
??? -lhcrypto-samba4 -lclidns-samba4 -lsmb-transport-samba4
-lcli-ldap-samba4 -lcommon-auth-samba4 \
??? -lnetif-samba4 -lcli-nbt-samba4 -lMESSAGING-SEND-samba4
-lcluster-samba4 -ljansson -lutil \
??? -lresolv -licuuc -licudata -licui18n -lldap -llber -lz -ldl
-lgnutls -lpthread \
??? -lcrypto \
??? -pie -Wl,-z,relro,-z,now -Wl,-no-undefined -Wl,--export-dynamic
That worked well, but here's my first question:
It must be possible to tell the build-system that smbscardd needs -lcrypto
Please let me know how.
There's another problem: My daemon does some sort of initilization
which I copied from smbpasswd.c
In short this initialization looks like:
configfile=get_dyn_CONFIGFILE();
lp_load_global(configfile);
secrets_init();
initialize_password_db(False, NULL);
get_global_sam_sid();
domain=lp_workgroup();
After this initialization the daemon accepts connections and
calls local_change_password()
Works very well but initialize_password_db() produces the
following warning:
no talloc stackframe at
../../source3/passdb/machine_account_secrets.c:60, leaking memory
So here's my second question: How do I avoid this warning?
Peter