use system crypt
* configure.in: revert r55237. replace crypt, not crypt_r, and check if crypt is broken more. * missing/crypt.c: move crypt_r.c * string.c (rb_str_crypt): use crypt_r if provided by the system. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1258bc559b
commit
a8bfa9bdf1
@ -1,3 +1,12 @@
|
|||||||
|
Wed Jun 1 15:58:20 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* configure.in: revert r55237. replace crypt, not crypt_r, and
|
||||||
|
check if crypt is broken more.
|
||||||
|
|
||||||
|
* missing/crypt.c: move crypt_r.c
|
||||||
|
|
||||||
|
* string.c (rb_str_crypt): use crypt_r if provided by the system.
|
||||||
|
|
||||||
Wed Jun 1 14:07:53 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Jun 1 14:07:53 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* missing/crypt_r.c (a64toi): initialize statically and fix out of
|
* missing/crypt_r.c (a64toi): initialize statically and fix out of
|
||||||
|
@ -705,7 +705,7 @@ RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \
|
|||||||
|
|
||||||
acosh.$(OBJEXT): {$(VPATH)}acosh.c
|
acosh.$(OBJEXT): {$(VPATH)}acosh.c
|
||||||
alloca.$(OBJEXT): {$(VPATH)}alloca.c {$(VPATH)}config.h
|
alloca.$(OBJEXT): {$(VPATH)}alloca.c {$(VPATH)}config.h
|
||||||
crypt_r.$(OBJEXT): {$(VPATH)}crypt_r.c {$(VPATH)}crypt.h
|
crypt.$(OBJEXT): {$(VPATH)}crypt.c {$(VPATH)}crypt.h
|
||||||
dup2.$(OBJEXT): {$(VPATH)}dup2.c
|
dup2.$(OBJEXT): {$(VPATH)}dup2.c
|
||||||
erf.$(OBJEXT): {$(VPATH)}erf.c
|
erf.$(OBJEXT): {$(VPATH)}erf.c
|
||||||
explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
|
explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
|
||||||
|
54
configure.in
54
configure.in
@ -1061,12 +1061,57 @@ AS_CASE(["$target_os"],
|
|||||||
test -d "$d" && RUBY_APPEND_OPTIONS(LDFLAGS, "-L$d")
|
test -d "$d" && RUBY_APPEND_OPTIONS(LDFLAGS, "-L$d")
|
||||||
done
|
done
|
||||||
ac_cv_type_getgroups=gid_t # getgroups() on Rosetta fills garbage
|
ac_cv_type_getgroups=gid_t # getgroups() on Rosetta fills garbage
|
||||||
ac_cv_lib_crypt_crypt_r=no
|
ac_cv_lib_crypt_crypt=no
|
||||||
ac_cv_func_fdatasync=no # Mac OS X wrongly reports it has fdatasync()
|
ac_cv_func_fdatasync=no # Mac OS X wrongly reports it has fdatasync()
|
||||||
ac_cv_func_vfork=no
|
ac_cv_func_vfork=no
|
||||||
if test $gcc_major -lt 4 -o \( $gcc_major -eq 4 -a $gcc_minor -lt 3 \); then
|
if test $gcc_major -lt 4 -o \( $gcc_major -eq 4 -a $gcc_minor -lt 3 \); then
|
||||||
ac_cv_func___builtin_setjmp=no
|
ac_cv_func___builtin_setjmp=no
|
||||||
fi
|
fi
|
||||||
|
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
|
||||||
|
[AC_TRY_RUN([
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
broken_crypt(const char *salt, const char *buf1, const char *buf2)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
printf("%.2x%.2x: %s -> %s\n", (unsigned char)salt[0], (unsigned char)salt[1],
|
||||||
|
buf1+2, buf2+2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char salt[2], buf[256], *s;
|
||||||
|
for (i = 0; i < 128*128; i++) {
|
||||||
|
salt[0] = 0x80 | (i & 0x7f);
|
||||||
|
salt[1] = 0x80 | (i >> 7);
|
||||||
|
strcpy(buf, crypt("", salt));
|
||||||
|
if (strcmp(buf, s = crypt("", salt))) {
|
||||||
|
broken_crypt(salt, buf, s);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
salt[0] = salt[1] = ' ';
|
||||||
|
strcpy(buf, crypt("", salt));
|
||||||
|
salt[0] = salt[1] = 0x80 | ' ';
|
||||||
|
if (strcmp(buf, s = crypt("", salt))) {
|
||||||
|
broken_crypt(salt, buf, s);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
rb_cv_broken_crypt=no,
|
||||||
|
rb_cv_broken_crypt=yes,
|
||||||
|
rb_cv_broken_crypt=yes)])
|
||||||
|
if test "$rb_cv_broken_crypt" = yes; then
|
||||||
|
AC_DEFINE(BROKEN_CRYPT, 1)
|
||||||
|
fi
|
||||||
AC_CHECK_PROGS(codesign, codesign)
|
AC_CHECK_PROGS(codesign, codesign)
|
||||||
if test -n "$codesign"; then
|
if test -n "$codesign"; then
|
||||||
POSTLINK="test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@"
|
POSTLINK="test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@"
|
||||||
@ -1163,7 +1208,7 @@ AS_CASE(["$target_os"],
|
|||||||
ac_cv_func_link=yes
|
ac_cv_func_link=yes
|
||||||
ac_cv_func_readlink=yes
|
ac_cv_func_readlink=yes
|
||||||
ac_cv_func_symlink=yes
|
ac_cv_func_symlink=yes
|
||||||
ac_cv_lib_crypt_crypt_r=no
|
ac_cv_lib_crypt_crypt=no
|
||||||
ac_cv_func_getpgrp_void=no
|
ac_cv_func_getpgrp_void=no
|
||||||
ac_cv_func_memcmp_working=yes
|
ac_cv_func_memcmp_working=yes
|
||||||
ac_cv_lib_dl_dlopen=no
|
ac_cv_lib_dl_dlopen=no
|
||||||
@ -1218,7 +1263,7 @@ AS_CASE(["$target_os"],
|
|||||||
],
|
],
|
||||||
[ LIBS="-lm $LIBS"])
|
[ LIBS="-lm $LIBS"])
|
||||||
|
|
||||||
AC_CHECK_LIB(crypt, crypt_r) # glibc (GNU/Linux, GNU/Hurd, GNU/kFreeBSD)
|
AC_CHECK_LIB(crypt, crypt) # glibc (GNU/Linux, GNU/Hurd, GNU/kFreeBSD)
|
||||||
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
|
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
|
||||||
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
|
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
|
||||||
AC_CHECK_LIB(socket, shutdown) # SunOS/Solaris
|
AC_CHECK_LIB(socket, shutdown) # SunOS/Solaris
|
||||||
@ -2173,7 +2218,7 @@ AS_CASE(["$target_os"],[freebsd*],[
|
|||||||
|
|
||||||
AC_REPLACE_FUNCS(acosh)
|
AC_REPLACE_FUNCS(acosh)
|
||||||
AC_REPLACE_FUNCS(cbrt)
|
AC_REPLACE_FUNCS(cbrt)
|
||||||
AC_REPLACE_FUNCS(crypt_r)
|
AC_REPLACE_FUNCS(crypt)
|
||||||
AC_REPLACE_FUNCS(dup2)
|
AC_REPLACE_FUNCS(dup2)
|
||||||
AC_REPLACE_FUNCS(erf)
|
AC_REPLACE_FUNCS(erf)
|
||||||
AC_REPLACE_FUNCS(explicit_bzero)
|
AC_REPLACE_FUNCS(explicit_bzero)
|
||||||
@ -2253,6 +2298,7 @@ AC_CHECK_FUNCS(chroot)
|
|||||||
AC_CHECK_FUNCS(chsize)
|
AC_CHECK_FUNCS(chsize)
|
||||||
AC_CHECK_FUNCS(clock_gettime)
|
AC_CHECK_FUNCS(clock_gettime)
|
||||||
AC_CHECK_FUNCS(cosh)
|
AC_CHECK_FUNCS(cosh)
|
||||||
|
AC_CHECK_FUNCS(crypt_r)
|
||||||
AC_CHECK_FUNCS(daemon)
|
AC_CHECK_FUNCS(daemon)
|
||||||
AC_CHECK_FUNCS(dirfd)
|
AC_CHECK_FUNCS(dirfd)
|
||||||
AC_CHECK_FUNCS(dl_iterate_phdr)
|
AC_CHECK_FUNCS(dl_iterate_phdr)
|
||||||
|
21
string.c
21
string.c
@ -29,7 +29,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CRYPT_R
|
||||||
#include <crypt.h>
|
#include <crypt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STRING_ENUMERATORS_WANTARRAY 0 /* next major */
|
#define STRING_ENUMERATORS_WANTARRAY 0 /* next major */
|
||||||
|
|
||||||
@ -8375,10 +8377,17 @@ rb_str_oct(VALUE str)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_str_crypt(VALUE str, VALUE salt)
|
rb_str_crypt(VALUE str, VALUE salt)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_CRYPT_R
|
||||||
struct crypt_data data;
|
struct crypt_data data;
|
||||||
|
#else
|
||||||
|
extern char *crypt(const char *, const char *);
|
||||||
|
#endif
|
||||||
VALUE result;
|
VALUE result;
|
||||||
const char *s, *saltp;
|
const char *s, *saltp;
|
||||||
char *res;
|
char *res;
|
||||||
|
#ifdef BROKEN_CRYPT
|
||||||
|
char salt_8bit_clean[3];
|
||||||
|
#endif
|
||||||
|
|
||||||
StringValue(salt);
|
StringValue(salt);
|
||||||
mustnot_wchar(str);
|
mustnot_wchar(str);
|
||||||
@ -8391,8 +8400,20 @@ rb_str_crypt(VALUE str, VALUE salt)
|
|||||||
s = StringValueCStr(str);
|
s = StringValueCStr(str);
|
||||||
saltp = RSTRING_PTR(salt);
|
saltp = RSTRING_PTR(salt);
|
||||||
if (!saltp[0] || !saltp[1]) goto short_salt;
|
if (!saltp[0] || !saltp[1]) goto short_salt;
|
||||||
|
#ifdef BROKEN_CRYPT
|
||||||
|
if (!ISASCII((unsigned char)saltp[0]) || !ISASCII((unsigned char)saltp[1])) {
|
||||||
|
salt_8bit_clean[0] = saltp[0] & 0x7f;
|
||||||
|
salt_8bit_clean[1] = saltp[1] & 0x7f;
|
||||||
|
salt_8bit_clean[2] = '\0';
|
||||||
|
saltp = salt_8bit_clean;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_CRYPT_R
|
||||||
data.initialized = 0;
|
data.initialized = 0;
|
||||||
res = crypt_r(s, saltp, &data);
|
res = crypt_r(s, saltp, &data);
|
||||||
|
#else
|
||||||
|
res = crypt(s, saltp);
|
||||||
|
#endif
|
||||||
if (!res) {
|
if (!res) {
|
||||||
rb_sys_fail("crypt");
|
rb_sys_fail("crypt");
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ LIBS = $(LIBS) iphlpapi.lib
|
|||||||
LIBS = $(LIBS) imagehlp.lib shlwapi.lib $(EXTLIBS)
|
LIBS = $(LIBS) imagehlp.lib shlwapi.lib $(EXTLIBS)
|
||||||
!endif
|
!endif
|
||||||
!if !defined(MISSING)
|
!if !defined(MISSING)
|
||||||
MISSING = crypt_r.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj win32/win32.obj win32/file.obj setproctitle.obj
|
MISSING = crypt.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj win32/win32.obj win32/file.obj setproctitle.obj
|
||||||
!if $(RT_VER) < 120
|
!if $(RT_VER) < 120
|
||||||
MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj tgamma.obj
|
MISSING = $(MISSING) acosh.obj cbrt.obj erf.obj tgamma.obj
|
||||||
!endif
|
!endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user