summary refs log tree commit diff
path: root/pkgs/applications/misc/ipmiview
diff options
context:
space:
mode:
authorLászló Vaskó <vlaci@balabit.hu>2019-09-25 09:10:41 +0200
committerLászló Vaskó <vlaci@balabit.hu>2019-09-25 09:59:25 +0200
commit15b847821191b5fe80c836cdf7146448603a8928 (patch)
tree435e8287922e3a6d3ea6ba96f834fc438ab6809f /pkgs/applications/misc/ipmiview
parent13cd9e1bf3fd12458d201f7908898b3ee7c5bb20 (diff)
downloadnixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar.gz
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar.bz2
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar.lz
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar.xz
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.tar.zst
nixpkgs-15b847821191b5fe80c836cdf7146448603a8928.zip
IPMIView: fix iKVM console
This commit fixes #26650

The main problem was that the iKVM related libraries are always loaded
from the current working directory. The bundled wrapper script makes
sure to CD to the package root folder. This is a no-go in nix as the
application writes its settings in the current working directory and the
store is read-only.

Workaround: create a directory in the users home, where the required
binaries are symlinked and is writable for the current user.

There was an additional issue that for some BMCs IPMIView relies on
the bundled `stunnel` binary to wrap the iKVM traffic in a TLS tunnel.
Therefore it has to be patched to make it executable and the `killall`
command is needed on the PATH because it is used to terminate the
`stunnel` process upon exit.
Diffstat (limited to 'pkgs/applications/misc/ipmiview')
-rw-r--r--pkgs/applications/misc/ipmiview/default.nix32
1 files changed, 28 insertions, 4 deletions
diff --git a/pkgs/applications/misc/ipmiview/default.nix b/pkgs/applications/misc/ipmiview/default.nix
index 17b552a141b..774b84947da 100644
--- a/pkgs/applications/misc/ipmiview/default.nix
+++ b/pkgs/applications/misc/ipmiview/default.nix
@@ -1,4 +1,14 @@
-{ stdenv, fetchurl, patchelf, makeWrapper, xorg, fontconfig, freetype, gcc, gcc-unwrapped }:
+{ stdenv
+, fetchurl
+, makeWrapper
+, patchelf
+, fontconfig
+, freetype
+, gcc
+, gcc-unwrapped
+, iputils
+, psmisc
+, xorg }:
 
 stdenv.mkDerivation rec {
   pname = "IPMIView";
@@ -11,12 +21,18 @@ stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [ patchelf makeWrapper ];
-
-  buildPhase = with xorg; ''
+  buildPhase = with xorg;
+    let
+      stunnelBinary = if stdenv.hostPlatform.system == "x86_64-linux" then "linux/stunnel64"
+      else if stdenv.hostPlatform.system == "i686-linux" then "linux/stunnel32"
+      else throw "IPMIView is not supported on this platform";
+    in
+  ''
     patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ libX11 libXext libXrender libXtst libXi ]}" ./jre/lib/amd64/libawt_xawt.so
     patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ freetype ]}" ./jre/lib/amd64/libfontmanager.so
     patchelf --set-rpath "${gcc-unwrapped.lib}/lib" ./libiKVM64.so
     patchelf --set-rpath "${gcc.cc}/lib:$out/jre/lib/amd64/jli" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./jre/bin/java
+    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ./BMCSecurity/${stunnelBinary}
   '';
 
   installPhase = ''
@@ -24,14 +40,22 @@ stdenv.mkDerivation rec {
     cp -R . $out/
 
     # LD_LIBRARY_PATH: fontconfig is used from java code
+    # PATH: iputils is used for ping, and psmisc is for killall
+    # WORK_DIR: unfortunately the ikvm related binaries are loaded from
+    #           and user configuration is written to files in the CWD
     makeWrapper $out/jre/bin/java $out/bin/IPMIView \
       --set LD_LIBRARY_PATH "${stdenv.lib.makeLibraryPath [ fontconfig ]}" \
-      --prefix PATH : "$out/jre/bin" \
+      --prefix PATH : "$out/jre/bin:${iputils}/bin:${psmisc}/bin" \
       --add-flags "-jar $out/IPMIView20.jar" \
+      --run 'WORK_DIR=''${XDG_DATA_HOME:-~/.local/share}/ipmiview
+             mkdir -p $WORK_DIR
+             ln -snf '$out'/iKVM.jar '$out'/libiKVM* '$out'/libSharedLibrary* $WORK_DIR
+             cd $WORK_DIR'
   '';
 
   meta = with stdenv.lib; {
     license = licenses.unfree;
     maintainers = with maintainers; [ vlaci ];
+    platforms = [ "x86_64-linux" "i686-linux" ];
   };
 }