landley / toybox

toybox
http://landley.net/toybox
BSD Zero Clause License
2.37k stars 331 forks source link

mkroot - undefined reference to `crypt' #464

Open newtime94 opened 9 months ago

newtime94 commented 9 months ago

Not sure what I'm doing wrong here I through I had all of the required dependencies but I'm new at this can someone take a look and tell me where I'm having the issue , system archlinux

[444min@archlinux toybox]$ make root mkroot/mkroot.sh which: no logpath in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl) logpath:egrep: warning: egrep is obsolescent; using grep -E egrep: warning: egrep is obsolescent; using grep -E Library probe generated/{Config.inegrep: warning: egrep is obsolescent; using grep -E ,newtoys.h,flags.h,globals.h,tags.h,help.h} Compile /home/444min/rice/build000/toybox/root/build/record-commands/logpath ................. find: warning: you have specified the global option -maxdepth after the argument -type, but global options are not positional, i.e., -maxdepth affects tests specified before it as well as those specified after it. Please specify global options before other arguments. Building for host

=== toybox cleaned cc -o kconfig/conf kconfig/conf.c kconfig/zconf.tab.c -DKBUILD_NO_NLS=1 \ -DPROJECT_NAME=\"ToyBox\" scripts/genconfig.sh yes '' | kconfig/conf -o Config.in > /dev/null scripts/make.sh egrep: warning: egrep is obsolescent; using grep -E

warning: using unfinished code from toys/pending Library probe generated/{Config.inegrep: warning: egrep is obsolescent; using grep -E ,newtoys.h,flags.h,globals.h,tags.h,help.h} Compile toybox .....................................................toys/other/count.c: In function 'display': toys/other/count.c:47:29: warning: '%s' directive writing up to 3839 bytes into a region of size 3070 [-Wformat-overflow=] 47 | sprintf(toybuf+1024, ", %sb, %sb/s, %um%02us", toybuf+256, toybuf+512, | ~~~~~~^~~~~~~~~~~~ 48 | seconds/60, seconds%60); | ~~~~~~~ toys/other/count.c:47:26: note: directive argument in the range [0, 71582788] 47 | sprintf(toybuf+1024, ", %sb, %sb/s, %um%02us", toybuf+256, toybuf+512, | ^~~~~~~~ toys/other/count.c:47:26: note: directive argument in the range [0, 59] toys/other/count.c:47:5: note: 'sprintf' output between 16 and 7445 bytes into a destination of size 3072 47 | sprintf(toybuf+1024, ", %sb, %sb/s, %um%02us", toybuf+256, toybuf+512, | ^~~~~~~~~~~~~~~~~~ 48 | seconds/60, seconds%60); | ~~~~~~~ toys/other/count.c:47:5: warning: 'sprintf' arguments 3, 4 may overlap destination object 'toybuf' [-Wrestrict] In file included from toys/other/count.c:19: ./toys.h:131:41: note: destination object referenced by 'restrict'-qualified argument 1 was declared here 131 | extern char environ, toybox_version, toybuf[4096], libbuf[4096]; | ^~ .................................................................................toys/pending/sh.c: In function 'run_lines': toys/pending/sh.c:3924:18: warning: pointer 'ss' used after 'free' [-Wuse-after-free] 3924 | if (!ss) { | ^~~ toys/pending/sh.c:3923:13: note: call to 'free' here 3923 | free(ss); | ^~~~ ........toys/posix/date.c: In function 'parse_date': toys/posix/date.c:88:17: warning: 'old_tz' may be used uninitialized [-Wmaybe-uninitialized] 88 | if (old_tz) setenv("TZ", old_tz, 1); | ^~~~~~~ toys/posix/date.c:71:25: note: 'old_tz' was declared here 71 | char new_tz = NULL, old_tz, s = str; | ^~ .......................toys/pending/sh.c: In function 'expand_arg_nobrace': toys/pending/sh.c:2169:33: warning: 'sprintf' argument 4 may overlap destination object 'ifs' [-Wrestrict] 2169 | else if (jj<dd) sprintf(ifs+ll, "%s%s", ss, ifs+ll+dd); | ^~~~~~~~~~ .................................../usr/bin/ld: generated/obj/id.o: in function do_id': id.c:(.text.do_id+0x146): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_xwrap.o: in functionxsetuser': xwrap.c:(.text.xsetuser+0xb): warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_xwrap.o: in function xgetgrgid': xwrap.c:(.text.xgetgrgid+0x4): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_xwrap.o: in functionxgetgid': xwrap.c:(.text.xgetgid+0x1a): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_lib.o: in function bufgetgrnamgid': lib.c:(.text.bufgetgrnamgid+0xdb): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: lib.c:(.text.bufgetgrnamgid+0xb7): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_xwrap.o: in functionxgetuid': xwrap.c:(.text.xgetuid+0x1a): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_xwrap.o: in function xgetpwuid': xwrap.c:(.text.xgetpwuid+0x4): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_lib.o: in functionbufgetpwnamuid': lib.c:(.text.bufgetpwnamuid+0xb7): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: lib.c:(.text.bufgetpwnamuid+0xdb): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/lib_net.o: in function xgetaddrinfo': net.c:(.text.xgetaddrinfo+0x59): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/su.o: in functionsu_main': su.c:(.text.su_main+0xe1): warning: Using 'getspnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/route.o: in function get_hostname.constprop.0': route.c:(.text.get_hostname.constprop.0+0x1f): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/hostname.o: in functionhostname_main': hostname.c:(.text.hostname_main+0xc0): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/netstat.o: in function addr2str': netstat.c:(.text.addr2str+0x11a): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: generated/obj/su.o: in functionsu_main': su.c:(.text.su_main+0x139): undefined reference to crypt' /usr/bin/ld: generated/obj/login.o: in functionlogin_main': login.c:(.text.login_main+0x1e9): undefined reference to crypt' /usr/bin/ld: generated/obj/mkpasswd.o: in functionmkpasswd_main': mkpasswd.c:(.text.mkpasswd_main+0x1eb): undefined reference to `crypt' collect2: error: ld returned 1 exit status make: [Makefile:17: toybox] Error 1 make: *** [Makefile:81: root] Error 1

