Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-only config file(s) #975

Open
anlutro opened this issue Jun 14, 2015 · 7 comments · May be fixed by #1583
Open

Read-only config file(s) #975

anlutro opened this issue Jun 14, 2015 · 7 comments · May be fixed by #1583

Comments

@anlutro
Copy link
Contributor

anlutro commented Jun 14, 2015

I'd like to make my config files read-only. I use a provisioning tool to manage my servers, including ZNC configuration, and would ideally like to prevent a running ZNC process from making any changes to the files.

I thought I could achieve this by making the files read-only (chmod 400), but apparently ZNC opens znc.conf in read+write mode even when only reading+parsing the file, so that's not a possibility.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/22017607-read-only-config-file-s?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github).
@Zarthus
Copy link
Contributor

Zarthus commented Jun 14, 2015

The comment above describes why it needs RW permissions. Are you asking us to look into alternative manners of handling this so it only needs read permissions, or are you looking for suggestions on how you can handle this differently?

I'm also pretty sure ZNC writes to the config every time a change is made (i.e. new user created, network added), so it definitely needs write permission.

@anlutro
Copy link
Contributor Author

anlutro commented Jun 14, 2015

Are you asking us to look into alternative manners of handling this so it only needs read permissions, or are you looking for suggestions on how you can handle this differently?

Either one would be fine by me, honestly. If there's a workaround that's available in the current version of ZNC I'd love to know about it.

Off the top of my head, I imagine you could create a znc.conf.lock file in the same directory as the config file to prevent two processes from using the same config file. Also, if the intent of the file lock is to prevent another process from modifying the config file, that intent is kinda moot if the file is set to read-only (chmod 400) in the first place. Correct me if I'm wrong.

I'm also pretty sure ZNC writes to the config every time a change is made (i.e. new user created, network added), so it definitely needs write permission.

This is true, but my plan is to not rely on this live-updating, instead I'd like to update my provisioning script (adding the user/network/module/whatever centrally), deploy the new config file and then /msg *status rehash. I'm guessing this is not the intent ZNC is designed around, but would still love if it was possible.

@Zarthus
Copy link
Contributor

Zarthus commented Jun 14, 2015

I don't know if ZNC has improved it over the years, but ZNC REHASH is supposedly very, very poorly written (and very unstable) and needs drastic improving.

@DarthGandalf
Copy link
Member

Also, if the intent of the file lock is to prevent another process from modifying the config file

No. It's to prevent 2 ZNC processes to run together with the same config.

/znc rehash is supposed to go away at some point. But before that, I'd like to provide some alternative way to configure ZNC from external.

If you really want to manage config file by something else, restarting ZNC would be better than rehashing.

I'm also pretty sure ZNC writes to the config every time a change is made (i.e. new user created, network added)

Not quite. It does that if changes are made through webadmin. Also config is saved if user joins/part a channel when chansaver is loaded. Adding a network through *status doesn't write config itself.

@DarthGandalf
Copy link
Member

Btw, znc.conf is only part of config. Modules store their settings in different places.

@anlutro
Copy link
Contributor Author

anlutro commented Jun 14, 2015

No. It's to prevent 2 ZNC processes to run together with the same config.

A separate lock file would still work to prevent this, then. Though if you were to theoretically change from a file lock to a lock file in a future version, that would make two differing versions of ZNC running on the same config possible.

I wasn't aware that rehash is being deprecated, I'll keep that in mind.

I don't currently have a problem with module config files, as they're being opened as read-only (at least .registry files).

@Wolf480pl
Copy link
Contributor

I'm also trying to automate ZNC deployment with a configuration management tool, and would love to see a way to have ZNC not write its config file (and possibly keep users and networks in a different file than listeners and global config)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants