Permissions for files/folder on the persistent volume

211 views
Skip to first unread message

Fabrice D.

unread,
Jan 29, 2019, 11:45:49 AM1/29/19
to Mender List mender.io
Hi !

I am stuck with a folder permissions problem, and I hope someone can help me :-)
By default the folder (and files) created on the data persistent partition are owned by the root user (and root group)
I want to set my own user:group to that folder but I am not able to do that.

here my example.bb file :

inherit useradd deploy

APPLI_USER
?= "user"

USERADD_PACKAGES
= "${PN}"
USERADD_PARAM_$
{PN} = " \
    --system --no-create-home -g ${APPLI_USER} ${APPLI_USER} "

GROUPADD_PARAM_$
{PN} = "${APPLI_USER}"


S
= "${WORKDIR}"

do_install
(){
     install
-d ${D}/opt
     install
-m 0500 ${WORKDIR}/script.sh ${D}$/opt

     
#set permissions => OK works well at this step
     chown $
{APPLI_USER}:${APPLI_USER} -R ${D}/opt
}

do_deploy
() {

   
# create folder
    install
-d -m 775 ${DEPLOYDIR}/persist/folder

   
# Not possible to set permissions for user "user" => chown: invalid user: ‘user:user’ !
    chown $
{APPLI_USER}:${APPLI_USER} -R ${DEPLOYDIR}/persist/folder

}
addtask do_deploy after do_compile before do_build

and the associated bitabke log :

ERROR:  do_deploy: Function failed: do_deploy (log file is located at ...)
ERROR
: Logfile of failure stored in: ...
Log data follows:
| DEBUG: Executing python function sstate_task_prefunc
| DEBUG: Removing manifest: /tmp/deploy/images/imx6-openrexmax/persist/folder/
| DEBUG: Removing manifest: /tmp/deploy/images/imx6-openrexmax/persist/
| DEBUG: Python function sstate_task_prefunc finished
| DEBUG: Executing shell function do_deploy
| chown: invalid user: user:user
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_deploy (log file is located at ...)

Is there a way to set the permissions of the folder ?
I am using mender for yocto ROCKO

Thanks for your help
regards
Fabrice

Mirza Krak

unread,
Jan 29, 2019, 12:42:24 PM1/29/19
to Mender List mender.io
On Tue, Jan 29, 2019 at 5:45 PM Fabrice D. <hav...@gmail.com> wrote:
Hi !

Hello,
You probably need to do "do_deploy" after "do_install" because it is there where the user:user is created I believe by the useradd.bbclass.

--
Mirza Krak | Embedded Solutions Architect | https://mender.io

 Northern.tech AS | @northerntechHQ




Message has been deleted

Fabrice D.

unread,
Jan 30, 2019, 4:00:04 AM1/30/19
to Mender List mender.io, mirza...@northern.tech
Hello

thanks for your answer
unfortunately it does not work :-/ I still have the same error.

Mirza Krak

unread,
Jan 30, 2019, 4:44:24 AM1/30/19
to Fabrice D., Mender List mender.io
On Wed, Jan 30, 2019 at 10:00 AM Fabrice D. <hav...@gmail.com> wrote:
Hello

thanks for your answer
unfortunately it does not work :-/ I still have the same error.

Kristian Amlie

unread,
Jan 30, 2019, 6:57:13 AM1/30/19
to men...@lists.mender.io, Fabrice D.
On 29/01/2019 17:45, Fabrice D. wrote:
> Hi !
>
> I am stuck with a folder permissions problem, and I hope someone can
> help me :-)
> By default the folder (and files) created on the data persistent
> partition are owned by the root user (and root group)
> I want to set my own user:group to that folder but I am not able to do that.
>
> here my example.bb file :
>
> |
> inherit useradd deploy
>
> APPLI_USER ?="user"
>
> USERADD_PACKAGES ="${PN}"
> USERADD_PARAM_${PN}=" \
>     --system --no-create-home -g ${APPLI_USER} ${APPLI_USER} "
> GROUPADD_PARAM_${PN}="${APPLI_USER}"
>
>
> S ="${WORKDIR}"
>
> do_install(){
>      install -d ${D}/opt
>      install -m 0500${WORKDIR}/script.sh ${D}$/opt
>
>      #set permissions => OK works well at this step
>      chown ${APPLI_USER}:${APPLI_USER}-R ${D}/opt
> }
>
> do_deploy(){
>
>     # create folder
>     install -d -m 775${DEPLOYDIR}/persist/folder
>
>     # Not possible to set permissions for user "user" => chown: invalid
> user: ‘user:user’ !
>     chown ${APPLI_USER}:${APPLI_USER}-R ${DEPLOYDIR}/persist/folder
>
> }
> addtask do_deploy after do_compile before do_build
> |
>
> and the associated bitabke log :
>
> |
> ERROR: do_deploy:Functionfailed:do_deploy (log file islocated at ...)
> ERROR:Logfileof failure stored in:...
> Logdata follows:
> |DEBUG:Executingpython functionsstate_task_prefunc
> |DEBUG:Removingmanifest:/tmp/deploy/images/imx6-openrexmax/persist/folder/
> |DEBUG:Removingmanifest:/tmp/deploy/images/imx6-openrexmax/persist/
> |DEBUG:Pythonfunctionsstate_task_prefunc finished
> |DEBUG:Executingshell functiondo_deploy
> |chown:invalid user:‘user:user’
> |WARNING:exitcode 1froma shell command.
> |ERROR:Functionfailed:do_deploy (log file islocated at ...)
> |
>
> Is there a way to set the permissions of the folder ?
> I am using mender for yocto ROCKO

I think this is not possible with branches earlier than sumo. The
problem is that poky has a bug that permissions are not preserved in the
deploy stage, which is why that "chown" command is there, to force root
permissions. The whole thing was completely rewritten in sumo, and there
you can make it work, although the method is different [1].

[1]
https://docs.mender.io/1.7/devices/yocto-project/partition-layout#deploying-files-to-the-persistent-data-partition

--
Kristian

signature.asc

Fabrice D.

unread,
Jan 30, 2019, 8:29:06 AM1/30/19
to Mender List mender.io, hav...@gmail.com
Allright,

thanks for the analysis and to confirm that it is not possible in that version. I will postpone my feature after the migration to an earlier mender version

Regards
Reply all
Reply to author
Forward
0 new messages