diff options
author | Ed Schouten <ed@FreeBSD.org> | 2016-08-10 15:16:28 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2016-08-10 15:16:28 +0000 |
commit | 5f521d7ba72145092ea23ff6081d8791ad6c1f9d (patch) | |
tree | 80c95ae1764bc54824036934952da43ecbf095e2 /include/unistd.h | |
parent | 3a77833e87a68b01242cfe5f7d0002be04f1a0b0 (diff) | |
download | src-test-5f521d7ba72145092ea23ff6081d8791ad6c1f9d.tar.gz src-test-5f521d7ba72145092ea23ff6081d8791ad6c1f9d.zip |
Make libcrypt thread-safe. Add crypt_r(3).
glibc has a pretty nice function called crypt_r(3), which is nothing
more than crypt(3), but thread-safe. It accomplishes this by introducing
a 'struct crypt_data' structure that contains a buffer that is large
enough to hold the resulting string.
Let's go ahead and also add this function. It would be a shame if a
useful function like this wouldn't be usable in multithreaded apps.
Refactor crypt.c and all of the backends to no longer declare static
arrays, but write their output in a provided buffer.
There is no need to do any buffer length computation here, as we'll just
need to ensure that 'struct crypt_data' is large enough, which it is.
_PASSWORD_LEN is defined to 128 bytes, but in this case I'm picking 256,
as this is going to be part of the actual ABI.
Differential Revision: https://reviews.freebsd.org/D7306
Notes
Notes:
svn path=/head/; revision=303920
Diffstat (limited to 'include/unistd.h')
-rw-r--r-- | include/unistd.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 0d20027f8d56a..0fb36e50e050e 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -484,11 +484,18 @@ pid_t vfork(void) __returns_twice; #if __BSD_VISIBLE struct timeval; /* select(2) */ + +struct crypt_data { + int initialized; /* For compatibility with glibc. */ + char __buf[256]; /* Buffer returned by crypt_r(). */ +}; + int acct(const char *); int async_daemon(void); int check_utility_compat(const char *); const char * crypt_get_format(void); +char *crypt_r(const char *, const char *, struct crypt_data *); int crypt_set_format(const char *); int des_cipher(const char *, char *, long, int); int des_setkey(const char *key); |