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

Config system #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Config system #26

wants to merge 4 commits into from

Conversation

rubenseyer
Copy link
Contributor

@rubenseyer rubenseyer commented Feb 15, 2018

Alright, so here's my suggestion for what the config system could look like. Sorry for being a bit spammy with the issue mentions--I didn't expect them to show up while I was still tidying history. I'm holding off on the Let's Encrypt implementation because I want to see how the tls-sni debacle ends before adding another HTTP server just to respond to the challenge.

  • I extended the pre-existing system in serverconf based on string maps. It is format independent - if it can encode string key-value pairs (and has a file format extension) it can be a config format.
  • The default config file generated is an .ini file. If the config file is named murmur.ini an additional translation step is performed, including warnings for some unsupported features (but I won't promise I catch all of them). (The .ini support uses go-ini.)
  • I still dislike the JSON-with-comments idea, but I quickly implemented it anyway to showcase the format independence. However, it would probably require a few good test cases for me to be confident it's usable.
  • The config files are only read, never written. The freeze system still acts as the persistent storage, which means that to revert a config value to defaults, you can't just comment it out, you have to specify it unset. I think this is an acceptable compromise.
  • The config system introduces one new feature: if the config format supports some form of subsets (sections in .ini, nested objects in .json) it is possible to set specific overrides for single virtual servers (including reverting to defaults). Not the best form of virtual server management, but at least it's something.

To make this meaningful, I also implemented some missing config keys that users migrating from Murmur probably would want. Features like databases, RPC and bandwidth limiting are still missing (but the latter should probably wait for web client support). I also added the SuperUser CLI flags from Murmur. I think the remaining unimplemented Murmur CLI flags would be meaningless for Grumble right now, at least.

@ghost ghost requested review from a user and mkrautz February 15, 2018 15:32
Copy link
Contributor

@mkrautz mkrautz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had time to do a full review. I'll post what I have now.

Also, I don't think we need the JSON reader if we have one for INI. Though it may be worth keeping around. I don't know. I am too sleepy. :)

@@ -835,7 +834,7 @@ func (server *Server) UpdateFrozenBans(bans []ban.Ban) {
}

