AppImageCrafters / appimage-builder

GNU/Linux packaging solution using the AppImage format
MIT License
308 stars 58 forks source link

Can't execute binaries with sudo inside AppImage - "command not found" #353

Open spvkgn opened 5 months ago

spvkgn commented 5 months ago

Sample AppImageBuilder.yml:

version: 1

AppDir:
  path: ./AppDir

  app_info:
    id: org.gnu.bash
    name: bash
    icon: utilities-terminal
    version: 5.0.16
    exec: bin/bash
    exec_args: $@

  apt:
    arch: amd64
    allow_unauthenticated: true
    sources:
      - sourceline: 'deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse'

    include:
      - bash
      - coreutils
    exclude:
      - libpcre3

AppImage:
  arch: x86_64
  comp: gzip

The AppImage is successfully built:

$ ./bash-5.0.16-x86_64.AppImage --version | head -n1
GNU bash, версия 5.0.16(1)-release (x86_64-pc-linux-gnu)

Execute any binary inside AppImage:

$APPDIR/usr/bin/head -n1 /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"

But when I try to execute it with sudo - it fails with error "command not found":

sudo $APPDIR/usr/bin/head -n1 /etc/os-release
[sudo] пароль для pavel:
sudo: /tmp/.mount_bash-4mDX6hg/usr/bin/head: команда не найдена
LC_ALL=C sudo $APPDIR/usr/bin/head -n1 /etc/os-release
[sudo] password for pavel:
sudo: /tmp/.mount_bash-4mDX6hg/usr/bin/head: command not found
$ LC_ALL=C $APPDIR/usr/bin/head -n1 /etc/sudoers
/tmp/.mount_bash-582FuSk/usr/bin/head: cannot open '/etc/sudoers' for reading: Permission denied

$ LC_ALL=C sudo $APPDIR/usr/bin/head -n1 /etc/sudoers
[sudo] password for pavel: 
sudo: /tmp/.mount_bash-582FuSk/usr/bin/head: command not found

$ stat -c '%A %a %n' /etc/sudoers
-r--r----- 440 /etc/sudoers