Sample Header Ad - 728x90

doas doesn't run a /usr/sbin binary

0 votes
0 answers
795 views
I'm using Debian/GNU/Linux Unstable, and I was trying doas for the first time today, with the following simple config file:
$ doas cat /etc/doas.conf 
permit persist alx as root
While it worked for some time (I could for example run doas apt-get update && doas apt-get upgrade), the following failed:
alx@ady1:~$ doas gdisk /dev/sdb
doas: gdisk: command not found
Hmm, is it that gdisk is an sbin binary? apt-get is a bin binary. Maybe the PATH is wrong. Let's check it:
$ sudo env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$ doas env | grep PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
doas seems to know sbin, but there seems to be something reversed in the PATH. Okay, where's gdisk?
alx@ady1:~$ sudo which gdisk
/usr/bin/which: this version of which' is deprecated; use command -v' in scripts instead.
/usr/sbin/gdisk
alx@ady1:~$ doas which gdisk
/usr/bin/which: this version of which' is deprecated; use command -v' in scripts instead.
/sbin/gdisk
command -v wouldn't work here, as it's a builtin, and won't work with sudo or doas, but let's ignore that warning (why would which be deprecated if there's no proper replacement?). Hmm, they don't agree. Let's see:
$ realpath /usr/sbin/gdisk 
/usr/sbin/gdisk
$ realpath /sbin/gdisk
/usr/sbin/gdisk
$ ls -l /sbin 
lrwxrwxrwx 1 root root 8 Nov 11 15:37 /sbin -> usr/sbin
Maybe it's due to the symlink that doas has trouble believing it should execute this binary? Let's modify the PATH so that it first finds the real path:
$ doas PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin gdisk /dev/sdb
doas: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: command not found
Huh, this is weird. Let's try using normal syntax (as opposed to sudo syntax; isn't this inconsistent or is it just me?):
$ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin doas gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): q
$
Okay, now it finds it. What should be the correct fix for this problem? Am I missing anything in the configuration?
Asked by alx - recommends codidact (322 rep)
Dec 25, 2021, 07:40 PM
Last activity: Feb 26, 2023, 05:47 PM