Skip to content

Commit b36c293

Browse files
committed
Merge remote-tracking branch 'upstream/master' into custom-socket-io
2 parents 1c7fd8c + a7671ad commit b36c293

File tree

14 files changed

+215
-53
lines changed

14 files changed

+215
-53
lines changed

CMakeLists.txt

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ option(WITH_24BPP "Allow 24 bpp" ON)
5858
option(WITH_IPv6 "Enable IPv6 Support" ON)
5959
option(WITH_WEBSOCKETS "Build with websockets support" ON)
6060
option(WITH_SASL "Build with SASL support" ON)
61+
option(WITH_EXAMPLES "Build examples" ON)
62+
option(WITH_TESTS "Build tests" ON)
6163

6264

6365

@@ -210,6 +212,7 @@ check_function_exists(strerror LIBVNCSERVER_HAVE_STRERROR)
210212
check_function_exists(strstr LIBVNCSERVER_HAVE_STRSTR)
211213

212214
check_symbol_exists(htobe64 "endian.h" LIBVNCSERVER_HAVE_HTOBE64)
215+
check_symbol_exists(htobe64 "sys/endian.h" LIBVNCSERVER_HAVE_HTOBE64)
213216
check_symbol_exists(OSSwapHostToBigInt64 "libkern/OSByteOrder.h" LIBVNCSERVER_HAVE_OSSWAPHOSTTOBIGINT64)
214217

215218
if(WITH_THREADS AND Threads_FOUND)
@@ -604,26 +607,28 @@ if(FFMPEG_FOUND)
604607
)
605608
endif(FFMPEG_FOUND)
606609

607-
608-
foreach(e ${LIBVNCSERVER_EXAMPLES})
609-
add_executable(examples_${e} ${LIBVNCSRVEXAMPLE_DIR}/${e}.c)
610-
set_target_properties(examples_${e} PROPERTIES OUTPUT_NAME ${e})
611-
set_target_properties(examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
612-
target_link_libraries(examples_${e} vncserver ${CMAKE_THREAD_LIBS_INIT} ${CARBON_LIBRARY} ${IOKIT_LIBRARY} ${IOSURFACE_LIBRARY})
613-
endforeach(e ${LIBVNCSERVER_EXAMPLES})
614-
615-
foreach(e ${LIBVNCCLIENT_EXAMPLES})
616-
add_executable(client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR}/${e}.c ${LIBVNCCLIEXAMPLE_DIR}/${${e}_EXTRA_SOURCES} )
617-
set_target_properties(client_examples_${e} PROPERTIES OUTPUT_NAME ${e})
618-
set_target_properties(client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client_examples)
619-
target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES})
620-
endforeach(e ${LIBVNCCLIENT_EXAMPLES})
621-
610+
if(WITH_EXAMPLES)
611+
foreach(e ${LIBVNCSERVER_EXAMPLES})
612+
add_executable(examples_${e} ${LIBVNCSRVEXAMPLE_DIR}/${e}.c)
613+
set_target_properties(examples_${e} PROPERTIES OUTPUT_NAME ${e})
614+
set_target_properties(examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
615+
target_link_libraries(examples_${e} vncserver ${CMAKE_THREAD_LIBS_INIT} ${CARBON_LIBRARY} ${IOKIT_LIBRARY} ${IOSURFACE_LIBRARY})
616+
endforeach(e ${LIBVNCSERVER_EXAMPLES})
617+
618+
foreach(e ${LIBVNCCLIENT_EXAMPLES})
619+
add_executable(client_examples_${e} ${LIBVNCCLIEXAMPLE_DIR}/${e}.c ${LIBVNCCLIEXAMPLE_DIR}/${${e}_EXTRA_SOURCES} )
620+
set_target_properties(client_examples_${e} PROPERTIES OUTPUT_NAME ${e})
621+
set_target_properties(client_examples_${e} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client_examples)
622+
target_link_libraries(client_examples_${e} vncclient ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY} ${GTK2_LIBRARIES} ${FFMPEG_LIBRARIES})
623+
endforeach(e ${LIBVNCCLIENT_EXAMPLES})
624+
endif(WITH_EXAMPLES)
622625

