site  contact  subhomenews

Tweak for run-as-user

February 14, 2026 — BarryK

I posted about run-as-user recently:

I received an email from Steve, testing 'run-as-user', and it has made me realise something...

In the case of chromium, normally what happens is, as we are the root operator, we will run /usr/bin/chromium, which will login as "chromium" user, then run /usr/bin/chromium.bin.  The /usr/bin/chromium script has this if we run it non-root:

if [ "$(whoami)" != "root" ];then exec sudo-sh ${PPID} ${0} ${xARGS}; fi

...which will ask for the root password then rerun the script as user root.

However, if we have used run-as-user to run some app as user "chromium", and that app needs to run chromium browser, then it is not appropriate to ask for a password to run chromium as the root user. We should just run chromium as user "chromium".

Script '4post-process-rootfs' in woofQ2 calls /usr/local/clients/setup-client to create rootfs/usr/bin/chromium, as well as chromium.bin and chromium.bin0. I have modified that script to detect if /usr/bin/chromium entered as user "chromium". Here is the start of the script:

#!/bin/bash
APPname='chromium'
ROOTOPTS='--no-sandbox --test-type'
NONROOTOPTS='--disable-features=AudioServiceSandbox --no-default-browser-check --no-first-run --enable-chrome-browser-cloud-management=no --disk-cache-size=20000000 --disable-file-system --enable-unsafe-swiftshader'

#instead of passing $@ to *.bin0, put quotes if space...
xARGS=""
if [ -n "$1" ];then
while [ -n "$1" ]
do
#do not put quotes around if a single word. example is "-edit" for seamonkey, the quotes stuff it up entirely...
if [ "${1/ /}" == "${1}" ];then
xARGS="${xARGS} ${1}"
else
xARGS="${xARGS} \"${1}\""
fi
shift
done
fi

#20260214 if enter as same user as target, go straight to .bin0...
if [ "$(whoami)" == "${APPname}" ];then
if [ -x /usr/bin/${APPname}.bin0 ];then
exec ${APPname}.bin0 ${NONROOTOPTS} ${xARGS}
elif [ -x /usr/bin/${APPname}.bin ];then
exec ${APPname}.bin ${NONROOTOPTS} ${xARGS}
fi
fi
if [ "$(whoami)" != "root" ];then exec sudo-sh ${PPID} ${0} ${xARGS}; fi

...so, chromium browser will run as user "chromium".    

Tags: easy