From a219ffc012ffa9059e81ff53a46cbd386a13ebce Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Thu, 9 Oct 2014 10:52:57 +0200 Subject: [PATCH 1/2] mksh: moved to github Signed-off-by: Thorsten Glaser --- utils/mksh/Makefile | 81 +++++++++++++++++++++++++++++++ utils/mksh/patches/100-dot_mkshrc | 50 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 utils/mksh/Makefile create mode 100644 utils/mksh/patches/100-dot_mkshrc diff --git a/utils/mksh/Makefile b/utils/mksh/Makefile new file mode 100644 index 000000000..66e8e63a2 --- /dev/null +++ b/utils/mksh/Makefile @@ -0,0 +1,81 @@ +# +# Copyright (C) 2007-2011 OpenWrt.org +# Copyright (c) 2009-2013 Thorsten Glaser +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mksh +PKG_VERSION:=47 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-R$(PKG_VERSION).tgz +PKG_SOURCE_URL:=http://www.mirbsd.org/MirOS/dist/mir/mksh +PKG_MD5SUM:=71c7cbcd78306897801b8b6691091e66 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/mksh + SECTION:=shells + CATEGORY:=Base system + TITLE:=MirBSD Korn Shell + DEPENDS:=$(DEP) + URL:=http://mirbsd.de/mksh +endef + +define Package/mksh/description +mksh is the MirBSD enhanced version of the Public Domain Korn +shell (pdksh), a Bourne-compatible shell which is largely si- +milar to the original AT&T Korn shell; mksh is the only pdksh +derivate currently being actively developed. It includes bug +fixes and feature improvements, in order to produce a modern, +robust shell good for interactive and especially script use. +mksh has UTF-8 support (in substring operations and the Emacs +editing mode) and - while R47 corresponds to OpenBSD 5.1-cur- +rent ksh (without GNU bash-like PS1 and fancy character clas- +ses) - adheres to SUSv4 and is much more robust. The code has +been cleaned up and simplified, bugs fixed, standards compli- +ance added, and several enhancements (for extended compatibi- +lity to other modern shells - as well as a couple of its own) +are available. It has sensible defaults as usual with BSD. +endef + +define Build/Compile + # -DMKSH_SMALL=1 ⇒ reduce functionality quite a lot + # -DMKSH_ASSUME_UTF8=0 ⇒ never automatically enable + # UTF-8 mode, neither use setlocale/nl_langinfo + # nor look at $LC_* and $LANG (not recommended) + # HAVE_CAN_FSTACKPROTECTORALL=0 ⇒ nuke libssp dependency + cd $(PKG_BUILD_DIR); \ + CC="$(TARGET_CC)" \ + TARGET_OS="$(shell uname -s)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + CPPFLAGS="-DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=0" \ + HAVE_CAN_FSTACKPROTECTORALL=0 \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + $(BASH) Build.sh -Q -r -c lto +endef + +define Package/mksh/postinst +#!/bin/sh +grep mksh $${IPKG_INSTROOT}/etc/shells || \ + echo "/bin/mksh" >> $${IPKG_INSTROOT}/etc/shells +endef + +define Package/mksh/install + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) $(PKG_BUILD_DIR)/dot.mkshrc $(1)/etc/mkshrc + $(INSTALL_DIR) $(1)/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/mksh $(1)/bin/ +endef + +define Package/mksh/conffiles +/etc/mkshrc +endef + +$(eval $(call BuildPackage,mksh)) diff --git a/utils/mksh/patches/100-dot_mkshrc b/utils/mksh/patches/100-dot_mkshrc new file mode 100644 index 000000000..7cdd162fc --- /dev/null +++ b/utils/mksh/patches/100-dot_mkshrc @@ -0,0 +1,50 @@ +From 2bee59bb9e6b142a78c94f5e77a54e4e2366c1b8 Mon Sep 17 00:00:00 2001 +From: Thorsten Glaser +Date: Thu, 25 Jul 2013 22:07:33 +0200 +Subject: [PATCH] Make default mkshrc file suitable for OpenWrt environment: + +* Part of the FreeWRT patches: + - no hostname(1) + - ls(1) has no -o option +* OpenWrt and FreeWRT-1.0 fix: + - since this is not ~/.mkshrc make sure subshells find it +--- + dot.mkshrc | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/dot.mkshrc b/dot.mkshrc +index c10b8fd..3a389b2 100644 +--- a/dot.mkshrc ++++ b/dot.mkshrc +@@ -28,8 +28,8 @@ case $KSH_VERSION in + *) return 0 ;; + esac + +-PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(ulimit -c 0; hostname -s \ +- 2>/dev/null)} = *([ ]|localhost) ]] && HOSTNAME=$(ulimit -c 0; hostname \ ++PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(/dev/null); : ${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${TERM:=vt100} + : ${MKSH:=$(whence -p mksh)}; PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${| + local e=$? +@@ -50,7 +50,7 @@ unalias ls + alias l='ls -F' + alias la='l -a' + alias ll='l -l' +-alias lo='l -alo' ++alias lo='l -al' + alias doch='fc -ln -1 | sudo mksh -s' + whence -p rot13 >/dev/null || alias rot13='tr \ + abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \ +@@ -413,4 +413,8 @@ alias cls='print -n \\033c' + + unset p + ++# we need this in OpenWrt for subshells that are not login shells ++: ${ENV=/etc/mkshrc} ++[[ -z $ENV ]] || export ENV ++ + : place customisations above this line +-- +1.8.3.2 + From d341cf9dccafa928873ada7a4e9e656c944e936f Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Thu, 9 Oct 2014 01:22:06 +0200 Subject: [PATCH 2/2] mksh: SECURITY update to R50d - new upstream version - update my eMail address - add maintainer and licence tag Signed-off-by: Thorsten Glaser --- utils/mksh/Makefile | 18 +++++++++++++----- utils/mksh/patches/100-dot_mkshrc | 12 ++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/utils/mksh/Makefile b/utils/mksh/Makefile index 66e8e63a2..89380a927 100644 --- a/utils/mksh/Makefile +++ b/utils/mksh/Makefile @@ -1,6 +1,6 @@ # # Copyright (C) 2007-2011 OpenWrt.org -# Copyright (c) 2009-2013 Thorsten Glaser +# Copyright (c) 2009-2014 Thorsten Glaser # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,12 +9,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mksh -PKG_VERSION:=47 +PKG_VERSION:=50d PKG_RELEASE:=1 +PKG_MAINTAINER:=Thorsten Glaser +PKG_LICENSE:=MirOS + PKG_SOURCE:=$(PKG_NAME)-R$(PKG_VERSION).tgz PKG_SOURCE_URL:=http://www.mirbsd.org/MirOS/dist/mir/mksh -PKG_MD5SUM:=71c7cbcd78306897801b8b6691091e66 +PKG_MD5SUM:=1c3882c07a760b23df1ad94ad0b4ed2e PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) @@ -36,7 +39,7 @@ derivate currently being actively developed. It includes bug fixes and feature improvements, in order to produce a modern, robust shell good for interactive and especially script use. mksh has UTF-8 support (in substring operations and the Emacs -editing mode) and - while R47 corresponds to OpenBSD 5.1-cur- +editing mode) and - while R50 corresponds to OpenBSD 5.5-cur- rent ksh (without GNU bash-like PS1 and fancy character clas- ses) - adheres to SUSv4 and is much more robust. The code has been cleaned up and simplified, bugs fixed, standards compli- @@ -50,13 +53,18 @@ define Build/Compile # -DMKSH_ASSUME_UTF8=0 ⇒ never automatically enable # UTF-8 mode, neither use setlocale/nl_langinfo # nor look at $LC_* and $LANG (not recommended) + # -DMKSH_BINSHPOSIX ⇒ enable POSIX mode if called as sh + #XXX maybe change to -DMKSH_ASSUME_UTF8=1 now (which + #XXX is always assume UTF-8 mode) # HAVE_CAN_FSTACKPROTECTORALL=0 ⇒ nuke libssp dependency + # HAVE_CAN_FSTACKPROTECTORSTRONG=0 ⇒ same, for gcc 4.9+ cd $(PKG_BUILD_DIR); \ CC="$(TARGET_CC)" \ TARGET_OS="$(shell uname -s)" \ CFLAGS="$(TARGET_CFLAGS)" \ - CPPFLAGS="-DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=0" \ + CPPFLAGS="-DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=0 -DMKSH_BINSHPOSIX" \ HAVE_CAN_FSTACKPROTECTORALL=0 \ + HAVE_CAN_FSTACKPROTECTORSTRONG=0 \ LDFLAGS="$(TARGET_LDFLAGS)" \ $(BASH) Build.sh -Q -r -c lto endef diff --git a/utils/mksh/patches/100-dot_mkshrc b/utils/mksh/patches/100-dot_mkshrc index 7cdd162fc..a7bf840b9 100644 --- a/utils/mksh/patches/100-dot_mkshrc +++ b/utils/mksh/patches/100-dot_mkshrc @@ -1,5 +1,5 @@ -From 2bee59bb9e6b142a78c94f5e77a54e4e2366c1b8 Mon Sep 17 00:00:00 2001 -From: Thorsten Glaser +From 23712cea8e2a623fd952eb781df0011c501703d0 Mon Sep 17 00:00:00 2001 +From: Thorsten Glaser Date: Thu, 25 Jul 2013 22:07:33 +0200 Subject: [PATCH] Make default mkshrc file suitable for OpenWrt environment: @@ -13,7 +13,7 @@ Subject: [PATCH] Make default mkshrc file suitable for OpenWrt environment: 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dot.mkshrc b/dot.mkshrc -index c10b8fd..3a389b2 100644 +index 233a10c..caf482c 100644 --- a/dot.mkshrc +++ b/dot.mkshrc @@ -28,8 +28,8 @@ case $KSH_VERSION in @@ -33,10 +33,10 @@ index c10b8fd..3a389b2 100644 alias ll='l -l' -alias lo='l -alo' +alias lo='l -al' - alias doch='fc -ln -1 | sudo mksh -s' + alias doch='sudo mksh -c "$(fc -ln -1)"' whence -p rot13 >/dev/null || alias rot13='tr \ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \ -@@ -413,4 +413,8 @@ alias cls='print -n \\033c' +@@ -402,4 +402,8 @@ alias cls='print -n \\033c' unset p @@ -46,5 +46,5 @@ index c10b8fd..3a389b2 100644 + : place customisations above this line -- -1.8.3.2 +2.1.1