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

openRC init script for chrooted apache #411

Closed
mariaczi opened this issue Mar 12, 2021 · 5 comments
Closed

openRC init script for chrooted apache #411

mariaczi opened this issue Mar 12, 2021 · 5 comments
Labels

Comments

@mariaczi
Copy link

Hi all.

I try to write init script for chrooted apache and it works but not exactly as I need.
When I start chrooted apache manually:
chroot --userspec=apache /opt/jail/apache/ /usr/local/apache24/bin/httpd -k start
all processes are owned by apache user:

# ps -ef | grep http
apache   111196      1  0 14:41 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   111197 111196  0 14:41 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   111198 111196  1 14:41 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   111199 111196  0 14:41 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   111201 111196  0 14:41 ?        00:00:00 /usr/local/apache24/bin/httpd -k start

When I use my own openrc init script (based on init script from alpine linux) the apache process is started but the first root process is owned by root:

/etc/init.d/apache2 start
# ps -ef | grep http
root     110679      1  0 14:39 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   110687 110679  0 14:39 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   110688 110679  0 14:39 ?        00:00:00 /usr/local/apache24/bin/httpd -k start
apache   110689 110679  1 14:39 ?        00:00:01 /usr/local/apache24/bin/httpd -k start
apache   110690 110679  1 14:39 ?        00:00:01 /usr/local/apache24/bin/httpd -k start

Init script in attachment: apache2-jail.txt
Important part of /etc/conf.d/apache2-jail:

CHROOT_DIR="/opt/jail/apache/"
USERSPEC=apache

HTTPD="/usr/local/apache24/bin/httpd"

PIDFILE=/usr/local/apache24/logs/httpd.pid

CONFIGFILE=/opt/usr/local/apache24/conf/vhosts.conf

How to start chrooted apache in the same way when I start it manually? I have in mind - all processes was owned by specified user.

@cromerc
Copy link
Contributor

cromerc commented Mar 14, 2021

You can use this in openrc scripts to have it launch the command with a specific user/group:

command_user="user:group"

@mariaczi
Copy link
Author

I tried 'command_user' before post. Not helped. The situation is still the same as I described.

@vapier
Copy link
Member

vapier commented Jan 15, 2023

please attach your exact init.d & conf.d files

@vapier vapier closed this as completed Jan 15, 2023
@mariaczi
Copy link
Author

@vapier Everything what you ask is in my first post here:

Init script in attachment: apache2-jail.txt
Important part of /etc/conf.d/apache2-jail:

@sijanec
Copy link

sijanec commented Sep 25, 2023

Related? #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants