chown -R not working in Yocto-Project recipe - yocto

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.

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

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

Related

node-poppler installation of poppler-utils and poppler-data

https://github.com/Fdawgs/node-poppler
When following the readme one thing I ran into is poppler-utils and poppler-data didn't get installed in /usr/bin. Based on that readme I'm expecting them to get installed there by default.
After running a find inside the container I found the files in /usr/share/doc. This doesn't seem right based on the readme.
How do I ensure poppler-utils and poppler-data get added into /usr/bin as expected in the readme.
Ultimately this is the code I'm instantiating:
const poppler = new Poppler('/usr/bin');
Dockerfile:
FROM docker.registry.sfg.corp.local/devops/nodejs-build-docker:16.16.60850 as build
ARG NAME
ARG IMAGE
ARG SNYK_TOKEN
ARG SNYK_ORGANIZATION
ARG SNYK_PROJECT
COPY . .
RUN apt-get update
RUN apt-get install poppler-utils -y
RUN apt-get install poppler-data -y
RUN chmod +x install-puppeteer.sh
RUN ./install-puppeteer.sh
RUN ./build.sh -n $NAME -i $IMAGE -t $SNYK_TOKEN -o $SNYK_ORGANIZATION -p $SNYK_PROJECT
FROM docker.registry.sfg.corp.local/node:16-buster
RUN apt-get update
RUN apt-get install poppler-utils -y
RUN apt-get install poppler-data -y
COPY ./install-puppeteer.sh .
RUN chmod +x install-puppeteer.sh
RUN ./install-puppeteer.sh
# add the chrome folder to the PATH
ENV PATH "$PATH:/opt/google/chrome"
COPY --from=build package.json package.json
COPY --from=build src src/
COPY --from=build node_modules node_modules/
COPY --from=build artifacts artifacts/
# Add tini to help prevent zombie chrome processes.
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini
RUN chmod +x /tini
# Add user so we don't need --no-sandbox.
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& mkdir -p /home/pptruser/.cache \
&& mkdir -p /home/pptruser/.cache/puppeteer \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /node_modules
USER pptruser
RUN chmod +x node_modules/riley/bin/riley.sh
ENTRYPOINT ["/tini", "--"]
CMD ["node_modules/riley/bin/riley.sh"]

Yocto: Change ownership of /usr/lib

How can I change ownership of /usr/lib directory and all libraries inside for a specific user?
I tried to write a custom bb recipe without success.
SUMMARY = "Change /usr/lib ownership."
LICENSE = "MIT"
FILES_${PN} = "${libdir}\*"
do_install () {
chown user1:group1 ${D}${libdir}
}
I also try use ${libdir} instead /usr/lib, but without success. How can I access correctly /usr/lib?
It's impossible to change it during yocto compilation because the filesystem is built at the end of the process. There are two ways to achieve it. The first is to add chmod in the system image installation script.
The second one is to prepare a system service and bash script, which can check the owner and set the current one if necessary.
owner-updater.service
[Unit]
Description=Directory Owner Updater
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/opt/update-owner
StandardOutput=journal
[Install]
WantedBy=multi-user.target
update-owner
#!/bin/bash
USER=user_name
DIR_PATH="/usr/lib"
DIR_OWNER="$(stat --format '%U' $DIR_PATH)"
DIR_GROUP="$(stat --format '%G' $DIR_PATH)"
if [ "$(id -u $DIR_OWNER)" -eq "$(id -u $USER)" ] &&
[ "$(id -g $DIR_GROUP)" -eq "$(id -g $USER)" ]; then
echo Correct owner
else
echo Incorrect owner
fi
chown -R [user_name/user_id]:[group_name/group_id] /usr/lib

Magento 2.3 - CentOS 7 - page_cache is not writable

I am trying to installed Magento 2.3.4 in CentOS bases server. And getting below error:
Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/mage2/var/page_cache" is not writable in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...') #1 /var/www/html/mage2/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/m...') #2 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array) #3 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true) #4 /var/www/html/mage2/vendor/magento/framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true) #5 /var/www/html/mage2/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(38): Magento\Framework in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php on line 209
Already I ran below commands:
sudo chmod -R 777 var/ pub/ generated
Seems like file & folder owner|group issue. Then, I created one user and assigned it to apache group and ran below command to change file & folder owner|group
sudo chown -R magento_user:apache * .[^.]*
sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
sudo chmod u+x bin/magento
sudo service httpd restart
I installed Magento using CLI with below command and got success message
php bin/magento setup:install --base-url=http://example.com/ --db-host=localhost --db-name=dbname --db-user=dbuser --db-password=dbpass --admin-firstname=Rajiv --admin-lastname=Ranjan --admin-email=rajiv#gmail.com --admin-user=admin --admin-password=admin#123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
Still I am not getting same 'write permission' error while accessing from browser.
Any help is much appreciated.
After spending too much time, found solution. centos was restricting to write in directories. So I executed below commands and it worked fine.
sudo chcon -R --type httpd_sys_rw_content_t var
sudo chcon -R --type httpd_sys_rw_content_t pub/media
sudo chcon -R --type httpd_sys_rw_content_t pub/static
sudo chcon -R --type httpd_sys_rw_content_t generated
Run cache clean command and then give 777 permission again and check.
php bin/magento cache:clean
sudo chmod -R 777 var

