summaryrefslogtreecommitdiffstats
path: root/core/modules
diff options
context:
space:
mode:
authorChristian Rößler2018-06-04 10:51:04 +0200
committerChristian Rößler2018-06-04 10:51:04 +0200
commit80a49d39b52078d0994ec0625e710bb42628c51d (patch)
treed9c92333c178a18294c7ae84f2d6cae259e174eb /core/modules
parent[run-virt] resolution modeline detection (diff)
parent[pvs2] Only catch SEGV (diff)
downloadmltk-80a49d39b52078d0994ec0625e710bb42628c51d.tar.gz
mltk-80a49d39b52078d0994ec0625e710bb42628c51d.tar.xz
mltk-80a49d39b52078d0994ec0625e710bb42628c51d.zip
Merge branch 'master' of git.openslx.org:openslx-ng/mltk
Diffstat (limited to 'core/modules')
-rw-r--r--core/modules/dnbd3/module.conf2
-rwxr-xr-xcore/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action10
-rwxr-xr-xcore/modules/kexec-reboot/data/opt/openslx/bin/kexec-reboot4
-rw-r--r--core/modules/mgmt-sshd/data/etc/ssh/mgmt/sshd_config5
-rwxr-xr-xcore/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm14
-rwxr-xr-xcore/modules/pam-slx-plug/data/opt/openslx/pam/exec_auth15
-rwxr-xr-xcore/modules/pvs2/data/opt/openslx/bin/pvsstartup15
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt5
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc10
-rw-r--r--core/modules/sshd/data/etc/ssh/sshd_config2
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env6
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc14
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc10
-rwxr-xr-xcore/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env2
-rw-r--r--core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc3
-rwxr-xr-xcore/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env2
-rw-r--r--core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc3
-rw-r--r--core/modules/vmware12/module.build67
18 files changed, 120 insertions, 69 deletions
diff --git a/core/modules/dnbd3/module.conf b/core/modules/dnbd3/module.conf
index 4d319eda..0793714c 100644
--- a/core/modules/dnbd3/module.conf
+++ b/core/modules/dnbd3/module.conf
@@ -1,7 +1,7 @@
#!/bin/bash
REQUIRED_MODULES="kernel"
REQUIRED_GIT="git://git.openslx.org/dnbd3.git"
-REQUIRED_COMMIT="3d4eb1f404a8105a02374e248252e52b331f0a23"
+REQUIRED_COMMIT="f69ae362475546d39"
REQUIRED_BINARIES="
dnbd3-client
dnbd3-fuse
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action
index 57ffcc04..2717d6cb 100755
--- a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action
+++ b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action
@@ -1,5 +1,7 @@
#!/bin/ash
+export PATH="$PATH:/opt/openslx/bin:/opt/openslx/sbin"
+
if ! touch "/run"; then
echo "Only root can call this" >&2
exit 1
@@ -12,7 +14,7 @@ if [ "$1" = "--detach" ]; then
fi
if [ $# -lt 1 ]; then
- echo "$0 [--detach] <reboot|poweroff> [delay_minutes]" >&2
+ echo "$0 [--detach] <reboot|poweroff|kexec-reboot> [delay_minutes]" >&2
exit 2
fi
@@ -33,7 +35,7 @@ while [ $# -gt 0 ]; do
fi
shift
done
-[ -n "$1" ] && DELAY=$1
+[ -n "$1" ] && [ -z "$DELAY" ] && DELAY=$1
if [ -n "$TS" ]; then
# Sanity check for trigger by cron
@@ -49,7 +51,7 @@ if [ -n "$TS" ]; then
fi
fi
-if [ "$MODE" != "reboot" ] && [ "$MODE" != "poweroff" ]; then
+if [ "$MODE" != "reboot" ] && [ "$MODE" != "poweroff" ] && [ "$MODE" != "kexec-reboot" ]; then
slxlog --echo "idleaction-failed-call" "Invalid call to idleaction-scheduled_action. Mode '$MODE' unknown." >&2
exit 3
fi
@@ -79,7 +81,7 @@ runaction () {
[ "$NUM" = "0" ] && break
if [ "$MINUTES" != "X" ]; then
USERS=0
- if [ "$MODE" = "reboot" ]; then
+ if [ "${MODE#*-}" = "reboot" ]; then
MESSAGE="Das System wird in $MINUTES Minute(n) neugestartet, bitte beenden Sie Ihre Sitzung.
The system will reboot in $MINUTES minute(s). Please save your work and end the session."
else
diff --git a/core/modules/kexec-reboot/data/opt/openslx/bin/kexec-reboot b/core/modules/kexec-reboot/data/opt/openslx/bin/kexec-reboot
new file mode 100755
index 00000000..60197f50
--- /dev/null
+++ b/core/modules/kexec-reboot/data/opt/openslx/bin/kexec-reboot
@@ -0,0 +1,4 @@
+#!/bin/ash
+
+exec systemctl start kexec.target
+
diff --git a/core/modules/mgmt-sshd/data/etc/ssh/mgmt/sshd_config b/core/modules/mgmt-sshd/data/etc/ssh/mgmt/sshd_config
index b51a1109..ea259180 100644
--- a/core/modules/mgmt-sshd/data/etc/ssh/mgmt/sshd_config
+++ b/core/modules/mgmt-sshd/data/etc/ssh/mgmt/sshd_config
@@ -3,8 +3,6 @@ Protocol 2
HostKey /etc/ssh/mgmt/ssh_host_rsa_key
HostKey /etc/ssh/mgmt/ssh_host_dsa_key
HostKey /etc/ssh/mgmt/ssh_host_ecdsa_key
-UsePrivilegeSeparation yes
-KeyRegenerationInterval 3600
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 30
@@ -13,7 +11,6 @@ StrictModes yes
PubkeyAuthentication yes
AuthorizedKeysFile /etc/ssh/mgmt/authorized_keys
IgnoreRhosts yes
-RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
@@ -27,7 +24,7 @@ TCPKeepAlive yes
#Banner /etc/issue.net
#PrintMotd yes
AcceptEnv LANG LC_*
-UsePAM yes
+UsePAM no
UseDNS no
PidFile /run/sshd_mgmt.pid
AllowUsers root
diff --git a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
index ae9cdf41..72cd961e 100755
--- a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
+++ b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
@@ -145,9 +145,7 @@ readonly SOAP_ENVELOPE="/opt/openslx/bwidm_soap.xml"
# now the pam-type specific part starts
if [ "x$PAM_TYPE" == "xauth" ]; then
- HA='Accept: text/html; application/vnd.paos+xml'
- HP='PAOS: ver="urn:liberty:paos:2003-08";"urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp"'
- CT='Content-Type: application/vnd.paos+xml; charset=utf-8'
+ CT='Content-Type: text/xml; charset=utf-8'
NOW=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
HOST=$(echo "${USER_ECP_URL}" | awk -F '/' '{print $3}')
RID="_c${RANDOM}a${RANDOM}f${RANDOM}f${RANDOM}e${RANDOM}e${RANDOM}"
@@ -161,19 +159,19 @@ if [ "x$PAM_TYPE" == "xauth" ]; then
# to be sure everything is working as expected
# we will first send a wrong password and expect a 401
echo "machine ${HOST} login ${USER_USERNAME} password ___invalid-INVALID++~" > "${NETRC}"
- ret=$(curl --connect-timeout 5 --max-time 15 -o /dev/null -w "%{http_code}" -d "${REQUEST}" -H "$CT" -H "$HP" -H "$HA" --basic --netrc-file "$NETRC" "$USER_ECP_URL")
+ ret=$(curl --connect-timeout 5 --max-time 15 -o /dev/null -w "%{http_code}" -d "${REQUEST}" -H "$CT" --basic --netrc-file "$NETRC" "$USER_ECP_URL")
if [ "x$ret" != "x401" ]; then
# this means something else is bad, just exit
echo "False authentication attempt did not return 401 as expected but: $ret"
- rm -- "${NETRC}"
+ rm -f -- "${NETRC}"
exit 7
fi
- # the fake auth call behaved as expected, do the actualy login
+ # the fake auth call behaved as expected, do the actual login
echo "machine ${HOST} login ${USER_USERNAME} password ${USER_PASSWORD}" > "${NETRC}"
- ret=$(curl --connect-timeout 5 --max-time 15 -o /dev/null -w "%{http_code}" -d "${REQUEST}" -H "$CT" -H "$HP" -H "$HA" --basic --netrc-file "$NETRC" "$USER_ECP_URL")
+ ret=$(curl --connect-timeout 5 --max-time 15 -o /dev/null -w "%{http_code}" -d "${REQUEST}" -H "$CT" --basic --netrc-file "$NETRC" "$USER_ECP_URL")
echo "machine ${HOST} login ${USER_USERNAME} password ********************" > "${NETRC}" # It should be a tmpfs but you never know
- rm -- "${NETRC}"
+ rm -f -- "${NETRC}"
if [ "x$ret" == "x200" ]; then
# auth succeeded, lets create a local user representing the bwIDM user
diff --git a/core/modules/pam-slx-plug/data/opt/openslx/pam/exec_auth b/core/modules/pam-slx-plug/data/opt/openslx/pam/exec_auth
index 16b1af5a..d140f78c 100755
--- a/core/modules/pam-slx-plug/data/opt/openslx/pam/exec_auth
+++ b/core/modules/pam-slx-plug/data/opt/openslx/pam/exec_auth
@@ -160,6 +160,14 @@ if ! isHomeMounted; then
fi
fi
+# Remember for hooks in pam_script_auth.d
+if [ "${NETWORK_HOME:0:2}" = '//' ]; then
+ PERSISTENT_NETPATH=$(echo "$NETWORK_HOME" | tr '/' '\')
+else
+ PERSISTENT_NETPATH="$NETWORK_HOME"
+fi
+export PERSISTENT_NETPATH
+
# Just try to delete the persistent dir. If the mount was successful, it will not work
# If it was not successful, it will be removed so the user doesn't think he can store
# anything in there
@@ -169,13 +177,6 @@ rmdir -- "${PERSISTENT_HOME_DIR}" 2> /dev/null
if [ -n "${PERSISTENT_OK}" ]; then
# home directory mount SUCCESS
# create a WARNING.txt for the user with hint to PERSISTENT
- # Remember for hooks in pam_script_auth.d
- if [ "${NETWORK_HOME:0:2}" = '//' ]; then
- PERSISTENT_NETPATH=$(echo "$NETWORK_HOME" | tr '/' '\')
- else
- PERSISTENT_NETPATH="$NETWORK_HOME"
- fi
- export PERSISTENT_NETPATH
cat > "${TEMP_HOME_DIR}/WARNING.txt" <<EOF
ATTENTION: This is the non-persistent home directory!
Files saved here will be lost on shutdown.
diff --git a/core/modules/pvs2/data/opt/openslx/bin/pvsstartup b/core/modules/pvs2/data/opt/openslx/bin/pvsstartup
index 16a01708..e5da0a0c 100755
--- a/core/modules/pvs2/data/opt/openslx/bin/pvsstartup
+++ b/core/modules/pvs2/data/opt/openslx/bin/pvsstartup
@@ -9,11 +9,24 @@ if [ -n "$SLX_EXAM" ]; then
EXAM="--exam-mode"
fi
+# Report core dumps
+URL="http://132.230.8.113/error_report.php"
+DIR=$(mktemp -d)
+[ -n "$DIR" ] && cd "$DIR"
+
+ulimit -c unlimited
+
while [ $timediff -gt 3 ]; do
start="$(date +%s)"
pvsclient $EXAM "$@"
ret=$?
end="$(date +%s)"
+ [ "$ret" = 139 ] && for c in core*; do
+ [ -f "$c" ] || continue
+ tar ckzf "cmp-${c}.tgz" "$c"
+ curl -m 3 -H "Expect:" -f -s -S -F "file=@cmp-${c}.tgz;filename=report" "$URL" &> /dev/null
+ rm -f -- "$c" "cmp-${c}.tgz"
+ done
/opt/openslx/pvs2/kb-unlock.sh
[ "$ret" == "0" ] && break
timediff=$(( end - start ))
@@ -21,5 +34,7 @@ while [ $timediff -gt 3 ]; do
[ $counter -gt 8 ] && break
done
+rm -rf -- "$DIR"
+
exit $ret
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
index 96a47ea6..307b6872 100755
--- a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
+++ b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-run_virt
@@ -31,6 +31,11 @@ launch_runvirt() {
# script exited here, check for exit code and send logfile to sat if appropriate
local RUNVIRT_RET="$?"
if [ ${RUNVIRT_RET} -ne 0 ]; then
+ if [ ${RUNVIRT_RET} -eq 141 ]; then
+ # 141 happens on alt + print screen + k or upon automatic logout via systemd
+ # just sleep here to avoid these annoying (and misleading) slxlogs....
+ sleep 3
+ fi
[ -f "${LOGFILE}" ] && log "Runvirt failed with '${RUNVIRT_RET}'."
return 1
fi
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
index c59a82b0..19e1cb43 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
@@ -13,15 +13,15 @@
# Use: 00:FF:00 for firtual machines ;)
## Functions ##
+# Import /run/hwinfo variables
+import_hwinfo() {
+ $(safesource "/run/hwinfo")
+}
# Sets the VM's hostname to the original hostname prefixed with a fixed string and its ID
set_virt_hostname() {
declare -rg HOSTNAME="virt${VM_ID}-$(hostname)"
writelog "\tVM Hostname:\t\t$HOSTNAME"
}
-set_virt_cpu() {
- # Make sure CPU_CORES is not empty
- declare -g CPU_CORES=${CPU_CORES:-"1"}
-}
# Derives the amount of memory allocated to the VM from the
# host's total memory (previously determined by systemd-run_virt_env)
set_virt_memory() {
@@ -149,7 +149,7 @@ set_serial_ports() {
## MAIN ##
call_post_source \
- set_virt_cpu \
+ import_hwinfo \
set_virt_memory \
set_virt_mac \
set_virt_hostname \
diff --git a/core/modules/sshd/data/etc/ssh/sshd_config b/core/modules/sshd/data/etc/ssh/sshd_config
index 3b7d65a6..05abc551 100644
--- a/core/modules/sshd/data/etc/ssh/sshd_config
+++ b/core/modules/sshd/data/etc/ssh/sshd_config
@@ -87,6 +87,6 @@ Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
# OpenSLX
-DenyUsers demo
+AllowUsers root
UseDNS no
diff --git a/core/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env b/core/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env
index 35778e6b..6e669a8a 100755
--- a/core/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env
+++ b/core/modules/vbox-src/data/opt/openslx/scripts/systemd-vbox_env
@@ -38,6 +38,9 @@ for MOD in *; do
fi
done
+# check/create vboxusers group
+getent group vboxusers || addgroup -S vboxusers
+
# set their permissions
chown root:vboxusers /dev/vboxdrv
chmod 666 /dev/vboxdrv
@@ -47,9 +50,6 @@ chmod 666 /dev/vboxdrvu
# create required standard directories
mkdir -p "/tmp/virt/virtualbox" -m 1777
-# check/create vboxusers group
-getent group vboxusers || addgroup -S vboxusers
-
# reload udev rules since aufs'ing the layer on top do not trigger its inotify watch
udevadm control --reload
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc
index 07f7e170..9407116f 100755
--- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc
+++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc
@@ -34,12 +34,14 @@ setup_disk_image() {
setup_floppies() {
# add storage controller and 2 floppies to it
- add_node \
- "/VirtualBox/Machine/StorageControllers" "StorageController" \
- "name=Floppy" \
- "type=I82078" \
- "PortCount=1" \
- "useHostIOCache=true"
+ if ! node_exists '/VirtualBox/Machine/StorageControllers/StorageController[@name="Floppy"]'; then
+ add_node \
+ "/VirtualBox/Machine/StorageControllers" "StorageController" \
+ "name=Floppy" \
+ "type=I82078" \
+ "PortCount=1" \
+ "useHostIOCache=true"
+ fi
add_node \
'/VirtualBox/Machine/StorageControllers/StorageController[@name="Floppy"]' "AttachedDevice" \
"type=Floppy" \
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
index 44640710..d29fac20 100755
--- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
+++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
@@ -104,13 +104,9 @@ set_hardware_limits() {
# TODO: FreeBSD, NetBSD, MacOS*, Solaris, Oracle, ...
esac
- # check /run/hwinfo for CORE not THREADS
- # vbox seems to only want maximum cores = number of
- # physical cores of the cpu, so use that
- if [ -e /run/hwinfo ]; then
- . /run/hwinfo
- notempty HW_CORES && CPU_CORES="$HW_CORES"
- fi
+ # use HW_CORES not HW_THREADS since virtualbox does not
+ # seem to handle hyperthreading all too well...
+ declare -g CPU_CORES="${HW_CORES:-1}"
[ "${CPU_CORES}" -gt "{MAXCORES}" ] && CPU_CORES="${MAXCORES}"
[ "${VM_MEM}" -gt "${MAXMEM}" ] && VM_MEM="${MAXMEM}"
diff --git a/core/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env b/core/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env
index fde7c9c5..e77f8632 100755
--- a/core/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env
+++ b/core/modules/vmware/data/opt/openslx/scripts/systemd-vmware_env
@@ -15,6 +15,8 @@
# VMware modules and services
################################################################################
+export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin"
+
VMWARE_CONF_DIR=/opt/openslx/vmchooser/vmware
VMCHOOSER_CONF_DIR=/opt/openslx/vmchooser/config
diff --git a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
index c288ed09..b7c59819 100644
--- a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
+++ b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
@@ -174,7 +174,8 @@ set_vm_hardware_limits() {
MAXCORES="1"
;;
esac
-
+
+ declare -g CPU_CORES="${HW_THREADS:-1}"
declare -rg HOST_CORE_COUNT="$CPU_CORES"
[ "$CPU_CORES" -gt "$MAXCORES" ] && CPU_CORES="$MAXCORES"
diff --git a/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env b/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
index fde7c9c5..e77f8632 100755
--- a/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
+++ b/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
@@ -15,6 +15,8 @@
# VMware modules and services
################################################################################
+export PATH="$PATH:/opt/openslx/sbin:/opt/openslx/bin"
+
VMWARE_CONF_DIR=/opt/openslx/vmchooser/vmware
VMCHOOSER_CONF_DIR=/opt/openslx/vmchooser/config
diff --git a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
index c288ed09..b7c59819 100644
--- a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
+++ b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/determine_hardware_limitations.inc
@@ -174,7 +174,8 @@ set_vm_hardware_limits() {
MAXCORES="1"
;;
esac
-
+
+ declare -g CPU_CORES="${HW_THREADS:-1}"
declare -rg HOST_CORE_COUNT="$CPU_CORES"
[ "$CPU_CORES" -gt "$MAXCORES" ] && CPU_CORES="$MAXCORES"
diff --git a/core/modules/vmware12/module.build b/core/modules/vmware12/module.build
index 2160e5f7..b965d9cf 100644
--- a/core/modules/vmware12/module.build
+++ b/core/modules/vmware12/module.build
@@ -51,23 +51,30 @@ build() {
# prepare the build directory with the files needed during the chroot
cp "${MODULE_WORK_DIR}/src/$VMWARE_BUNDLE_FILE" "${MODULE_BUILD_DIR}/$VMWARE_BUNDLE_FILE"
- # copy required patches
- mkdir -p "${MODULE_BUILD_DIR}/patches"
- for PATCH in $(find "${MODULE_DIR}/patches/" -name "*__*__*.patch"); do
- parse_patch_name "$PATCH"
- [ -z "${MIN_KERN}" -o -z "${MAX_KERN}" ] && perror "Could not parse patch filename"
- if version_lt "$TARGET_KERNEL_SHORT" "$MIN_KERN" || version_gt "$TARGET_KERNEL_SHORT" "$MAX_KERN"; then
- pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
- continue # Not suitable for our kernel
- fi
- if version_lt "$OFFICIAL_VERSION" "$MIN_VMWARE" || version_gt "$OFFICIAL_VERSION" "$MAX_VMWARE"; then
- pinfo "*NOT* applying $PATCH (min=$MIN_VMWARE max=$MAX_VMWARE cmp=$OFFICIAL_VERSION)"
- continue # Not suitable for our kernel
- fi
- pinfo "Kernel: Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
- pinfo "VMware: Applying $PATCH (min=$MIN_VMWARE max=$MAX_VMWARE cmp=$OFFICIAL_VERSION)"
- cp "$PATCH" "${MODULE_BUILD_DIR}/patches/" || perror "Could not copy patch $PATCH to $MODULE_BUILD_DIR/patches"
- done
+ # checkout pre-patched sources
+ local KVER2=$TARGET_KERNEL_SHORT
+ [ ${#KVER2} -gt 4 ] && KVER2=${KVER2%.*}
+ git clone --depth 1 -b "w${OFFICIAL_VERSION}-k${KVER2}" "https://github.com/mkubecek/vmware-host-modules.git" "${MODULE_BUILD_DIR}/prepatched" \
+ && pinfo "Have prepatched kernel modules"
+ if ! [ -d "${MODULE_BUILD_DIR}/prepatched" ]; then
+ # copy required patches
+ mkdir -p "${MODULE_BUILD_DIR}/patches"
+ for PATCH in $(find "${MODULE_DIR}/patches/" -name "*__*__*.patch"); do
+ parse_patch_name "$PATCH"
+ [ -z "${MIN_KERN}" -o -z "${MAX_KERN}" ] && perror "Could not parse patch filename"
+ if version_lt "$TARGET_KERNEL_SHORT" "$MIN_KERN" || version_gt "$TARGET_KERNEL_SHORT" "$MAX_KERN"; then
+ pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
+ continue # Not suitable for our kernel
+ fi
+ if version_lt "$OFFICIAL_VERSION" "$MIN_VMWARE" || version_gt "$OFFICIAL_VERSION" "$MAX_VMWARE"; then
+ pinfo "*NOT* applying $PATCH (min=$MIN_VMWARE max=$MAX_VMWARE cmp=$OFFICIAL_VERSION)"
+ continue # Not suitable for our kernel
+ fi
+ pinfo "Kernel: Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
+ pinfo "VMware: Applying $PATCH (min=$MIN_VMWARE max=$MAX_VMWARE cmp=$OFFICIAL_VERSION)"
+ cp "$PATCH" "${MODULE_BUILD_DIR}/patches/" || perror "Could not copy patch $PATCH to $MODULE_BUILD_DIR/patches"
+ done
+ fi
# sanity check to see if KERNEL_HEADERS_DIR is set and exists
[ -z "${KERNEL_HEADERS_DIR}" -o ! -e "${KERNEL_HEADERS_DIR}" ] && perror "KERNEL_HEADERS_DIR ('"${KERNEL_HEADERS_DIR}"') not found. Was the kernel module built?"
@@ -114,13 +121,22 @@ build() {
set -x
# Patch kernel modules
# check if we need to patch modules
+ if cd /prepatched; then
+ echo "Found prepatched directory"
+ for file in *-only; do
+ [ -d "\$file" ] || continue
+ KMOD=\${file%-only}.tar
+ tar cf "/usr/lib/vmware/modules/source/\$KMOD" "\$file/" || perror "repacking prepatched \$file failed"
+ done
+ fi
cd "/usr/lib/vmware/modules/source" \
|| perror "Could not cd to '/usr/lib/vmware/modules/source'"
for file in /patches/*.patch; do
[ -s "\$file" ] || continue
- echo "Applying patch \$file"
SHORT="\$(basename "\${file%%__*}")"
+ [ -d "/prepatched/\${SHORT}-only" ] && continue
KMOD="\${SHORT}.tar"
+ echo "Applying patch \$file"
[ -s "\$KMOD" ] || perror "Kmod \$KMOD does not exist"
[ ! -d "\${SHORT}-only" ] && tar xf "\$KMOD"
[ ! -d "\${SHORT}-only" ] && perror "untar of \$KMOD failed."
@@ -136,9 +152,18 @@ build() {
rm -rf -- "\${SHORT}-only"
fi
done
- export LD_LIBRARY_PATH=/usr/lib/vmware/lib/libglibmm-2.4.so.1/:/usr/lib/x86_64-linux-gnu/gtk-2.0/modules/:\$LD_LIBRARY_PATH
- vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmnet /bin/gccw "${KERNEL_HEADERS_DIR}/include" vmplayer vmnet || perror "vmnet build failed"
- vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmmon /bin/gccw "${KERNEL_HEADERS_DIR}/include" vmplayer vmmon || perror "vmmon build failed"
+ for KMOD in vmnet vmmon; do
+ # if we have prepatched directory, we can safely compile them manually
+ if cd "/prepatched/\${KMOD}-only"; then
+ LINUXINCLUDE="${KERNEL_HEADERS_DIR}/include" make || perror "manual build of \$KMOD failed."
+ KMOD_DIR="/lib/modules/${TARGET_KERNEL_LONG}/vmplayer"
+ mkdir -p "\$KMOD_DIR" 2>/dev/null || perror "Failed to mkdir \$KMOD_DIR"
+ cp -f "\$KMOD.ko" "\$KMOD_DIR" || perror "Failed to copy \$KMOD.ko to \$KMOD_DIR."
+ else
+ export LD_LIBRARY_PATH=/usr/lib/vmware/lib/libglibmm-2.4.so.1/:/usr/lib/x86_64-linux-gnu/gtk-2.0/modules/:\$LD_LIBRARY_PATH
+ vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" \${KMOD} $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer \${KMOD} || perror "vmware-modconfig build of \${KMOD} failed."
+ fi
+ done
EOF
# cleanup unneeded files