[PATCH] Improve talloc security
Andreas Schneider
asn at samba.org
Tue Feb 24 00:39:37 MST 2015
On Monday 23 February 2015 17:30:19 Jeremy Allison wrote:
> I think if we want to do this we need to bite the bullet
> and add in the pthread_mutex_t guards around the global
> variables and make talloc fully MT-safe.
In libssh we have the same issue. During initialization we need to lock
correctly, specially if we initialize the crypto libraries!
We came up with a solution for that:
ssh_threads_set_callbacks(ssh_threads_get_noop());
ssh_init();
ssh_threads_noop is the threading structure that does nothing. It's the
threading callbacks being used by default when you're not using threading. The
first line is not needed. ssh_init() does it if the threading callbacks are
not set yet.
If you use phtreads you can do:
ssh_threads_set_callbacks(ssh_threads_get_pthread());
ssh_init();
http://git.libssh.org/projects/libssh.git/tree/src/threads/pthread.c
This makes it also possible to implement threading with Windows threads by the
user for example ...
-- andreas
--
Andreas Schneider GPG-ID: CC014E3D
Samba Team asn at samba.org
www.samba.org
More information about the samba-technical
mailing list