Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LAMP] set bitnami apache php process to run with umask 002 #1724

Closed
tacoma50 opened this issue Nov 27, 2024 · 9 comments
Closed

[LAMP] set bitnami apache php process to run with umask 002 #1724

tacoma50 opened this issue Nov 27, 2024 · 9 comments
Assignees
Labels
how-to How to issues reported by users lamp/mamp/wamp/xampp solved stale 15 days without activity triage Triage is needed

Comments

@tacoma50
Copy link

Describe your issue as much as you can

I created a Google VM by going to the Google Marketplace and creating a new BITNAMI PACKAGE FOR LAMP VM at: https://console.cloud.google.com/marketplace/product/bitnami-launchpad/lampstack

How do I configure the Bitnami apache and PHP processes to run with a umask of 002 so files are created with 0664 and folders with 0775.

@tacoma50 tacoma50 added the how-to How to issues reported by users label Nov 27, 2024
@github-actions github-actions bot added the triage Triage is needed label Nov 27, 2024
@tacoma50 tacoma50 changed the title [<application>] <title>BITNAMI PACKAGE FOR LAMP VM - set bitnami apache php process to run with umask 002 BITNAMI PACKAGE FOR LAMP VM - set bitnami apache php process to run with umask 002 Nov 27, 2024
@jotamartos
Copy link
Collaborator

You could change the start.sh scripts under /opt/bitnami/scripts/COMPONENT to set the umask before running the process or you can create a home folder for the daemon user and configure the profile.

https://serverfault.com/questions/166176/ways-to-set-umask-on-ubuntu-for-daemon-processes
https://unix.stackexchange.com/questions/703111/modify-umask-of-a-running-process

Please note that these questions are admin-related ones and it's out of the scope of this support forum. Please check the information available online to know how to set the umask of a running process.

@jotamartos jotamartos changed the title BITNAMI PACKAGE FOR LAMP VM - set bitnami apache php process to run with umask 002 [LAMP] set bitnami apache php process to run with umask 002 Nov 29, 2024
@tacoma50
Copy link
Author

tacoma50 commented Dec 3, 2024

Hi
Thank you. I tried your suggest as shown here but it did not work:

=== vi /opt/bitnami/scripts/apache-env.sh and added these 2 lines: ===

#- set umask of 002 so DIR=775 and FILES=664
umask 0002

=== restart server ===
/opt/bitnami/ctlscript.sh stop
/opt/bitnami/ctlscript.sh start

=== get httpd process ID ===
$ps -aef |grep httpd
5 S www-data 40685 40675 0 80 0 - 401375 pipe_r 17:51 ? 00:00:00 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf

=== check the umask of a running proccess id ===========
root@test1:/data/etc/logs/test# grep -i umask /proc/40675/status
Umask: 0022

as you can see the umask is still 0022 and not 0002

=== I even adding this line to bitnami.apache.service did not work =======
vi /etc/systemd/system/bitnami.apache.service

[Service]
UMask=0002

@jotamartos
Copy link
Collaborator

Try editing the start.sh file under /opt/bitnami/scripts/apache and set the umask just before the apache command

@tacoma50
Copy link
Author

tacoma50 commented Dec 5, 2024

Hmm I can't find a start.sh anywhere:

ls -al /opt/bitnami/scripts/apache
ls: cannot access '/opt/bitnami/scripts/apache': No such file or directory

find /opt/bitnami/ -type f -print |grep -i start
/opt/bitnami/scripts/prestart/00_update_motd_banner.sh
/opt/bitnami/scripts/prestart/00_resize_root_partition.sh
/opt/bitnami/scripts/firstboot/80_start_services.sh
/opt/bitnami/apache/bin/fcgistarter
/opt/bitnami/apache/manual/getting-started.html.ru.utf8
/opt/bitnami/apache/manual/programs/fcgistarter.html.tr.utf8
/opt/bitnami/apache/manual/programs/fcgistarter.html.en
/opt/bitnami/apache/manual/programs/fcgistarter.html
/opt/bitnami/apache/manual/programs/fcgistarter.html.fr.utf8
/opt/bitnami/apache/manual/getting-started.html.en
/opt/bitnami/apache/manual/getting-started.html
/opt/bitnami/apache/manual/getting-started.html.fr.utf8
/opt/bitnami/php/lib/php/test/XML_Util/tests/CreateStartElementTests.php
/opt/bitnami/phpmyadmin/vendor/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php
/opt/bitnami/phpmyadmin/templates/table/start_and_number_of_rows_fieldset.twig

@jotamartos
Copy link
Collaborator

Sorry for the wrong info, I thought you were using a different asset.

=== I even adding this line to bitnami.apache.service did not work =======
vi /etc/systemd/system/bitnami.apache.service

[Service]
UMask=0002

I understand this file existed and you only edited it to add the UMask line, right?

https://unix.stackexchange.com/questions/367757/set-umask-for-systemd-unit

Please remember to reload the information before restarting the services. If that doesn't work, you can try setting the umask value in the /opt/bitnami/apache2/bin/envvars file

https://serverfault.com/questions/383734/how-do-i-set-default-umask-in-apache-on-debian

@tacoma50
Copy link
Author

Hi,

I found the solution!! Your comment about: "remember to reload the information before restarting the services" made me think... I realized I was only restarting the bitnami services.

So what I did was edit /etc/systemd/system/bitnami.apache.service and add UMask=0002 in the [Service] section, and then reboot the whole server.

$ ps -aef |grep httpd
root 489 1 0 14:03 ? /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf
daemon 491 489 0 14:03 ? /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf

$ grep -i umask /proc/489/status
Umask: 0002

Thank you for your support!

@jotamartos
Copy link
Collaborator

I'm glad to hear that everything is working as expected now. However, just for future reference, it's not necessary to reboot the server, simply reload the systemd configuration

sudo systemctl daemon-reload

https://askubuntu.com/questions/1336532/what-is-the-difference-betweem-daemon-reload-and-reload

Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Dec 29, 2024
Copy link

github-actions bot commented Jan 4, 2025

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

@github-actions github-actions bot added the solved label Jan 4, 2025
@bitnami-bot bitnami-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
how-to How to issues reported by users lamp/mamp/wamp/xampp solved stale 15 days without activity triage Triage is needed
Projects
None yet
Development

No branches or pull requests

3 participants