new package: libc-client

This commit is contained in:
Tee KOBAYASHI 2021-12-11 02:19:45 +09:00 committed by Leonid Pliushch
parent 49a1854c93
commit 166b39fa98
8 changed files with 224 additions and 0 deletions

View File

@ -0,0 +1,58 @@
Description: Support OpenSSL 1.1
When building with OpenSSL 1.1 and newer, use the new built-in
hostname verification instead of code that doesn't compile due to
structs having been made opaque.
Bug-Debian: https://bugs.debian.org/828589
--- a/src/osdep/unix/ssl_unix.c
+++ b/src/osdep/unix/ssl_unix.c
@@ -227,8 +227,16 @@ static char *ssl_start_work (SSLSTREAM *
/* disable certificate validation? */
if (flags & NET_NOVALIDATECERT)
SSL_CTX_set_verify (stream->context,SSL_VERIFY_NONE,NIL);
- else SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify);
+ else {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(stream->context);
+ X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
+ X509_VERIFY_PARAM_set1_host(param, host, 0);
+#endif
+
+ SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify);
/* set default paths to CAs... */
+ }
SSL_CTX_set_default_verify_paths (stream->context);
/* ...unless a non-standard path desired */
if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL))
@@ -266,6 +274,7 @@ static char *ssl_start_work (SSLSTREAM *
if (SSL_write (stream->con,"",0) < 0)
return ssl_last_error ? ssl_last_error : "SSL negotiation failed";
/* need to validate host names? */
+#if OPENSSL_VERSION_NUMBER < 0x10100000
if (!(flags & NET_NOVALIDATECERT) &&
(err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con),
host))) {
@@ -275,6 +284,7 @@ static char *ssl_start_work (SSLSTREAM *
sprintf (tmp,"*%.128s: %.255s",err,cert ? cert->name : "???");
return ssl_last_error = cpystr (tmp);
}
+#endif
return NIL;
}
@@ -313,6 +323,7 @@ static int ssl_open_verify (int ok,X509_
* Returns: NIL if validated, else string of error message
*/
+#if OPENSSL_VERSION_NUMBER < 0x10100000
static char *ssl_validate_cert (X509 *cert,char *host)
{
int i,n;
@@ -342,6 +353,7 @@ static char *ssl_validate_cert (X509 *ce
else ret = "Unable to locate common name in certificate";
return ret;
}
+#endif
/* Case-independent wildcard pattern match
* Accepts: base string

View File

@ -0,0 +1,18 @@
--- a/Makefile
+++ b/Makefile
@@ -705,15 +705,6 @@
$(SH) -c '$(RM) rebuild || true'
bundled:
- @echo Building bundled tools...
- $(CD) mtest;$(MAKE)
- $(CD) ipopd;$(MAKE)
- $(CD) imapd;$(MAKE)
- $(CD) mailutil;$(MAKE)
- @$(SH) -c '(test -f /usr/include/sysexits.h ) || make sysexitwarn'
- $(CD) mlock;$(MAKE) || true
- $(CD) dmail;$(MAKE) || true
- $(CD) tmail;$(MAKE) || true
sysexitwarn:

View File

@ -0,0 +1,31 @@
TERMUX_PKG_HOMEPAGE=https://www.washington.edu/imap/ # Gone.
TERMUX_PKG_DESCRIPTION="UW IMAP c-client library"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2007f
TERMUX_PKG_SRCURL=https://www.mirrorservice.org/sites/ftp.cac.washington.edu/imap/imap-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=53e15a2b5c1bc80161d42e9f69792a3fa18332b7b771910131004eb520004a28
TERMUX_PKG_DEPENDS="libcrypt, openssl"
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_pre_configure() {
CFLAGS+=" -fPIC $CPPFLAGS -DFNDELAY=O_NONBLOCK -DL_SET=SEEK_SET"
LDFLAGS+=" -lcrypt -lssl -lcrypto"
}
termux_step_configure() {
:
}
termux_step_make() {
make -e slx
mv c-client/{,lib}c-client.a
$CC -Wl,--whole-archive c-client/libc-client.a -Wl,--no-whole-archive -shared -o c-client/libc-client.so -Wl,-soname=libc-client.so $LDFLAGS
}
termux_step_make_install() {
install -Dm600 -t $TERMUX_PREFIX/lib c-client/libc-client.{a,so}
install -Dm600 -t $TERMUX_PREFIX/include/c-client c-client/linkage.[ch] src/c-client/*.h src/osdep/unix/*.h
cp -a c-client/osdep.h $TERMUX_PREFIX/include/c-client/
}

View File

@ -0,0 +1,20 @@
--- a/src/c-client/c-client.h
+++ b/src/c-client/c-client.h
@@ -39,6 +39,9 @@
#endif
#include "mail.h" /* primary interfaces */
+#ifdef __cplusplus
+#undef private
+#endif
#include "osdep.h" /* OS-dependent routines */
#include "rfc822.h" /* RFC822 and MIME routines */
#include "smtp.h" /* SMTP sending routines */
@@ -48,7 +51,6 @@
#include "misc.h" /* miscellaneous utility routines */
#ifdef __cplusplus /* undo the C++ mischief */
-#undef private
}
#endif

View File

@ -0,0 +1,58 @@
--- a/src/osdep/unix/Makefile
+++ b/src/osdep/unix/Makefile
@@ -48,14 +48,14 @@
# Try to have some consistency in GCC builds. We want optimization, but we
# also want to be able to debug.
-GCCCFLAGS= -g $(GCCOPTLEVEL) -pipe -fno-omit-frame-pointer
+GCCCFLAGS= $(CFLAGS)
GCC4CFLAGS= $(GCCCFLAGS) -Wno-pointer-sign
# Extended flags needed for SSL. You may need to modify.
-SSLDIR=/usr/local/ssl
-SSLCERTS=$(SSLDIR)/certs
+SSLDIR=@TERMUX_PREFIX@
+SSLCERTS=@TERMUX_PREFIX@/etc/tls/certs
SSLKEYS=$(SSLCERTS)
SSLINCLUDE=$(SSLDIR)/include
SSLLIB=$(SSLDIR)/lib
@@ -96,18 +96,18 @@
LOGINPW=std
SIGTYPE=bsd
CRXTYPE=std
-ACTIVEFILE=/usr/lib/news/active
-SPOOLDIR=/usr/spool
+ACTIVEFILE=@TERMUX_PREFIX@/var/lib/news/active
+SPOOLDIR=@TERMUX_PREFIX@/var/spool
MAILSPOOL=$(SPOOLDIR)/mail
NEWSSPOOL=$(SPOOLDIR)/news
RSHPATH=/usr/ucb/rsh
-MD5PWD=/etc/cram-md5.pwd
+MD5PWD=@TERMUX_PREFIX@/etc/cram-md5.pwd
# Tries one of the test alternatives below if not specified.
LOCKPGM=
# Test alternatives if LOCKPGM not specified
-LOCKPGM1=/usr/libexec/mlock
-LOCKPGM2=/usr/sbin/mlock
-LOCKPGM3=/etc/mlock
+LOCKPGM1=@TERMUX_PREFIX@/libexec/mlock
+LOCKPGM2=@TERMUX_PREFIX@/bin/mlock
+LOCKPGM3=@TERMUX_PREFIX@/etc/mlock
# Default formats for creating new mailboxes and for empty mailboxes in the
@@ -676,9 +676,9 @@
@echo If you want libc4 versions you must use sl4 instead!
$(BUILD) `$(CAT) SPECIALS` OS=$@ \
SIGTYPE=psx CHECKPW=psx CRXTYPE=nfs \
- SPOOLDIR=/var/spool \
- ACTIVEFILE=/var/lib/news/active \
- RSHPATH=/usr/bin/rsh \
+ SPOOLDIR=@TERMUX_PREFIX@/var/spool \
+ ACTIVEFILE=@TERMUX_PREFIX@/var/lib/news/active \
+ RSHPATH=@TERMUX_PREFIX@/bin/rsh \
BASECFLAGS="$(GCCCFLAGS)" \
BASELDFLAGS="-lcrypt"

View File

@ -0,0 +1,18 @@
--- a/src/osdep/unix/ckp_psx.c
+++ b/src/osdep/unix/ckp_psx.c
@@ -36,6 +36,9 @@
struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[])
{
+#ifdef __ANDROID__
+ return NIL;
+#else
char tmp[MAILTMPLEN];
struct spwd *sp = NIL;
time_t left;
@@ -98,4 +101,5 @@
else pw = NIL; /* password failed */
}
return pw;
+#endif /* __ANDROID__ */
}

View File

@ -0,0 +1,11 @@
--- a/src/osdep/unix/env_unix.c
+++ b/src/osdep/unix/env_unix.c
@@ -124,7 +124,7 @@
* systems.
*/
-static const char *tmpdir = "/tmp";
+static const char *tmpdir = "@TERMUX_PREFIX@/tmp";
/* Do not change shlock_mode. Doing so can cause mailbox corruption and
* denial of service. It also defeats the entire purpose of the shared

View File

@ -0,0 +1,10 @@
--- a/src/osdep/unix/os_slx.c
+++ b/src/osdep/unix/os_slx.c
@@ -40,7 +40,6 @@
#include <errno.h>
extern int errno; /* just in case */
#include <pwd.h>
-#include <shadow.h>
#include "misc.h"