Set new user permissions in Yocto recipe

I have a recipe to add a user called foo:
inherit useradd
USERADD_PACKAGES = "${PN}"
USERADD_PARAM_${PN} = "-P foo -u 1000 -d /home/foo -r -s /bin/bash foo;"
LICENSE = "CLOSED"
do_install () {
install -d ${D}/data/docker
install -d ${D}/home/foo
chown -R foo ${D}/home/foo
chown -R foo ${D}/data/docker
}
FILES_${PN} = " \
/home/foo \
/data \
"
For an obscure reason, data/docker is owned by foo but not /home/foo. Any idea why?
Actually, you don't need to install /home/foo(nor chown) since that task should be already accomplished by useradd, thus you can remove those commands. However, you might want to modify your recipe as follows:
do_install () {
install -d -m 755 ${D}${datadir}/foo
install -d -m 755 ${D}/data/docker
chown -R foo ${D}${datadir}/foo
chown -R foo ${D}/data/docker
}
FILES_${PN} = "${datadir}/foo/* /data/docker/*"
So the reason was that another recipe was creating a subfolder in the home directory first and was owned by root by default.
When the recipe to add the user was baked, the home folder was already created with root permissions.
My solution was to add the creation of this folder in the recipe adding the user instead.
Thanks #danior for the corrections

iOS DOxygen adding docSet to Xcode Documents

Hey Everyone just having a problem with DOxygen, Ive generated my documentation and its allthere, but i find i am unable to add it to Xcode.
I currently have a script which takes the HTML directory containing all the files, and generates the .docset file.
# Run the makefile. The --silent parameter stops it from spamming us with too much output.
#/Applications/Xcode.app/Contents/Developer/usr/bin/docsetutil
make --silent -C "$DOCSET_OUTPUT/html" install
# Load docset
osascript "$[location of personal library]/Scripts/XcodeLoadDocSet.scpt"
"~/Library/Developer/Shared/Documentation/DocSets/$DOXYGEN_ID.docset"
This should also add the item to xcode, but running it manually reveals a problem..
/Developer/usr/bin/docsetutil index com.[my app].docset
make: /Developer/usr/bin/docsetutil: No such file or directory
make: *** [docset] Error 1
This is what i have atm for the makefile,
DOCSET_NAME=com.[my app].docset
DOCSET_CONTENTS=$(DOCSET_NAME)/Contents
DOCSET_RESOURCES=$(DOCSET_CONTENTS)/Resources
DOCSET_DOCUMENTS=$(DOCSET_RESOURCES)/Documents
DESTDIR=~/Library/Developer/Shared/Documentation/DocSets
XCODE_INSTALL=$(shell xcode-select -print-path)
all: docset
docset:
mkdir -p $(DOCSET_DOCUMENTS)
cp Nodes.xml $(DOCSET_RESOURCES)
cp Tokens.xml $(DOCSET_RESOURCES)
cp Info.plist $(DOCSET_CONTENTS)
tar --exclude $(DOCSET_NAME) \
--exclude Nodes.xml \
--exclude Tokens.xml \
--exclude Info.plist \
--exclude Makefile -c -f - . \
| (cd $(DOCSET_DOCUMENTS); tar xvf -)
$(XCODE_INSTALL)/usr/bin/docsetutil index $(DOCSET_NAME)
rm -f $(DOCSET_DOCUMENTS)/Nodes.xml
rm -f $(DOCSET_DOCUMENTS)/Info.plist
rm -f $(DOCSET_DOCUMENTS)/Makefile
rm -f $(DOCSET_RESOURCES)/Nodes.xml
rm -f $(DOCSET_RESOURCES)/Tokens.xml
install: docset
mkdir -p $(DESTDIR)
cp -R $(DOCSET_NAME) $(DESTDIR)
uninstall:
rm -rf $(DESTDIR)/$(DOCSET_NAME)
always:
If anyone has had a similer problem please let me know.
Cheers
Michael.
With Xcode 4, docsetutil is located under /Applications/Xcode.app/Contents/Developer/usr/bin/