0

Sorry, I'm not a native English speaker.

I'm trying to install my web application using a Yocto-Project recipe file.

PR = "r0"
PV = "1.0"

LIC_FILES_CHKSUM = "file://COPYING;md5=d41d8cd98f00b204e9800998ecf8427e"

SRC_URI = "\
    file://sources \
    file://COPYING \
"
S = "${WORKDIR}"

do_install() {
    install -d ${D}${localstatedir}/www
    cp -r ${S}/sources/* ${D}${localstatedir}/www/
    chown -R www-data:www-data ${D}${localstatedir}/www/
    chmod -R 775 ${D}${localstatedir}/www/cgi-bin
}

But /var/www is still owned by root:root and not www-data:www-data like desired.

Question

So how do I chown the /var/www directory recusively to www-data:www-data?

EDIT

I have seen page 9 of the following presentation: https://wiki.yoctoproject.org/wiki/images/e/e6/Custom_Users_Groups_in_Yocto1.1.pdf .

I created this recipe file to mimic this page.

Community
  • 1
  • 1
jsuzu
  • 103
  • 1
  • 5
  • Are you running this script as root? Is www-data a valid user / group? Did you get any error messages from `chown`? How are variables `D` and `localstatedir` set? Without these details, nobody can make the guess work for you. – codeforester Feb 23 '17 at 05:32
  • No, running this script as default user not root.Yes, www-data is valid user / group. – jsuzu Feb 23 '17 at 05:33
  • 2
    You can't `chown` a file/directory not owned by you unless you are root. – codeforester Feb 23 '17 at 05:34
  • 1
    if cannot `chown`, then error may be occurred.I think this problem is concerned in `pseudo`. `pseudo` is used building yocto recipes, and it can become a user which is pseudo-root. – jsuzu Feb 23 '17 at 05:57
  • create a cron job – ZiTAL Feb 23 '17 at 08:08

2 Answers2

1

First, chown and chmod should work in YP/OE recipes the way you use them.

The problem may be that you've missed a / in your path arguments for the commands. According to the documentation [1] ${D} has no trailing /.

Therefore the following should work:

do_install() {
  install -d ${D}/${localstatedir}/www
  cp -r ${S}/sources/* ${D}/${localstatedir}/www/
  chown -R www-data:www-data ${D}/${localstatedir}/www/
  chmod -R 775 ${D}/${localstatedir}/www/cgi-bin
}

(If not please post your bitbake logs)

[1] https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#var-D

g0hl1n
  • 1,367
  • 14
  • 28
-2

sudo chown -R wwwdata:wwwdata /var/www/ to make the ownership of the desired folder and its inner folders or files recursively

admin123
  • 17
  • 2