diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2015-08-05 10:34:30 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2015-08-05 12:20:12 +0200 |
commit | 0df0452c34a0f2322bdac8f316ad38194a4ddbbf (patch) | |
tree | 25aa460ffd60b2b3ca3156a2b3f52153c3e8ddf6 | |
parent | b24bd6f245b9527592ce0fcfbc67bb0a145c1b8c (diff) | |
download | pykolab-0df0452c34a0f2322bdac8f316ad38194a4ddbbf.tar.gz |
chown files in /etc/roundcubemail/ that are not owned by the httpd process user
-rw-r--r-- | pykolab/setup/setup_roundcube.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py index 1af0f9e..51412fc 100644 --- a/pykolab/setup/setup_roundcube.py +++ b/pykolab/setup/setup_roundcube.py @@ -226,6 +226,30 @@ password='%s' time.sleep(2) + # Find Roundcube configuration that is not readable by the + # webserver user/group. + if os.path.isdir('/etc/roundcubemail/'): + rccpath = "/etc/roundcubemail/" + elif os.path.isdir('/etc/roundcube/'): + rccpath = "/etc/roundcube" + else: + log.warning(_("Cannot find the configuration directory for roundcube.")) + rccpath = None + + root_uid = 0 + + for webserver_group in [ 'apache', 'www-data' ]: + try: + (a,b,webserver_gid,c) = grp.getgrnam('apache') + break + except Exception, errmsg: + pass + + if not rccpath == None: + for root, directories, filenames in os.walk(rccpath): + for filename in filenames: + os.chown(os.path.join(root, filename), root_uid, webserver_gid) + if os.path.isfile('/bin/systemctl'): if os.path.isfile('/etc/debian_version'): subprocess.call(['/bin/systemctl', 'restart', 'apache2.service']) |