[HOWTO] mod_ruid2

Phpsysinfo shows the content of the variables which hold the startup user and group of the apache processes. Since this value is not modified by mod_ruid2 phpsysinfo displays wrong information. If it's possible I fix this behavior in the next mod_ruid2 version..

Put this in a php script to verify mod_ruid operation
PHP:
<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "id" executable in the path)
//phpinfo();
echo exec('id');
?>

now it shows the right user! :)
but the process of apache still running under apache user.
is it supposed to be like this?

ps aux | grep httpd
apache 4629 0.2 0.4 195856 16920 ? S 12:06 0:02 /usr/sbin/httpd -k start -DSSL
apache 4750 0.2 0.4 196948 18016 ? S 12:13 0:01 /usr/sbin/httpd -k start -DSSL
apache 4818 0.4 0.4 196132 17196 ? S 12:17 0:02 /usr/sbin/httpd -k start -DSSL
apache 4884 0.1 0.4 196448 17520 ? S 12:18 0:00 /usr/sbin/httpd -k start -DSSL
apache 4887 0.2 0.4 196688 17752 ? S 12:18 0:00 /usr/sbin/httpd -k start -DSSL
apache 4905 0.3 0.4 197728 18640 ? S 12:19 0:01 /usr/sbin/httpd -k start -DSSL
apache 4907 0.3 0.4 197952 18988 ? S 12:19 0:01 /usr/sbin/httpd -k start -DSSL
apache 4909 0.1 0.4 198196 19256 ? S 12:19 0:00 /usr/sbin/httpd -k start -DSSL
apache 4933 0.3 0.4 196892 17576 ? S 12:19 0:01 /usr/sbin/httpd -k start -DSSL
apache 4947 0.2 0.4 198208 18876 ? S 12:19 0:00 /usr/sbin/httpd -k start -DSSL
apache 4989 0.3 0.4 195872 16936 ? S 12:20 0:00 /usr/sbin/httpd -k start -DSSL
apache 4994 0.1 0.4 195408 16436 ? S 12:20 0:00 /usr/sbin/httpd -k start -DSSL
apache 5004 0.1 0.4 197152 18208 ? S 12:21 0:00 /usr/sbin/httpd -k start -DSSL
apache 5005 0.1 0.4 197760 18832 ? S 12:21 0:00 /usr/sbin/httpd -k start -DSSL
apache 5012 1.0 0.4 197952 19012 ? S 12:21 0:01 /usr/sbin/httpd -k start -DSSL
apache 5016 0.1 0.4 197468 18072 ? S 12:21 0:00 /usr/sbin/httpd -k start -DSSL
apache 5019 0.1 0.4 196908 17976 ? S 12:21 0:00 /usr/sbin/httpd -k start -DSSL
apache 5032 0.4 0.4 196916 17848 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5033 0.1 0.4 196400 17448 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5036 0.2 0.4 196940 17624 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5040 0.1 0.4 196652 17656 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5043 0.4 0.4 196896 17952 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5044 0.3 0.4 195408 16444 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5046 0.1 0.4 196908 17840 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5048 0.1 0.4 197924 18544 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5050 0.4 0.4 196932 17576 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5052 0.0 0.4 197580 18424 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5054 0.1 0.4 198716 19412 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5055 0.1 0.4 196696 17260 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5060 0.2 0.4 198192 19152 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5061 0.3 0.4 197940 18932 ? S 12:22 0:00 /usr/sbin/httpd -k start -DSSL
apache 5069 0.4 0.4 196908 17896 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5071 0.9 0.4 197428 18460 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5073 1.1 0.4 197940 19004 ? S 12:23 0:01 /usr/sbin/httpd -k start -DSSL
apache 5074 0.6 0.4 195596 16620 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5075 0.1 0.4 197952 18916 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5076 1.2 0.4 198464 18984 ? S 12:23 0:01 /usr/sbin/httpd -k start -DSSL
apache 5078 0.0 0.3 194576 13848 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5085 0.1 0.4 198464 18984 ? S 12:23 0:00 /usr/sbin/httpd -k start -DSSL
apache 5093 0.8 0.4 197684 18704 ? S 12:24 0:00 /usr/sbin/httpd -k start -DSSL
apache 5096 0.7 0.4 197940 18856 ? S 12:24 0:00 /usr/sbin/httpd -k start -DSSL
apache 5097 0.2 0.4 195880 16656 ? S 12:24 0:00 /usr/sbin/httpd -k start -DSSL
root 5100 0.0 0.0 103304 840 pts/1 S+ 12:24 0:00 grep httpd
root 57469 0.0 0.3 193892 15404 ? Ss 00:11 0:05 /usr/sbin/httpd -k start -DSSL
 
