summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-09-13 15:34:23 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-09-13 15:34:23 +0000
commit154fdff60dfaf55373633176c4b9877a197d71ee (patch)
tree7a34f53363120c852c010405d46856337622fb63 /lib/libc
parentcd198de1f84819c04a4b49675cc454094cf58b4e (diff)
Wrap <pwd.h> so that calls go direct and the symbols are all weak.
Hide bcrypt_autorounds(), prefixing with an underbar for static builds.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/Symbols.list1
-rw-r--r--lib/libc/crypt/bcrypt.c7
-rw-r--r--lib/libc/crypt/cryptutil.c8
-rw-r--r--lib/libc/gen/getpwent.c7
-rw-r--r--lib/libc/gen/pw_dup.c3
-rw-r--r--lib/libc/hidden/pwd.h43
6 files changed, 59 insertions, 10 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list
index 98d2a9772f3..1a8fbee6b27 100644
--- a/lib/libc/Symbols.list
+++ b/lib/libc/Symbols.list
@@ -819,7 +819,6 @@ arc4random
arc4random_buf
arc4random_uniform
bcrypt
-bcrypt_autorounds
bcrypt_checkpass
bcrypt_gensalt
bcrypt_newhash
diff --git a/lib/libc/crypt/bcrypt.c b/lib/libc/crypt/bcrypt.c
index 0e6b00f12d4..a8c1b9e7c86 100644
--- a/lib/libc/crypt/bcrypt.c
+++ b/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcrypt.c,v 1.54 2015/09/13 12:42:39 millert Exp $ */
+/* $OpenBSD: bcrypt.c,v 1.55 2015/09/13 15:33:48 guenther Exp $ */
/*
* Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
@@ -215,6 +215,7 @@ bcrypt_newhash(const char *pass, int log_rounds, char *hash, size_t hashlen)
explicit_bzero(salt, sizeof(salt));
return 0;
}
+DEF_WEAK(bcrypt_newhash);
int
bcrypt_checkpass(const char *pass, const char *goodhash)
@@ -232,13 +233,14 @@ bcrypt_checkpass(const char *pass, const char *goodhash)
explicit_bzero(hash, sizeof(hash));
return 0;
}
+DEF_WEAK(bcrypt_checkpass);
/*
* Measure this system's performance by measuring the time for 8 rounds.
* We are aiming for something that takes around 0.1s, but not too much over.
*/
int
-bcrypt_autorounds(void)
+_bcrypt_autorounds(void)
{
struct timespec before, after;
int r = 8;
@@ -391,3 +393,4 @@ bcrypt(const char *pass, const char *salt)
return gencrypted;
}
+DEF_WEAK(bcrypt);
diff --git a/lib/libc/crypt/cryptutil.c b/lib/libc/crypt/cryptutil.c
index 20d68b3fd30..f48ba1af2c2 100644
--- a/lib/libc/crypt/cryptutil.c
+++ b/lib/libc/crypt/cryptutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cryptutil.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */
+/* $OpenBSD: cryptutil.c,v 1.12 2015/09/13 15:33:48 guenther Exp $ */
/*
* Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
*
@@ -21,8 +21,6 @@
#include <login_cap.h>
#include <errno.h>
-int bcrypt_autorounds(void);
-
int
crypt_checkpass(const char *pass, const char *goodhash)
{
@@ -70,12 +68,12 @@ crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen)
const char *choice = choices[i];
size_t len = strlen(choice);
if (strcmp(pref, choice) == 0) {
- rounds = bcrypt_autorounds();
+ rounds = _bcrypt_autorounds();
break;
} else if (strncmp(pref, choice, len) == 0 &&
pref[len] == ',') {
if (strcmp(pref + len + 1, "a") == 0) {
- rounds = bcrypt_autorounds();
+ rounds = _bcrypt_autorounds();
} else {
rounds = strtonum(pref + len + 1, 4, 31, &errstr);
if (errstr) {
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 2d58e3f9bec..f7b7d37b926 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getpwent.c,v 1.54 2015/06/03 02:24:36 millert Exp $ */
+/* $OpenBSD: getpwent.c,v 1.55 2015/09/13 15:33:48 guenther Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@@ -753,6 +753,7 @@ fail:
_THREAD_PRIVATE_MUTEX_UNLOCK(pw);
return (my_errno);
}
+DEF_WEAK(getpwnam_r);
struct passwd *
getpwnam(const char *name)
@@ -768,6 +769,7 @@ getpwnam(const char *name)
}
return (pw);
}
+DEF_WEAK(getpwnam);
int
getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t buflen,
@@ -812,6 +814,7 @@ fail:
_THREAD_PRIVATE_MUTEX_UNLOCK(pw);
return (my_errno);
}
+DEF_WEAK(getpwuid_r);
struct passwd *
getpwuid(uid_t uid)
@@ -827,6 +830,7 @@ getpwuid(uid_t uid)
}
return (pw);
}
+DEF_WEAK(getpwuid);
int
setpassent(int stayopen)
@@ -845,6 +849,7 @@ setpassent(int stayopen)
_THREAD_PRIVATE_MUTEX_UNLOCK(pw);
return (1);
}
+DEF_WEAK(setpassent);
void
setpwent(void)
diff --git a/lib/libc/gen/pw_dup.c b/lib/libc/gen/pw_dup.c
index da7b6b034dd..2484736ef74 100644
--- a/lib/libc/gen/pw_dup.c
+++ b/lib/libc/gen/pw_dup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pw_dup.c,v 1.7 2005/08/08 08:05:34 espie Exp $ */
+/* $OpenBSD: pw_dup.c,v 1.8 2015/09/13 15:33:48 guenther Exp $ */
/*
* Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -80,3 +80,4 @@ pw_dup(const struct passwd *pw)
return (newpw);
}
+DEF_WEAK(pw_dup);
diff --git a/lib/libc/hidden/pwd.h b/lib/libc/hidden/pwd.h
new file mode 100644
index 00000000000..d5302275f6a
--- /dev/null
+++ b/lib/libc/hidden/pwd.h
@@ -0,0 +1,43 @@
+/* $OpenBSD: pwd.h,v 1.1 2015/09/13 15:34:22 guenther Exp $ */
+/*
+ * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBC_PWD_H_
+#define _LIBC_PWD_H_
+
+#include_next <pwd.h>
+
+__BEGIN_HIDDEN_DECLS
+int _bcrypt_autorounds(void);
+__END_HIDDEN_DECLS
+
+
+PROTO_NORMAL(bcrypt);
+PROTO_NORMAL(bcrypt_checkpass);
+PROTO_DEPRECATED(bcrypt_gensalt);
+PROTO_NORMAL(bcrypt_newhash);
+PROTO_DEPRECATED(endpwent);
+PROTO_DEPRECATED(getpwent);
+PROTO_NORMAL(getpwnam);
+PROTO_NORMAL(getpwnam_r);
+PROTO_NORMAL(getpwuid);
+PROTO_NORMAL(getpwuid_r);
+PROTO_NORMAL(pw_dup);
+PROTO_NORMAL(setpassent);
+PROTO_DEPRECATED(setpwent);
+PROTO_DEPRECATED(user_from_uid);
+
+#endif /* !_LIBC_PWD_H_ */