Skip to content

Commit

Permalink
Fix pdfopener
Browse files Browse the repository at this point in the history
- change path to absolute for realpath
- allow business-vm to open pdfs

Signed-off-by: Manuel Bluhm <[email protected]>
  • Loading branch information
mbssrc authored and brianmcgillion committed Sep 13, 2024
1 parent 8101247 commit 89accf2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/reference/appvms/business.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ in
mimeTypes = [ "application/pdf" ];
};
xdgOpenPdf = pkgs.writeShellScriptBin "xdgopenpdf" ''
filepath=$(realpath "$1")
filepath=$(/run/current-system/sw/bin/realpath "$1")
echo "Opening $filepath" | systemd-cat -p info
echo $filepath | ${pkgs.netcat}/bin/nc -N gui-vm ${toString xdgPdfPort}
'';
Expand Down
2 changes: 1 addition & 1 deletion modules/reference/appvms/chromium.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ in
mimeTypes = [ "application/pdf" ];
};
xdgOpenPdf = pkgs.writeShellScriptBin "xdgopenpdf" ''
filepath=$(realpath "$1")
filepath=$(/run/current-system/sw/bin/realpath "$1")
echo "Opening $filepath" | systemd-cat -p info
echo $filepath | ${pkgs.netcat}/bin/nc -N gui-vm ${toString xdgPdfPort}
'';
Expand Down
7 changes: 4 additions & 3 deletions packages/openPdf/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ writeShellApplication {
read -r sourcepath
filename=$(basename "$sourcepath")
zathurapath="/var/tmp/$filename"
chromiumip=$(dig +short chromium-vm | head -1)
chromiumvmip=$(dig +short chromium-vm | head -1)
businessvmip=$(dig +short business-vm | head -1)
if [[ "$chromiumip" != "$REMOTE_ADDR" ]]; then
echo "Open PDF request received from $REMOTE_ADDR, but it is only permitted for chromium-vm with IP $chromiumip"
if [[ "$chromiumvmip" != "$REMOTE_ADDR" && "$businessvmip" != "$REMOTE_ADDR" ]]; then
echo "Open PDF request received from $REMOTE_ADDR, but it is only permitted for chromium-vm or business-vm"
exit 0
fi
Expand Down

0 comments on commit 89accf2

Please sign in to comment.