running application in user mode instead of root #yocto


mail2uvijay@...
 

Hi All,

I am trying to run my application in less privilege mode instead of root user.
As i am new to Yocto build could you please some one suggest on how to configure my build environment to get user and run
my application with the user privileges at startup.

Regards,
Vijay


Yann Dirson
 

Hello,

I am trying to run my application in less privilege mode instead of root user.
As i am new to Yocto build could you please some one suggest on how to configure my build environment to get user and run
my application with the user privileges at startup.
You may be interested in ROOTLESS_X="1", to open a non-priviledged X11 session.


Regards,
Vijay


--
Yann Dirson <yann@...>
Blade / Shadow -- http://shadow.tech


Alessandro Tagliapietra
 

I'm new to yocto as well but what we do is in our own custom image:

inherit extrausers
EXTRA_USERS_PARAMS = " useradd nodered"

and then since we use systemd we've created our own service file that includes:

User=nodered

in the [service] block definition, so the executable is run using that user instead of root.

Extrausers docs are https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#ref-classes-extrausers

An alternative you might look at is the useradd class https://git.yoctoproject.org/cgit.cgi/poky/tree/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb which probably lets you set the users in your own recipe instead at image level


mail2uvijay@...
 

any one has example bitbake script which runs the application by the user instead of root.
When i start the application using startup scripts [init.d] its running with root user.


Anton Antonov
 

Hi,

   You can use start-stop-daemon command with "--chiud" parameter. Here is an example:

https://git.yoctoproject.org/meta-security/tree/meta-parsec/recipes-parsec/parsec-service/files/parsec_init

Cheers,
Anton