I believe you need to execute the script with CAP_SYS_TTY_CONFIG. Either this, or (if you work on the console), using a control tag (for example /dev/tty1) instead /dev/consolemay work.
The kernel code that applies this looks like the / tty / vt / vt _ioctl.c driver:
perm = 0;
if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
perm = 1;
⋮
case KDSETLED:
if (!perm)
goto eperm;
setledstate(kbd, arg);
break;
So, it definitely looks like these are your two options.
source
share