Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string properties, which led to a proliferation of code all over the place making up new options without any sort of central registry of valid options. This commit pulls all those options back into the central Settings class and removes the public get() methods, to discourage future abuses like that. Furthermore, because we know the full set of options ahead of time, we now fail loudly if someone enters an unrecognized option, thus preventing subtle typos. With some template fun, we could probably also dump the full set of options (with documentation, defaults, etc.) to the command line, but I'm not doing that yet here.
This commit is contained in:
		
							parent
							
								
									8b1b5f9a12
								
							
						
					
					
						commit
						e7cb2847ab
					
				
					 10 changed files with 218 additions and 87 deletions
				
			
		|  | @ -865,8 +865,8 @@ static void daemonLoop(char * * argv) | |||
|             struct group * gr = peer.gidKnown ? getgrgid(peer.gid) : 0; | ||||
|             string group = gr ? gr->gr_name : std::to_string(peer.gid); | ||||
| 
 | ||||
|             Strings trustedUsers = settings.get("trusted-users", Strings({"root"})); | ||||
|             Strings allowedUsers = settings.get("allowed-users", Strings({"*"})); | ||||
|             Strings trustedUsers = settings.trustedUsers; | ||||
|             Strings allowedUsers = settings.allowedUsers; | ||||
| 
 | ||||
|             if (matchUser(user, group, trustedUsers)) | ||||
|                 trusted = true; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue