1

I'm looking for way to modify configuration file that resides below /etc directory via web (in particular case PHP) interface. While it's not a problem to read (if you set up file permissions correctly) it is when it comes to modifying/writing to files that cannot be written by non-owner and non-root user (www-data user).

To be specific I'm after dovecot passwd file (/etc/dovecot/passwd) and I want to write to in so I could change password for dovecot virtual user. I have PHP logic that can read, rearrange and prepare string for saving to /etc/dovecot/passwd , except that it cannot go any further since, as I mentioned www-data user cannot write to anything below /etc directory.

Is there workaround for this?

Is there maybe some kind of proxy-binary or script that can be triggered via PHP with input parameters to do the job?

Thanks in advance.

0

You need to add a level of indirection: feed a database (either a file, or a real one) with php application, and run bots that actually run privileged to perform the actual operation.

If you choose to use files, you may be interrested in incron, which lets you run a command whenever an action occurs on a file (for instance, saving).

  • "and run bots that actually run privileged to perform the actual operation." that is the problematic part for me. Do you have suggestion how exactly? Cron can run every minute but it's not so appropriate. – greenV May 3 '14 at 10:39
  • for instance, feed a database with the wanted password (hashed), and have a script which updates the /etc/dovecot/passwd with that password. Or use dovecot against MySQL for authentication. – aif May 3 '14 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.