Bug 2112 - Android doesn't provide an implementation of crypt().
Summary: Android doesn't provide an implementation of crypt().
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 6.2p1
Hardware: Other Linux
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_3
  Show dependency treegraph
 
Reported: 2013-06-02 05:28 AEST by Nathan Osman
Modified: 2015-08-11 23:05 AEST (History)
1 user (show)

See Also:


Attachments
Use OpenSSL DES_crypt function as a drop-in replacement for crypt(). (473 bytes, patch)
2013-06-02 05:28 AEST, Nathan Osman
no flags Details | Diff
Use OpenSSL DES_crypt function as a drop-in replacement for crypt(). (1005 bytes, patch)
2013-06-02 06:07 AEST, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Osman 2013-06-02 05:28:50 AEST
Created attachment 2284 [details]
Use OpenSSL DES_crypt function as a drop-in replacement for crypt().

The Android platform does not provide a crypt() function (crypt.h does not exist) and therefore the following error is produced when attempting to link xcrypt.o from the openbsd-compat library:

  libopenbsd-compat.a(xcrypt.o): in function xcrypt:xcrypt.c:78: error: undefined reference to 'crypt'

However, OpenSSL includes an implementation of crypt in the libcrypto library. I have attached a small patch that:

 - checks if crypt.h is available
 - if not, checks if openssl is available
 - uses a #define to point crypt to DES_crypt
Comment 1 Nathan Osman 2013-06-02 05:31:10 AEST
Actually I made a mistake in describing my patch - the first two steps are reversed. First a check for OpenSSL is made and then DES_crypt is used only if crypt is missing.

I wasn't sure which order to do things in. I can reverse the '#if defined' lines if needed.
Comment 2 Darren Tucker 2013-06-02 05:53:21 AEST
Comment on attachment 2284 [details]
Use OpenSSL DES_crypt function as a drop-in replacement for crypt().

>+# if defined(HAVE_OPENSSL)

openssl is mandatory so there's no point checking for this (I'm not sure why configure even sets it).

>+#  if !defined(HAVE_CRYPT_H)

you don't really care whether or not crypt.h exists, what you really care about is whether or not you have a crypt function, so that's what you should be checking for.

I'll attach a modified patch shortly.
Comment 3 Darren Tucker 2013-06-02 06:07:14 AEST
Created attachment 2288 [details]
Use OpenSSL DES_crypt function as a drop-in replacement for crypt().

Please try this.  note that you'll need to run "autoreconf" to rebuild configure before running ./configure.
Comment 4 Nathan Osman 2013-06-02 06:24:12 AEST
I applied the patch on a clean copy of the OpenSSH source code and can confirm that it solves the problem.

Thanks!
Comment 5 Darren Tucker 2013-06-02 06:28:23 AEST
Patch applied, thanks.
Comment 6 Damien Miller 2015-08-11 23:05:35 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1