// Write an updated config value to the datastore.
func (server *Server) UpdateConfig(key, value string) {
/*func (server *Server) UpdateConfig(key, value string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to remove. We can restore from history if necessary.


// Write to the freezelog that the config with key
// has been reset to its default value.
func (server *Server) ResetConfig(key string) {
/*func (server *Server) ResetConfig(key string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to remove. We can restore from history if necessary.

@rubenseyer
Copy link
Contributor Author

I don't mind whether you keep the JSON support or not. If there is no use-case for it we could just drop it.

@@ -30,6 +30,20 @@ var usageTmpl = `usage: grumble [options]
--log <log-path> (default: $DATADIR/grumble.log)
Log file path.

--config, --ini <config-path> (default: $DATADIR/grumble.ini)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

murmur doesn't have --config, only --ini, so let's drop it from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--ini by itself wouldn't make sense if we had multiple formats (although it should still be there for murmur compatibility), but we won't right now, so I'll get rid of it

if ok {
ciphers = append(ciphers, c)
} else {
log.Printf("Ignoring invalid or unsupported cipher \"%v\"", v)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont like the log in this function. If you need to report in this, make the function a multi-return that contains the unsupported values.

switch filepath.Ext(path) {
case ".ini":
f, err = newinicfg(path)
case ".json":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop json support

func NewConfigFile(path string) (*ConfigFile, error) {
var f cfg
var err error
switch filepath.Ext(path) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't require the config file have a particular extension, just always parse as ini

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per #21 I'll still keep the multiple-format boilerplate around (separate NewConfigFile from newinicfg). Please tell me if you think I should get rid of it as well.

if !f.murmurCompat {
return f.file.Section("").KeysHash()
} else {
return TranslateMurmur(f.file.Section("").KeysHash())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would be preferable if the ini file had as many common fields with the murmur config as possible. Can we rename all config values appropriately (e.g. Address -> host)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few reasons I didn't do this.

  1. Backwards compatibility with previous grumble freezes. The current way supports both the previous/current grumble key names and the previous murmur key names. (I don't know if this matters, and I actually accidentally broke it by renaming MaxChannelUsers to MaxUsersPerChannel. Oops! Fixing that when I have time to write a patch.)
  2. I want a TranslateMurmur step and a list of supported murmur keys anyway to print messages regarding common unsupported configuration. (It also strips unsupported keys as to not pollute the freeze files, but that will be unnecessary later, see below.)
  3. Subjective: My interpretation of Introduce compatibility with Murmur .ini files #21 is that the murmur support should be a non-default personality. (I chose to trigger it if the config file is named murmur.ini, but other solutions are possible, too.) This means that the normal configuration isn't dependent on murmur, so there's no guarantee everything works the same way in normal mode. (However, the murmur mode instead promises compatibility -- two sides of the same coin.) This means there is no need to rename things like Address either (it's had that name for 7 years). Rather, murmur configuration should be converted.

Because of the freeze persistence, grumble still wouldn't behave like murmur when you try to reconfigure murmur.ini to defaults. I didn't have time to fix that just yet, but I want the config to not persist in the freeze (overriding defaults, but not config set through future RPC).

This obviously does not preclude renaming the new keys closer to their murmur counterparts (like TLS* to SSL*, *Path to *File etc.), and fixing the persisting configs are on my to-do list. Even if you're not convinced about the field names, I'd still like to hear what you think about the translation/filter step.

@@ -0,0 +1,154 @@
package serverconf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete file

"log"
)

var murmurCompatRules = map[string]string{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like mentioned above, drop this (file); use common names with murmur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@mkrautz
Copy link
Contributor

mkrautz commented Mar 26, 2018

Sorry for leaving this be.

I'll quickly sketch up my thoughts on the personalities in Grumble:

I think the code we're working with now should just be "grumble". If we do implement personalities, they'd probably be a separate command (separate package main). That seems cleaner to me. The way I imagine it would pan out is that we refactor the Server part into a package, with the hooks necessary to implement custom handling.

Anyway, in my mind, since Murmur doesn't have config files at the moment, we should probably just use the Murmur .ini format all the way through.

I guess that does make some sense: Grumble, as it is right now has no way to set config options. (I removed my JSON-RPC thing and/or SSH thing I had for a while).
With that in mind, I don't think there's much to lose from changing the config names Grumble uses already. Users of the current builds have no way to set them, right? Also, I don't think anyone really uses it in production, though I could be wrong, of course. So, there's no shame in dropping backwards compatibility with the freeze files.

@ghost ghost mentioned this pull request Apr 14, 2018
"path/filepath"
"strconv"

"gopkg.in/ini.v1"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a build error on this line, no package found

@rubenseyer
Copy link
Contributor Author

Sorry for being inactive. I've been busy with other stuff and the ACME spec doesn't seem to be making a lot of progress anyway. I had some patches on my computer waiting for consensus that I am uploading now.

Seems like I am outvoted on the CamelCase point so I've dropped the compatibility layer design entirely and made grumble.ini configuration a superset of murmur.ini. (I still left some convenience features enabled in the .ini parser regarding quote escaping and boolean keys etc.).

I did keep the warnings for unsupported common Murmur configuration around but they are separate and easily removed now if you don't want them.

The branch history is a bit long now but I want to avoid rewriting the commits with issue mentions until the squash and merge.

@quite
Copy link

quite commented Jul 29, 2019

Is @mkrautz waiting for changes by @rubenseyer here, still? I only mean well. Looks like this PR could solve a number issues related to not having a proper configuration file system in place!

@poVoq
Copy link

poVoq commented Apr 14, 2020

Sorry to ask, but is there any news on this? I am about to setup a mumble server again, and would really like to use Grumble.

@actown
Copy link
Contributor

actown commented Apr 15, 2020

Given this PR is a few years out of date, if you would like to rebase it on master and give it a test that would be awesome. If I have time this weekend I can take a look myself.

@poVoq
Copy link

poVoq commented Apr 15, 2020

If I have time this weekend I can take a look myself.

Would be awesome if you could have a look at it.
Anything basic will do, if some channels could be preconfigured like in uMurmur that's totally sufficient.

@rubenseyer
Copy link
Contributor Author

rubenseyer commented Apr 15, 2020

Wow, I had forgotten about this! I'm still around, but probably too busy to do anything too soon. I'll try to rebase and update everything if I get time and no one else beats me.

Looking through what has happened since I'm gone, here's a few things off the top of my head:

  • Check that Add a configuration parameter making it possible to avoid the web port #51 works (also more on Grumble-specific configuration later)
  • Make it possible to change configuration parameters on a server #52 presents a design decision. No user in normal (that is, running Grumble itself) operation can currently set configuration in that way (with RPC unimplemented). However, unless you are careful, the settings persist in the freezelog and this may cause unexpected behaviour (or at least it worked that way back in 2018). The .ini files take care to not persist, but they will also override settings set in the freezelog on load for this reason (in case old configuration was left in), because I think that's more obvious for the user. We should think about what we want to happen.
  • Add support for server passwords #55 conflicts with this one (that's right, server password support was hidden here all along!), so we'll have to merge those changes -- notably, you can't be Murmur.ini-compatible and stored hashed passwords like for SU, so we need to special-case and hash incoming passwords from the config file (which is pointless because you'll still have them unhashed on disk anyway) or special-case and allow unhashed passwords to accept Murmur behaviour (but you might not like that for security reasons)
  • As you can probably read from the history of this pull request, these features have gone through a lot of redesign in terms of scope. I went in with some suggestions for enhancements for the configuration (json support, new configuration keys unsupported by Murmur, virtual server config without rpc) but in the end it was decided to scale back so that it essentially is literally murmur.ini. That meant no Grumble-specific configuration and renaming every key to Murmur names. This breaks every single existing server, so that configuration must be generated again, but when consensus made that decision in 2018 the reasoning was that nobody uses Grumble in production anyway. If someone actually is using this for real nowadays we ought to avoid renaming the keys, and probably just bring back the murmur.ini translation layer (but that would just be a matter of dropping some later commits, because I kept everything!). (Also, if those other features sound interesting this time and we consider that Grumble may diverge from Murmur in configuration feature set I might consider fixing the other suggestions too.)
  • Lastly, I added myself to AUTHORS because every contributor back then had done so, but this file has since gone entirely unused. I'd suggest dropping that commit from this pull request and just update it separately with every contributor, or getting rid of it.

Sorry for dropping a book on you, but I thought I'd write down some of these considerations so we can think about the decisions involved. Merging this is not far away in terms of code changes but it is an entirely new part to Grumble so it was always gonna be a matter of design problems first and foremost.

@actown
Copy link
Contributor

actown commented Apr 16, 2020

It sounds like this PR brings up a bunch of questions that we should figure out the best way to handle.

  • I’m unsure if anyone is using Grumble in production and I’m unsure of the best way to determine that. Given the state of this repo I suspect that most people are still using the main server provided by their local package repo or via the static builds on the project website.
  • What’s the goal of this project? I have my views, please don’t take them as gospel. Personally I’d like to see this project be the default server backend for Mumble (a long way to go for this), splitting out the server from the client+QT base. Ideally doing so would allow the server and client to move in a direction that works best for each component. This also brings up some points that will need to be considered: Do we keep compatibility with older configs? ICE (please no)? gRPC (yes please)? Most of these can be worked around but will require some work. Would love to hear some opinions of this.
  • AUTHORS is fine, the main project uses this so we might as well follow suit. This should be its own task to get the file caught up.

@rubenseyer
Copy link
Contributor Author

I think my views on this have remained unchanged since I first began this PR --- in essence, I agree.

I think that for Grumble to become a default choice we will need compatibility to allow easy migration (but compatibility need not mean that we enforce Grumble to have exactly the same feature set as Murmur). My solution for that was the translation layer which was a compromise between not breaking existing Grumble servers and allowing compatibility with existing configuration, because I have no problem with the real Grumble config not being exactly the same as murmur.ini (and apparently neither did the original author of serverconf) but I understand it seems like a lot of trouble just because we don't want to rename config keys.

(Also, we clearly would need gRPC for any major production user to consider switching. That was my idea for the next step after this PR back in 2018.)

(see also issue mumble-voip#21)
Removes synchronizing set config keys to freezelog,
since the system is the preferred way to persist configuration.
@rubenseyer rubenseyer force-pushed the config branch 2 times, most recently from 1ae1f08 to d7a0c46 Compare April 16, 2020 20:27
@rubenseyer
Copy link
Contributor Author

I rebased everything and re-organized the slew of WIP commits into something more logical. I have changed no design decisions here compared to where I left off in 2018, so I do not expect this to be merged until everyone is satisfied on those. Please do test and review the changes, because I have only built it and nothing more.

Some notes:

Also adds some Murmur CLI flags, see mumble-voip#25
Since the only way right now to set the SuperUser pw is through
the CLI on start, this commit also drops the config updates through
the freezelog (probably a remnant of RPC), which the SetSuperUserPassword
function was the last user of.
MaxUsers: modifies existing sessionpool similar to Murmur
MaxUsersPerChannel: already implemented, inconsistent name
AllowPing: affects registration, too
DefaultChannel
RememberChannel
ServerPassword
SendOSInfo: already implemented, inconsistent name

Config keys are renamed to conform to murmur.ini
@streaps
Copy link

streaps commented May 28, 2020

I get this error on first start. The message is also missing a "\n".
Unable to open log file (/home/mumble/.grumble/grumble.log): open : no such file or directory

@streaps
Copy link

streaps commented Jun 10, 2020

I'm not able to add @all permissions to the root channel, it only adds another SuperUser everytime I try. Is this a new problem with this PR or a known issue? I also cannot start the server anymore. Could this be related?

$ ./grumble
[G] 2020/06/10 16:55:12.632307 Grumble
[G] 2020/06/10 16:55:12.633083 Using data directory: /home/mumble/.grumble
[G] 2020/06/10 16:55:12.633692 Loading server 1
panic: assignment to entry in nil map

goroutine 1 [running]:
main.(*Channel).Unfreeze(0xc0000f4360, 0xc0000f4120)
        /home/mumble/repos/grumble/cmd/grumble/freeze.go:272 +0x4d2
main.NewServerFromFrozen(0xd015f1, 0x1, 0xc0000bec80, 0x0, 0x0)
        /home/mumble/repos/grumble/cmd/grumble/freeze.go:451 +0x808
main.main()
        /home/mumble/repos/grumble/cmd/grumble/grumble.go:245 +0x1494

@rubenseyer
Copy link
Contributor Author

I can reproduce the same crash on both master and this PR:

  1. Log in as SuperUser (on master you need to "cheat" to do this)
  2. Make any change to the @all acl
  3. Stop the server
  4. Fail to start the server

I have filed PR #71 to fix it, because it is not really pertinent to this one (which is bogged down in years of reviews anyway). You should be able to easily rebase those changes onto this one if you want to combine them immediately -- this shouldn't touch those areas too much. I'll rebase here later if the other one is merged.

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 this pull request may close these issues.

7 participants