From cf38a01d2f3fda59d06bf2d510ab3ae21687238e Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Wed, 19 Jun 2019 17:30:29 +0530 Subject: [PATCH 01/18] Initial commit for DropbearServer plugin --- configs/raspberrypi3_wpe_ml_defconfig | 1 + .../dropbear/0001-Makefile.in-changes.patch | 76 ++++++++ .../dropbear/0002-svr-main.c-changes.patch | 181 ++++++++++++++++++ .../dropbear/0003-configure.ac-changes.patch | 12 ++ .../dropbear/0004-libdropbear.h-added.patch | 19 ++ .../0005-libdropbear.pc.in-added.patch | 14 ++ package/dropbear/dropbear.mk | 18 +- 7 files changed, 314 insertions(+), 7 deletions(-) create mode 100644 package/dropbear/0001-Makefile.in-changes.patch create mode 100644 package/dropbear/0002-svr-main.c-changes.patch create mode 100644 package/dropbear/0003-configure.ac-changes.patch create mode 100644 package/dropbear/0004-libdropbear.h-added.patch create mode 100644 package/dropbear/0005-libdropbear.pc.in-added.patch diff --git a/configs/raspberrypi3_wpe_ml_defconfig b/configs/raspberrypi3_wpe_ml_defconfig index baba5e872322..6332141970dc 100644 --- a/configs/raspberrypi3_wpe_ml_defconfig +++ b/configs/raspberrypi3_wpe_ml_defconfig @@ -66,6 +66,7 @@ BR2_PACKAGE_WPEFRAMEWORK=y BR2_PACKAGE_WPEFRAMEWORK_VIRTUALINPUT=y BR2_PACKAGE_WPEFRAMEWORK_PROVISIONPROXY=y BR2_PACKAGE_WPEFRAMEWORK_DHCPSERVER=y +BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER=y BR2_PACKAGE_WPEFRAMEWORK_LOCATIONSYNC=y BR2_PACKAGE_WPEFRAMEWORK_LOCATIONSYNC_URI="http://jsonip.metrological.com/?maf=true" BR2_PACKAGE_WPEFRAMEWORK_MONITOR=y diff --git a/package/dropbear/0001-Makefile.in-changes.patch b/package/dropbear/0001-Makefile.in-changes.patch new file mode 100644 index 000000000000..366938f6864d --- /dev/null +++ b/package/dropbear/0001-Makefile.in-changes.patch @@ -0,0 +1,76 @@ +--- a/Makefile.in 2016-07-21 20:47:09.000000000 +0530 ++++ b/Makefile.in 2019-06-07 15:08:42.613982883 +0530 +@@ -10,7 +10,7 @@ + # Hopefully that seems intuitive. + + ifndef PROGRAMS +- PROGRAMS=dropbear dbclient dropbearkey dropbearconvert ++ PROGRAMS=dropbear + endif + + STATIC_LTC=libtomcrypt/libtomcrypt.a +@@ -18,6 +18,8 @@ + + LIBTOM_LIBS=@LIBTOM_LIBS@ + ++DROPBEAR_SERVER_LIB=libdropbear.so ++ + ifeq (@BUNDLED_LIBTOM@, 1) + LIBTOM_DEPS=$(STATIC_LTC) $(STATIC_LTM) + CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ +@@ -75,6 +77,9 @@ + bindir=@bindir@ + sbindir=@sbindir@ + mandir=@mandir@ ++libdir = @libdir@ ++includedir = @includedir@ ++pkgconfigdir = $(libdir)/pkgconfig + + CC=@CC@ + AR=@AR@ +@@ -82,9 +87,10 @@ + STRIP=@STRIP@ + INSTALL=@INSTALL@ + CPPFLAGS=@CPPFLAGS@ +-CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ ++CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ -fPIC + LIBS+=@LIBS@ + LDFLAGS=@LDFLAGS@ ++ARFLAGS=rcT + + EXEEXT=@EXEEXT@ + +@@ -106,12 +112,14 @@ + + ifeq ($(STATIC), 1) + LDFLAGS+=-static ++else ++ LDFLAGS +=-shared + endif + + ifeq ($(MULTI), 1) + TARGETS=dropbearmulti + else +- TARGETS=$(PROGRAMS) ++ TARGETS=$(DROPBEAR_SERVER_LIB) + endif + + # for the scp progress meter. The -D doesn't affect anything else. +@@ -175,6 +183,8 @@ + scp: $(SCPOBJS) $(HEADERS) Makefile + $(CC) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS) + ++$(DROPBEAR_SERVER_LIB):$(LIBTOM_LIBS)$(dropbearobjs) ++ $(CC) $(LDFLAGS) -o $@ $(dropbearobjs) $(LIBTOM_LIBS) + + # multi-binary compilation. + MULTIOBJS= +@@ -215,7 +225,7 @@ + + thisclean: + -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \ +- dropbearmulti *.o *.da *.bb *.bbg *.prof ++ dropbearmulti *.o *.da *.bb *.bbg *.prof libdropbear.pc $(DROPBEAR_SERVER_LIB) + + distclean: clean tidy + -rm -f config.h diff --git a/package/dropbear/0002-svr-main.c-changes.patch b/package/dropbear/0002-svr-main.c-changes.patch new file mode 100644 index 000000000000..28140780dd11 --- /dev/null +++ b/package/dropbear/0002-svr-main.c-changes.patch @@ -0,0 +1,181 @@ +--- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 ++++ b/svr-main.c 2019-06-18 20:58:34.023322679 +0530 +@@ -30,19 +30,27 @@ + #include "runopts.h" + #include "dbrandom.h" + #include "crypto_desc.h" ++#include ++#include "libdropbear.h" + + static size_t listensockets(int *sock, size_t sockcount, int *maxfd); + static void sigchld_handler(int dummy); + static void sigsegv_handler(int); + static void sigintterm_handler(int fish); ++ ++static int pluginActivated; ++static pthread_t threadID; ++void init_dropbear(int argc, char ** argv); ++ + #ifdef INETD_MODE + static void main_inetd(void); + #endif + #ifdef NON_INETD_MODE +-static void main_noinetd(void); ++static void* main_noinetd(void *); + #endif + static void commonsetup(void); + ++#if 0 + #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) + #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) + int dropbear_main(int argc, char ** argv) +@@ -75,6 +83,55 @@ + return -1; + } + #endif ++#endif ++void init_dropbear(int argc, char ** argv) ++{ ++ _dropbear_exit = svr_dropbear_exit; ++ _dropbear_log = svr_dropbear_log; ++ ++ disallow_core(); ++ ++ /* get commandline options */ ++ svr_getopts(argc, argv); ++ /* Note: commonsetup() must happen before we daemon()ise. Otherwise ++ daemon() will chdir("/"), and we won't be able to find local-dir ++ hostkeys. */ ++ commonsetup(); ++} ++ ++void activate_dropbear(int argc, char ** argv) ++{ ++ int status; ++ int i; ++ ++ if(pluginActivated == 1) ++ { ++ printf("Plugin already Activated \n"); ++ return; ++ } ++ ++ init_dropbear(argc, argv); ++ status = pthread_create(&threadID,NULL,main_noinetd,NULL); ++ if(status != 0) ++ { ++ printf("Error in creating thread\n"); ++ return; ++ } ++ printf("Plugin Activated \n"); ++ pluginActivated =1; ++} ++ ++void deactivate_dropbear() ++{ ++ if(pluginActivated == 1) ++ { ++ exitflag =1; ++ pthread_join(threadID, 0); ++ pluginActivated = 0; ++ } ++ printf("Plugin DeActivated \n"); ++ return; ++} + + #ifdef INETD_MODE + static void main_inetd() { +@@ -104,7 +161,7 @@ + #endif /* INETD_MODE */ + + #ifdef NON_INETD_MODE +-static void main_noinetd() { ++static void* main_noinetd(void *UNUSED(unused)){ + fd_set fds; + unsigned int i, j; + int val; +@@ -118,11 +175,7 @@ + + int childsock; + int childpipe[2]; +- +- /* Note: commonsetup() must happen before we daemon()ise. Otherwise +- daemon() will chdir("/"), and we won't be able to find local-dir +- hostkeys. */ +- commonsetup(); ++ struct timeval timeout; + + /* sockets to identify pre-authenticated clients */ + for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { +@@ -141,6 +194,7 @@ + FD_SET(listensocks[i], &fds); + } + ++#if 0 + /* fork */ + if (svr_opts.forkbg) { + int closefds = 0; +@@ -153,7 +207,7 @@ + dropbear_exit("Failed to daemonize: %s", strerror(errno)); + } + } +- ++#endif + /* should be done after syslog is working */ + if (svr_opts.forkbg) { + dropbear_log(LOG_INFO, "Running in background"); +@@ -168,6 +222,8 @@ + fclose(pidfile); + } + ++ timeout.tv_sec = 5; ++ timeout.tv_usec = 0; + /* incoming connection select loop */ + for(;;) { + +@@ -186,11 +242,18 @@ + } + } + +- val = select(maxsock+1, &fds, NULL, NULL, NULL); ++ val = select(maxsock+1, &fds, NULL, NULL, &timeout); + + if (exitflag) { + unlink(svr_opts.pidfile); +- dropbear_exit("Terminated by signal"); ++ //dropbear_exit("Terminated by signal"); ++ /* make sure we close sockets */ ++ FD_ZERO(&fds); ++ for (i = 0; i < listensockcount; i++) { ++ m_close(listensocks[i]); ++ } ++ ++ break; + } + + if (val == 0) { +@@ -281,6 +344,8 @@ + if (fork_ret > 0) { + + /* parent */ ++ //getaddrstring(&remoteaddr, NULL, &remote_port, 0); ++ //printf("\nChild forked. Childpipe:%d conn_idx:%ld remotehost:%s remoteport:%s childPID:%d \n",childpipe[0],conn_idx,remote_host,remote_port,fork_ret); + childpipes[conn_idx] = childpipe[0]; + m_close(childpipe[1]); + preauth_addrs[conn_idx] = remote_host; +@@ -328,6 +393,7 @@ + } /* for(;;) loop */ + + /* don't reach here */ ++ return NULL; + } + #endif /* NON_INETD_MODE */ + +@@ -358,7 +424,6 @@ + + /* catch ctrl-c or sigterm */ + static void sigintterm_handler(int UNUSED(unused)) { +- + exitflag = 1; + } + diff --git a/package/dropbear/0003-configure.ac-changes.patch b/package/dropbear/0003-configure.ac-changes.patch new file mode 100644 index 000000000000..910845a3cc0f --- /dev/null +++ b/package/dropbear/0003-configure.ac-changes.patch @@ -0,0 +1,12 @@ +--- a/configure.ac 2016-07-21 20:47:09.000000000 +0530 ++++ b/configure.ac 2019-06-07 16:05:13.409598623 +0530 +@@ -730,6 +730,9 @@ + AC_CONFIG_FILES(Makefile $LIBTOM_FILES) + AC_OUTPUT + ++AC_CONFIG_FILES(libdropbear.pc) ++AC_OUTPUT ++ + AC_MSG_NOTICE() + if test $BUNDLED_LIBTOM = 1 ; then + AC_MSG_NOTICE([Using bundled libtomcrypt and libtommath]) diff --git a/package/dropbear/0004-libdropbear.h-added.patch b/package/dropbear/0004-libdropbear.h-added.patch new file mode 100644 index 000000000000..e34a245057fa --- /dev/null +++ b/package/dropbear/0004-libdropbear.h-added.patch @@ -0,0 +1,19 @@ +--- a/libdropbear.h 1970-01-01 05:30:00.000000000 +0530 ++++ b/libdropbear.h 2019-06-06 18:14:09.217381680 +0530 +@@ -0,0 +1,16 @@ ++#ifndef __LIBDROPBEAR_H ++#define __LIBDROPBEAR_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++ ++void activate_dropbear(int argc, char ** argv); ++void deactivate_dropbear(); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif diff --git a/package/dropbear/0005-libdropbear.pc.in-added.patch b/package/dropbear/0005-libdropbear.pc.in-added.patch new file mode 100644 index 000000000000..cb1007b833d5 --- /dev/null +++ b/package/dropbear/0005-libdropbear.pc.in-added.patch @@ -0,0 +1,14 @@ +--- a/libdropbear.pc.in 1970-01-01 05:30:00.000000000 +0530 ++++ b/libdropbear.pc.in 2019-06-06 21:49:56.122986983 +0530 +@@ -0,0 +1,11 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++ ++Name: libdropbear ++Version: @PACKAGE_VERSION@ ++Description: Dropbear SSH ++URL: http://matt.ucc.asn.au/dropbear/releases ++Libs: -L${libdir} -ldropbear ++Cflags: -I${includedir} diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index 743d52479e96..c280d6a41772 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -10,16 +10,17 @@ DROPBEAR_SOURCE = dropbear-$(DROPBEAR_VERSION).tar.bz2 DROPBEAR_LICENSE = MIT, BSD-2c-like, BSD-2c DROPBEAR_LICENSE_FILES = LICENSE DROPBEAR_TARGET_BINS = dropbearkey dropbearconvert scp -DROPBEAR_PROGRAMS = dropbear $(DROPBEAR_TARGET_BINS) +DROPBEAR_PROGRAMS = dropbear #$(DROPBEAR_TARGET_BINS) +DROPBEAR_AUTORECONF = YES -ifeq ($(BR2_PACKAGE_DROPBEAR_CLIENT),y) +#ifeq ($(BR2_PACKAGE_DROPBEAR_CLIENT),y) # Build dbclient, and create a convenience symlink named ssh -DROPBEAR_PROGRAMS += dbclient -DROPBEAR_TARGET_BINS += dbclient ssh -endif +#DROPBEAR_PROGRAMS += dbclient +#DROPBEAR_TARGET_BINS += dbclient ssh +#endif DROPBEAR_MAKE = \ - $(MAKE) MULTI=1 SCPPROGRESS=1 \ + $(MAKE) #MULTI=1 SCPPROGRESS=1 \ PROGRAMS="$(DROPBEAR_PROGRAMS)" ifeq ($(BR2_STATIC_LIBS),y) @@ -89,7 +90,10 @@ DROPBEAR_CONF_OPTS += --disable-lastlog endif define DROPBEAR_INSTALL_TARGET_CMDS - $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear + $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib + $(INSTALL) -m 755 $(@D)/libdropbear.so $(TARGET_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include + $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc for f in $(DROPBEAR_TARGET_BINS); do \ ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \ done From 8d9d73f03eba25d3da86b4aebc6d294efd30c143 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Tue, 25 Jun 2019 18:05:19 +0530 Subject: [PATCH 02/18] [DropbearServerPlugin]Made build changes to support both Dropbear shared library & executable --- ...001-Makefile.in-changes.patch.conditional} | 0 ...0002-svr-main.c-changes.patch.conditional} | 0 ...03-configure.ac-changes.patch.conditional} | 0 ...004-libdropbear.h-added.patch.conditional} | 0 ...libdropbear.pc.in-added.patch.conditional} | 0 package/dropbear/Config.in | 21 ++++++++ package/dropbear/dropbear.mk | 48 +++++++++++++------ package/wpe/wpeframework-plugins/Config.in | 7 +++ .../wpeframework-plugins.mk | 4 ++ 9 files changed, 65 insertions(+), 15 deletions(-) rename package/dropbear/{0001-Makefile.in-changes.patch => 0001-Makefile.in-changes.patch.conditional} (100%) rename package/dropbear/{0002-svr-main.c-changes.patch => 0002-svr-main.c-changes.patch.conditional} (100%) rename package/dropbear/{0003-configure.ac-changes.patch => 0003-configure.ac-changes.patch.conditional} (100%) rename package/dropbear/{0004-libdropbear.h-added.patch => 0004-libdropbear.h-added.patch.conditional} (100%) rename package/dropbear/{0005-libdropbear.pc.in-added.patch => 0005-libdropbear.pc.in-added.patch.conditional} (100%) diff --git a/package/dropbear/0001-Makefile.in-changes.patch b/package/dropbear/0001-Makefile.in-changes.patch.conditional similarity index 100% rename from package/dropbear/0001-Makefile.in-changes.patch rename to package/dropbear/0001-Makefile.in-changes.patch.conditional diff --git a/package/dropbear/0002-svr-main.c-changes.patch b/package/dropbear/0002-svr-main.c-changes.patch.conditional similarity index 100% rename from package/dropbear/0002-svr-main.c-changes.patch rename to package/dropbear/0002-svr-main.c-changes.patch.conditional diff --git a/package/dropbear/0003-configure.ac-changes.patch b/package/dropbear/0003-configure.ac-changes.patch.conditional similarity index 100% rename from package/dropbear/0003-configure.ac-changes.patch rename to package/dropbear/0003-configure.ac-changes.patch.conditional diff --git a/package/dropbear/0004-libdropbear.h-added.patch b/package/dropbear/0004-libdropbear.h-added.patch.conditional similarity index 100% rename from package/dropbear/0004-libdropbear.h-added.patch rename to package/dropbear/0004-libdropbear.h-added.patch.conditional diff --git a/package/dropbear/0005-libdropbear.pc.in-added.patch b/package/dropbear/0005-libdropbear.pc.in-added.patch.conditional similarity index 100% rename from package/dropbear/0005-libdropbear.pc.in-added.patch rename to package/dropbear/0005-libdropbear.pc.in-added.patch.conditional diff --git a/package/dropbear/Config.in b/package/dropbear/Config.in index d92361fa397f..caeac2684801 100644 --- a/package/dropbear/Config.in +++ b/package/dropbear/Config.in @@ -17,6 +17,26 @@ config BR2_PACKAGE_DROPBEAR if BR2_PACKAGE_DROPBEAR +menu "Extra options" + +choice + bool "Application type" + default BR2_PACKAGE_DROPBEAR_LIB + help + Choose application type. + +config BR2_PACKAGE_DROPBEAR_PROGRAM + bool "executable" + help + Create Dropbear standalone program. + +config BR2_PACKAGE_DROPBEAR_LIB + bool "library" + help + Create Dropbear library. + +endchoice + config BR2_PACKAGE_DROPBEAR_CLIENT bool "client programs" default y @@ -55,4 +75,5 @@ config BR2_PACKAGE_DROPBEAR_LASTLOG Enable logging of dropbear access to lastlog. Notice that Buildroot does not generate lastlog by default. +endmenu endif diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index c280d6a41772..b7346182381b 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -9,19 +9,34 @@ DROPBEAR_SITE = http://matt.ucc.asn.au/dropbear/releases DROPBEAR_SOURCE = dropbear-$(DROPBEAR_VERSION).tar.bz2 DROPBEAR_LICENSE = MIT, BSD-2c-like, BSD-2c DROPBEAR_LICENSE_FILES = LICENSE + +ifeq ($(BR2_PACKAGE_DROPBEAR_PROGRAM),y) DROPBEAR_TARGET_BINS = dropbearkey dropbearconvert scp -DROPBEAR_PROGRAMS = dropbear #$(DROPBEAR_TARGET_BINS) +DROPBEAR_PROGRAMS = dropbear $(DROPBEAR_TARGET_BINS) +else #case for BR2_PACKAGE_DROPBEAR_LIB +DROPBEAR_PROGRAMS = dropbear DROPBEAR_AUTORECONF = YES +define DROPBEAR_APPLY_LOCAL_PATCHES + # Apply these patches only incase of WPEFramework/DropbearServer plugin is enabled. + $(APPLY_PATCHES) $(@D) package/dropbear/ *.patch.conditional +endef +DROPBEAR_POST_PATCH_HOOKS += DROPBEAR_APPLY_LOCAL_PATCHES +endif -#ifeq ($(BR2_PACKAGE_DROPBEAR_CLIENT),y) +ifeq ($(BR2_PACKAGE_DROPBEAR_CLIENT),y) # Build dbclient, and create a convenience symlink named ssh -#DROPBEAR_PROGRAMS += dbclient -#DROPBEAR_TARGET_BINS += dbclient ssh -#endif +DROPBEAR_PROGRAMS += dbclient +DROPBEAR_TARGET_BINS += dbclient ssh +endif +ifeq ($(BR2_PACKAGE_DROPBEAR_PROGRAM),y) DROPBEAR_MAKE = \ - $(MAKE) #MULTI=1 SCPPROGRESS=1 \ - PROGRAMS="$(DROPBEAR_PROGRAMS)" + $(MAKE) MULTI=1 SCPPROGRESS=1 \ + PROGRAMS="$(DROPBEAR_PROGRAMS)" +else #case for BR2_PACKAGE_DROPBEAR_LIB +DROPBEAR_MAKE = \ + $(MAKE) DROPBEAR_SHARED_LIB=1 +endif ifeq ($(BR2_STATIC_LIBS),y) DROPBEAR_MAKE += STATIC=1 @@ -90,14 +105,17 @@ DROPBEAR_CONF_OPTS += --disable-lastlog endif define DROPBEAR_INSTALL_TARGET_CMDS - $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib - $(INSTALL) -m 755 $(@D)/libdropbear.so $(TARGET_DIR)/usr/lib - $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include - $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc - for f in $(DROPBEAR_TARGET_BINS); do \ - ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \ - done - ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear +ifeq ($(BR2_PACKAGE_DROPBEAR_PROGRAM),y) + $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear + for f in $(DROPBEAR_TARGET_BINS); do \ + ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \ + done + ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear +else #case for BR2_PACKAGE_DROPBEAR_LIB + $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include + $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc +endif endef $(eval $(autotools-package)) diff --git a/package/wpe/wpeframework-plugins/Config.in b/package/wpe/wpeframework-plugins/Config.in index 03e18821eecb..3e353c971a72 100644 --- a/package/wpe/wpeframework-plugins/Config.in +++ b/package/wpe/wpeframework-plugins/Config.in @@ -485,6 +485,13 @@ config BR2_PACKAGE_WPEFRAMEWORK_SYSTEMCOMMANDS help SystemCommands Plugin +config BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER + select BR2_PACKAGE_WPEFRAMEWORK_PLUGINS + select BR2_PACKAGE_DROPBEAR + bool "DropbearServer" + help + DropbearServer Plugin + menuconfig BR2_PACKAGE_WPEFRAMEWORK_SPARK bool "Spark" depends on BR2_PACKAGE_SPARK_LIB diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index e8e1597c9c9f..3f3cc54c4a76 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -68,6 +68,10 @@ ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_DICTIONARY),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_DICTIONARY=ON endif +ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER),y) +WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_DROPBEARSERVER=ON +endif + ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_IOCONNECTOR=ON ifneq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR_PAIRING_PIN),) From 0d6215b74b21e630ac48de9bcfbbba8ff567ac8f Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Tue, 16 Jul 2019 15:46:37 +0530 Subject: [PATCH 03/18] [DropbearServerPlugin]Session management support in native Dropbear codebase --- .../0002-svr-main.c-changes.patch.conditional | 265 ++++++++++++++---- ...0004-libdropbear.h-added.patch.conditional | 20 +- .../0006-linkedlist.h-added.patch.conditional | 171 +++++++++++ 3 files changed, 397 insertions(+), 59 deletions(-) create mode 100644 package/dropbear/0006-linkedlist.h-added.patch.conditional diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index 28140780dd11..67646a8d10ce 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -1,20 +1,32 @@ ---- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 -+++ b/svr-main.c 2019-06-18 20:58:34.023322679 +0530 -@@ -30,19 +30,27 @@ +--- a/svr-main.c 2019-07-11 10:17:33.624000000 +0530 ++++ b/svr-main.c 2019-07-12 18:28:22.417651251 +0530 +@@ -30,19 +30,39 @@ #include "runopts.h" #include "dbrandom.h" #include "crypto_desc.h" +#include +#include "libdropbear.h" ++#include "linkedlist.h" static size_t listensockets(int *sock, size_t sockcount, int *maxfd); static void sigchld_handler(int dummy); static void sigsegv_handler(int); static void sigintterm_handler(int fish); ++void init_dropbear(int argc, char ** argv); ++void free_child_info(); ++ ++struct list_head child_connections_info; ++ ++struct active_childs{ ++ struct child_info info; ++ struct list_head child_list; ++}; + -+static int pluginActivated; ++static int pluginActivated = 0; +static pthread_t threadID; -+void init_dropbear(int argc, char ** argv); ++int served_clients = 0; ++int server_active = 0; ++int child_info_available = 0; + #ifdef INETD_MODE static void main_inetd(void); @@ -29,30 +41,39 @@ #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +83,55 @@ +@@ -75,6 +95,154 @@ return -1; } #endif +#endif ++ +void init_dropbear(int argc, char ** argv) +{ -+ _dropbear_exit = svr_dropbear_exit; -+ _dropbear_log = svr_dropbear_log; -+ -+ disallow_core(); -+ -+ /* get commandline options */ -+ svr_getopts(argc, argv); -+ /* Note: commonsetup() must happen before we daemon()ise. Otherwise ++ server_active = 1; ++ _dropbear_exit = svr_dropbear_exit; ++ _dropbear_log = svr_dropbear_log; ++ disallow_core(); ++ /* get commandline options */ ++ svr_getopts(argc, argv); ++ /* Note: commonsetup() must happen before we daemon()ise. Otherwise + daemon() will chdir("/"), and we won't be able to find local-dir + hostkeys. */ -+ commonsetup(); ++ commonsetup(); ++ INIT_LIST_HEAD(&child_connections_info); ++ child_info_available = 1; +} + -+void activate_dropbear(int argc, char ** argv) ++void activate_dropbear(char* host_opt, char* port_opt, char* port_num) +{ + int status; -+ int i; ++ int argc=4; ++ char *name = "file name"; ++ char **argv; ++ argv = (char **)malloc(sizeof(char *)*4); ++ argv[0]= name; ++ argv[1]=host_opt; ++ argv[2]=port_opt; ++ argv[3]=port_num; + + if(pluginActivated == 1) + { @@ -63,29 +84,120 @@ + init_dropbear(argc, argv); + status = pthread_create(&threadID,NULL,main_noinetd,NULL); + if(status != 0) -+ { -+ printf("Error in creating thread\n"); -+ return; -+ } -+ printf("Plugin Activated \n"); -+ pluginActivated =1; ++ { ++ printf("Error in creating thread\n"); ++ return; ++ } ++ printf("Plugin Activated \n"); ++ pluginActivated =1; +} + +void deactivate_dropbear() +{ + if(pluginActivated == 1) -+ { -+ exitflag =1; -+ pthread_join(threadID, 0); -+ pluginActivated = 0; -+ } -+ printf("Plugin DeActivated \n"); ++ { ++ server_active = 0; ++ pthread_join(threadID, 0); ++ pluginActivated = 0; ++ } ++ printf("Plugin DeActivated \n"); + return; +} ++ ++/*Return the number of clients currently connected*/ ++ ++int get_active_sessions_count(){ ++ int count=0; ++ if(child_info_available){ ++ struct active_childs *child; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list,&child_connections_info){ ++ child = list_entry(ptr_list,struct active_childs,child_list); ++ if(child){ ++ count++; ++ } ++ } ++ } ++ return count; ++} ++ ++/*To get the list of connections that are currently serving*/ ++void get_active_sessions_info(struct child_info* connected_childs,int connections_count){ ++ if(child_info_available){ ++ int count = 0; ++ struct active_childs *child; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list,&child_connections_info){ ++ child = list_entry(ptr_list, struct active_childs, child_list ); ++ if(child && (count < connections_count)){ ++ connected_childs[count].pid=child->info.pid; ++ strcpy(connected_childs[count].ipaddress,child->info.ipaddress); ++ strcpy(connected_childs[count].timestamp,child->info.timestamp); ++ count++; ++ } ++ else{ ++ break; ++ } ++ } ++ } ++} ++ ++/* To terminate the server connection to client with the pid */ ++int close_client_session(int client_pid){ ++ int pid_existing=0; ++ struct active_childs *child; ++ struct list_head *ptr_list; ++ if(child_info_available){ ++ list_for_each(ptr_list,&child_connections_info){ ++ child = list_entry(ptr_list,struct active_childs,child_list); ++ if(child && (child->info.pid == client_pid)){ ++ pid_existing=1; ++ break; ++ } ++ } ++ if(pid_existing){ ++ if(kill(client_pid,SIGTERM)== -1){ ++ return errno; ++ } ++ else{ ++ return 0; ++ } ++ } ++ else{ ++ return -1; ++ } ++ } ++ else{ ++ return -1; ++ } ++} ++ ++/* total number of connections are srved till now*/ ++int get_total_sessions_served(){ ++ return served_clients; ++} ++ ++void free_child_info(){ ++ if(child_info_available){ ++ struct active_childs *child; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list, &child_connections_info){ ++ child = list_entry(ptr_list,struct active_childs, child_list); ++ if (child){ ++ kill(child->info.pid,SIGTERM); ++ } ++ else{ ++ break; ++ } ++ } ++ } ++ ++} ++ #ifdef INETD_MODE static void main_inetd() { -@@ -104,7 +161,7 @@ +@@ -104,25 +272,23 @@ #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -94,20 +206,28 @@ fd_set fds; unsigned int i, j; int val; -@@ -118,11 +175,7 @@ + int maxsock = -1; + int listensocks[MAX_LISTEN_ADDR]; + size_t listensockcount = 0; +- FILE *pidfile = NULL; ++ //FILE *pidfile = NULL; + + int childpipes[MAX_UNAUTH_CLIENTS]; + char * preauth_addrs[MAX_UNAUTH_CLIENTS]; int childsock; int childpipe[2]; -- ++ struct timeval timeout; + - /* Note: commonsetup() must happen before we daemon()ise. Otherwise - daemon() will chdir("/"), and we won't be able to find local-dir - hostkeys. */ - commonsetup(); -+ struct timeval timeout; ++ INIT_LIST_HEAD(&child_connections_info); /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +194,7 @@ +@@ -141,6 +307,7 @@ FD_SET(listensocks[i], &fds); } @@ -115,55 +235,76 @@ /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -153,7 +207,7 @@ - dropbear_exit("Failed to daemonize: %s", strerror(errno)); +@@ -154,6 +321,7 @@ } } -- + +#endif /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -168,6 +222,8 @@ +@@ -161,13 +329,17 @@ + dropbear_log(LOG_INFO, "Not backgrounding"); + } + ++#if 0 + /* create a PID file so that we can be killed easily */ + pidfile = fopen(svr_opts.pidfile, "w"); + if (pidfile) { + fprintf(pidfile, "%d\n", getpid()); fclose(pidfile); } ++#endif + timeout.tv_sec = 5; + timeout.tv_usec = 0; /* incoming connection select loop */ for(;;) { -@@ -186,11 +242,18 @@ +@@ -186,11 +358,18 @@ } } - val = select(maxsock+1, &fds, NULL, NULL, NULL); + val = select(maxsock+1, &fds, NULL, NULL, &timeout); - if (exitflag) { - unlink(svr_opts.pidfile); +- if (exitflag) { +- unlink(svr_opts.pidfile); - dropbear_exit("Terminated by signal"); ++ if (!server_active) { ++ //unlink(svr_opts.pidfile); + //dropbear_exit("Terminated by signal"); + /* make sure we close sockets */ + FD_ZERO(&fds); -+ for (i = 0; i < listensockcount; i++) { -+ m_close(listensocks[i]); -+ } -+ ++ for (i = 0; i < listensockcount; i++) { ++ m_close(listensocks[i]); ++ } ++ free_child_info(); + break; } if (val == 0) { -@@ -281,6 +344,8 @@ +@@ -281,6 +460,19 @@ if (fork_ret > 0) { /* parent */ -+ //getaddrstring(&remoteaddr, NULL, &remote_port, 0); -+ //printf("\nChild forked. Childpipe:%d conn_idx:%ld remotehost:%s remoteport:%s childPID:%d \n",childpipe[0],conn_idx,remote_host,remote_port,fork_ret); ++ /* taking the pids and respective IP address and timestamp to structure list*/ ++ time_t now; ++ time(&now); ++ struct active_childs *child=NULL; ++ served_clients++; ++ child = (struct active_childs *)malloc(sizeof(struct active_childs)); ++ if(!child){ ++ perror("malloc"); ++ } ++ child->info.pid = fork_ret; ++ strcpy(child->info.ipaddress, remote_host); ++ strcpy(child->info.timestamp,ctime(&now)); ++ list_add_tail(&(child->child_list),&child_connections_info); childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +393,7 @@ +@@ -328,6 +520,7 @@ } /* for(;;) loop */ /* don't reach here */ @@ -171,11 +312,25 @@ } #endif /* NON_INETD_MODE */ -@@ -358,7 +424,6 @@ +@@ -338,7 +531,20 @@ - /* catch ctrl-c or sigterm */ - static void sigintterm_handler(int UNUSED(unused)) { -- - exitflag = 1; - } + const int saved_errno = errno; + +- while(waitpid(-1, NULL, WNOHANG) > 0) {} ++ int pid; ++ /* disconnected ports are removing from structure List */ ++ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { ++ struct active_childs *child; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list, &child_connections_info){ ++ child = list_entry(ptr_list,struct active_childs, child_list); ++ if (child && child->info.pid == pid){ ++ list_del(ptr_list); ++ free(child); ++ break; ++ } ++ } ++ } + sa_chld.sa_handler = sigchld_handler; + sa_chld.sa_flags = SA_NOCLDSTOP; diff --git a/package/dropbear/0004-libdropbear.h-added.patch.conditional b/package/dropbear/0004-libdropbear.h-added.patch.conditional index e34a245057fa..c4361f43a5d0 100644 --- a/package/dropbear/0004-libdropbear.h-added.patch.conditional +++ b/package/dropbear/0004-libdropbear.h-added.patch.conditional @@ -1,6 +1,6 @@ ---- a/libdropbear.h 1970-01-01 05:30:00.000000000 +0530 -+++ b/libdropbear.h 2019-06-06 18:14:09.217381680 +0530 -@@ -0,0 +1,16 @@ +--- a/libdropbear.h 2019-07-11 11:45:13.848000000 +0530 ++++ b/libdropbear.h 2019-07-12 17:36:05.210348598 +0530 +@@ -0,0 +1,28 @@ +#ifndef __LIBDROPBEAR_H +#define __LIBDROPBEAR_H + @@ -8,9 +8,21 @@ +extern "C" { +#endif + ++#define IPADDRESSLENGTH 16 ++#define TIMESTAMPLENGTH 26 + -+void activate_dropbear(int argc, char ** argv); ++struct child_info{ ++ int pid; ++ char ipaddress[IPADDRESSLENGTH]; //Client IPv4 address ++ char timestamp[TIMESTAMPLENGTH]; //timestamp of the received client ++}; ++ ++void activate_dropbear(char* , char* , char*); +void deactivate_dropbear(); ++int get_active_sessions_count(); ++void get_active_sessions_info(struct child_info*, int); ++int close_client_session(int); ++int get_total_sessions_served(); + +#ifdef __cplusplus +} diff --git a/package/dropbear/0006-linkedlist.h-added.patch.conditional b/package/dropbear/0006-linkedlist.h-added.patch.conditional new file mode 100644 index 000000000000..1d41e34fc5da --- /dev/null +++ b/package/dropbear/0006-linkedlist.h-added.patch.conditional @@ -0,0 +1,171 @@ +--- a/linkedlist.h 2019-07-11 14:07:04.040000000 +0530 ++++ b/linkedlist.h 2019-07-12 17:13:25.350676534 +0530 +@@ -0,0 +1,168 @@ ++/** ++ * info: linkedlist.h file is derived from the ++ * linux-headers-4.15.0-29-generic/include/linux/list.h ++ * ++ * ++ */ ++ ++#ifndef _LINKED_LIST_H ++#define _LINKED_LIST_H ++#include ++ ++/** ++ * Get offset of a member ++ */ ++#define offsetoff(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) ++ ++/** ++ * Casts a member of a structure out to the containing structure ++ * @param ptr the pointer to the member. ++ * @param type the type of the container struct this is embedded in. ++ * @param member the name of the member within the struct. ++ * ++ */ ++#define container_of(ptr,type,member) ({ \ ++ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetof(type,member) );}) ++/* ++ * These are non-NULL pointers that will result in page faults ++ * under normal circumstances, used to verify that nobody uses ++ * non-initialized list entries. ++ */ ++#define LIST_POISON1 ((void *) 0x00100100) ++#define LIST_POISON2 ((void *) 0x00200200) ++ ++ ++#define WRITE_ONCE(ptr,value) (ptr=value) ++ ++typedef _Bool bool; ++ ++enum { ++ false = 0, ++ true = 1 ++}; ++ ++ ++struct list_head { ++ struct list_head *next, *prev; ++}; ++ ++/* ++ * Simple doubly linked list implementation. ++ * ++ * Some of the internal functions ("__xxx") are useful when ++ * manipulating whole lists rather than single entries, as ++ * sometimes we already know the next/prev entries and we can ++ * generate better code by using them directly rather than ++ * using the generic single-entry routines. ++ */ ++ ++static inline void INIT_LIST_HEAD(struct list_head *list) ++{ ++ WRITE_ONCE(list->next, list); ++ list->prev = list; ++} ++ ++#ifdef CONFIG_DEBUG_LIST ++extern bool __list_add_valid(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next); ++extern bool __list_del_entry_valid(struct list_head *entry); ++#else ++static inline bool __list_add_valid(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next) ++{ ++ return true; ++} ++static inline bool __list_del_entry_valid(struct list_head *entry) ++{ ++ return true; ++} ++#endif ++ ++/* ++ * Insert a new entry between two known consecutive entries. ++ * ++ * This is only for internal list manipulation where we know ++ * the prev/next entries already! ++ */ ++static inline void __list_add(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next) ++{ ++ if (!__list_add_valid(new, prev, next)) ++ return; ++ ++ next->prev = new; ++ new->next = next; ++ new->prev = prev; ++ WRITE_ONCE(prev->next, new); ++} ++ ++ ++/** ++ * list_add_tail - add a new entry ++ * @new: new entry to be added ++ * @head: list head to add it before ++ * ++ * Insert a new entry before the specified head. ++ * This is useful for implementing queues. ++ */ ++static inline void list_add_tail(struct list_head *new, struct list_head *head) ++{ ++ __list_add(new, head->prev, head); ++} ++ ++/* ++ * Delete a list entry by making the prev/next entries ++ * point to each other. ++ * ++ * This is only for internal list manipulation where we know ++ * the prev/next entries already! ++ */ ++static inline void __list_del(struct list_head * prev, struct list_head * next) ++{ ++ next->prev = prev; ++ WRITE_ONCE(prev->next, next); ++} ++ ++/** ++ * list_del - deletes entry from list. ++ * @entry: the element to delete from the list. ++ * Note: list_empty() on entry does not return true after this, the entry is ++ * in an undefined state. ++ */ ++static inline void __list_del_entry(struct list_head *entry) ++{ ++ if (!__list_del_entry_valid(entry)) ++ return; ++ ++ __list_del(entry->prev, entry->next); ++} ++ ++static inline void list_del(struct list_head *entry) ++{ ++ __list_del_entry(entry); ++ entry->next = LIST_POISON1; ++ entry->prev = LIST_POISON2; ++} ++ ++/** ++ * list_entry - get the struct for this entry ++ * @ptr: the &struct list_head pointer. ++ * @type: the type of the struct this is embedded in. ++ * @member: the name of the list_head within the struct. ++ */ ++#define list_entry(ptr, type, member) \ ++ container_of(ptr, type, member) ++ ++/** ++ * list_for_each - iterate over a list ++ * @pos: the &struct list_head to use as a loop cursor. ++ * @head: the head for your list. ++ */ ++#define list_for_each(pos, head) \ ++ for (pos = (head)->next; pos != (head); pos = pos->next) ++ ++#endif From dc1264fc901dabca8889369e2ad632340a3891bd Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Wed, 24 Jul 2019 20:37:37 +0530 Subject: [PATCH 04/18] [DropbearServerPlugin] Fixes to the session management implementation of Dropbear plugin --- .../0002-svr-main.c-changes.patch.conditional | 147 ++++++++++-------- ...0004-libdropbear.h-added.patch.conditional | 4 +- .../0006-linkedlist.h-added.patch.conditional | 18 +-- .../wpeframework-plugins.mk | 4 +- package/wpe/wpeframework/wpeframework.mk | 4 +- 5 files changed, 93 insertions(+), 84 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index 67646a8d10ce..d998e4d162ca 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -1,5 +1,5 @@ --- a/svr-main.c 2019-07-11 10:17:33.624000000 +0530 -+++ b/svr-main.c 2019-07-12 18:28:22.417651251 +0530 ++++ b/svr-main.c 2019-07-17 10:15:46.069206179 +0530 @@ -30,19 +30,39 @@ #include "runopts.h" #include "dbrandom.h" @@ -13,20 +13,20 @@ static void sigsegv_handler(int); static void sigintterm_handler(int fish); +void init_dropbear(int argc, char ** argv); -+void free_child_info(); ++void free_client_info(); + -+struct list_head child_connections_info; ++struct list_head client_connections_info; + -+struct active_childs{ -+ struct child_info info; -+ struct list_head child_list; ++struct active_clients{ ++ struct client_info info; ++ struct list_head client_list; +}; + +static int pluginActivated = 0; +static pthread_t threadID; +int served_clients = 0; +int server_active = 0; -+int child_info_available = 0; ++int client_info_available = 0; + #ifdef INETD_MODE static void main_inetd(void); @@ -41,7 +41,7 @@ #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +95,154 @@ +@@ -75,6 +95,159 @@ return -1; } #endif @@ -59,21 +59,21 @@ + daemon() will chdir("/"), and we won't be able to find local-dir + hostkeys. */ + commonsetup(); -+ INIT_LIST_HEAD(&child_connections_info); -+ child_info_available = 1; ++ INIT_LIST_HEAD(&client_connections_info); ++ client_info_available = 1; +} + +void activate_dropbear(char* host_opt, char* port_opt, char* port_num) +{ + int status; -+ int argc=4; ++ int argc = 4; + char *name = "file name"; + char **argv; -+ argv = (char **)malloc(sizeof(char *)*4); -+ argv[0]= name; -+ argv[1]=host_opt; -+ argv[2]=port_opt; -+ argv[3]=port_num; ++ argv = (char **)malloc(sizeof(char *)*argc); ++ argv[0] = name; ++ argv[1] = host_opt; ++ argv[2] = port_opt; ++ argv[3] = port_num; + + if(pluginActivated == 1) + { @@ -88,6 +88,7 @@ + printf("Error in creating thread\n"); + return; + } ++ free(argv); + printf("Plugin Activated \n"); + pluginActivated =1; +} @@ -100,6 +101,8 @@ + pthread_join(threadID, 0); + pluginActivated = 0; + } ++ client_info_available = 0; ++ served_clients =0; + printf("Plugin DeActivated \n"); + return; +} @@ -108,12 +111,12 @@ + +int get_active_sessions_count(){ + int count=0; -+ if(child_info_available){ -+ struct active_childs *child; ++ if(client_info_available){ ++ struct active_clients *client; + struct list_head *ptr_list; -+ list_for_each(ptr_list,&child_connections_info){ -+ child = list_entry(ptr_list,struct active_childs,child_list); -+ if(child){ ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients,client_list); ++ if(client){ + count++; + } + } @@ -122,17 +125,17 @@ +} + +/*To get the list of connections that are currently serving*/ -+void get_active_sessions_info(struct child_info* connected_childs,int connections_count){ -+ if(child_info_available){ ++void get_active_sessions_info(struct client_info* connected_clients,int connections_count){ ++ if(client_info_available){ + int count = 0; -+ struct active_childs *child; ++ struct active_clients *client; + struct list_head *ptr_list; -+ list_for_each(ptr_list,&child_connections_info){ -+ child = list_entry(ptr_list, struct active_childs, child_list ); -+ if(child && (count < connections_count)){ -+ connected_childs[count].pid=child->info.pid; -+ strcpy(connected_childs[count].ipaddress,child->info.ipaddress); -+ strcpy(connected_childs[count].timestamp,child->info.timestamp); ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list, struct active_clients, client_list ); ++ if(client && (count < connections_count)){ ++ connected_clients[count].pid=client->info.pid; ++ strcpy(connected_clients[count].ipaddress,client->info.ipaddress); ++ strcpy(connected_clients[count].timestamp,client->info.timestamp); + count++; + } + else{ @@ -145,12 +148,12 @@ +/* To terminate the server connection to client with the pid */ +int close_client_session(int client_pid){ + int pid_existing=0; -+ struct active_childs *child; ++ struct active_clients *client; + struct list_head *ptr_list; -+ if(child_info_available){ -+ list_for_each(ptr_list,&child_connections_info){ -+ child = list_entry(ptr_list,struct active_childs,child_list); -+ if(child && (child->info.pid == client_pid)){ ++ if(client_info_available){ ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients,client_list); ++ if(client && (client->info.pid == client_pid)){ + pid_existing=1; + break; + } @@ -177,14 +180,16 @@ + return served_clients; +} + -+void free_child_info(){ -+ if(child_info_available){ -+ struct active_childs *child; ++void free_client_info(){ ++ if(client_info_available){ ++ struct active_clients *client; + struct list_head *ptr_list; -+ list_for_each(ptr_list, &child_connections_info){ -+ child = list_entry(ptr_list,struct active_childs, child_list); -+ if (child){ -+ kill(child->info.pid,SIGTERM); ++ list_for_each(ptr_list, &client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients, client_list); ++ if (client){ ++ if(close_client_session(client->info.pid) != 0 ){ ++ printf("unable to kill the process : %d\n",client->info.pid); ++ } + } + else{ + break; @@ -197,7 +202,7 @@ #ifdef INETD_MODE static void main_inetd() { -@@ -104,25 +272,23 @@ +@@ -104,25 +277,21 @@ #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -217,17 +222,16 @@ int childsock; int childpipe[2]; -+ struct timeval timeout; - +- - /* Note: commonsetup() must happen before we daemon()ise. Otherwise - daemon() will chdir("/"), and we won't be able to find local-dir - hostkeys. */ - commonsetup(); -+ INIT_LIST_HEAD(&child_connections_info); ++ struct timeval timeout; /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +307,7 @@ +@@ -141,6 +310,7 @@ FD_SET(listensocks[i], &fds); } @@ -235,7 +239,7 @@ /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -154,6 +321,7 @@ +@@ -154,6 +324,7 @@ } } @@ -243,7 +247,7 @@ /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +329,17 @@ +@@ -161,13 +332,17 @@ dropbear_log(LOG_INFO, "Not backgrounding"); } @@ -261,7 +265,7 @@ /* incoming connection select loop */ for(;;) { -@@ -186,11 +358,18 @@ +@@ -186,11 +361,18 @@ } } @@ -279,32 +283,32 @@ + for (i = 0; i < listensockcount; i++) { + m_close(listensocks[i]); + } -+ free_child_info(); ++ free_client_info(); + break; } if (val == 0) { -@@ -281,6 +460,19 @@ +@@ -281,6 +463,19 @@ if (fork_ret > 0) { /* parent */ + /* taking the pids and respective IP address and timestamp to structure list*/ + time_t now; + time(&now); -+ struct active_childs *child=NULL; ++ struct active_clients *client; + served_clients++; -+ child = (struct active_childs *)malloc(sizeof(struct active_childs)); -+ if(!child){ -+ perror("malloc"); ++ client = (struct active_clients *)malloc(sizeof(struct active_clients)); ++ if(!client){ ++ printf("unable to create a memory for active clients structure\n "); + } -+ child->info.pid = fork_ret; -+ strcpy(child->info.ipaddress, remote_host); -+ strcpy(child->info.timestamp,ctime(&now)); -+ list_add_tail(&(child->child_list),&child_connections_info); ++ client->info.pid = fork_ret; ++ strcpy(client->info.ipaddress, remote_host); ++ strcpy(client->info.timestamp,ctime(&now)); ++ list_add_tail(&(client->client_list),&client_connections_info); childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +520,7 @@ +@@ -328,6 +523,7 @@ } /* for(;;) loop */ /* don't reach here */ @@ -312,7 +316,7 @@ } #endif /* NON_INETD_MODE */ -@@ -338,7 +531,20 @@ +@@ -338,10 +534,24 @@ const int saved_errno = errno; @@ -320,17 +324,22 @@ + int pid; + /* disconnected ports are removing from structure List */ + while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { -+ struct active_childs *child; ++ struct active_clients *client; + struct list_head *ptr_list; -+ list_for_each(ptr_list, &child_connections_info){ -+ child = list_entry(ptr_list,struct active_childs, child_list); -+ if (child && child->info.pid == pid){ ++ ++ list_for_each(ptr_list, &client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients, client_list); ++ if (client && client->info.pid == pid){ + list_del(ptr_list); -+ free(child); ++ free(client); + break; + } -+ } ++ } + } sa_chld.sa_handler = sigchld_handler; - sa_chld.sa_flags = SA_NOCLDSTOP; +- sa_chld.sa_flags = SA_NOCLDSTOP; ++ sa_chld.sa_flags = SA_NOCLDSTOP | SA_RESTART ; + sigemptyset(&sa_chld.sa_mask); + if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { + dropbear_exit("signal() error"); diff --git a/package/dropbear/0004-libdropbear.h-added.patch.conditional b/package/dropbear/0004-libdropbear.h-added.patch.conditional index c4361f43a5d0..257a03615c24 100644 --- a/package/dropbear/0004-libdropbear.h-added.patch.conditional +++ b/package/dropbear/0004-libdropbear.h-added.patch.conditional @@ -11,7 +11,7 @@ +#define IPADDRESSLENGTH 16 +#define TIMESTAMPLENGTH 26 + -+struct child_info{ ++struct client_info{ + int pid; + char ipaddress[IPADDRESSLENGTH]; //Client IPv4 address + char timestamp[TIMESTAMPLENGTH]; //timestamp of the received client @@ -20,7 +20,7 @@ +void activate_dropbear(char* , char* , char*); +void deactivate_dropbear(); +int get_active_sessions_count(); -+void get_active_sessions_info(struct child_info*, int); ++void get_active_sessions_info(struct client_info*, int); +int close_client_session(int); +int get_total_sessions_served(); + diff --git a/package/dropbear/0006-linkedlist.h-added.patch.conditional b/package/dropbear/0006-linkedlist.h-added.patch.conditional index 1d41e34fc5da..9a88e99394fe 100644 --- a/package/dropbear/0006-linkedlist.h-added.patch.conditional +++ b/package/dropbear/0006-linkedlist.h-added.patch.conditional @@ -1,10 +1,10 @@ --- a/linkedlist.h 2019-07-11 14:07:04.040000000 +0530 -+++ b/linkedlist.h 2019-07-12 17:13:25.350676534 +0530 -@@ -0,0 +1,168 @@ ++++ b/linkedlist.h 2019-07-17 11:49:34.416678720 +0530 +@@ -0,0 +1,166 @@ +/** + * info: linkedlist.h file is derived from the -+ * linux-headers-4.15.0-29-generic/include/linux/list.h -+ * ++ * linux-5.2.1/include/linux/list.h ++ * https://www.kernel.org + * + */ + @@ -24,9 +24,9 @@ + * @param member the name of the member within the struct. + * + */ -+#define container_of(ptr,type,member) ({ \ -+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -+ (type *)( (char *)__mptr - offsetof(type,member) );}) ++#define container_of(ptr,type,member) ({ \ ++ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetoff(type,member) );}) +/* + * These are non-NULL pointers that will result in page faults + * under normal circumstances, used to verify that nobody uses @@ -161,8 +161,8 @@ + container_of(ptr, type, member) + +/** -+ * list_for_each - iterate over a list -+ * @pos: the &struct list_head to use as a loop cursor. ++ * list_for_each - iterate over a list ++ * @pos: the &struct list_head to use as a loop cursor. + * @head: the head for your list. + */ +#define list_for_each(pos, head) \ diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 3f3cc54c4a76..ff4db93bdd31 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,8 +4,8 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = d5787cae9fd5d85ff4cf1ba22e08435022220c0e -WPEFRAMEWORK_PLUGINS_SITE = $(call github,WebPlatformForEmbedded,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) +WPEFRAMEWORK_PLUGINS_VERSION = 4cf855084ce50918fd347eee0dceb7cf2f32f2e0 +WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng diff --git a/package/wpe/wpeframework/wpeframework.mk b/package/wpe/wpeframework/wpeframework.mk index 69b9f5f07818..dee45c45ed33 100644 --- a/package/wpe/wpeframework/wpeframework.mk +++ b/package/wpe/wpeframework/wpeframework.mk @@ -4,8 +4,8 @@ # ################################################################################ -WPEFRAMEWORK_VERSION = aa452ab1673e86b206f6737ec77d48ce8066437d -WPEFRAMEWORK_SITE = $(call github,WebPlatformForEmbedded,WPEFramework,$(WPEFRAMEWORK_VERSION)) +WPEFRAMEWORK_VERSION = fbc184eae6a909921e259d093fbd034d2f625596 +WPEFRAMEWORK_SITE = $(call github,s-rapolu,WPEFramework,$(WPEFRAMEWORK_VERSION)) WPEFRAMEWORK_INSTALL_STAGING = YES WPEFRAMEWORK_DEPENDENCIES = zlib $(call qstrip,$(BR2_PACKAGE_SDK_INSTALL)) From cfa99121dc27563f55122ae12ffb442c68bba9b1 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Thu, 25 Jul 2019 22:41:14 +0530 Subject: [PATCH 05/18] [DropbearServerPlugin] Fixes to RPC implementation of Dropbear plugin --- .../0002-svr-main.c-changes.patch.conditional | 1 - .../0006-linkedlist.h-added.patch.conditional | 3 ++- package/dropbear/Config.in | 2 ++ package/dropbear/dropbear.mk | 11 ++++++----- .../wpe/wpeframework-plugins/wpeframework-plugins.mk | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index d998e4d162ca..520399ba230d 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -80,7 +80,6 @@ + printf("Plugin already Activated \n"); + return; + } -+ + init_dropbear(argc, argv); + status = pthread_create(&threadID,NULL,main_noinetd,NULL); + if(status != 0) diff --git a/package/dropbear/0006-linkedlist.h-added.patch.conditional b/package/dropbear/0006-linkedlist.h-added.patch.conditional index 9a88e99394fe..598bc8b0ee22 100644 --- a/package/dropbear/0006-linkedlist.h-added.patch.conditional +++ b/package/dropbear/0006-linkedlist.h-added.patch.conditional @@ -1,6 +1,6 @@ --- a/linkedlist.h 2019-07-11 14:07:04.040000000 +0530 +++ b/linkedlist.h 2019-07-17 11:49:34.416678720 +0530 -@@ -0,0 +1,166 @@ +@@ -0,0 +1,169 @@ +/** + * info: linkedlist.h file is derived from the + * linux-5.2.1/include/linux/list.h @@ -169,3 +169,4 @@ + for (pos = (head)->next; pos != (head); pos = pos->next) + +#endif ++ diff --git a/package/dropbear/Config.in b/package/dropbear/Config.in index caeac2684801..2692cf94046e 100644 --- a/package/dropbear/Config.in +++ b/package/dropbear/Config.in @@ -27,11 +27,13 @@ choice config BR2_PACKAGE_DROPBEAR_PROGRAM bool "executable" + default n help Create Dropbear standalone program. config BR2_PACKAGE_DROPBEAR_LIB bool "library" + default y help Create Dropbear library. diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index b7346182381b..1f2cd166e67d 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -105,16 +105,17 @@ DROPBEAR_CONF_OPTS += --disable-lastlog endif define DROPBEAR_INSTALL_TARGET_CMDS -ifeq ($(BR2_PACKAGE_DROPBEAR_PROGRAM),y) +ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) + ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear + $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include + $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc +else #case for BR2_PACKAGE_DROPBEAR_PROGRAM $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear for f in $(DROPBEAR_TARGET_BINS); do \ ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \ done ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear -else #case for BR2_PACKAGE_DROPBEAR_LIB - $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib - $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include - $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc endif endef diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index ff4db93bdd31..baff2ac9e715 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 4cf855084ce50918fd347eee0dceb7cf2f32f2e0 +WPEFRAMEWORK_PLUGINS_VERSION = 03fc663dff3dcfc377cc4cec2bea1154ba4dce5a WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng From 615268007f54beb05db00f1ff287f87a1f40de99 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Thu, 25 Jul 2019 22:48:01 +0530 Subject: [PATCH 06/18] [DropbearServerPlugin] Fix for dropbear configuration issue --- package/dropbear/dropbear.mk | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index 1f2cd166e67d..07f6894c1628 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -104,19 +104,21 @@ ifneq ($(BR2_PACKAGE_DROPBEAR_LASTLOG),y) DROPBEAR_CONF_OPTS += --disable-lastlog endif -define DROPBEAR_INSTALL_TARGET_CMDS ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) +define DROPBEAR_INSTALL_TARGET_CMDS ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear - $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.so $(TARGET_DIR)/usr/lib $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc -else #case for BR2_PACKAGE_DROPBEAR_PROGRAM +endef +else +define DROPBEAR_INSTALL_TARGET_CMDS $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear for f in $(DROPBEAR_TARGET_BINS); do \ ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \ done ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear -endif endef +endif $(eval $(autotools-package)) From 2721a4dac70b065caa662d29f1c358a3d893fdef Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 26 Jul 2019 00:01:44 +0530 Subject: [PATCH 07/18] [DropbearServerPlugin] Fix for finding dropbear shared library at correct path --- package/wpe/wpeframework-plugins/wpeframework-plugins.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index baff2ac9e715..ffaf5bcd8862 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 03fc663dff3dcfc377cc4cec2bea1154ba4dce5a +WPEFRAMEWORK_PLUGINS_VERSION = 7651ef996a650964a7ef5f34c0079896142f79c8 WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng From 8eb3db7ea1960c3bf4d46663b4acbd9890b97c09 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 26 Jul 2019 23:07:11 +0530 Subject: [PATCH 08/18] [DropbearServerPlugin] Fix for closing client connections --- package/dropbear/0002-svr-main.c-changes.patch.conditional | 2 +- package/wpe/wpeframework-plugins/wpeframework-plugins.mk | 2 +- package/wpe/wpeframework/wpeframework.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index 520399ba230d..ad5fe7b21b36 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -158,7 +158,7 @@ + } + } + if(pid_existing){ -+ if(kill(client_pid,SIGTERM)== -1){ ++ if(kill(client_pid,SIGKILL)== -1){ + return errno; + } + else{ diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index ffaf5bcd8862..ff3791d932e8 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 7651ef996a650964a7ef5f34c0079896142f79c8 +WPEFRAMEWORK_PLUGINS_VERSION = 66543b5a3b8a9a6477e9eeff48b25d9034264413 WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng diff --git a/package/wpe/wpeframework/wpeframework.mk b/package/wpe/wpeframework/wpeframework.mk index dee45c45ed33..aa583953981e 100644 --- a/package/wpe/wpeframework/wpeframework.mk +++ b/package/wpe/wpeframework/wpeframework.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_VERSION = fbc184eae6a909921e259d093fbd034d2f625596 +WPEFRAMEWORK_VERSION = e8e37426627e751277d73e71c250fee87b6d4aea WPEFRAMEWORK_SITE = $(call github,s-rapolu,WPEFramework,$(WPEFRAMEWORK_VERSION)) WPEFRAMEWORK_INSTALL_STAGING = YES WPEFRAMEWORK_DEPENDENCIES = zlib $(call qstrip,$(BR2_PACKAGE_SDK_INSTALL)) From 5e91eb45ffa1139591de7800eed6ee21511e5249 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Tue, 27 Aug 2019 18:53:06 +0530 Subject: [PATCH 09/18] [SecureShellServerPlugin] Removed separate JSON RPC methods as per code review feedback --- package/dropbear/Config.in | 1 + package/dropbear/dropbear.mk | 2 +- package/wpe/wpeframework-plugins/Config.in | 6 +++--- .../wpe/wpeframework-plugins/wpeframework-plugins.mk | 11 +++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package/dropbear/Config.in b/package/dropbear/Config.in index 2692cf94046e..1d6cde18e87c 100644 --- a/package/dropbear/Config.in +++ b/package/dropbear/Config.in @@ -34,6 +34,7 @@ config BR2_PACKAGE_DROPBEAR_PROGRAM config BR2_PACKAGE_DROPBEAR_LIB bool "library" default y + select BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER help Create Dropbear library. diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index 07f6894c1628..8e000547ddc8 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -107,7 +107,7 @@ endif ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) define DROPBEAR_INSTALL_TARGET_CMDS ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear - $(INSTALL) -D $(@D)/libdropbear.so $(TARGET_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc endef diff --git a/package/wpe/wpeframework-plugins/Config.in b/package/wpe/wpeframework-plugins/Config.in index 3e353c971a72..47708d9e1e7e 100644 --- a/package/wpe/wpeframework-plugins/Config.in +++ b/package/wpe/wpeframework-plugins/Config.in @@ -485,12 +485,12 @@ config BR2_PACKAGE_WPEFRAMEWORK_SYSTEMCOMMANDS help SystemCommands Plugin -config BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER +config BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER select BR2_PACKAGE_WPEFRAMEWORK_PLUGINS select BR2_PACKAGE_DROPBEAR - bool "DropbearServer" + bool "SecureShellServer" help - DropbearServer Plugin + SecureShellServer Plugin menuconfig BR2_PACKAGE_WPEFRAMEWORK_SPARK bool "Spark" diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index ff3791d932e8..7ff395994b6e 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -68,10 +68,17 @@ ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_DICTIONARY),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_DICTIONARY=ON endif -ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER),y) -WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_DROPBEARSERVER=ON +ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER),y) +WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER=ON +ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) +WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER_IMPLEMENTATION=Dropbear +WPEFRAMEWORK_DEPENDENCIES += dropbear +else +$(error Missing a secureshellserver implemtation, please provide one or disable PLUGIN_SECURESHELLSERVER) +endif endif + ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_IOCONNECTOR=ON ifneq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR_PAIRING_PIN),) From 1c67d20e362639368117a26c58ce754097e062c4 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Tue, 3 Sep 2019 13:25:07 +0530 Subject: [PATCH 10/18] [SecureShellServerPlugin] Changes made to native dropbear implementation --- .../0002-svr-main.c-changes.patch.conditional | 94 ++++++++++++++----- ...0004-libdropbear.h-added.patch.conditional | 6 +- package/dropbear/Config.in | 3 - package/dropbear/dropbear.mk | 4 +- .../wpeframework-plugins.mk | 2 +- package/wpe/wpeframework/wpeframework.mk | 2 +- 6 files changed, 79 insertions(+), 32 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index ad5fe7b21b36..55c9894a6c24 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -1,6 +1,6 @@ ---- a/svr-main.c 2019-07-11 10:17:33.624000000 +0530 -+++ b/svr-main.c 2019-07-17 10:15:46.069206179 +0530 -@@ -30,19 +30,39 @@ +--- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 ++++ b/svr-main.c 2019-08-28 19:56:27.378453512 +0530 +@@ -30,19 +30,44 @@ #include "runopts.h" #include "dbrandom.h" #include "crypto_desc.h" @@ -14,6 +14,11 @@ static void sigintterm_handler(int fish); +void init_dropbear(int argc, char ** argv); +void free_client_info(); ++static int setargs(char *args, char **argv); ++char **parsedargs(char *args, int *argc); ++void freeparsedargs(char **argv); ++ ++ + +struct list_head client_connections_info; + @@ -41,7 +46,7 @@ #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +95,159 @@ +@@ -75,6 +100,202 @@ return -1; } #endif @@ -62,18 +67,61 @@ + INIT_LIST_HEAD(&client_connections_info); + client_info_available = 1; +} ++ ++ ++static int setargs(char *args, char **argv) ++{ ++ int count = 0; ++ while (isspace(*args)) ++args; ++ while (*args) { ++ if (argv) argv[count] = args; ++ while (*args && !isspace(*args)) ++args; ++ if (argv && *args) *args++ = '\0'; ++ while (isspace(*args)) ++args; ++ count++; ++ } ++ return count; ++} + -+void activate_dropbear(char* host_opt, char* port_opt, char* port_num) ++char **parsedargs(char *args, int *argc) +{ -+ int status; -+ int argc = 4; -+ char *name = "file name"; ++ char **argv = NULL; ++ int argn = 0; ++ ++ if (args && *args ++ && (args = strdup(args)) ++ && (argn = setargs(args,NULL)) ++ && (argv = malloc((argn+1) * sizeof(char *)))) { ++ *argv++ = args; ++ argn = setargs(args,argv); ++ } ++ ++ if (args && !argv) free(args); ++ *argc = argn; ++ return argv; ++} ++ ++void freeparsedargs(char **argv) ++{ ++ if (argv) { ++ free(argv[-1]); ++ free(argv-1); ++ } ++} ++ ++ ++void activate_dropbear(char* string) ++{ ++ ++ int status; ++ int argc; + char **argv; -+ argv = (char **)malloc(sizeof(char *)*argc); -+ argv[0] = name; -+ argv[1] = host_opt; -+ argv[2] = port_opt; -+ argv[3] = port_num; ++ int len = strlen("dropbear ")+strlen(string); ++ char *str=(char *)malloc(len*sizeof(char)); ++ str = strcat(str,"dropbear"); ++ str = strcat(str, string); ++ argv = parsedargs(str,&argc); ++ free(str); + + if(pluginActivated == 1) + { @@ -87,7 +135,7 @@ + printf("Error in creating thread\n"); + return; + } -+ free(argv); ++ freeparsedargs(argv); + printf("Plugin Activated \n"); + pluginActivated =1; +} @@ -158,7 +206,7 @@ + } + } + if(pid_existing){ -+ if(kill(client_pid,SIGKILL)== -1){ ++ if(kill(client_pid,SIGTERM)== -1){ + return errno; + } + else{ @@ -201,7 +249,7 @@ #ifdef INETD_MODE static void main_inetd() { -@@ -104,25 +277,21 @@ +@@ -104,25 +325,21 @@ #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -230,7 +278,7 @@ /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +310,7 @@ +@@ -141,6 +358,7 @@ FD_SET(listensocks[i], &fds); } @@ -238,7 +286,7 @@ /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -154,6 +324,7 @@ +@@ -154,6 +372,7 @@ } } @@ -246,7 +294,7 @@ /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +332,17 @@ +@@ -161,13 +380,17 @@ dropbear_log(LOG_INFO, "Not backgrounding"); } @@ -264,7 +312,7 @@ /* incoming connection select loop */ for(;;) { -@@ -186,11 +361,18 @@ +@@ -186,11 +409,18 @@ } } @@ -287,7 +335,7 @@ } if (val == 0) { -@@ -281,6 +463,19 @@ +@@ -281,6 +511,19 @@ if (fork_ret > 0) { /* parent */ @@ -307,7 +355,7 @@ childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +523,7 @@ +@@ -328,6 +571,7 @@ } /* for(;;) loop */ /* don't reach here */ @@ -315,7 +363,7 @@ } #endif /* NON_INETD_MODE */ -@@ -338,10 +534,24 @@ +@@ -338,10 +582,24 @@ const int saved_errno = errno; diff --git a/package/dropbear/0004-libdropbear.h-added.patch.conditional b/package/dropbear/0004-libdropbear.h-added.patch.conditional index 257a03615c24..88f9547c6598 100644 --- a/package/dropbear/0004-libdropbear.h-added.patch.conditional +++ b/package/dropbear/0004-libdropbear.h-added.patch.conditional @@ -1,5 +1,5 @@ ---- a/libdropbear.h 2019-07-11 11:45:13.848000000 +0530 -+++ b/libdropbear.h 2019-07-12 17:36:05.210348598 +0530 +--- a/libdropbear.h 2019-08-28 20:32:09.684490106 +0530 ++++ b/libdropbear.h 2019-08-28 20:30:35.571212068 +0530 @@ -0,0 +1,28 @@ +#ifndef __LIBDROPBEAR_H +#define __LIBDROPBEAR_H @@ -17,7 +17,7 @@ + char timestamp[TIMESTAMPLENGTH]; //timestamp of the received client +}; + -+void activate_dropbear(char* , char* , char*); ++void activate_dropbear(char*); +void deactivate_dropbear(); +int get_active_sessions_count(); +void get_active_sessions_info(struct client_info*, int); diff --git a/package/dropbear/Config.in b/package/dropbear/Config.in index 1d6cde18e87c..caeac2684801 100644 --- a/package/dropbear/Config.in +++ b/package/dropbear/Config.in @@ -27,14 +27,11 @@ choice config BR2_PACKAGE_DROPBEAR_PROGRAM bool "executable" - default n help Create Dropbear standalone program. config BR2_PACKAGE_DROPBEAR_LIB bool "library" - default y - select BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER help Create Dropbear library. diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index 8e000547ddc8..1f13ebe7dad2 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -111,7 +111,9 @@ define DROPBEAR_INSTALL_TARGET_CMDS $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc endef -else +endif + +ifeq ($(BR2_PACKAGE_DROPBEAR_PROGRAM),y) define DROPBEAR_INSTALL_TARGET_CMDS $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear for f in $(DROPBEAR_TARGET_BINS); do \ diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 7ff395994b6e..45fa1daa3558 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 66543b5a3b8a9a6477e9eeff48b25d9034264413 +WPEFRAMEWORK_PLUGINS_VERSION = 9c0817a036d2d6b59b0b202df5e2410ab6531d16 WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng diff --git a/package/wpe/wpeframework/wpeframework.mk b/package/wpe/wpeframework/wpeframework.mk index aa583953981e..953b8d2f1ca2 100644 --- a/package/wpe/wpeframework/wpeframework.mk +++ b/package/wpe/wpeframework/wpeframework.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_VERSION = e8e37426627e751277d73e71c250fee87b6d4aea +WPEFRAMEWORK_VERSION = 2c1a62d177473c67c1abbd41147a051edb436433 WPEFRAMEWORK_SITE = $(call github,s-rapolu,WPEFramework,$(WPEFRAMEWORK_VERSION)) WPEFRAMEWORK_INSTALL_STAGING = YES WPEFRAMEWORK_DEPENDENCIES = zlib $(call qstrip,$(BR2_PACKAGE_SDK_INSTALL)) From d15fa4ff39bb8fa7d57314c17a3f37a205317c38 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 6 Sep 2019 18:17:33 +0530 Subject: [PATCH 11/18] [SecureShellServerPlugin] fixed issues with native dropbear --- .../0002-svr-main.c-changes.patch.conditional | 38 +++++++++++-------- .../wpeframework-plugins.mk | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index 55c9894a6c24..acd965e695b4 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -1,5 +1,5 @@ --- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 -+++ b/svr-main.c 2019-08-28 19:56:27.378453512 +0530 ++++ b/svr-main.c 2019-09-06 17:56:36.129013600 +0530 @@ -30,19 +30,44 @@ #include "runopts.h" #include "dbrandom.h" @@ -46,7 +46,7 @@ #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +100,202 @@ +@@ -75,6 +100,208 @@ return -1; } #endif @@ -112,16 +112,22 @@ + +void activate_dropbear(char* string) +{ -+ + int status; + int argc; + char **argv; -+ int len = strlen("dropbear ")+strlen(string); -+ char *str=(char *)malloc(len*sizeof(char)); -+ str = strcat(str,"dropbear"); -+ str = strcat(str, string); ++ char str[100]; ++ ++ printf("recieved input=%s\n", string); ++ memset(str, '\0', sizeof(str)); ++ ++ strncpy(str, "dropbear ", strlen("dropbear ")); ++ strncpy(str+strlen("dropbear "), string, strlen(string)); ++ printf("str = %s\n", str); ++ + argv = parsedargs(str,&argc); -+ free(str); ++ printf("Argument count (argc) = %d\n",argc); ++ for (int i = 0; i < argc; i++) ++ printf("argv[%d] = %s\n", i, argv[i]); + + if(pluginActivated == 1) + { @@ -249,7 +255,7 @@ #ifdef INETD_MODE static void main_inetd() { -@@ -104,25 +325,21 @@ +@@ -104,25 +331,21 @@ #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -278,7 +284,7 @@ /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +358,7 @@ +@@ -141,6 +364,7 @@ FD_SET(listensocks[i], &fds); } @@ -286,7 +292,7 @@ /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -154,6 +372,7 @@ +@@ -154,6 +378,7 @@ } } @@ -294,7 +300,7 @@ /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +380,17 @@ +@@ -161,13 +386,17 @@ dropbear_log(LOG_INFO, "Not backgrounding"); } @@ -312,7 +318,7 @@ /* incoming connection select loop */ for(;;) { -@@ -186,11 +409,18 @@ +@@ -186,11 +415,18 @@ } } @@ -335,7 +341,7 @@ } if (val == 0) { -@@ -281,6 +511,19 @@ +@@ -281,6 +517,19 @@ if (fork_ret > 0) { /* parent */ @@ -355,7 +361,7 @@ childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +571,7 @@ +@@ -328,6 +577,7 @@ } /* for(;;) loop */ /* don't reach here */ @@ -363,7 +369,7 @@ } #endif /* NON_INETD_MODE */ -@@ -338,10 +582,24 @@ +@@ -338,10 +588,24 @@ const int saved_errno = errno; diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 45fa1daa3558..2c068006f480 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 9c0817a036d2d6b59b0b202df5e2410ab6531d16 +WPEFRAMEWORK_PLUGINS_VERSION = 5d0769cea06138762ac8ecc102b5b8e5c9b3a863 WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng From 33a89b07a2e1c59681864609c81f36baf5d1fe9c Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 6 Sep 2019 18:23:21 +0530 Subject: [PATCH 12/18] [SecureShellServerPlugin] enable SSH plugin through defaults --- configs/raspberrypi3_wpe_ml_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/raspberrypi3_wpe_ml_defconfig b/configs/raspberrypi3_wpe_ml_defconfig index 6332141970dc..1304573e1e69 100644 --- a/configs/raspberrypi3_wpe_ml_defconfig +++ b/configs/raspberrypi3_wpe_ml_defconfig @@ -66,7 +66,7 @@ BR2_PACKAGE_WPEFRAMEWORK=y BR2_PACKAGE_WPEFRAMEWORK_VIRTUALINPUT=y BR2_PACKAGE_WPEFRAMEWORK_PROVISIONPROXY=y BR2_PACKAGE_WPEFRAMEWORK_DHCPSERVER=y -BR2_PACKAGE_WPEFRAMEWORK_DROPBEARSERVER=y +BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER=y BR2_PACKAGE_WPEFRAMEWORK_LOCATIONSYNC=y BR2_PACKAGE_WPEFRAMEWORK_LOCATIONSYNC_URI="http://jsonip.metrological.com/?maf=true" BR2_PACKAGE_WPEFRAMEWORK_MONITOR=y From fd2444988f5bff4b296cee60fdcbfbc277349186 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Mon, 23 Sep 2019 20:54:44 +0530 Subject: [PATCH 13/18] [SecureShellServerPlugin] IClient interface implementation --- .../0002-svr-main.c-changes.patch.conditional | 22 ++++++++++--------- package/dropbear/dropbear.mk | 2 +- .../wpeframework-plugins.mk | 2 +- package/wpe/wpeframework/wpeframework.mk | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional index acd965e695b4..d82c9cfdb044 100644 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ b/package/dropbear/0002-svr-main.c-changes.patch.conditional @@ -1,5 +1,5 @@ --- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 -+++ b/svr-main.c 2019-09-06 17:56:36.129013600 +0530 ++++ b/svr-main.c 2019-09-23 20:43:58.462169941 +0530 @@ -30,19 +30,44 @@ #include "runopts.h" #include "dbrandom.h" @@ -46,7 +46,7 @@ #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +100,208 @@ +@@ -75,6 +100,209 @@ return -1; } #endif @@ -213,6 +213,7 @@ + } + if(pid_existing){ + if(kill(client_pid,SIGTERM)== -1){ ++ printf("Error during close session: %s\n", strerror(errno)); + return errno; + } + else{ @@ -255,7 +256,7 @@ #ifdef INETD_MODE static void main_inetd() { -@@ -104,25 +331,21 @@ +@@ -104,25 +332,21 @@ #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -284,7 +285,7 @@ /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +364,7 @@ +@@ -141,6 +365,7 @@ FD_SET(listensocks[i], &fds); } @@ -292,7 +293,7 @@ /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -154,6 +378,7 @@ +@@ -154,6 +379,7 @@ } } @@ -300,7 +301,7 @@ /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +386,17 @@ +@@ -161,13 +387,17 @@ dropbear_log(LOG_INFO, "Not backgrounding"); } @@ -318,7 +319,7 @@ /* incoming connection select loop */ for(;;) { -@@ -186,11 +415,18 @@ +@@ -186,11 +416,18 @@ } } @@ -341,7 +342,7 @@ } if (val == 0) { -@@ -281,6 +517,19 @@ +@@ -281,6 +518,20 @@ if (fork_ret > 0) { /* parent */ @@ -357,11 +358,12 @@ + client->info.pid = fork_ret; + strcpy(client->info.ipaddress, remote_host); + strcpy(client->info.timestamp,ctime(&now)); ++ client->info.timestamp[strlen(client->info.timestamp) - 1 ] = '\0'; + list_add_tail(&(client->client_list),&client_connections_info); childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +577,7 @@ +@@ -328,6 +579,7 @@ } /* for(;;) loop */ /* don't reach here */ @@ -369,7 +371,7 @@ } #endif /* NON_INETD_MODE */ -@@ -338,10 +588,24 @@ +@@ -338,10 +590,24 @@ const int saved_errno = errno; diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk index 1f13ebe7dad2..a0310fca3c1d 100644 --- a/package/dropbear/dropbear.mk +++ b/package/dropbear/dropbear.mk @@ -107,7 +107,7 @@ endif ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) define DROPBEAR_INSTALL_TARGET_CMDS ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear - $(INSTALL) -D $(@D)/libdropbear.so $(STAGING_DIR)/usr/lib + $(INSTALL) -D $(@D)/libdropbear.so $(TARGET_DIR)/usr/lib $(INSTALL) -D $(@D)/libdropbear.h $(STAGING_DIR)/usr/include $(INSTALL) -D $(@D)/libdropbear.pc $(STAGING_DIR)/usr/lib/pkgconfig/LibDropbear.pc endef diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 73d4795571de..0415325a0e6d 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_PLUGINS_VERSION = 5d0769cea06138762ac8ecc102b5b8e5c9b3a863 +WPEFRAMEWORK_PLUGINS_VERSION = ef787ff61ee83e1b1431fb337e5caae02c1fce1f WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng diff --git a/package/wpe/wpeframework/wpeframework.mk b/package/wpe/wpeframework/wpeframework.mk index 5d17da6409b3..15c0151fe9d5 100644 --- a/package/wpe/wpeframework/wpeframework.mk +++ b/package/wpe/wpeframework/wpeframework.mk @@ -4,7 +4,7 @@ # ################################################################################ -WPEFRAMEWORK_VERSION = 2c1a62d177473c67c1abbd41147a051edb436433 +WPEFRAMEWORK_VERSION = e60bbfda4b0997c3053afff227e709b88032894a WPEFRAMEWORK_SITE = $(call github,s-rapolu,WPEFramework,$(WPEFRAMEWORK_VERSION)) WPEFRAMEWORK_INSTALL_STAGING = YES WPEFRAMEWORK_DEPENDENCIES = zlib $(call qstrip,$(BR2_PACKAGE_SDK_INSTALL)) host-python host-python-jsonref From 5b8da33d6d2a18fe0fd8cc6112f177a006600d2e Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 27 Sep 2019 12:01:37 +0530 Subject: [PATCH 14/18] [SecureShellServerPlugin] updated dropbear patches with git format-patch Signed-off-by: Suman Rapolu --- ...0001-Makefile.in-changes.patch.conditional | 76 -- ...-for-ThunderNanoServices.patch.conditional | 745 ++++++++++++++++++ .../0002-svr-main.c-changes.patch.conditional | 400 ---------- ...003-configure.ac-changes.patch.conditional | 12 - ...0004-libdropbear.h-added.patch.conditional | 31 - ...-libdropbear.pc.in-added.patch.conditional | 14 - .../0006-linkedlist.h-added.patch.conditional | 172 ---- 7 files changed, 745 insertions(+), 705 deletions(-) delete mode 100644 package/dropbear/0001-Makefile.in-changes.patch.conditional create mode 100644 package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional delete mode 100644 package/dropbear/0002-svr-main.c-changes.patch.conditional delete mode 100644 package/dropbear/0003-configure.ac-changes.patch.conditional delete mode 100644 package/dropbear/0004-libdropbear.h-added.patch.conditional delete mode 100644 package/dropbear/0005-libdropbear.pc.in-added.patch.conditional delete mode 100644 package/dropbear/0006-linkedlist.h-added.patch.conditional diff --git a/package/dropbear/0001-Makefile.in-changes.patch.conditional b/package/dropbear/0001-Makefile.in-changes.patch.conditional deleted file mode 100644 index 366938f6864d..000000000000 --- a/package/dropbear/0001-Makefile.in-changes.patch.conditional +++ /dev/null @@ -1,76 +0,0 @@ ---- a/Makefile.in 2016-07-21 20:47:09.000000000 +0530 -+++ b/Makefile.in 2019-06-07 15:08:42.613982883 +0530 -@@ -10,7 +10,7 @@ - # Hopefully that seems intuitive. - - ifndef PROGRAMS -- PROGRAMS=dropbear dbclient dropbearkey dropbearconvert -+ PROGRAMS=dropbear - endif - - STATIC_LTC=libtomcrypt/libtomcrypt.a -@@ -18,6 +18,8 @@ - - LIBTOM_LIBS=@LIBTOM_LIBS@ - -+DROPBEAR_SERVER_LIB=libdropbear.so -+ - ifeq (@BUNDLED_LIBTOM@, 1) - LIBTOM_DEPS=$(STATIC_LTC) $(STATIC_LTM) - CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ -@@ -75,6 +77,9 @@ - bindir=@bindir@ - sbindir=@sbindir@ - mandir=@mandir@ -+libdir = @libdir@ -+includedir = @includedir@ -+pkgconfigdir = $(libdir)/pkgconfig - - CC=@CC@ - AR=@AR@ -@@ -82,9 +87,10 @@ - STRIP=@STRIP@ - INSTALL=@INSTALL@ - CPPFLAGS=@CPPFLAGS@ --CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ -+CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ -fPIC - LIBS+=@LIBS@ - LDFLAGS=@LDFLAGS@ -+ARFLAGS=rcT - - EXEEXT=@EXEEXT@ - -@@ -106,12 +112,14 @@ - - ifeq ($(STATIC), 1) - LDFLAGS+=-static -+else -+ LDFLAGS +=-shared - endif - - ifeq ($(MULTI), 1) - TARGETS=dropbearmulti - else -- TARGETS=$(PROGRAMS) -+ TARGETS=$(DROPBEAR_SERVER_LIB) - endif - - # for the scp progress meter. The -D doesn't affect anything else. -@@ -175,6 +183,8 @@ - scp: $(SCPOBJS) $(HEADERS) Makefile - $(CC) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS) - -+$(DROPBEAR_SERVER_LIB):$(LIBTOM_LIBS)$(dropbearobjs) -+ $(CC) $(LDFLAGS) -o $@ $(dropbearobjs) $(LIBTOM_LIBS) - - # multi-binary compilation. - MULTIOBJS= -@@ -215,7 +225,7 @@ - - thisclean: - -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \ -- dropbearmulti *.o *.da *.bb *.bbg *.prof -+ dropbearmulti *.o *.da *.bb *.bbg *.prof libdropbear.pc $(DROPBEAR_SERVER_LIB) - - distclean: clean tidy - -rm -f config.h diff --git a/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional new file mode 100644 index 000000000000..ae16b73f4612 --- /dev/null +++ b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional @@ -0,0 +1,745 @@ +From 3049d91f7b0ac4f1b9cb72591ccdf4b15714cf4c Mon Sep 17 00:00:00 2001 +From: Suman Rapolu +Date: Fri, 27 Sep 2019 11:10:57 +0530 +Subject: [PATCH 1/1] New interface for ThunderNanoServices + +1. Created API interface for Dropbear service +2. Implemented Session management using linked list +3. Integrated with pkg-config tool +4. Modified Configure.ac and Makefile.in to generate shared library + +Signed-off-by: Suman Rapolu +--- + Makefile.in | 18 ++- + configure.ac | 3 + + libdropbear.h | 28 +++++ + libdropbear.pc.in | 11 ++ + linkedlist.h | 169 ++++++++++++++++++++++++++ + svr-main.c | 293 +++++++++++++++++++++++++++++++++++++++++++--- + 6 files changed, 504 insertions(+), 18 deletions(-) + create mode 100644 libdropbear.h + create mode 100644 libdropbear.pc.in + create mode 100644 linkedlist.h + +diff --git a/Makefile.in b/Makefile.in +index d9bfdfa..79c15c0 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -10,7 +10,7 @@ + # Hopefully that seems intuitive. + + ifndef PROGRAMS +- PROGRAMS=dropbear dbclient dropbearkey dropbearconvert ++ PROGRAMS=dropbear + endif + + STATIC_LTC=libtomcrypt/libtomcrypt.a +@@ -18,6 +18,8 @@ STATIC_LTM=libtommath/libtommath.a + + LIBTOM_LIBS=@LIBTOM_LIBS@ + ++DROPBEAR_SERVER_LIB=libdropbear.so ++ + ifeq (@BUNDLED_LIBTOM@, 1) + LIBTOM_DEPS=$(STATIC_LTC) $(STATIC_LTM) + CFLAGS+=-I$(srcdir)/libtomcrypt/src/headers/ +@@ -75,6 +77,9 @@ datarootdir = @datarootdir@ + bindir=@bindir@ + sbindir=@sbindir@ + mandir=@mandir@ ++libdir = @libdir@ ++includedir = @includedir@ ++pkgconfigdir = $(libdir)/pkgconfig + + CC=@CC@ + AR=@AR@ +@@ -82,9 +87,10 @@ RANLIB=@RANLIB@ + STRIP=@STRIP@ + INSTALL=@INSTALL@ + CPPFLAGS=@CPPFLAGS@ +-CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ ++CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) @CFLAGS@ -fPIC + LIBS+=@LIBS@ + LDFLAGS=@LDFLAGS@ ++ARFLAGS=rcT + + EXEEXT=@EXEEXT@ + +@@ -106,12 +112,14 @@ export RANLIB AR STRIP + + ifeq ($(STATIC), 1) + LDFLAGS+=-static ++else ++ LDFLAGS +=-shared + endif + + ifeq ($(MULTI), 1) + TARGETS=dropbearmulti + else +- TARGETS=$(PROGRAMS) ++ TARGETS=$(DROPBEAR_SERVER_LIB) + endif + + # for the scp progress meter. The -D doesn't affect anything else. +@@ -175,6 +183,8 @@ dropbearkey dropbearconvert: $(HEADERS) $(LIBTOM_DEPS) Makefile + scp: $(SCPOBJS) $(HEADERS) Makefile + $(CC) $(LDFLAGS) -o $@$(EXEEXT) $(SCPOBJS) + ++$(DROPBEAR_SERVER_LIB):$(LIBTOM_LIBS)$(dropbearobjs) ++ $(CC) $(LDFLAGS) -o $@ $(dropbearobjs) $(LIBTOM_LIBS) + + # multi-binary compilation. + MULTIOBJS= +@@ -215,7 +225,7 @@ clean: ltc-clean ltm-clean thisclean + + thisclean: + -rm -f dropbear dbclient dropbearkey dropbearconvert scp scp-progress \ +- dropbearmulti *.o *.da *.bb *.bbg *.prof ++ dropbearmulti *.o *.da *.bb *.bbg *.prof libdropbear.pc $(DROPBEAR_SERVER_LIB) + + distclean: clean tidy + -rm -f config.h +diff --git a/configure.ac b/configure.ac +index 893b904..f99ae67 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -730,6 +730,9 @@ AC_CONFIG_HEADER(config.h) + AC_CONFIG_FILES(Makefile $LIBTOM_FILES) + AC_OUTPUT + ++AC_CONFIG_FILES(libdropbear.pc) ++AC_OUTPUT ++ + AC_MSG_NOTICE() + if test $BUNDLED_LIBTOM = 1 ; then + AC_MSG_NOTICE([Using bundled libtomcrypt and libtommath]) +diff --git a/libdropbear.h b/libdropbear.h +new file mode 100644 +index 0000000..405b034 +--- /dev/null ++++ b/libdropbear.h +@@ -0,0 +1,28 @@ ++#ifndef __LIBDROPBEAR_H ++#define __LIBDROPBEAR_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define IPADDRESSLENGTH 16 ++#define TIMESTAMPLENGTH 26 ++ ++struct client_info{ ++ int pid; ++ char ipaddress[IPADDRESSLENGTH]; //Client IPv4 address ++ char timestamp[TIMESTAMPLENGTH]; //timestamp of the received client ++}; ++ ++void activate_dropbear(char*); ++void deactivate_dropbear(); ++int get_active_sessions_count(); ++void get_active_sessions_info(struct client_info*, int); ++int close_client_session(int); ++int get_total_sessions_served(); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/libdropbear.pc.in b/libdropbear.pc.in +new file mode 100644 +index 0000000..2d3ce41 +--- /dev/null ++++ b/libdropbear.pc.in +@@ -0,0 +1,11 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++ ++Name: libdropbear ++Version: @PACKAGE_VERSION@ ++Description: Dropbear SSH ++URL: http://matt.ucc.asn.au/dropbear/releases ++Libs: -L${libdir} -ldropbear ++Cflags: -I${includedir} +diff --git a/linkedlist.h b/linkedlist.h +new file mode 100644 +index 0000000..8da6057 +--- /dev/null ++++ b/linkedlist.h +@@ -0,0 +1,169 @@ ++/** ++ * info: linkedlist.h file is derived from the ++ * linux-5.2.1/include/linux/list.h ++ * https://www.kernel.org ++ * ++ */ ++ ++#ifndef _LINKED_LIST_H ++#define _LINKED_LIST_H ++#include ++ ++/** ++ * Get offset of a member ++ */ ++#define offsetoff(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) ++ ++/** ++ * Casts a member of a structure out to the containing structure ++ * @param ptr the pointer to the member. ++ * @param type the type of the container struct this is embedded in. ++ * @param member the name of the member within the struct. ++ * ++ */ ++#define container_of(ptr,type,member) ({ \ ++ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ++ (type *)( (char *)__mptr - offsetoff(type,member) );}) ++/* ++ * These are non-NULL pointers that will result in page faults ++ * under normal circumstances, used to verify that nobody uses ++ * non-initialized list entries. ++ */ ++#define LIST_POISON1 ((void *) 0x00100100) ++#define LIST_POISON2 ((void *) 0x00200200) ++ ++ ++#define WRITE_ONCE(ptr,value) (ptr=value) ++ ++typedef _Bool bool; ++ ++enum { ++ false = 0, ++ true = 1 ++}; ++ ++ ++struct list_head { ++ struct list_head *next, *prev; ++}; ++ ++/* ++ * Simple doubly linked list implementation. ++ * ++ * Some of the internal functions ("__xxx") are useful when ++ * manipulating whole lists rather than single entries, as ++ * sometimes we already know the next/prev entries and we can ++ * generate better code by using them directly rather than ++ * using the generic single-entry routines. ++ */ ++ ++static inline void INIT_LIST_HEAD(struct list_head *list) ++{ ++ WRITE_ONCE(list->next, list); ++ list->prev = list; ++} ++ ++#ifdef CONFIG_DEBUG_LIST ++extern bool __list_add_valid(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next); ++extern bool __list_del_entry_valid(struct list_head *entry); ++#else ++static inline bool __list_add_valid(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next) ++{ ++ return true; ++} ++static inline bool __list_del_entry_valid(struct list_head *entry) ++{ ++ return true; ++} ++#endif ++ ++/* ++ * Insert a new entry between two known consecutive entries. ++ * ++ * This is only for internal list manipulation where we know ++ * the prev/next entries already! ++ */ ++static inline void __list_add(struct list_head *new, ++ struct list_head *prev, ++ struct list_head *next) ++{ ++ if (!__list_add_valid(new, prev, next)) ++ return; ++ ++ next->prev = new; ++ new->next = next; ++ new->prev = prev; ++ WRITE_ONCE(prev->next, new); ++} ++ ++ ++/** ++ * list_add_tail - add a new entry ++ * @new: new entry to be added ++ * @head: list head to add it before ++ * ++ * Insert a new entry before the specified head. ++ * This is useful for implementing queues. ++ */ ++static inline void list_add_tail(struct list_head *new, struct list_head *head) ++{ ++ __list_add(new, head->prev, head); ++} ++ ++/* ++ * Delete a list entry by making the prev/next entries ++ * point to each other. ++ * ++ * This is only for internal list manipulation where we know ++ * the prev/next entries already! ++ */ ++static inline void __list_del(struct list_head * prev, struct list_head * next) ++{ ++ next->prev = prev; ++ WRITE_ONCE(prev->next, next); ++} ++ ++/** ++ * list_del - deletes entry from list. ++ * @entry: the element to delete from the list. ++ * Note: list_empty() on entry does not return true after this, the entry is ++ * in an undefined state. ++ */ ++static inline void __list_del_entry(struct list_head *entry) ++{ ++ if (!__list_del_entry_valid(entry)) ++ return; ++ ++ __list_del(entry->prev, entry->next); ++} ++ ++static inline void list_del(struct list_head *entry) ++{ ++ __list_del_entry(entry); ++ entry->next = LIST_POISON1; ++ entry->prev = LIST_POISON2; ++} ++ ++/** ++ * list_entry - get the struct for this entry ++ * @ptr: the &struct list_head pointer. ++ * @type: the type of the struct this is embedded in. ++ * @member: the name of the list_head within the struct. ++ */ ++#define list_entry(ptr, type, member) \ ++ container_of(ptr, type, member) ++ ++/** ++ * list_for_each - iterate over a list ++ * @pos: the &struct list_head to use as a loop cursor. ++ * @head: the head for your list. ++ */ ++#define list_for_each(pos, head) \ ++ for (pos = (head)->next; pos != (head); pos = pos->next) ++ ++#endif ++ +diff --git a/svr-main.c b/svr-main.c +index b274551..d9d2952 100644 +--- a/svr-main.c ++++ b/svr-main.c +@@ -30,19 +30,44 @@ + #include "runopts.h" + #include "dbrandom.h" + #include "crypto_desc.h" ++#include ++#include "libdropbear.h" ++#include "linkedlist.h" + + static size_t listensockets(int *sock, size_t sockcount, int *maxfd); + static void sigchld_handler(int dummy); + static void sigsegv_handler(int); + static void sigintterm_handler(int fish); ++void init_dropbear(int argc, char ** argv); ++void free_client_info(); ++static int setargs(char *args, char **argv); ++char **parsedargs(char *args, int *argc); ++void freeparsedargs(char **argv); ++ ++ ++ ++struct list_head client_connections_info; ++ ++struct active_clients{ ++ struct client_info info; ++ struct list_head client_list; ++}; ++ ++static int pluginActivated = 0; ++static pthread_t threadID; ++int served_clients = 0; ++int server_active = 0; ++int client_info_available = 0; ++ + #ifdef INETD_MODE + static void main_inetd(void); + #endif + #ifdef NON_INETD_MODE +-static void main_noinetd(void); ++static void* main_noinetd(void *); + #endif + static void commonsetup(void); + ++#if 0 + #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) + #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) + int dropbear_main(int argc, char ** argv) +@@ -75,6 +100,208 @@ int main(int argc, char ** argv) + return -1; + } + #endif ++#endif ++ ++void init_dropbear(int argc, char ** argv) ++{ ++ server_active = 1; ++ _dropbear_exit = svr_dropbear_exit; ++ _dropbear_log = svr_dropbear_log; ++ disallow_core(); ++ /* get commandline options */ ++ svr_getopts(argc, argv); ++ /* Note: commonsetup() must happen before we daemon()ise. Otherwise ++ daemon() will chdir("/"), and we won't be able to find local-dir ++ hostkeys. */ ++ commonsetup(); ++ INIT_LIST_HEAD(&client_connections_info); ++ client_info_available = 1; ++} ++ ++static int setargs(char *args, char **argv) ++{ ++ int count = 0; ++ while (isspace(*args)) ++args; ++ while (*args) { ++ if (argv) argv[count] = args; ++ while (*args && !isspace(*args)) ++args; ++ if (argv && *args) *args++ = '\0'; ++ while (isspace(*args)) ++args; ++ count++; ++ } ++ return count; ++} ++ ++char **parsedargs(char *args, int *argc) ++{ ++ char **argv = NULL; ++ int argn = 0; ++ ++ if (args && *args ++ && (args = strdup(args)) ++ && (argn = setargs(args,NULL)) ++ && (argv = malloc((argn+1) * sizeof(char *)))) { ++ *argv++ = args; ++ argn = setargs(args,argv); ++ } ++ ++ if (args && !argv) free(args); ++ *argc = argn; ++ return argv; ++} ++ ++void freeparsedargs(char **argv) ++{ ++ if (argv) { ++ free(argv[-1]); ++ free(argv-1); ++ } ++} ++ ++ ++void activate_dropbear(char* string) ++{ ++ int status; ++ int argc; ++ char **argv; ++ char str[100]; ++ ++ printf("recieved input=%s\n", string); ++ memset(str, '\0', sizeof(str)); ++ ++ strncpy(str, "dropbear ", strlen("dropbear ")); ++ strncpy(str+strlen("dropbear "), string, strlen(string)); ++ printf("str = %s\n", str); ++ ++ argv = parsedargs(str,&argc); ++ printf("Argument count (argc) = %d\n",argc); ++ for (int i = 0; i < argc; i++) ++ printf("argv[%d] = %s\n", i, argv[i]); ++ ++ if(pluginActivated == 1) ++ { ++ printf("Plugin already Activated \n"); ++ return; ++ } ++ init_dropbear(argc, argv); ++ status = pthread_create(&threadID,NULL,main_noinetd,NULL); ++ if(status != 0) ++ { ++ printf("Error in creating thread\n"); ++ return; ++ } ++ freeparsedargs(argv); ++ printf("Plugin Activated \n"); ++ pluginActivated =1; ++} ++ ++void deactivate_dropbear() ++{ ++ if(pluginActivated == 1) ++ { ++ server_active = 0; ++ pthread_join(threadID, 0); ++ pluginActivated = 0; ++ } ++ client_info_available = 0; ++ served_clients =0; ++ printf("Plugin DeActivated \n"); ++ return; ++} ++ ++/*Return the number of clients currently connected*/ ++ ++int get_active_sessions_count(){ ++ int count=0; ++ if(client_info_available){ ++ struct active_clients *client; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients,client_list); ++ if(client){ ++ count++; ++ } ++ } ++ } ++ return count; ++} ++ ++/*To get the list of connections that are currently serving*/ ++void get_active_sessions_info(struct client_info* connected_clients,int connections_count){ ++ if(client_info_available){ ++ int count = 0; ++ struct active_clients *client; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list, struct active_clients, client_list ); ++ if(client && (count < connections_count)){ ++ connected_clients[count].pid=client->info.pid; ++ strcpy(connected_clients[count].ipaddress,client->info.ipaddress); ++ strcpy(connected_clients[count].timestamp,client->info.timestamp); ++ count++; ++ } ++ else{ ++ break; ++ } ++ } ++ } ++} ++ ++/* To terminate the server connection to client with the pid */ ++int close_client_session(int client_pid){ ++ int pid_existing=0; ++ struct active_clients *client; ++ struct list_head *ptr_list; ++ if(client_info_available){ ++ list_for_each(ptr_list,&client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients,client_list); ++ if(client && (client->info.pid == client_pid)){ ++ pid_existing=1; ++ break; ++ } ++ } ++ if(pid_existing){ ++ if(kill(client_pid,SIGKILL)== -1){ ++ printf("Error during close session: %s\n", strerror(errno)); ++ return errno; ++ } ++ else{ ++ return 0; ++ } ++ } ++ else{ ++ return -1; ++ } ++ } ++ else{ ++ return -1; ++ } ++} ++ ++/* total number of connections are srved till now*/ ++int get_total_sessions_served(){ ++ return served_clients; ++} ++ ++void free_client_info(){ ++ if(client_info_available){ ++ struct active_clients *client; ++ struct list_head *ptr_list; ++ list_for_each(ptr_list, &client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients, client_list); ++ if (client){ ++ if(close_client_session(client->info.pid) != 0 ){ ++ printf("unable to kill the process : %d\n",client->info.pid); ++ } ++ } ++ else{ ++ break; ++ } ++ } ++ } ++ ++} ++ + + #ifdef INETD_MODE + static void main_inetd() { +@@ -104,25 +331,21 @@ static void main_inetd() { + #endif /* INETD_MODE */ + + #ifdef NON_INETD_MODE +-static void main_noinetd() { ++static void* main_noinetd(void *UNUSED(unused)){ + fd_set fds; + unsigned int i, j; + int val; + int maxsock = -1; + int listensocks[MAX_LISTEN_ADDR]; + size_t listensockcount = 0; +- FILE *pidfile = NULL; ++ //FILE *pidfile = NULL; + + int childpipes[MAX_UNAUTH_CLIENTS]; + char * preauth_addrs[MAX_UNAUTH_CLIENTS]; + + int childsock; + int childpipe[2]; +- +- /* Note: commonsetup() must happen before we daemon()ise. Otherwise +- daemon() will chdir("/"), and we won't be able to find local-dir +- hostkeys. */ +- commonsetup(); ++ struct timeval timeout; + + /* sockets to identify pre-authenticated clients */ + for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { +@@ -141,6 +364,7 @@ static void main_noinetd() { + FD_SET(listensocks[i], &fds); + } + ++#if 0 + /* fork */ + if (svr_opts.forkbg) { + int closefds = 0; +@@ -154,6 +378,7 @@ static void main_noinetd() { + } + } + ++#endif + /* should be done after syslog is working */ + if (svr_opts.forkbg) { + dropbear_log(LOG_INFO, "Running in background"); +@@ -161,13 +386,17 @@ static void main_noinetd() { + dropbear_log(LOG_INFO, "Not backgrounding"); + } + ++#if 0 + /* create a PID file so that we can be killed easily */ + pidfile = fopen(svr_opts.pidfile, "w"); + if (pidfile) { + fprintf(pidfile, "%d\n", getpid()); + fclose(pidfile); + } ++#endif + ++ timeout.tv_sec = 5; ++ timeout.tv_usec = 0; + /* incoming connection select loop */ + for(;;) { + +@@ -186,11 +415,18 @@ static void main_noinetd() { + } + } + +- val = select(maxsock+1, &fds, NULL, NULL, NULL); ++ val = select(maxsock+1, &fds, NULL, NULL, &timeout); + +- if (exitflag) { +- unlink(svr_opts.pidfile); +- dropbear_exit("Terminated by signal"); ++ if (!server_active) { ++ //unlink(svr_opts.pidfile); ++ //dropbear_exit("Terminated by signal"); ++ /* make sure we close sockets */ ++ FD_ZERO(&fds); ++ for (i = 0; i < listensockcount; i++) { ++ m_close(listensocks[i]); ++ } ++ free_client_info(); ++ break; + } + + if (val == 0) { +@@ -281,6 +517,20 @@ static void main_noinetd() { + if (fork_ret > 0) { + + /* parent */ ++ /* taking the pids and respective IP address and timestamp to structure list*/ ++ time_t now; ++ time(&now); ++ struct active_clients *client; ++ served_clients++; ++ client = (struct active_clients *)malloc(sizeof(struct active_clients)); ++ if(!client){ ++ printf("unable to create a memory for active clients structure\n "); ++ } ++ client->info.pid = fork_ret; ++ strcpy(client->info.ipaddress, remote_host); ++ strcpy(client->info.timestamp,ctime(&now)); ++ client->info.timestamp[strlen(client->info.timestamp) - 1 ] = '\0'; ++ list_add_tail(&(client->client_list),&client_connections_info); + childpipes[conn_idx] = childpipe[0]; + m_close(childpipe[1]); + preauth_addrs[conn_idx] = remote_host; +@@ -328,6 +578,7 @@ out: + } /* for(;;) loop */ + + /* don't reach here */ ++ return NULL; + } + #endif /* NON_INETD_MODE */ + +@@ -338,10 +589,24 @@ static void sigchld_handler(int UNUSED(unused)) { + + const int saved_errno = errno; + +- while(waitpid(-1, NULL, WNOHANG) > 0) {} ++ int pid; ++ /* disconnected ports are removing from structure List */ ++ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { ++ struct active_clients *client; ++ struct list_head *ptr_list; ++ ++ list_for_each(ptr_list, &client_connections_info){ ++ client = list_entry(ptr_list,struct active_clients, client_list); ++ if (client && client->info.pid == pid){ ++ list_del(ptr_list); ++ free(client); ++ break; ++ } ++ } ++ } + + sa_chld.sa_handler = sigchld_handler; +- sa_chld.sa_flags = SA_NOCLDSTOP; ++ sa_chld.sa_flags = SA_NOCLDSTOP | SA_RESTART ; + sigemptyset(&sa_chld.sa_mask); + if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { + dropbear_exit("signal() error"); +-- +2.17.1 + diff --git a/package/dropbear/0002-svr-main.c-changes.patch.conditional b/package/dropbear/0002-svr-main.c-changes.patch.conditional deleted file mode 100644 index d82c9cfdb044..000000000000 --- a/package/dropbear/0002-svr-main.c-changes.patch.conditional +++ /dev/null @@ -1,400 +0,0 @@ ---- a/svr-main.c 2016-07-21 20:47:09.000000000 +0530 -+++ b/svr-main.c 2019-09-23 20:43:58.462169941 +0530 -@@ -30,19 +30,44 @@ - #include "runopts.h" - #include "dbrandom.h" - #include "crypto_desc.h" -+#include -+#include "libdropbear.h" -+#include "linkedlist.h" - - static size_t listensockets(int *sock, size_t sockcount, int *maxfd); - static void sigchld_handler(int dummy); - static void sigsegv_handler(int); - static void sigintterm_handler(int fish); -+void init_dropbear(int argc, char ** argv); -+void free_client_info(); -+static int setargs(char *args, char **argv); -+char **parsedargs(char *args, int *argc); -+void freeparsedargs(char **argv); -+ -+ -+ -+struct list_head client_connections_info; -+ -+struct active_clients{ -+ struct client_info info; -+ struct list_head client_list; -+}; -+ -+static int pluginActivated = 0; -+static pthread_t threadID; -+int served_clients = 0; -+int server_active = 0; -+int client_info_available = 0; -+ - #ifdef INETD_MODE - static void main_inetd(void); - #endif - #ifdef NON_INETD_MODE --static void main_noinetd(void); -+static void* main_noinetd(void *); - #endif - static void commonsetup(void); - -+#if 0 - #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) - #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) - int dropbear_main(int argc, char ** argv) -@@ -75,6 +100,209 @@ - return -1; - } - #endif -+#endif -+ -+void init_dropbear(int argc, char ** argv) -+{ -+ server_active = 1; -+ _dropbear_exit = svr_dropbear_exit; -+ _dropbear_log = svr_dropbear_log; -+ disallow_core(); -+ /* get commandline options */ -+ svr_getopts(argc, argv); -+ /* Note: commonsetup() must happen before we daemon()ise. Otherwise -+ daemon() will chdir("/"), and we won't be able to find local-dir -+ hostkeys. */ -+ commonsetup(); -+ INIT_LIST_HEAD(&client_connections_info); -+ client_info_available = 1; -+} -+ -+ -+static int setargs(char *args, char **argv) -+{ -+ int count = 0; -+ while (isspace(*args)) ++args; -+ while (*args) { -+ if (argv) argv[count] = args; -+ while (*args && !isspace(*args)) ++args; -+ if (argv && *args) *args++ = '\0'; -+ while (isspace(*args)) ++args; -+ count++; -+ } -+ return count; -+} -+ -+char **parsedargs(char *args, int *argc) -+{ -+ char **argv = NULL; -+ int argn = 0; -+ -+ if (args && *args -+ && (args = strdup(args)) -+ && (argn = setargs(args,NULL)) -+ && (argv = malloc((argn+1) * sizeof(char *)))) { -+ *argv++ = args; -+ argn = setargs(args,argv); -+ } -+ -+ if (args && !argv) free(args); -+ *argc = argn; -+ return argv; -+} -+ -+void freeparsedargs(char **argv) -+{ -+ if (argv) { -+ free(argv[-1]); -+ free(argv-1); -+ } -+} -+ -+ -+void activate_dropbear(char* string) -+{ -+ int status; -+ int argc; -+ char **argv; -+ char str[100]; -+ -+ printf("recieved input=%s\n", string); -+ memset(str, '\0', sizeof(str)); -+ -+ strncpy(str, "dropbear ", strlen("dropbear ")); -+ strncpy(str+strlen("dropbear "), string, strlen(string)); -+ printf("str = %s\n", str); -+ -+ argv = parsedargs(str,&argc); -+ printf("Argument count (argc) = %d\n",argc); -+ for (int i = 0; i < argc; i++) -+ printf("argv[%d] = %s\n", i, argv[i]); -+ -+ if(pluginActivated == 1) -+ { -+ printf("Plugin already Activated \n"); -+ return; -+ } -+ init_dropbear(argc, argv); -+ status = pthread_create(&threadID,NULL,main_noinetd,NULL); -+ if(status != 0) -+ { -+ printf("Error in creating thread\n"); -+ return; -+ } -+ freeparsedargs(argv); -+ printf("Plugin Activated \n"); -+ pluginActivated =1; -+} -+ -+void deactivate_dropbear() -+{ -+ if(pluginActivated == 1) -+ { -+ server_active = 0; -+ pthread_join(threadID, 0); -+ pluginActivated = 0; -+ } -+ client_info_available = 0; -+ served_clients =0; -+ printf("Plugin DeActivated \n"); -+ return; -+} -+ -+/*Return the number of clients currently connected*/ -+ -+int get_active_sessions_count(){ -+ int count=0; -+ if(client_info_available){ -+ struct active_clients *client; -+ struct list_head *ptr_list; -+ list_for_each(ptr_list,&client_connections_info){ -+ client = list_entry(ptr_list,struct active_clients,client_list); -+ if(client){ -+ count++; -+ } -+ } -+ } -+ return count; -+} -+ -+/*To get the list of connections that are currently serving*/ -+void get_active_sessions_info(struct client_info* connected_clients,int connections_count){ -+ if(client_info_available){ -+ int count = 0; -+ struct active_clients *client; -+ struct list_head *ptr_list; -+ list_for_each(ptr_list,&client_connections_info){ -+ client = list_entry(ptr_list, struct active_clients, client_list ); -+ if(client && (count < connections_count)){ -+ connected_clients[count].pid=client->info.pid; -+ strcpy(connected_clients[count].ipaddress,client->info.ipaddress); -+ strcpy(connected_clients[count].timestamp,client->info.timestamp); -+ count++; -+ } -+ else{ -+ break; -+ } -+ } -+ } -+} -+ -+/* To terminate the server connection to client with the pid */ -+int close_client_session(int client_pid){ -+ int pid_existing=0; -+ struct active_clients *client; -+ struct list_head *ptr_list; -+ if(client_info_available){ -+ list_for_each(ptr_list,&client_connections_info){ -+ client = list_entry(ptr_list,struct active_clients,client_list); -+ if(client && (client->info.pid == client_pid)){ -+ pid_existing=1; -+ break; -+ } -+ } -+ if(pid_existing){ -+ if(kill(client_pid,SIGTERM)== -1){ -+ printf("Error during close session: %s\n", strerror(errno)); -+ return errno; -+ } -+ else{ -+ return 0; -+ } -+ } -+ else{ -+ return -1; -+ } -+ } -+ else{ -+ return -1; -+ } -+} -+ -+/* total number of connections are srved till now*/ -+int get_total_sessions_served(){ -+ return served_clients; -+} -+ -+void free_client_info(){ -+ if(client_info_available){ -+ struct active_clients *client; -+ struct list_head *ptr_list; -+ list_for_each(ptr_list, &client_connections_info){ -+ client = list_entry(ptr_list,struct active_clients, client_list); -+ if (client){ -+ if(close_client_session(client->info.pid) != 0 ){ -+ printf("unable to kill the process : %d\n",client->info.pid); -+ } -+ } -+ else{ -+ break; -+ } -+ } -+ } -+ -+} -+ - - #ifdef INETD_MODE - static void main_inetd() { -@@ -104,25 +332,21 @@ - #endif /* INETD_MODE */ - - #ifdef NON_INETD_MODE --static void main_noinetd() { -+static void* main_noinetd(void *UNUSED(unused)){ - fd_set fds; - unsigned int i, j; - int val; - int maxsock = -1; - int listensocks[MAX_LISTEN_ADDR]; - size_t listensockcount = 0; -- FILE *pidfile = NULL; -+ //FILE *pidfile = NULL; - - int childpipes[MAX_UNAUTH_CLIENTS]; - char * preauth_addrs[MAX_UNAUTH_CLIENTS]; - - int childsock; - int childpipe[2]; -- -- /* Note: commonsetup() must happen before we daemon()ise. Otherwise -- daemon() will chdir("/"), and we won't be able to find local-dir -- hostkeys. */ -- commonsetup(); -+ struct timeval timeout; - - /* sockets to identify pre-authenticated clients */ - for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +365,7 @@ - FD_SET(listensocks[i], &fds); - } - -+#if 0 - /* fork */ - if (svr_opts.forkbg) { - int closefds = 0; -@@ -154,6 +379,7 @@ - } - } - -+#endif - /* should be done after syslog is working */ - if (svr_opts.forkbg) { - dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +387,17 @@ - dropbear_log(LOG_INFO, "Not backgrounding"); - } - -+#if 0 - /* create a PID file so that we can be killed easily */ - pidfile = fopen(svr_opts.pidfile, "w"); - if (pidfile) { - fprintf(pidfile, "%d\n", getpid()); - fclose(pidfile); - } -+#endif - -+ timeout.tv_sec = 5; -+ timeout.tv_usec = 0; - /* incoming connection select loop */ - for(;;) { - -@@ -186,11 +416,18 @@ - } - } - -- val = select(maxsock+1, &fds, NULL, NULL, NULL); -+ val = select(maxsock+1, &fds, NULL, NULL, &timeout); - -- if (exitflag) { -- unlink(svr_opts.pidfile); -- dropbear_exit("Terminated by signal"); -+ if (!server_active) { -+ //unlink(svr_opts.pidfile); -+ //dropbear_exit("Terminated by signal"); -+ /* make sure we close sockets */ -+ FD_ZERO(&fds); -+ for (i = 0; i < listensockcount; i++) { -+ m_close(listensocks[i]); -+ } -+ free_client_info(); -+ break; - } - - if (val == 0) { -@@ -281,6 +518,20 @@ - if (fork_ret > 0) { - - /* parent */ -+ /* taking the pids and respective IP address and timestamp to structure list*/ -+ time_t now; -+ time(&now); -+ struct active_clients *client; -+ served_clients++; -+ client = (struct active_clients *)malloc(sizeof(struct active_clients)); -+ if(!client){ -+ printf("unable to create a memory for active clients structure\n "); -+ } -+ client->info.pid = fork_ret; -+ strcpy(client->info.ipaddress, remote_host); -+ strcpy(client->info.timestamp,ctime(&now)); -+ client->info.timestamp[strlen(client->info.timestamp) - 1 ] = '\0'; -+ list_add_tail(&(client->client_list),&client_connections_info); - childpipes[conn_idx] = childpipe[0]; - m_close(childpipe[1]); - preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +579,7 @@ - } /* for(;;) loop */ - - /* don't reach here */ -+ return NULL; - } - #endif /* NON_INETD_MODE */ - -@@ -338,10 +590,24 @@ - - const int saved_errno = errno; - -- while(waitpid(-1, NULL, WNOHANG) > 0) {} -+ int pid; -+ /* disconnected ports are removing from structure List */ -+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { -+ struct active_clients *client; -+ struct list_head *ptr_list; -+ -+ list_for_each(ptr_list, &client_connections_info){ -+ client = list_entry(ptr_list,struct active_clients, client_list); -+ if (client && client->info.pid == pid){ -+ list_del(ptr_list); -+ free(client); -+ break; -+ } -+ } -+ } - - sa_chld.sa_handler = sigchld_handler; -- sa_chld.sa_flags = SA_NOCLDSTOP; -+ sa_chld.sa_flags = SA_NOCLDSTOP | SA_RESTART ; - sigemptyset(&sa_chld.sa_mask); - if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { - dropbear_exit("signal() error"); diff --git a/package/dropbear/0003-configure.ac-changes.patch.conditional b/package/dropbear/0003-configure.ac-changes.patch.conditional deleted file mode 100644 index 910845a3cc0f..000000000000 --- a/package/dropbear/0003-configure.ac-changes.patch.conditional +++ /dev/null @@ -1,12 +0,0 @@ ---- a/configure.ac 2016-07-21 20:47:09.000000000 +0530 -+++ b/configure.ac 2019-06-07 16:05:13.409598623 +0530 -@@ -730,6 +730,9 @@ - AC_CONFIG_FILES(Makefile $LIBTOM_FILES) - AC_OUTPUT - -+AC_CONFIG_FILES(libdropbear.pc) -+AC_OUTPUT -+ - AC_MSG_NOTICE() - if test $BUNDLED_LIBTOM = 1 ; then - AC_MSG_NOTICE([Using bundled libtomcrypt and libtommath]) diff --git a/package/dropbear/0004-libdropbear.h-added.patch.conditional b/package/dropbear/0004-libdropbear.h-added.patch.conditional deleted file mode 100644 index 88f9547c6598..000000000000 --- a/package/dropbear/0004-libdropbear.h-added.patch.conditional +++ /dev/null @@ -1,31 +0,0 @@ ---- a/libdropbear.h 2019-08-28 20:32:09.684490106 +0530 -+++ b/libdropbear.h 2019-08-28 20:30:35.571212068 +0530 -@@ -0,0 +1,28 @@ -+#ifndef __LIBDROPBEAR_H -+#define __LIBDROPBEAR_H -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+#define IPADDRESSLENGTH 16 -+#define TIMESTAMPLENGTH 26 -+ -+struct client_info{ -+ int pid; -+ char ipaddress[IPADDRESSLENGTH]; //Client IPv4 address -+ char timestamp[TIMESTAMPLENGTH]; //timestamp of the received client -+}; -+ -+void activate_dropbear(char*); -+void deactivate_dropbear(); -+int get_active_sessions_count(); -+void get_active_sessions_info(struct client_info*, int); -+int close_client_session(int); -+int get_total_sessions_served(); -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif diff --git a/package/dropbear/0005-libdropbear.pc.in-added.patch.conditional b/package/dropbear/0005-libdropbear.pc.in-added.patch.conditional deleted file mode 100644 index cb1007b833d5..000000000000 --- a/package/dropbear/0005-libdropbear.pc.in-added.patch.conditional +++ /dev/null @@ -1,14 +0,0 @@ ---- a/libdropbear.pc.in 1970-01-01 05:30:00.000000000 +0530 -+++ b/libdropbear.pc.in 2019-06-06 21:49:56.122986983 +0530 -@@ -0,0 +1,11 @@ -+prefix=@prefix@ -+exec_prefix=@exec_prefix@ -+libdir=@libdir@ -+includedir=@includedir@ -+ -+Name: libdropbear -+Version: @PACKAGE_VERSION@ -+Description: Dropbear SSH -+URL: http://matt.ucc.asn.au/dropbear/releases -+Libs: -L${libdir} -ldropbear -+Cflags: -I${includedir} diff --git a/package/dropbear/0006-linkedlist.h-added.patch.conditional b/package/dropbear/0006-linkedlist.h-added.patch.conditional deleted file mode 100644 index 598bc8b0ee22..000000000000 --- a/package/dropbear/0006-linkedlist.h-added.patch.conditional +++ /dev/null @@ -1,172 +0,0 @@ ---- a/linkedlist.h 2019-07-11 14:07:04.040000000 +0530 -+++ b/linkedlist.h 2019-07-17 11:49:34.416678720 +0530 -@@ -0,0 +1,169 @@ -+/** -+ * info: linkedlist.h file is derived from the -+ * linux-5.2.1/include/linux/list.h -+ * https://www.kernel.org -+ * -+ */ -+ -+#ifndef _LINKED_LIST_H -+#define _LINKED_LIST_H -+#include -+ -+/** -+ * Get offset of a member -+ */ -+#define offsetoff(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -+ -+/** -+ * Casts a member of a structure out to the containing structure -+ * @param ptr the pointer to the member. -+ * @param type the type of the container struct this is embedded in. -+ * @param member the name of the member within the struct. -+ * -+ */ -+#define container_of(ptr,type,member) ({ \ -+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -+ (type *)( (char *)__mptr - offsetoff(type,member) );}) -+/* -+ * These are non-NULL pointers that will result in page faults -+ * under normal circumstances, used to verify that nobody uses -+ * non-initialized list entries. -+ */ -+#define LIST_POISON1 ((void *) 0x00100100) -+#define LIST_POISON2 ((void *) 0x00200200) -+ -+ -+#define WRITE_ONCE(ptr,value) (ptr=value) -+ -+typedef _Bool bool; -+ -+enum { -+ false = 0, -+ true = 1 -+}; -+ -+ -+struct list_head { -+ struct list_head *next, *prev; -+}; -+ -+/* -+ * Simple doubly linked list implementation. -+ * -+ * Some of the internal functions ("__xxx") are useful when -+ * manipulating whole lists rather than single entries, as -+ * sometimes we already know the next/prev entries and we can -+ * generate better code by using them directly rather than -+ * using the generic single-entry routines. -+ */ -+ -+static inline void INIT_LIST_HEAD(struct list_head *list) -+{ -+ WRITE_ONCE(list->next, list); -+ list->prev = list; -+} -+ -+#ifdef CONFIG_DEBUG_LIST -+extern bool __list_add_valid(struct list_head *new, -+ struct list_head *prev, -+ struct list_head *next); -+extern bool __list_del_entry_valid(struct list_head *entry); -+#else -+static inline bool __list_add_valid(struct list_head *new, -+ struct list_head *prev, -+ struct list_head *next) -+{ -+ return true; -+} -+static inline bool __list_del_entry_valid(struct list_head *entry) -+{ -+ return true; -+} -+#endif -+ -+/* -+ * Insert a new entry between two known consecutive entries. -+ * -+ * This is only for internal list manipulation where we know -+ * the prev/next entries already! -+ */ -+static inline void __list_add(struct list_head *new, -+ struct list_head *prev, -+ struct list_head *next) -+{ -+ if (!__list_add_valid(new, prev, next)) -+ return; -+ -+ next->prev = new; -+ new->next = next; -+ new->prev = prev; -+ WRITE_ONCE(prev->next, new); -+} -+ -+ -+/** -+ * list_add_tail - add a new entry -+ * @new: new entry to be added -+ * @head: list head to add it before -+ * -+ * Insert a new entry before the specified head. -+ * This is useful for implementing queues. -+ */ -+static inline void list_add_tail(struct list_head *new, struct list_head *head) -+{ -+ __list_add(new, head->prev, head); -+} -+ -+/* -+ * Delete a list entry by making the prev/next entries -+ * point to each other. -+ * -+ * This is only for internal list manipulation where we know -+ * the prev/next entries already! -+ */ -+static inline void __list_del(struct list_head * prev, struct list_head * next) -+{ -+ next->prev = prev; -+ WRITE_ONCE(prev->next, next); -+} -+ -+/** -+ * list_del - deletes entry from list. -+ * @entry: the element to delete from the list. -+ * Note: list_empty() on entry does not return true after this, the entry is -+ * in an undefined state. -+ */ -+static inline void __list_del_entry(struct list_head *entry) -+{ -+ if (!__list_del_entry_valid(entry)) -+ return; -+ -+ __list_del(entry->prev, entry->next); -+} -+ -+static inline void list_del(struct list_head *entry) -+{ -+ __list_del_entry(entry); -+ entry->next = LIST_POISON1; -+ entry->prev = LIST_POISON2; -+} -+ -+/** -+ * list_entry - get the struct for this entry -+ * @ptr: the &struct list_head pointer. -+ * @type: the type of the struct this is embedded in. -+ * @member: the name of the list_head within the struct. -+ */ -+#define list_entry(ptr, type, member) \ -+ container_of(ptr, type, member) -+ -+/** -+ * list_for_each - iterate over a list -+ * @pos: the &struct list_head to use as a loop cursor. -+ * @head: the head for your list. -+ */ -+#define list_for_each(pos, head) \ -+ for (pos = (head)->next; pos != (head); pos = pos->next) -+ -+#endif -+ From 0ac656478ef9c2c727ebe79ca37d4782b6dfd245 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 27 Sep 2019 12:05:48 +0530 Subject: [PATCH 15/18] [SecureShellServerPlugin] changed the position of SecureShellServer build options --- package/wpe/wpeframework-plugins/Config.in | 1 - .../wpeframework-plugins.mk | 22 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/package/wpe/wpeframework-plugins/Config.in b/package/wpe/wpeframework-plugins/Config.in index effb9ae0c738..fb7d4af29293 100644 --- a/package/wpe/wpeframework-plugins/Config.in +++ b/package/wpe/wpeframework-plugins/Config.in @@ -604,7 +604,6 @@ config BR2_PACKAGE_WPEFRAMEWORK_SYSTEMCOMMANDS SystemCommands Plugin config BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER - select BR2_PACKAGE_WPEFRAMEWORK_PLUGINS select BR2_PACKAGE_DROPBEAR bool "SecureShellServer" help diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 0415325a0e6d..6532ed381546 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -72,17 +72,6 @@ ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_DICTIONARY),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_DICTIONARY=ON endif -ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER),y) -WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER=ON -ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) -WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER_IMPLEMENTATION=Dropbear -WPEFRAMEWORK_DEPENDENCIES += dropbear -else -$(error Missing a secureshellserver implemtation, please provide one or disable PLUGIN_SECURESHELLSERVER) -endif -endif - - ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR),y) WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_IOCONNECTOR=ON ifneq ($(BR2_PACKAGE_WPEFRAMEWORK_IOCONNECTOR_PAIRING_PIN),) @@ -202,6 +191,17 @@ WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_REMOTECONTROL_CUSTOM_VIRTUAL_NAME="$( WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_REMOTECONTROL_CUSTOM_VIRTUAL_MAP_FILE="$(call qstrip,$(BR2_PACKAGE_WPEFRAMEWORK_REMOTECONTROL_CUSTOM_VIRTUAL_MAP_FILE))" endif endif + +ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_SECURESHELLSERVER),y) +WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER=ON +ifeq ($(BR2_PACKAGE_DROPBEAR_LIB),y) +WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SECURESHELLSERVER_IMPLEMENTATION=Dropbear +WPEFRAMEWORK_DEPENDENCIES += dropbear +else +$(error Missing a secureshellserver implemtation, please provide one or disable PLUGIN_SECURESHELLSERVER) +endif +endif + ifeq ($(BR2_PACKAGE_WPEFRAMEWORK_SNAPSHOT),y) WPEFRAMEWORK_PLUGINS_DEPENDENCIES += libpng WPEFRAMEWORK_PLUGINS_CONF_OPTS += -DPLUGIN_SNAPSHOT=ON From 03467b13b909b3ffc7a6035ca912841e0175e18f Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Wed, 2 Oct 2019 00:16:07 +0530 Subject: [PATCH 16/18] [SecureShellServerPlugin] updated native dropbear with mutex lock --- ...-for-ThunderNanoServices.patch.conditional | 116 ++++++++---------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional index ae16b73f4612..2a6d8d7e30d4 100644 --- a/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional +++ b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional @@ -1,4 +1,4 @@ -From 3049d91f7b0ac4f1b9cb72591ccdf4b15714cf4c Mon Sep 17 00:00:00 2001 +From 34c64297ef3b718b7685ec3e1f8e768f0de3dbb1 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 27 Sep 2019 11:10:57 +0530 Subject: [PATCH 1/1] New interface for ThunderNanoServices @@ -12,11 +12,11 @@ Signed-off-by: Suman Rapolu --- Makefile.in | 18 ++- configure.ac | 3 + - libdropbear.h | 28 +++++ + libdropbear.h | 27 +++++ libdropbear.pc.in | 11 ++ - linkedlist.h | 169 ++++++++++++++++++++++++++ - svr-main.c | 293 +++++++++++++++++++++++++++++++++++++++++++--- - 6 files changed, 504 insertions(+), 18 deletions(-) + linkedlist.h | 169 +++++++++++++++++++++++++++ + svr-main.c | 288 ++++++++++++++++++++++++++++++++++++++++++++-- + 6 files changed, 500 insertions(+), 16 deletions(-) create mode 100644 libdropbear.h create mode 100644 libdropbear.pc.in create mode 100644 linkedlist.h @@ -115,10 +115,10 @@ index 893b904..f99ae67 100644 AC_MSG_NOTICE([Using bundled libtomcrypt and libtommath]) diff --git a/libdropbear.h b/libdropbear.h new file mode 100644 -index 0000000..405b034 +index 0000000..70999c9 --- /dev/null +++ b/libdropbear.h -@@ -0,0 +1,28 @@ +@@ -0,0 +1,27 @@ +#ifndef __LIBDROPBEAR_H +#define __LIBDROPBEAR_H + @@ -140,7 +140,6 @@ index 0000000..405b034 +int get_active_sessions_count(); +void get_active_sessions_info(struct client_info*, int); +int close_client_session(int); -+int get_total_sessions_served(); + +#ifdef __cplusplus +} @@ -340,10 +339,10 @@ index 0000000..8da6057 +#endif + diff --git a/svr-main.c b/svr-main.c -index b274551..d9d2952 100644 +index b274551..efb60d3 100644 --- a/svr-main.c +++ b/svr-main.c -@@ -30,19 +30,44 @@ +@@ -30,19 +30,43 @@ #include "runopts.h" #include "dbrandom.h" #include "crypto_desc.h" @@ -372,9 +371,8 @@ index b274551..d9d2952 100644 + +static int pluginActivated = 0; +static pthread_t threadID; -+int served_clients = 0; +int server_active = 0; -+int client_info_available = 0; ++pthread_mutex_t lock; + #ifdef INETD_MODE static void main_inetd(void); @@ -389,7 +387,7 @@ index b274551..d9d2952 100644 #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) int dropbear_main(int argc, char ** argv) -@@ -75,6 +100,208 @@ int main(int argc, char ** argv) +@@ -75,6 +99,205 @@ int main(int argc, char ** argv) return -1; } #endif @@ -408,7 +406,6 @@ index b274551..d9d2952 100644 + hostkeys. */ + commonsetup(); + INIT_LIST_HEAD(&client_connections_info); -+ client_info_available = 1; +} + +static int setargs(char *args, char **argv) @@ -454,36 +451,39 @@ index b274551..d9d2952 100644 + +void activate_dropbear(char* string) +{ -+ int status; -+ int argc; ++ int status; ++ int argc,len; + char **argv; -+ char str[100]; -+ -+ printf("recieved input=%s\n", string); -+ memset(str, '\0', sizeof(str)); -+ -+ strncpy(str, "dropbear ", strlen("dropbear ")); -+ strncpy(str+strlen("dropbear "), string, strlen(string)); -+ printf("str = %s\n", str); -+ -+ argv = parsedargs(str,&argc); -+ printf("Argument count (argc) = %d\n",argc); -+ for (int i = 0; i < argc; i++) -+ printf("argv[%d] = %s\n", i, argv[i]); ++ char *str; + + if(pluginActivated == 1) + { + printf("Plugin already Activated \n"); + return; + } ++ ++ len = strlen("dropbear ")+strlen(string)+1; ++ str=(char *)malloc(len*sizeof(char)); ++ strncpy(str, "dropbear ", strlen("dropbear ")); ++ strncpy(str+strlen("dropbear "), string, strlen(string)+1); ++ argv = parsedargs(str,&argc); ++ free(str); ++ /*for (int i = 0; i < argc; i++) ++ printf("argv[%d] = %s\n", i, argv[i]);*/ ++ + init_dropbear(argc, argv); ++ freeparsedargs(argv); ++ if (pthread_mutex_init(&lock, NULL) != 0) ++ { ++ printf("\n mutex init has failed\n"); ++ return; ++ } + status = pthread_create(&threadID,NULL,main_noinetd,NULL); + if(status != 0) + { + printf("Error in creating thread\n"); + return; + } -+ freeparsedargs(argv); + printf("Plugin Activated \n"); + pluginActivated =1; +} @@ -494,10 +494,9 @@ index b274551..d9d2952 100644 + { + server_active = 0; + pthread_join(threadID, 0); ++ pthread_mutex_destroy(&lock); + pluginActivated = 0; + } -+ client_info_available = 0; -+ served_clients =0; + printf("Plugin DeActivated \n"); + return; +} @@ -506,7 +505,7 @@ index b274551..d9d2952 100644 + +int get_active_sessions_count(){ + int count=0; -+ if(client_info_available){ ++ if(pluginActivated){ + struct active_clients *client; + struct list_head *ptr_list; + list_for_each(ptr_list,&client_connections_info){ @@ -521,7 +520,7 @@ index b274551..d9d2952 100644 + +/*To get the list of connections that are currently serving*/ +void get_active_sessions_info(struct client_info* connected_clients,int connections_count){ -+ if(client_info_available){ ++ if(pluginActivated){ + int count = 0; + struct active_clients *client; + struct list_head *ptr_list; @@ -545,7 +544,7 @@ index b274551..d9d2952 100644 + int pid_existing=0; + struct active_clients *client; + struct list_head *ptr_list; -+ if(client_info_available){ ++ if(pluginActivated){ + list_for_each(ptr_list,&client_connections_info){ + client = list_entry(ptr_list,struct active_clients,client_list); + if(client && (client->info.pid == client_pid)){ @@ -571,13 +570,9 @@ index b274551..d9d2952 100644 + } +} + -+/* total number of connections are srved till now*/ -+int get_total_sessions_served(){ -+ return served_clients; -+} + +void free_client_info(){ -+ if(client_info_available){ ++ if(pluginActivated){ + struct active_clients *client; + struct list_head *ptr_list; + list_for_each(ptr_list, &client_connections_info){ @@ -598,7 +593,7 @@ index b274551..d9d2952 100644 #ifdef INETD_MODE static void main_inetd() { -@@ -104,25 +331,21 @@ static void main_inetd() { +@@ -104,7 +327,7 @@ static void main_inetd() { #endif /* INETD_MODE */ #ifdef NON_INETD_MODE @@ -607,14 +602,7 @@ index b274551..d9d2952 100644 fd_set fds; unsigned int i, j; int val; - int maxsock = -1; - int listensocks[MAX_LISTEN_ADDR]; - size_t listensockcount = 0; -- FILE *pidfile = NULL; -+ //FILE *pidfile = NULL; - - int childpipes[MAX_UNAUTH_CLIENTS]; - char * preauth_addrs[MAX_UNAUTH_CLIENTS]; +@@ -118,11 +341,7 @@ static void main_noinetd() { int childsock; int childpipe[2]; @@ -627,7 +615,7 @@ index b274551..d9d2952 100644 /* sockets to identify pre-authenticated clients */ for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) { -@@ -141,6 +364,7 @@ static void main_noinetd() { +@@ -141,6 +360,7 @@ static void main_noinetd() { FD_SET(listensocks[i], &fds); } @@ -635,7 +623,7 @@ index b274551..d9d2952 100644 /* fork */ if (svr_opts.forkbg) { int closefds = 0; -@@ -154,6 +378,7 @@ static void main_noinetd() { +@@ -154,6 +374,7 @@ static void main_noinetd() { } } @@ -643,25 +631,25 @@ index b274551..d9d2952 100644 /* should be done after syslog is working */ if (svr_opts.forkbg) { dropbear_log(LOG_INFO, "Running in background"); -@@ -161,13 +386,17 @@ static void main_noinetd() { +@@ -161,6 +382,7 @@ static void main_noinetd() { dropbear_log(LOG_INFO, "Not backgrounding"); } -+#if 0 ++ /* create a PID file so that we can be killed easily */ pidfile = fopen(svr_opts.pidfile, "w"); if (pidfile) { - fprintf(pidfile, "%d\n", getpid()); +@@ -168,6 +390,9 @@ static void main_noinetd() { fclose(pidfile); } -+#endif ++ + timeout.tv_sec = 5; + timeout.tv_usec = 0; /* incoming connection select loop */ for(;;) { -@@ -186,11 +415,18 @@ static void main_noinetd() { +@@ -186,11 +411,18 @@ static void main_noinetd() { } } @@ -669,10 +657,9 @@ index b274551..d9d2952 100644 + val = select(maxsock+1, &fds, NULL, NULL, &timeout); - if (exitflag) { -- unlink(svr_opts.pidfile); -- dropbear_exit("Terminated by signal"); + if (!server_active) { -+ //unlink(svr_opts.pidfile); + unlink(svr_opts.pidfile); +- dropbear_exit("Terminated by signal"); + //dropbear_exit("Terminated by signal"); + /* make sure we close sockets */ + FD_ZERO(&fds); @@ -684,7 +671,7 @@ index b274551..d9d2952 100644 } if (val == 0) { -@@ -281,6 +517,20 @@ static void main_noinetd() { +@@ -281,6 +513,21 @@ static void main_noinetd() { if (fork_ret > 0) { /* parent */ @@ -692,7 +679,6 @@ index b274551..d9d2952 100644 + time_t now; + time(&now); + struct active_clients *client; -+ served_clients++; + client = (struct active_clients *)malloc(sizeof(struct active_clients)); + if(!client){ + printf("unable to create a memory for active clients structure\n "); @@ -701,11 +687,13 @@ index b274551..d9d2952 100644 + strcpy(client->info.ipaddress, remote_host); + strcpy(client->info.timestamp,ctime(&now)); + client->info.timestamp[strlen(client->info.timestamp) - 1 ] = '\0'; ++ pthread_mutex_lock(&lock); + list_add_tail(&(client->client_list),&client_connections_info); ++ pthread_mutex_unlock(&lock); childpipes[conn_idx] = childpipe[0]; m_close(childpipe[1]); preauth_addrs[conn_idx] = remote_host; -@@ -328,6 +578,7 @@ out: +@@ -328,6 +575,7 @@ out: } /* for(;;) loop */ /* don't reach here */ @@ -713,7 +701,7 @@ index b274551..d9d2952 100644 } #endif /* NON_INETD_MODE */ -@@ -338,10 +589,24 @@ static void sigchld_handler(int UNUSED(unused)) { +@@ -338,10 +586,26 @@ static void sigchld_handler(int UNUSED(unused)) { const int saved_errno = errno; @@ -727,7 +715,9 @@ index b274551..d9d2952 100644 + list_for_each(ptr_list, &client_connections_info){ + client = list_entry(ptr_list,struct active_clients, client_list); + if (client && client->info.pid == pid){ ++ pthread_mutex_lock(&lock); + list_del(ptr_list); ++ pthread_mutex_unlock(&lock); + free(client); + break; + } From de980e171885ba51fe0b6484b53ea01ad142fd6c Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Wed, 9 Oct 2019 22:28:50 +0530 Subject: [PATCH 17/18] [SecureShellServerPlugin] fixed issues related to session management --- ...-for-ThunderNanoServices.patch.conditional | 71 ++++++++++++++++--- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional index 2a6d8d7e30d4..c7aa931661b7 100644 --- a/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional +++ b/package/dropbear/0001-New-interface-for-ThunderNanoServices.patch.conditional @@ -1,7 +1,7 @@ -From 34c64297ef3b718b7685ec3e1f8e768f0de3dbb1 Mon Sep 17 00:00:00 2001 +From 05167c418323663498d9f7d92cce140eba070528 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Fri, 27 Sep 2019 11:10:57 +0530 -Subject: [PATCH 1/1] New interface for ThunderNanoServices +Subject: [PATCH] New interface for ThunderNanoServices 1. Created API interface for Dropbear service 2. Implemented Session management using linked list @@ -14,9 +14,10 @@ Signed-off-by: Suman Rapolu configure.ac | 3 + libdropbear.h | 27 +++++ libdropbear.pc.in | 11 ++ - linkedlist.h | 169 +++++++++++++++++++++++++++ - svr-main.c | 288 ++++++++++++++++++++++++++++++++++++++++++++-- - 6 files changed, 500 insertions(+), 16 deletions(-) + linkedlist.h | 169 ++++++++++++++++++++++++++ + svr-main.c | 302 ++++++++++++++++++++++++++++++++++++++++++++-- + svr-session.c | 2 +- + 7 files changed, 514 insertions(+), 18 deletions(-) create mode 100644 libdropbear.h create mode 100644 libdropbear.pc.in create mode 100644 linkedlist.h @@ -339,7 +340,7 @@ index 0000000..8da6057 +#endif + diff --git a/svr-main.c b/svr-main.c -index b274551..efb60d3 100644 +index b274551..d581dfa 100644 --- a/svr-main.c +++ b/svr-main.c @@ -30,19 +30,43 @@ @@ -553,7 +554,7 @@ index b274551..efb60d3 100644 + } + } + if(pid_existing){ -+ if(kill(client_pid,SIGKILL)== -1){ ++ if(kill(client_pid,SIGUSR1)== -1){ + printf("Error during close session: %s\n", strerror(errno)); + return errno; + } @@ -708,7 +709,7 @@ index b274551..efb60d3 100644 - while(waitpid(-1, NULL, WNOHANG) > 0) {} + int pid; + /* disconnected ports are removing from structure List */ -+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { ++ while ((pid = waitpid(0, NULL, WNOHANG)) > 0) { + struct active_clients *client; + struct list_head *ptr_list; + @@ -730,6 +731,60 @@ index b274551..efb60d3 100644 sigemptyset(&sa_chld.sa_mask); if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { dropbear_exit("signal() error"); +@@ -361,6 +625,11 @@ static void sigintterm_handler(int UNUSED(unused)) { + + exitflag = 1; + } ++static void sigusr1_handler(int UNUSED(unused)) { ++ ++ exitflag = 1; ++} ++ + + /* Things used by inetd and non-inetd modes */ + static void commonsetup() { +@@ -371,7 +640,7 @@ static void commonsetup() { + startsyslog(PROGNAME); + } + #endif +- ++#if 0 + /* set up cleanup handler */ + if (signal(SIGINT, sigintterm_handler) == SIG_ERR || + #ifndef DEBUG_VALGRIND +@@ -385,12 +654,19 @@ static void commonsetup() { + sa_chld.sa_handler = sigchld_handler; + sa_chld.sa_flags = SA_NOCLDSTOP; + sigemptyset(&sa_chld.sa_mask); ++ + if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { + dropbear_exit("signal() error"); + } ++#endif ++ if (signal(SIGUSR1, sigusr1_handler) == SIG_ERR) { ++ dropbear_exit("signal() error"); ++ } ++#if 0 + if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) { + dropbear_exit("signal() error"); + } ++#endif + + crypto_init(); + +diff --git a/svr-session.c b/svr-session.c +index 4f56cd9..b0fdf6b 100644 +--- a/svr-session.c ++++ b/svr-session.c +@@ -191,7 +191,7 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) { + m_free(svr_opts.ports[i]); + } + +- exit(exitcode); ++ _exit(exitcode); + + } + -- 2.17.1 From 3b8989eba50c619bdba639ff3318ed82e2599705 Mon Sep 17 00:00:00 2001 From: Suman Rapolu Date: Tue, 15 Oct 2019 12:41:55 +0530 Subject: [PATCH 18/18] [SecureShellServerPlugin] revert the changes done for wpeframework.mk and wpeframework-plugins.mk to refer main repositories instead of a forked repository --- package/wpe/wpeframework-plugins/wpeframework-plugins.mk | 5 ++--- package/wpe/wpeframework/wpeframework.mk | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk index 6532ed381546..a0108e2089f9 100644 --- a/package/wpe/wpeframework-plugins/wpeframework-plugins.mk +++ b/package/wpe/wpeframework-plugins/wpeframework-plugins.mk @@ -3,9 +3,8 @@ # wpeframework-plugins # ################################################################################ - -WPEFRAMEWORK_PLUGINS_VERSION = ef787ff61ee83e1b1431fb337e5caae02c1fce1f -WPEFRAMEWORK_PLUGINS_SITE = $(call github,s-rapolu,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) +WPEFRAMEWORK_PLUGINS_VERSION = c863067c05989859bee3a47dfcebe6a14327af12 +WPEFRAMEWORK_PLUGINS_SITE = $(call github,WebPlatformForEmbedded,WPEFrameworkPlugins,$(WPEFRAMEWORK_PLUGINS_VERSION)) WPEFRAMEWORK_PLUGINS_INSTALL_STAGING = YES WPEFRAMEWORK_PLUGINS_DEPENDENCIES = wpeframework libpng diff --git a/package/wpe/wpeframework/wpeframework.mk b/package/wpe/wpeframework/wpeframework.mk index 15c0151fe9d5..1d4bc034f2cc 100644 --- a/package/wpe/wpeframework/wpeframework.mk +++ b/package/wpe/wpeframework/wpeframework.mk @@ -4,8 +4,8 @@ # ################################################################################ -WPEFRAMEWORK_VERSION = e60bbfda4b0997c3053afff227e709b88032894a -WPEFRAMEWORK_SITE = $(call github,s-rapolu,WPEFramework,$(WPEFRAMEWORK_VERSION)) +WPEFRAMEWORK_VERSION = e67256318dd23be69f467fd8daecf268bd0d86e1 +WPEFRAMEWORK_SITE = $(call github,WebPlatformForEmbedded,WPEFramework,$(WPEFRAMEWORK_VERSION)) WPEFRAMEWORK_INSTALL_STAGING = YES WPEFRAMEWORK_DEPENDENCIES = zlib $(call qstrip,$(BR2_PACKAGE_SDK_INSTALL)) host-python host-python-jsonref