On 2020-07-14, Lévai  Dániel <[email protected]> wrote:
> I'm trying to implement pledge(2) support into kc(1) (in ports) while using 
> it with a Yubikey.
> So far this is my pledge string:
> char            *pledges = "cpath exec fattr flock proc rpath stdio tty unix 
> wpath";
>
> This covers everything it would do without the Yubikey. But I can't seem to 
> find the proper "promise" that would allow it to use the Yubikey (I've tried 
> adding everything at one point).
> The application dies with (on -current):
> Abort trap (core dumped)
> kc[35302]: pledge "tty", syscall 54

Most ioctls are blocked by pledge. To do this, you'll either need to
avoid pledge completely, or handle device communications with a separate
process that remains unpledged.

>  35302 kc       RET   open -1 errno 13 Permission denied
>  35302 kc       CALL  kbind(0x7f7ffffede88,24,0x18365a7b5e816bae)
>  35302 kc       RET   kbind 0
>  35302 kc       CALL  open(0x7f7ffffee1f0,0x2<O_RDWR>)
>  35302 kc       NAMI  "/dev/usb1"
>  35302 kc       RET   open 7
>  35302 kc       CALL  kbind(0x7f7ffffede88,24,0x18365a7b5e816bae)
>  35302 kc       RET   kbind 0
>  35302 kc       CALL  ioctl(7,USB_DEVICEINFO,0x7f7ffffedf50)
>  35302 kc       PLDG  ioctl, "tty", errno 1 Operation not permitted
>  35302 kc       PSIG  SIGABRT SIG_DFL
>  35302 kc       NAMI  "kc.core"
>
>
> I don't know if this matters, but for even ykinfo(1) (in the ykpers port) to 
> work, I had to:
> # chmod g+w /dev/usb1
> # chmod g+rw /dev/ugen0.00

Known problem, there's no nice way around it though. The standard model
used on most OS of controlling many simpler USB devices from a low
privileged userland process does not work too well with the approach
in https://cvsweb.openbsd.org/src/etc/MAKEDEV.common#rev1.105

afaik the options for this are chmod, run as root, or write a driver that
works similar to fido(4) and modify the existing software that interfaces
with the device to use that instead (I guess for yk it will need a way to
hook into the keyboard driver too for the usual button-press keyboard
emulation otp mode).


Reply via email to