Those should be just access to phpmyadmin and webmail (file present in /var/www/html)

No other user use httpd on your system now?
 
Those should be just access to phpmyadmin and webmail (file present in /var/www/html)

No other user use httpd on your system now?

i run ab (apache benchmark tool) from another server to a file that i have in my test user.
in the meantime, i check with top & ps.
all the proccess of httpd owned by apache and not my test user.

by the way, for better security it's a nice idea to include RDocumentChRoot in the virtualhost of each user (just add into the custom template).
 
can you tell me your specific configuration (which version of apache, which mpm, mod_ruid2 version, etc..)?
thanks.
 
>httpd -V
Server version: Apache/2.4.1 (Unix)
Server built: Mar 28 2012 09:04:07
Server's Module Magic Number: 20120211:0
Server loaded: APR 1.4.6, APR-UTIL 1.4.1
Compiled using: APR 1.4.6, APR-UTIL 1.4.1
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)

mod_ruid2 0.9.5

Dont know how check mpm version installed honestly.

Regards
 
Server MPM: prefork
you have prefork mpm.

i'll try to compile apache again with mpm-prefork and see what happen..

EDIT:

it's working now.
so i was right, mod_ruid2 isn't compatible with multi-threaded mpms like event and worker.
 
Last edited:
How to upgrade from 0.9.4 with apache 2.2 to 0.9.5 with apache 2.4? Do I have to uninstall it first or can I just compile both and get it to work?
 
Allright, I'll give it a try. Thanks.

At first it will break apache then since mod_ruid is broken, lets hope the compiling goes fast because my sites will be down ;)

--
working fine now :)

For others:
- change version of apache from 2.2 to 2.4
- ./build apache
- ./build php n (applied the autoconf fix http://help.directadmin.com/item.php?id=434)
- compile mod_ruid2 0.9.5
- compile mod_security 2.6.5
- working like a charm

Got 2 warnings though from apache:

Starting httpd: [Sun Apr 15 10:10:48.570930 2012] [core:warn] [pid 4216] AH00117: Ignoring deprecated use of DefaultType in line 63 of /etc/httpd/conf/httpd.conf.
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf/ips.conf:6

but these seem to have no negative side effects so far.
 
Last edited:
Are just warnings, will be error in next release, you can ignore them now or manually fix editing those two listed files and commenting the lines described.

Regards
 
I'll leave it like this for now, they don't bug me :)

edit: the updates break the session handler in PHP:

Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /home/user/domains/domain.nl/2011/application/bootstrap.php on line 33

Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /home/user/domains/domain.nl/2011/application/bootstrap.php on line 33

anyone?

---
I fixed it by uncommenting ;session.save_path = "/tmp" so it became session.save_path = "/tmp", is this a proper fix?
 
Last edited:
Allways check for the newest version! There is an update for mod_ruid2, it's now version 0.9.6.

Most important change is that it fixed a bug in default config.
This bug could cause strange situaties in static mode, whereby the default uid and gid would be switched.

You could better install version 0.9.6.

There is a workaround for 0.9.5 users, this would require to add "RDefaultUidGid uid gid" to the config of each virtual host.
So I guess upgrading to 0.9.6 will spare you a lot of work, and might fix your problem too.:)
 
0.9.6 was released less than a day ago, thats easy to miss.

I just downloaded and recompiled and it's working fine, thanks.
 
Yep that's true, sorry, I didn't check your previous posting, at that time it wasn't released yet indeed.

Glad to hear it fixed your problem!
 
Hello ;

I installed mod ruid 2 for apache 2.4.1 evertying goes smoothly until i came end; when i add this to main httpd file it stops working when restart apache. When i delete these it starts again working. On the other hand it is creating domains in da panel but when i add subdomain for the domain it is not showing in the internet only domain works fine.

Any help!

Regards.

<Directory "/var/www/html">
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_suphp.c>
suPHP_Engine On
suPHP_UserGroup webapps webapps
SetEnv PHP_INI_SCAN_DIR
</IfModule>
RUidGid webapps webapps
</Directory>
 
Yes I followed;


-rw-r--r-- 1 diradmin diradmin 1388 Apr 18 16:37 virtual_host2.conf
-rw-r--r-- 1 diradmin diradmin 1495 Apr 18 16:40 virtual_host2_secure.conf
-rw-r--r-- 1 diradmin diradmin 1551 Apr 18 16:39 virtual_host2_secure_sub.conf
-rw-r--r-- 1 diradmin diradmin 1442 Apr 18 16:41 virtual_host2_sub.conf

I edited all these four temps in /usr/local/directadmin/data/templates/custom/

Thanks.
 
Back
Top