Forms based file permissions?

I use a home-rolled (mostly files-based) CMS I’ve been working on for a decade. As a developer I use ssh, bash, perl sed occasionally awk and php to make my sites work. I try to avoid mysql and use it only for forums and shopping carts. Not counting LOG files I have all files in my DOCUMENT_ROOT belong to me instead the apache process. I’ve never been hacked.

But a growing number of customers want to be able to upload images and short, newsy html fragments. Others want to be able to change the text on any and all pages. To allow editing with a files-based system I have to give file system write permission to the apache process. Which makes me nervous.

I’d like to figure out a way to make the entire DOCUMENT_ROOT read only in between short-lived editing sessions, and still have the file system belong to me instead of pseudo user apache.apache

I could see using an https form to invoke some compiled setuid C-code, that runs as me, that does a chmod -R on the document root. But maybe that’s a bad idea no matter what. Is there any other way to do this? Or do I have to: chown -R DOCUMENT_ROOT apache.apache? Perhaps that’s best. An https form would could chmod the file system just long enough to make edits. And then make it read only again.

What am I not thinking about?

pitten,

I had created just such a system for a club where different club officers had write permission over specific pages and that was enforced via login. I’d recommend that you tie your editing permission to a set of logins with specific permissions for specific logins. Be sure to use VERY STRONG passwords (http://strongpasswordgenerator.com), too.

My real concern over your post is that it would be a serious target for hackers. Once a hacker breaks one of your passwords (unless you implement that page edit login briefly discussed above), he could wreak havoc over your website. Therefore, unless you’re quite certain of your protection, I’d recommend that you upload the images and text to a temporary area so you can review and post when you’ve “cleared” the entries. IMHO, it’s best not to share editing of websites unless you’re REALLY confident of the other parties’ capabilities.

Regards,

DK

I’m just going to point out you are resorting to writing custom C code messing with deep linux security underpinnings when this is a problem that has been solved in a number of ways without taking those steps.