623626
#
624627
# them tests
625628
#
626629

630+
if(WITH_TESTS)
631+
627632
if(UNIX)
628633
set(ADDITIONAL_TEST_LIBS m)
629634
endif(UNIX)
@@ -695,6 +700,8 @@ if(LIBVNCSERVER_WITH_WEBSOCKETS)
695700
add_test(NAME wstest COMMAND test_wstest)
696701
endif(LIBVNCSERVER_WITH_WEBSOCKETS)
697702

703+
endif(WITH_TESTS)
704+
698705
#
699706
# this gets the libraries needed by TARGET in "-libx -liby ..." form
700707
#
@@ -724,22 +731,65 @@ get_link_libraries(PRIVATE_LIBS vncclient)
724731
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libvncclient.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc @ONLY)
725732

726733
if(LIBVNCSERVER_INSTALL)
727-
install(TARGETS vncserver DESTINATION ${CMAKE_INSTALL_LIBDIR})
728-
install(TARGETS vncclient DESTINATION ${CMAKE_INSTALL_LIBDIR})
729-
install(FILES
730-
rfb/keysym.h
731-
rfb/threading.h
732-
rfb/rfb.h
733-
rfb/rfbclient.h
734-
${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h
735-
rfb/rfbproto.h
736-
rfb/rfbregion.h
737-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rfb
738-
)
739-
740-
install(FILES
741-
${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc
742-
${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc
743-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
744-
)
734+
set(INSTALL_HEADER_FILES
735+
rfb/keysym.h
736+
rfb/threading.h
737+
rfb/rfb.h
738+
rfb/rfbclient.h
739+
${CMAKE_CURRENT_BINARY_DIR}/rfb/rfbconfig.h
740+
rfb/rfbproto.h
741+
rfb/rfbregion.h
742+
)
743+
744+
set_property(TARGET vncclient PROPERTY PUBLIC_HEADER ${INSTALL_HEADER_FILES})
745+
set_property(TARGET vncserver PROPERTY PUBLIC_HEADER ${INSTALL_HEADER_FILES})
746+
if(WIN32)
747+
INSTALL(TARGETS vncclient vncserver
748+
EXPORT LibVNCServerTargets
749+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
750+
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}"
751+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
752+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rfb
753+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
754+
)
755+
else()
756+
INSTALL(TARGETS vncclient vncserver
757+
EXPORT LibVNCServerTargets
758+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
759+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
760+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
761+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rfb
762+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
763+
)
764+
endif()
765+
766+
# Install cmake configure files
767+
install(EXPORT LibVNCServerTargets
768+
NAMESPACE
769+
"LibVNCServer::"
770+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/LibVNCServer"
771+
)
772+
773+
include(CMakePackageConfigHelpers)
774+
configure_package_config_file(
775+
${PROJECT_SOURCE_DIR}/cmake/Modules/LibVNCServerConfig.cmake.in
776+
${CMAKE_BINARY_DIR}/LibVNCServerConfig.cmake
777+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/LibVNCServer"
778+
)
779+
# Install cmake version configure file
780+
write_basic_package_version_file(
781+
"${CMAKE_BINARY_DIR}/LibVNCServerConfigVersion.cmake"
782+
VERSION ${PARA_VERSION}
783+
COMPATIBILITY AnyNewerVersion)
784+
install(FILES
785+
"${CMAKE_BINARY_DIR}/LibVNCServerConfigVersion.cmake"
786+
"${CMAKE_BINARY_DIR}/LibVNCServerConfig.cmake"
787+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/LibVNCServer")
788+
789+
790+
install(FILES
791+
${CMAKE_CURRENT_BINARY_DIR}/libvncserver.pc
792+
${CMAKE_CURRENT_BINARY_DIR}/libvncclient.pc
793+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
794+
)
745795
endif()

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Pull Requests
2+
3+
* Make sure you only include relevant changes in your commit(s). In particular, don't re-format
4+
whole source files as those indentation changes add a lot of unrelated changes to your commit.
5+
6+
* Make your commits as [atomic as possible](https://www.freshconsulting.com/atomic-commits/).
7+
* Fundamental question 1: what could we need to revert later?
8+
* Fundamental question 2: what could we need to cherry-pick?
9+
* Fundamental question 3: is there an _and_ in the commit message? -> split it!
10+
11+
* Adhere to the commit message [guidelines](https://chris.beams.io/posts/git-commit/):
12+
* Start with the module you are changing, ended with a ':'. Common ones used here are "CMake:"
13+
or "examples:" or "libvncclient:", but there are more! A good way to find common module
14+
descriptions is to look into the git history of the project.
15+
* Keep the commit message short and in the form of "When applied, this commit will ' `<your commit message>`
16+
* Do _not_ end the subject line with a '.'.
17+
* Example: `warpdrive: increase fuel capacity to 100k`

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/LibVNC/libvncserver.svg?branch=master)](https://travis-ci.org/LibVNC/libvncserver)
1+
[![Build Status](https://app.travis-ci.com/LibVNC/libvncserver.svg?branch=master)](https://app.travis-ci.com/LibVNC/libvncserver)
22
[![Build status](https://ci.appveyor.com/api/projects/status/fao6m1md3q4g2bwn/branch/master?svg=true)](https://ci.appveyor.com/project/bk138/libvncserver/branch/master)
33
[![Help making this possible](https://img.shields.io/badge/liberapay-donate-yellow.png)](https://liberapay.com/LibVNC/donate) [![Join the chat at https://gitter.im/LibVNC/libvncserver](https://badges.gitter.im/LibVNC/libvncserver.svg)](https://gitter.im/LibVNC/libvncserver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

@@ -40,6 +40,7 @@ RFB Protocol Support Status
4040
|Apple ARD | 30 | ||
4141
|TLS | 18 | ||
4242
|VeNCrypt | 19 | ||
43+
|UltraVNC MSLogonII | 113 | ||
4344

4445
## [Encodings](https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#76encodings)
4546

@@ -131,6 +132,30 @@ In case you prefer to learn LibVNCServer by example, have a look at the servers
131132

132133
For LibVNCClient, examples can be found in [client_examples](client_examples).
133134

135+
Incorporating LibVNCServer/LibVNCClient into your build system
136+
--------------------------------------------------------------
137+
138+
The install process installs [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)
139+
.pc files for LibVNCServer as well as LibVNCClient which you can use in your build
140+
system via the usual `pkg-config --cflags libvncserver` et al.
141+
142+
If using CMake, LibVNCServer versions > 0.9.13 provide CMake configure files so
143+
in your project's CMakeLists.txt, you can say:
144+
145+
```cmake
146+
find_package(LibVNCServer)
147+
if(LibVNCServer_FOUND)
148+
# libs and headers location are now accessible via properties, but you only
149+
# need to add the respective export target to your project's target_link_libraries,
150+
# cmake will automatically add libs and headers
151+
# eg: add client (YOUR_PROJECT_TARGET being a placeholder for your real target -
152+
# it must be defined by add_executable or add_library):
153+
target_link_libraries(YOUR_PROJECT_TARGET LibVNCServer::vncclient)
154+
# add server:
155+
target_link_libraries(YOUR_PROJECT_TARGET LibVNCServer::vncserver)
156+
endif()
157+
```
158+
134159
Using Websockets
135160
----------------
136161

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/LibVNCServerTargets.cmake")
4+
check_required_components(
5+
vncclient
6+
vncserver
7+
)
8+

libvncclient/rfbproto.c

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ ReadSupportedSecurityType(rfbClient* client, uint32_t *result, rfbBool subAuth)
512512
#ifdef LIBVNCSERVER_HAVE_SASL
513513
tAuth[loop]==rfbSASL ||
514514
#endif /* LIBVNCSERVER_HAVE_SASL */
515-
(tAuth[loop]==rfbARD && client->GetCredential))
515+
((tAuth[loop]==rfbARD || tAuth[loop]==rfbUltraMSLogonII) && client->GetCredential))
516516
{
517517
if (!subAuth && client->clientAuthSchemes)
518518
{
@@ -685,6 +685,60 @@ rfbPowM64(uint64_t b, uint64_t e, uint64_t m)
685685
return r;
686686
}
687687

688+
static rfbBool
689+
HandleUltraMSLogonIIAuth(rfbClient *client)
690+
{
691+
uint8_t gen[8], mod[8], resp[8], pub[8], priv[8];
692+
uint8_t username[256], password[64], key[8];
693+
rfbCredential *cred;
694+
695+
if (!ReadFromRFBServer(client, (char *)gen, sizeof(gen))) return FALSE;
696+
if (!ReadFromRFBServer(client, (char *)mod, sizeof(mod))) return FALSE;
697+
if (!ReadFromRFBServer(client, (char *)resp, sizeof(resp))) return FALSE;
698+
699+
if(!dh_generate_keypair(priv, pub, gen, sizeof(gen), mod, sizeof(priv))) {
700+
rfbClientErr("HandleUltraMSLogonIIAuth: generating keypair failed\n");
701+
return FALSE;
702+
}
703+
704+
if(!dh_compute_shared_key(key, priv, resp, mod, sizeof(key))) {
705+
rfbClientErr("HandleUltraMSLogonIIAuth: creating shared key failed\n");
706+
return FALSE;
707+
}
708+
709+
if (!client->GetCredential)
710+
{
711+
rfbClientLog("GetCredential callback is not set.\n");
712+
return FALSE;
713+
}
714+
rfbClientLog("WARNING! MSLogon security type has very low password encryption! "\
715+
"Use it only with SSH tunnel or trusted network.\n");
716+
cred = client->GetCredential(client, rfbCredentialTypeUser);
717+
if (!cred)
718+
{
719+
rfbClientLog("Reading credential failed\n");
720+
return FALSE;
721+
}
722+
723+
memset(username, 0, sizeof(username));
724+
strncpy((char *)username, cred->userCredential.username, sizeof(username)-1);
725+
memset(password, 0, sizeof(password));
726+
strncpy((char *)password, cred->userCredential.password, sizeof(password)-1);
727+
FreeUserCredential(cred);
728+
729+
rfbClientEncryptBytes2(username, sizeof(username), (unsigned char *)key);
730+
rfbClientEncryptBytes2(password, sizeof(password), (unsigned char *)key);
731+
732+
if (!WriteToRFBServer(client, (char *)pub, sizeof(pub))) return FALSE;
733+
if (!WriteToRFBServer(client, (char *)username, sizeof(username))) return FALSE;
734+
if (!WriteToRFBServer(client, (char *)password, sizeof(password))) return FALSE;
735+
736+
/* Handle the SecurityResult message */
737+
if (!rfbHandleAuthResult(client)) return FALSE;
738+
739+
return TRUE;
740+
}
741+
688742
static rfbBool
689743
HandleMSLogonAuth(rfbClient *client)
690744
{
@@ -1008,6 +1062,10 @@ InitialiseRFBConnection(rfbClient* client)
10081062
break;
10091063
#endif /* LIBVNCSERVER_HAVE_SASL */
10101064

1065+
case rfbUltraMSLogonII:
1066+
if (!HandleUltraMSLogonIIAuth(client)) return FALSE;
1067+
break;
1068+
10111069
case rfbMSLogon:
10121070
if (!HandleMSLogonAuth(client)) return FALSE;
10131071
break;

libvncclient/tls_openssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ open_ssl_connection (rfbClient *client, int sockfd, rfbBool anonTLS, rfbCredenti
327327
SSL_CTX_set1_param(ssl_ctx, param);
328328
SSL_CTX_set_cipher_list(ssl_ctx, "ALL");
329329
} else { /* anonTLS here */
330-
/* Need ADH cipher for anonTLS, see https://github.com/LibVNC/libvncserver/issues/347#issuecomment-597477103 */
331-
SSL_CTX_set_cipher_list(ssl_ctx, "ADH");
330+
/* Need anonymous ciphers for anonTLS, see https://github.com/LibVNC/libvncserver/issues/347#issuecomment-597477103 */
331+
SSL_CTX_set_cipher_list(ssl_ctx, "aNULL");
332332
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined LIBRESSL_VERSION_NUMBER
333333
/*
334334
See https://www.openssl.org/docs/man1.1.0/man3/SSL_set_security_level.html

libvncserver/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ rfbUnregisterProtocolExtension(rfbProtocolExtension* extension)
145145
rfbUnregisterProtocolExtension(extension->next);
146146
}
147147

148-
rfbProtocolExtension* rfbGetExtensionIterator()
148+
rfbProtocolExtension* rfbGetExtensionIterator(void)
149149
{
150150
if (! extMutex_initialized) {
151151
INIT_MUTEX(extMutex);
@@ -156,7 +156,7 @@ rfbProtocolExtension* rfbGetExtensionIterator()
156156
return rfbExtensionHead;
157157
}
158158

159-
void rfbReleaseExtensionIterator()
159+
void rfbReleaseExtensionIterator(void)
160160
{
161161
UNLOCK(extMutex);
162162
}

libvncserver/rfbssl_gnutls.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ int rfbssl_init(rfbClientPtr cl)
126126
if (!(keyfile = cl->screen->sslkeyfile))
127127
keyfile = cl->screen->sslcertfile;
128128

129-
if (NULL == (ctx = rfbssl_init_global(keyfile, cl->screen->sslcertfile))) {
129+
if (!cl->screen->sslcertfile || !cl->screen->sslcertfile[0]) {
130+
rfbErr("SSL connection but no cert specified\n");
131+
} else if (NULL == (ctx = rfbssl_init_global(keyfile, cl->screen->sslcertfile))) {
130132
/* */
131133
} else if (GNUTLS_E_SUCCESS != (ret = rfbssl_init_session(ctx, cl->sock))) {
132134
/* */

libvncserver/tightvnc-filetransfer/rfbtightserver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,13 @@ static rfbSecurityHandler tightVncSecurityHandler = {
536536
NULL
537537
};
538538

539-
void rfbRegisterTightVNCFileTransferExtension() {
539+
void rfbRegisterTightVNCFileTransferExtension(void) {
540540
rfbRegisterProtocolExtension(&tightVncFileTransferExtension);
541541
rfbRegisterSecurityHandler(&tightVncSecurityHandler);
542542
}
543543

544544
void
545-
rfbUnregisterTightVNCFileTransferExtension() {
545+
rfbUnregisterTightVNCFileTransferExtension(void) {
546546
rfbUnregisterProtocolExtension(&tightVncFileTransferExtension);
547547
rfbUnregisterSecurityHandler(&tightVncSecurityHandler);
548548
}

libvncserver/websockets.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
/* errno */
3535
#include <errno.h>
3636

37-
#ifdef LIBVNCSERVER_HAVE_ENDIAN_H
38-
#include <endian.h>
39-
#elif LIBVNCSERVER_HAVE_SYS_ENDIAN_H
40-
#include <sys/endian.h>
41-
#endif
42-
4337
#ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H
4438
#include <sys/types.h>
4539
#endif

0 commit comments

Comments
 (0)