OpenWrt Forum Archive

Topic: perl crypt() function is unimplemented due to excessive paranoia

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello Trying to get the perl crypt() function to work on CC 15.05.  I installed the perl package and then did a make. Perl compiles and runs.   However...  the crypt function does not work.  Note that this used to work on previous versions of OpenWRT.  Any thoughts are greatly appreciated.

Here is the error I get..

root@Optimizer:/usr/local/gmnbin# perl -d

Loading DB routines from perl5db.pl version 1.44
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

crypt("helllo","hello");
main::(-:1):    crypt("helllo","hello")
  DB<1> n
The crypt() function is unimplemented due to excessive paranoia. at - line 1.
at - line 1.
Debugged program terminated.  Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
  DB<1>


Here is perl -V showing that -lcrypt was compiled into the binary.

root@Optimizer:/usr/local/gmnbin# perl -V
Summary of my perl5 (revision 5 version 20 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=2.4.30, archname=mipsel-linux-uclibc
    uname='linux merope 2.4.30 #1 di 23. jan 15:23:42 cet 2007 mips unknown unknown gnulinux '
    config_args='-der -Dusethreads'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='mipsel-openwrt-linux-uclibc-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kec -mdsp -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/include -I/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kec -mdsp -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/include -I/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/include -I/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/include -I/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/include'
    ccversion='', gccversion='3.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='mipsel-openwrt-linux-uclibc-gcc', ldflags =''
    libpth=/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/lib /disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib
    libs=-lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-fPIC -Wl,-rpath,/usr/lib/perl5/5.20/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -rdynamic -L/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/usr/lib -L/disk2/lsoltero/openwrt.cc/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/lib -L/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/usr/lib -L/disk2/lsoltero/openwrt.cc/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/lib'


Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        USE_ITHREADS USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Built under linux
  Compiled at Oct 20 2015 04:10:52
  @INC:
    /usr/lib/perl5/5.20
    .

so i copied in version of the Perl Makefile from an older version of the package. then replaced the version from 5.20.1 to 5.20.2 and updated the md5 sum and then compiled...

now crypt works again.

Here are the diffs between the older version (the +s) and the newer version (the -s)

the bit difference seems to be CONFIG_USE_GLIBC in the new make file vs CONFIG_USE_EGLIBC in the old one? what is that about?

anyway.. its working.

root@Optimizer:~# perl -d

Loading DB routines from perl5db.pl version 1.44
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

crypt("hello","hello");
main::(-:1):    crypt("hello","hello");
  DB<1> quit


if anyone can shed light on this it would greatly be appreciated.


diff --git a/lang/perl/Makefile b/lang/perl/Makefile
index abd327f..c28d41d 100644
--- a/lang/perl/Makefile
+++ b/lang/perl/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2015 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -36,34 +36,19 @@ HOST_BUILD_PARALLEL:=1

# Variables used during configuration/build
HOST_PERL_PREFIX:=$(STAGING_DIR_HOST)/usr
-ifneq ($(CONFIG_USE_GLIBC),)
+ifneq ($(CONFIG_USE_EGLIBC),)
        EXTRA_LIBS:=bsd
        EXTRA_LIBDIRS:=$(STAGING_DIR)/lib
endif
-
# Filter -g3, it will break Compress-Raw-Zlib
TARGET_CFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CFLAGS))
TARGET_CPPFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CPPFLAGS))

-# Handle threading
-ifdef CONFIG_PERL_THREADS
-       PERL_CONFIG_SUFFIX:=-mt
-
-       # uclibc doesn't provide crypt_r(). Enable crypt() usage for glibc builds only
-       ifdef CONFIG_USE_GLIBC
-               CRYPT_R_PROTO:=REENTRANT_PROTO_B_CCS
-               CRYPT:=define
-       else
-               CRYPT_R_PROTO:=0
-               CRYPT:=undef
-       endif
-endif
-
-# A list of disabled tests
+# A list of disabled testss
# ExtUtils tests are disabled for now as we don't support building
# native extensions on the target machine at the moment
PERL_DISABLEDTESTS:=cpan/ExtUtils-Constant cpan/ExtUtils-MakeMaker
-# We're on Linux, so don't even package them
+# We're on Linux, so don't even package those
PERL_DISABLEDTESTS+=cpan/Win32API-File cpan/Win32 ext/VMS-DCLsym ext/VMS-Filespec ext/VMS-Stdio ext/Win32CORE
# NDBM and ODBM not supported
PERL_DISABLEDTESTS+=ext/NDBM_File ext/ODBM_File
@@ -79,7 +64,7 @@ define Package/perl
   CATEGORY:=Languages
   TITLE:=The Perl intepreter
   URL:=http://www.perl.com/
-  DEPENDS:=+USE_GLIBC:libbsd +PERL_THREADS:libpthread
+  DEPENDS:=+USE_EGLIBC:libbsd +libpthread
endef

define Package/perl/description
@@ -123,12 +108,13 @@ define Build/Configure
                -e 's!%%EXTRA_PERLLIBDIRS%%!$(EXTRA_LIBDIRS:%=-L%)!g' \
                -e 's!%%IPV6%%!$(if $($(CONFIG_IPV6)),define,undef)!g' \
                -e 's!%%HOSTMINIPERL%%!$(HOST_PERL_PREFIX)/bin/perl!g' \
-               -e 's!%%CRYPT_R_PROTO%%!$(CRYPT_R_PROTO)!g' \
-               -e 's!%%CRYPT%%!$(CRYPT)!g' \
                -e 's!%%HOSTGENERATE%%!$(HOST_PERL_PREFIX)/bin/generate_uudmap!g' \
-               files/config.sh-$(patsubst i386,i486,$(ARCH))$(PERL_CONFIG_SUFFIX).in \
+                -e "s!perllibs='!perllibs='-lpthread !" \
+                -e s!useithreads=.undef.!useithreads="'define'"! \
+                -e s!usemultiplicity=.undef.!usemultiplicity="'define'"! \
+               files/config.sh-$(patsubst i386,i486,$(ARCH)).in \
                > $(PKG_BUILD_DIR)/config.sh
-       (cd $(PKG_BUILD_DIR) && ./Configure -S)
+       (cd $(PKG_BUILD_DIR) && ./Configure -S -Duseithreads -Dusemultiplicity)
        install -m 0644 $(PKG_BUILD_DIR)/config.h $(PKG_BUILD_DIR)/xconfig.h
endef

lsoltero wrote:

the bit difference seems to be CONFIG_USE_GLIBC in the new make file vs CONFIG_USE_EGLIBC in the old one? what is that about?
....
   -       # uclibc doesn't provide crypt_r(). Enable crypt() usage for glibc builds only

This is about the "common C functions library" providing a wide range of system functions. Earlier Openwrt builds have used "uClibc", which is small and stripped down, or optionally a larger "glibc" or "eglibc". Eglibc was combined to glibc a while ago and all references to eglibc were changed to glibc.
https://dev.openwrt.org/changeset/44701
https://dev.openwrt.org/changeset/44702
https://github.com/openwrt/packages/com … 5360de582f

So that is the reason for glibc/eglibc change.

About perl & crypt:
Apparently crypt function is only available if threading is enabled (lines 52-59):
https://github.com/openwrt/packages/blo … kefile#L48

The logic is explained in:
https://github.com/openwrt/packages/pull/854

One drawback of enabling threading is that crypt() and anything related to it is not available. This is due to uclibc not providing crypt_r(). We could use regular crypt() and hope no application actually uses it in more than one thread at the same time, but I've just disabled it for now. crypt() will stay available for glibc builds though, regardless of whether threading is enabled or not.

You should open an issue about this in Github packages, if you want to discuss the matter.

(Last edited by hnyman on 30 Oct 2015, 09:04)

The discussion might have continued from here.