Skip to content
Snippets Groups Projects
Commit 98dae2ee authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Remove dlopen support.

Since we're modifying cryptlib anyway, we can't just dlopen any old
cryptlib library.  Require linking with the lib.  This will break
the MSVC build, so disable that for now.
parent b9420e45
No related branches found
No related tags found
No related merge requests found
Pipeline #5778 passed
...@@ -114,7 +114,7 @@ smoketest-jsexec-linux: ...@@ -114,7 +114,7 @@ smoketest-jsexec-linux:
paths: paths:
- "src/vdmodem/Release/*.exe" - "src/vdmodem/Release/*.exe"
"windows-x86 [syncterm-msvc]": ."windows-x86 [syncterm-msvc]":
tags: [Windows] tags: [Windows]
stage: build stage: build
extends: .rules extends: .rules
......
...@@ -45,7 +45,6 @@ set(SOURCE ...@@ -45,7 +45,6 @@ set(SOURCE
../smblib/crc32.c ../smblib/crc32.c
../sbbs3/zmodem.c ../sbbs3/zmodem.c
../sbbs3/xmodem.c ../sbbs3/xmodem.c
st_crypt.c
syncterm.c syncterm.c
ooii.c ooii.c
ooii_logons.c ooii_logons.c
......
...@@ -17,7 +17,7 @@ else ...@@ -17,7 +17,7 @@ else
endif endif
ifeq ($(os),sunos) # Solaris ifeq ($(os),sunos) # Solaris
LDFLAGS += -lnsl -lrt -lcurses -ldl LDFLAGS += -lnsl -lrt -lcurses
CFLAGS += -DNEED_CFMAKERAW CFLAGS += -DNEED_CFMAKERAW
endif endif
...@@ -26,7 +26,6 @@ ifdef WITHOUT_CRYPTLIB ...@@ -26,7 +26,6 @@ ifdef WITHOUT_CRYPTLIB
CRYPT_LDFLAGS := CRYPT_LDFLAGS :=
CRYPT_DEPS := CRYPT_DEPS :=
else else
OBJS += $(MTOBJODIR)$(DIRSEP)st_crypt$(OFILE)
OBJS += $(MTOBJODIR)$(DIRSEP)ssh$(OFILE) OBJS += $(MTOBJODIR)$(DIRSEP)ssh$(OFILE)
OBJS += $(MTOBJODIR)$(DIRSEP)telnets$(OFILE) OBJS += $(MTOBJODIR)$(DIRSEP)telnets$(OFILE)
CFLAGS += $(CRYPT_CFLAGS) $(SFTP-MT_CFLAGS) CFLAGS += $(CRYPT_CFLAGS) $(SFTP-MT_CFLAGS)
...@@ -36,9 +35,6 @@ else ...@@ -36,9 +35,6 @@ else
endif endif
ifeq ($(os),darwin) ifeq ($(os),darwin)
ifeq ($(shell uname -r),6.8)
EXTRA_LIBS += /usr/local/lib/libdl.a
endif
EXTRA_LIBS += -framework CoreServices EXTRA_LIBS += -framework CoreServices
STATIC_CRYPTLIB ?= 1 STATIC_CRYPTLIB ?= 1
endif endif
...@@ -47,12 +43,6 @@ ifdef STATIC_CRYPTLIB ...@@ -47,12 +43,6 @@ ifdef STATIC_CRYPTLIB
CFLAGS += -DSTATIC_CRYPTLIB CFLAGS += -DSTATIC_CRYPTLIB
endif endif
ifeq ($(os),linux)
ifeq ($(shell uname -m),x86_64)
LDFLAGS += -ldl
endif
endif
DESTDIR ?= DESTDIR ?=
PREFIX ?= /usr/local PREFIX ?= /usr/local
DESKTOPDIR ?= $(PREFIX)/share/applications DESKTOPDIR ?= $(PREFIX)/share/applications
......
...@@ -131,7 +131,6 @@ ...@@ -131,7 +131,6 @@
<ClCompile Include="ripper.c" /> <ClCompile Include="ripper.c" />
<ClCompile Include="rlogin.c" /> <ClCompile Include="rlogin.c" />
<ClCompile Include="ssh.c" /> <ClCompile Include="ssh.c" />
<ClCompile Include="st_crypt.c" />
<ClCompile Include="syncterm.c" /> <ClCompile Include="syncterm.c" />
<ClCompile Include="telnets.c" /> <ClCompile Include="telnets.c" />
<ClCompile Include="telnet_io.c" /> <ClCompile Include="telnet_io.c" />
...@@ -159,4 +158,4 @@ ...@@ -159,4 +158,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
$(MTOBJODIR)$(DIRSEP)conn$(OFILE): $(CRYPT_LIB) $(MTOBJODIR)$(DIRSEP)conn$(OFILE): $(CRYPT_LIB)
$(MTOBJODIR)$(DIRSEP)ssh$(OFILE): $(CRYPT_LIB) $(MTOBJODIR)$(DIRSEP)ssh$(OFILE): $(CRYPT_LIB)
$(MTOBJODIR)$(DIRSEP)st_crypt$(OFILE): $(CRYPT_LIB)
$(MTOBJODIR)$(DIRSEP)syncterm$(OFILE): $(CRYPT_LIB) $(CIOLIB-MT) $(MTOBJODIR)$(DIRSEP)syncterm$(OFILE): $(CRYPT_LIB) $(CIOLIB-MT)
$(MTOBJODIR)$(DIRSEP)telnets$(OFILE): $(CRYPT_LIB) $(MTOBJODIR)$(DIRSEP)telnets$(OFILE): $(CRYPT_LIB)
$(CIOLIB_INTERPOLATE_OBJS): $(CIOLIB-MT_BUILD) $(CIOLIB_INTERPOLATE_OBJS): $(CIOLIB-MT_BUILD)
This diff is collapsed.
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include <stdbool.h> #include <stdbool.h>
#include "st_crypt.h" #include "cryptlib.h"
void init_crypt(void);
void exit_crypt(void);
int ssh_connect(struct bbslist *bbs); int ssh_connect(struct bbslist *bbs);
int ssh_close(void); int ssh_close(void);
void ssh_input_thread(void *args); void ssh_input_thread(void *args);
......
/* Copyright (C), 2007 by Stephen Hurd */
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <stdlib.h>
#else
#include <unistd.h> /* _exit() */
#endif
#include <stdio.h> /* NULL */
#include <xp_dl.h>
#include "st_crypt.h"
int crypt_loaded = 0;
#ifdef WITHOUT_CRYPTLIB
int
init_crypt()
{
return -1;
}
void
exit_crypt()
{}
#else
struct crypt_funcs cl;
int
init_crypt(void)
{
#ifndef STATIC_CRYPTLIB
dll_handle cryptlib;
const char *libnames[] = {"cl", "cl34", "cl33", "cl32", NULL};
#endif
if (crypt_loaded)
return 0;
#ifdef STATIC_CRYPTLIB
cl.PopData = cryptPopData;
cl.PushData = cryptPushData;
cl.FlushData = cryptFlushData;
cl.Init = cryptInit;
cl.End = cryptEnd;
cl.CreateSession = cryptCreateSession;
cl.GetAttribute = cryptGetAttribute;
cl.GetAttributeString = cryptGetAttributeString;
cl.SetAttribute = cryptSetAttribute;
cl.SetAttributeString = cryptSetAttributeString;
cl.DestroySession = cryptDestroySession;
cl.AddRandom = cryptAddRandom;
cl.DeleteAttribute = cryptDeleteAttribute;
cl.KeysetOpen = cryptKeysetOpen;
cl.KeysetClose = cryptKeysetClose;
cl.GenerateKey = cryptGenerateKey;
cl.AddPrivateKey = cryptAddPrivateKey;
cl.GetPrivateKey = cryptGetPrivateKey;
cl.CreateContext = cryptCreateContext;
cl.DestroyContext = cryptDestroyContext;
#else
cryptlib = xp_dlopen(libnames, RTLD_LAZY, CRYPTLIB_VERSION / 1000);
if (cryptlib == NULL)
return -1;
if ((cl.PopData = xp_dlsym(cryptlib, cryptPopData)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.PushData = xp_dlsym(cryptlib, cryptPushData)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.FlushData = xp_dlsym(cryptlib, cryptFlushData)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.Init = xp_dlsym(cryptlib, cryptInit)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.End = xp_dlsym(cryptlib, cryptEnd)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.CreateSession = xp_dlsym(cryptlib, cryptCreateSession)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.GetAttribute = xp_dlsym(cryptlib, cryptGetAttribute)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.GetAttributeString = xp_dlsym(cryptlib, cryptGetAttributeString)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.SetAttribute = xp_dlsym(cryptlib, cryptSetAttribute)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.SetAttributeString = xp_dlsym(cryptlib, cryptSetAttributeString)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.DestroySession = xp_dlsym(cryptlib, cryptDestroySession)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.AddRandom = xp_dlsym(cryptlib, cryptAddRandom)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.DeleteAttribute = xp_dlsym(cryptlib, cryptDeleteAttribute)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.KeysetOpen = xp_dlsym(cryptlib, cryptKeysetOpen)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.KeysetClose = xp_dlsym(cryptlib, cryptKeysetClose)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.GenerateKey = xp_dlsym(cryptlib, cryptGenerateKey)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.AddPrivateKey = xp_dlsym(cryptlib, cryptAddPrivateKey)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.GetPrivateKey = xp_dlsym(cryptlib, cryptGetPrivateKey)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.CreateContext = xp_dlsym(cryptlib, cryptCreateContext)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
if ((cl.DestroyContext = xp_dlsym(cryptlib, cryptDestroyContext)) == NULL) {
xp_dlclose(cryptlib);
return -1;
}
#endif /* ifdef STATIC_CRYPTLIB */
if (cryptStatusOK(cl.Init())) {
if (cryptStatusOK(cl.AddRandom(NULL, CRYPT_RANDOM_SLOWPOLL))) {
crypt_loaded = 1;
return 0;
}
cl.End();
}
return -1;
}
void
exit_crypt(void)
{
if (crypt_loaded)
cl.End();
}
#endif /* ifdef WITHOUT_CRYPTLIB */
/* Copyright (C), 2007 by Stephen Hurd */
#ifndef _ST_CRYPT_H_
#define _ST_CRYPT_H_
#ifndef WITHOUT_CRYPTLIB
#include <cryptlib.h>
#if CRYPTLIB_VERSION < 3400
#if CRYPTLIB_VERSION < 340 || CRYPTLIB_VERSION > 999
#define CRYPT_ATTRIBUTE_ERRORMESSAGE CRYPT_ATTRIBUTE_INT_ERRORMESSAGE
#endif
#endif
struct crypt_funcs {
int (*PopData)(C_IN CRYPT_HANDLE envelope, C_OUT void C_PTR buffer,
C_IN int length, C_OUT int C_PTR bytesCopied);
int (*PushData)(C_IN CRYPT_HANDLE envelope, C_IN void C_PTR buffer,
C_IN int length, C_OUT int C_PTR bytesCopied);
int (*FlushData)(C_IN CRYPT_HANDLE envelope);
int (*Init)(void);
int (*End)(void);
int (*CreateSession)(C_OUT CRYPT_SESSION C_PTR session,
C_IN CRYPT_USER cryptUser,
C_IN CRYPT_SESSION_TYPE formatType);
int (*GetAttribute)(C_IN CRYPT_HANDLE cryptHandle,
C_IN CRYPT_ATTRIBUTE_TYPE attributeType,
C_OUT int C_PTR value);
int (*GetAttributeString)(C_IN CRYPT_HANDLE cryptHandle,
C_IN CRYPT_ATTRIBUTE_TYPE attributeType,
C_OUT void C_PTR value,
C_OUT int C_PTR valueLength);
int (*SetAttribute)(C_IN CRYPT_HANDLE cryptHandle,
C_IN CRYPT_ATTRIBUTE_TYPE attributeType,
C_IN int value);
int (*SetAttributeString)(C_IN CRYPT_HANDLE cryptHandle,
C_IN CRYPT_ATTRIBUTE_TYPE attributeType,
C_IN void C_PTR value, C_IN int valueLength);
int (*DestroySession)(C_IN CRYPT_SESSION session);
int (*AddRandom)(C_IN void C_PTR randomData, C_IN int randomDataLength);
int (*DeleteAttribute)(C_IN CRYPT_HANDLE cryptHandle,
C_IN CRYPT_ATTRIBUTE_TYPE attributeType);
int (*KeysetOpen)(C_OUT CRYPT_KEYSET C_PTR keyset,
C_IN CRYPT_USER cryptUser,
C_IN CRYPT_KEYSET_TYPE keysetType,
C_IN C_STR name, C_IN CRYPT_KEYOPT_TYPE options);
int (*KeysetClose)(C_IN CRYPT_KEYSET keyset);
int (*GenerateKey)(C_IN CRYPT_CONTEXT cryptContext);
int (*AddPrivateKey)(C_IN CRYPT_KEYSET keyset,
C_IN CRYPT_HANDLE cryptKey,
C_IN C_STR password );
int (*GetPrivateKey)(C_IN CRYPT_KEYSET keyset,
C_OUT CRYPT_CONTEXT C_PTR cryptContext,
C_IN CRYPT_KEYID_TYPE keyIDtype,
C_IN C_STR keyID, C_IN_OPT C_STR password );
int (*CreateContext)(C_OUT CRYPT_CONTEXT C_PTR cryptContext,
C_IN CRYPT_USER cryptUser,
C_IN CRYPT_ALGO_TYPE cryptAlgo);
int (*DestroyContext)(C_IN CRYPT_CONTEXT cryptContext);
};
#endif // ifndef WITHOUT_CRYPTLIB
extern struct crypt_funcs cl;
extern int crypt_loaded;
int init_crypt(void);
void exit_crypt(void);
#endif // ifndef _ST_CRYPT_H_
...@@ -72,9 +72,9 @@ enum { ...@@ -72,9 +72,9 @@ enum {
#include "bbslist.h" #include "bbslist.h"
#include "conn.h" #include "conn.h"
#include "cryptlib.h"
#include "fonts.h" #include "fonts.h"
#include "scale.h" #include "scale.h"
#include "st_crypt.h"
#include "syncterm.h" #include "syncterm.h"
#include "term.h" #include "term.h"
#include "uifcinit.h" #include "uifcinit.h"
...@@ -1558,9 +1558,7 @@ main(int argc, char **argv) ...@@ -1558,9 +1558,7 @@ main(int argc, char **argv)
#if !defined(WITHOUT_CRYPTLIB) #if !defined(WITHOUT_CRYPTLIB)
/* Cryptlib initialization MUST be done before ciolib init */ /* Cryptlib initialization MUST be done before ciolib init */
if (!crypt_loaded) init_crypt();
init_crypt();
atexit(exit_crypt);
#endif #endif
/* UIFC initialization */ /* UIFC initialization */
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#include "ciolib.h" #include "ciolib.h"
#include "conn.h" #include "conn.h"
#include "conn_telnet.h" #include "conn_telnet.h"
#include "cryptlib.h"
#include "gen_defs.h" #include "gen_defs.h"
#include "genwrap.h" #include "genwrap.h"
#include "sockwrap.h" #include "sockwrap.h"
#include "ssh.h" #include "ssh.h"
#include "st_crypt.h"
#include "syncterm.h" #include "syncterm.h"
#include "threadwrap.h" #include "threadwrap.h"
#include "uifcinit.h" #include "uifcinit.h"
...@@ -26,22 +26,6 @@ telnets_connect(struct bbslist *bbs) ...@@ -26,22 +26,6 @@ telnets_connect(struct bbslist *bbs)
init_uifc(true, true); init_uifc(true, true);
pthread_mutex_init(&ssh_mutex, NULL); pthread_mutex_init(&ssh_mutex, NULL);
if (!crypt_loaded) {
if (!bbs->hidepopups) {
uifcmsg("Cannot load cryptlib - TelnetS inoperative", "`Cannot load cryptlib`\n\n"
"Cannot load the file "
#ifdef _WIN32
"cl32.dll"
#else
"libcl.so"
#endif
"\nThis file is required for TLS functionality.\n\n"
"The newest version is always available from:\n"
"http://www.cs.auckland.ac.nz/~pgut001/cryptlib/");
return conn_api.terminate = -1;
}
}
ssh_sock = conn_socket_connect(bbs); ssh_sock = conn_socket_connect(bbs);
if (ssh_sock == INVALID_SOCKET) if (ssh_sock == INVALID_SOCKET)
return -1; return -1;
...@@ -50,7 +34,7 @@ telnets_connect(struct bbslist *bbs) ...@@ -50,7 +34,7 @@ telnets_connect(struct bbslist *bbs)
if (!bbs->hidepopups) if (!bbs->hidepopups)
uifc.pop("Creating Session"); uifc.pop("Creating Session");
status = cl.CreateSession(&ssh_session, CRYPT_UNUSED, CRYPT_SESSION_SSL); status = cryptCreateSession(&ssh_session, CRYPT_UNUSED, CRYPT_SESSION_SSL);
if (cryptStatusError(status)) { if (cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str, "Error %d creating session", status); sprintf(str, "Error %d creating session", status);
...@@ -70,7 +54,7 @@ telnets_connect(struct bbslist *bbs) ...@@ -70,7 +54,7 @@ telnets_connect(struct bbslist *bbs)
uifc.pop(NULL); uifc.pop(NULL);
/* Pass socket to cryptlib */ /* Pass socket to cryptlib */
status = cl.SetAttribute(ssh_session, CRYPT_SESSINFO_NETWORKSOCKET, ssh_sock); status = cryptSetAttribute(ssh_session, CRYPT_SESSINFO_NETWORKSOCKET, ssh_sock);
if (cryptStatusError(status)) { if (cryptStatusError(status)) {
char str[1024]; char str[1024];
sprintf(str, "Error %d passing socket", status); sprintf(str, "Error %d passing socket", status);
...@@ -82,14 +66,14 @@ telnets_connect(struct bbslist *bbs) ...@@ -82,14 +66,14 @@ telnets_connect(struct bbslist *bbs)
return -1; return -1;
} }
cl.SetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 1); cryptSetAttribute(ssh_session, CRYPT_OPTION_NET_READTIMEOUT, 1);
/* Activate the session */ /* Activate the session */
if (!bbs->hidepopups) { if (!bbs->hidepopups) {
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Activating Session"); uifc.pop("Activating Session");
} }
status = cl.SetAttribute(ssh_session, CRYPT_SESSINFO_ACTIVE, 1); status = cryptSetAttribute(ssh_session, CRYPT_SESSINFO_ACTIVE, 1);
if (cryptStatusError(status)) { if (cryptStatusError(status)) {
if (!bbs->hidepopups) if (!bbs->hidepopups)
cryptlib_error_message(status, "activating session"); cryptlib_error_message(status, "activating session");
...@@ -106,7 +90,7 @@ telnets_connect(struct bbslist *bbs) ...@@ -106,7 +90,7 @@ telnets_connect(struct bbslist *bbs)
uifc.pop(NULL); uifc.pop(NULL);
uifc.pop("Clearing Ownership"); uifc.pop("Clearing Ownership");
} }
status = cl.SetAttribute(ssh_session, CRYPT_PROPERTY_OWNER, CRYPT_UNUSED); status = cryptSetAttribute(ssh_session, CRYPT_PROPERTY_OWNER, CRYPT_UNUSED);
if (cryptStatusError(status)) { if (cryptStatusError(status)) {
if (!bbs->hidepopups) if (!bbs->hidepopups)
cryptlib_error_message(status, "clearing session ownership"); cryptlib_error_message(status, "clearing session ownership");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment