user_restore_post.sh

nobaloney

NoBaloney Internet Svcs - In Memoriam †
Joined
Jun 16, 2003
Messages
26,113
Location
California
I found this script: user_restore_post.sh

described here .

But little information. I need it to change ownership of certain squirrelmail files to webapps;webapps to run under mod-ruid2. Of course it needs to run as root.

Does anyone know if this will work?
Code:
#!/bin/sh
# Script written by JL 03-jul-2011
# run after restore is finished to change ownership of certain squirrelmail
# files to webapps:webapps
cd /var/www/html/squirrelmail
chown -R webapps:webapps *

Or do I need to test by restoring a user built on a machine not using mod_ruid2?

The main issue I see is whether or not the user_restore_post.sh script runs as root. If this won't work, then I'll have to run the commands in an hourly cron, or remember to do it manually after every restore.

Thanks.

Jeff
 
I think that will work without problem.

I use to use a script on domain_create_post.sh that change some file ownership and that work fine...

Example of the script i use:

Code:
mkdir /home/$username/domains/$domain/logs
chown root:$username /home/$username/domains/$domain/logs
chmod 750 /home/$username/domains/$domain/logs

This work fine giving ownership also to root: so your will work aswell...

A best way to try it maybe should be using su command with a different user:

ex:
Code:
touch /var/www/html/squirrelmail/TESTING
chown root:root /var/www/html/squirrelmail/TESTING
/bin/su - diradmin -c "/usr/local/directadmin/scripts/custom/user_restore_post.sh"
ls -l /var/www/html/squirrelmail/TESTING
rm -rf /var/www/html/squirrelmail/TESTING

If im right, you will have the TESTING file owned by webapps:webapps (this will show the owner and then delete the file aswell).

Regards
 
As far as I know, all or almost all POST/PRE scripts run with root privileges, otherwise it would not have any sense.
 
Thanks, folks. I'll move forward with this and post if I run into problems.

Jeff
 
I have installed mod_ruid2 on an established CentOS server with 100's of email accounts. Now nobody can login to Squirrelmail until I change the ownership for their squirrelmail .pref and .abook files to the website "hosting" username for that email account.


Does anyone else have this problem? I have had to manually chown each set of email accounts per hosting account using commands like this in the /var/www/html/squirrelmail folder,

from
chown webapps.webapps *yourwebsite.com*
to
chown username.username *yourwebsite.com*

Does anyone have a suggested script or command line to properly do this with one command instead of 100's of individual commands?

One possible choice - not recommended - is to delete all .prefs and .abooks in the folder and let the users start their address book from scratch. It would be fast and easy but probably lead to some seriously upset users. New users automatically create the properly owned .pref and .abook files when they first sign into squirrelmail.
 
Last edited:
I guess, you need to add these lines into your Apache configs:

Code:
            <location /phpMyAdmin>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>
            <location /phpmyadmin>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>
            <location /squirrelmail>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>
            <location /roundcube>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>
            <location /webmail>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>
            <location /atmail>
               RMode config
               RUidGid webapps webapps
               RGroups apache
            </location>


Note, you'd better read and ask your questions on the mod_ruid configure and usage here
 
Alex,

I had read all of the posts you suggest and gone over everything a number of times. I then added your suggested lines to the apache config files but that has not changed anything.

I found a link with preconfigured files at http://blog.yourwebhoster.eu/2010/07/25/DirectAdmin-IPv6-and-mod_ruid/

but they didn't help either.

Squirrelmail still doesn't like the ownership of .pref files to be webapps.webapps - it needs it to be hosting account username.username in order to work.

Any more ideas?
 
Alex,

thanks. That last hint worked fine. Now everything works as it should. PHP Scripts that used to have permission problems don't have them anymore - wonderful.

I have compiled a complete set of instructions on how to successfully do an entire mod_ruid2 install/conversion including your helpful tips and tips from other posts. I believe I have reduced pages of confusion and repetition into one straight line to success.

I have submitted it to John at DirectAdmin - hopefully, he can take that and make it an easy install option for all DirectAdmin users.
 
Back
Top