enh-google commented 9 months ago

i think this is probably a dupe of #450 --- i'm guessing you have a glibc new enough to have removed crypt()? ldd --version will tell you your glibc version if you're not sure.

newtime94 commented 9 months ago

ldd (GNU libc) 2.38 yup your on the money ok let me read #450 then I will close this thanks

newtime94 commented 9 months ago

"if you build against glibc 2.38 or later, dont declare crypt but rather include crypt.h and link against libxcrypt with -lcrypt."

I'm not clear on how to do this? I know have libxcrypt installed going through toybox docs now

enh-google commented 9 months ago

i think if you add xcrypt to this line in scripts/make.sh, it should work for you?

  for i in util crypt m resolv selinux smack attr crypto z log iconv tls ssl

(i don't think we can remove crypt without breaking older versions of glibc, and i don't know whether this is something we could check in, because i think there will be systems with both, and you don't want both? though maybe there aren't realistic systems that don't have xcrypt, so replacing crypt with xcrypt would actually be fine in practice? my [vague] understanding of what glibc has done here. i'm assuming musl already had this just in libc.so?)

landley commented 9 months ago

My plan is to have my own crypt() in lib/ using the existing internal md5sum and sha1sum code and adding other has functions as needed. I'm slowly shoveling out this area, commit 20eb4585a140 last night was a step in that direction. Won't be this coming release (which is already 2 days overdue), but I'm aiming at the release after that.

newtime94 commented 9 months ago

OK so i updated the script to for i in util crypt m resolv selinux smack attr crypto z log iconv tls ssl xcrypt same build error then I tried for i in util xcrypt m resolv selinux smack attr crypto z log iconv tls ssl still the same error . I used sudo find / -name "libcrypt*" the output is below

/usr/include/libcryptsetup.h /usr/lib/pkgconfig/libcryptsetup.pc /usr/lib/pkgconfig/libcrypto.pc /usr/lib/pkgconfig/libcrypt.pc /usr/lib/libcryptsetup.so /usr/lib/libcryptsetup.so.12 /usr/lib/libcryptsetup.so.12.9.0 /usr/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so /usr/lib/cryptsetup/libcryptsetup-token-systemd-pkcs11.so /usr/lib/cryptsetup/libcryptsetup-token-systemd-tpm2.so /usr/lib/libcrypto.so /usr/lib/libcrypto.so.3 /usr/lib/musl/lib/libcrypt.a /usr/lib/libcrypt.so /usr/lib/libcrypt.so.2 /usr/lib/libcrypt.so.2.0.0

CameronNemo commented 9 months ago

/usr/lib/musl/lib/libcrypt.a

Hmm... this is archlinux? Maybe you can try to build against musl if you have it / know how to (I don't, on Arch Linux). Musl doesn't suffer from #450.