[yocto] changing ownership of a file in a package

Gary Thomas gary at mlbassoc.com
Mon Jul 25 07:40:34 PDT 2016


On 2016-07-25 16:07, piotr.lewicki wrote:
> Thank you. I will try this, but I wonder what is the right way of dealing with that when I want to change the ownership
> of let's say 2 files from different packages to a user that I create?
>
> Is using "useradd" possible in 2 separate recipes (to create the same user)?

Probably not good practice - have one create the user and the other recipe
depend on it at build time so you know it's already in place.  Note that you
can set the ownership on the install command using -o and -g

> On 25.07.2016 15:58, Leonardo Sandoval wrote:
>> As a workaround, have you tried using the other class to include users (useradd)? Look at the 'note' of this section
>>
>> http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#ref-classes-extrausers
>>
>> Leo
>>
>>
>> El 07/25/2016 a las 07:22 AM, piotr.lewicki escribió:
>>> Hi,
>>>
>>> I have a package where I want to install some files into a home directory of a user "testuser". I create a user in my
>>> image bb file using "extrausers".
>>>
>>> My problem is that I'm unable to change ownership of those files from root to the testuser.
>>>
>>> Simple "chown testuser:testuser -R /home/testuser" inside do_install task makes those files being owned by "nobody".
>>>
>>> How can I manage ownership of those files properly?
>>>
>>>
>>>
>>> The recipe is like so:
>>>
>>> DESCRIPTION = "Files installed in testuser user home directory"
>>> LICENSE = "CLOSED"
>>>
>>> SRC_URI += " \
>>>            file://authorized_keys \
>>>            file://bash_profile \
>>>            file://bashrc \
>>>            "
>>>
>>> do_install(){
>>>     install -d ${D}/home/testuser/
>>>     install -m 0644 ${WORKDIR}/bash_profile ${D}/home/testuser/.bash_profile
>>>     install -m 0644 ${WORKDIR}/bashrc ${D}/home/testuser/.bashrc
>>>
>>>     install -d ${D}/home/testuser/.ssh
>>>     install -m 0644 ${WORKDIR}/authorized_keys ${D}/home/testuser/.ssh/
>>> }
>>>
>>> FILES_${PN} = "/home/testuser"
>>>
>>>
>>> Thanks,
>>>
>>> Piotr
>>>
>>
>


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------



More information about the yocto mailing list