Skip to content

[BUG] Whitespaces unnaccounted for on launch and desktop file scripts #37

@saltachin

Description

@saltachin

Preface

I'm unaware of any issue template suggested for this repo, apologies if I missed it.

Issue

The bash script responsible for generating the desktop file script (make-desktop-file.sh) puts the raw output of the pwd command as a prefix for the launch script.

#!/bin/sh

FILENAME="oplpctools.desktop"
rm -f "${FILENAME}"

echo "[Desktop Entry]" > "${FILENAME}"
echo "Exec=`pwd`/oplpctools.sh" >> "${FILENAME}"
echo "Icon=`pwd`/images/icon.png" >> "${FILENAME}"

# (...)

The FreeDesktop specification for the Exec key of Desktop Files specifies that an unquoted space is a reserved character for delimiting arguments to the executable. This means that if the desktop file generation script runs under a path with whitespaces, the resulting desktop file is ill-redacted.

A possible fix incurs in quoting the path to the launch script so whitespaces are accounted for:

#!/bin/sh

FILENAME="oplpctools.desktop"
rm -f "${FILENAME}"

echo "[Desktop Entry]" > "${FILENAME}"
echo "Exec=\"`pwd`/oplpctools.sh\"" >> "${FILENAME}"
echo "Icon=`pwd`/images/icon.png" >> "${FILENAME}"

# (...)

A similar error can be observed on the launch script (oplpctools.sh). When invoked indirectly through a functional desktop file, the BINDIR variable can be ill-constructed following the raw output from dirname, which doesn't account for whitespaces either:

#!/bin/sh

BINDIR="$(dirname $0)/bin"

LD_LIBRARY_PATH="$BINDIR" "$BINDIR/oplpctools"

Similary, a possible fix incurs in quoting the $0 expansion representing the script's path, and preceding it with -- to safeguard against paths starting with dashes (which would register arguments incorrectly):

#!/bin/sh

BINDIR="$(dirname -- "$0")/bin"

LD_LIBRARY_PATH="$BINDIR" "$BINDIR/oplpctools"

To Reproduce

My system information as reported by inxi -SG:

System:
  Host: hp-laptop Kernel: 6.12.69+deb13-amd64 arch: x86_64 bits: 64
  Desktop: KDE Plasma v: 6.3.6 Distro: Debian GNU/Linux 13 (trixie)
Graphics:
  Device-1: Intel TigerLake-LP GT2 [Iris Xe Graphics] driver: i915 v: kernel
  Device-2: Luxvisions Innotech HP TrueVision HD Camera driver: uvcvideo
    type: USB
  Display: wayland server: X.org v: 1.21.1.16 with: Xwayland v: 24.1.6
    compositor: kwin_wayland driver: X: loaded: modesetting unloaded: fbdev,vesa
    dri: iris gpu: i915 resolution: 1920x1080~60Hz
  API: EGL v: 1.5 drivers: iris,swrast
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 25.0.7-2
    renderer: Mesa Intel Iris Xe Graphics (TGL GT2)
  API: Vulkan v: 1.4.309 drivers: intel,llvmpipe surfaces: xcb,xlib,wayland
  Info: Tools: api: clinfo, eglinfo, glxinfo, vulkaninfo
    de: kscreen-console,kscreen-doctor gpu: gputop, intel_gpu_top, lsgpu
    wl: wayland-info x11: xdriinfo, xdpyinfo, xprop, xrandr

Steps:

  1. Download the latest v3.1 release. I opted for the oplpctools_linux_3.1_amd64.tar.gz artifact.
  2. Extract the contents to a path with whitespaces on it
  3. Attempt to run the make-desktop-file.sh script
  4. After attempting proposed fix to said script, attempt to launch the generated oplpctools.desktop desktop file from your dekstop, or any other appropiate location
  5. After attempting the proposed fix to oplpctools.sh, review proper functionality by launching said script directly, or indirectly through the generated desktop file

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions