Permalink
Browse files

runs_as -> can_run_as which reads better and makes the config less co…

…nfusing (hopefully).

[runs_as] remains for backwards compatibility but is not documented.

Closes: 751f3894b4
  • Loading branch information...
caldwell committed Nov 13, 2011
1 parent 65e8ff6 commit 720908ffc9e831c7e6449f41008ea93fed555fa4
Showing with 13 additions and 12 deletions.
  1. +2 −1 config.cc
  2. +1 −1 config.h
  3. +5 −5 daemon-manager.cc
  4. +4 −4 daemon-manager.conf.asciidoc
  5. +1 −1 daemon-manager.conf.basic
View
@@ -34,7 +34,8 @@ struct master_config parse_master_config(string path)
string sect = line.substr(1, end-1);
if (trim(line.substr(end+1)).length()) throw_str("%s:%d Junk at end of section header line", path.c_str(), n);
- if (sect == "runs_as") section = &config.runs_as;
+ if (sect == "runs_as" || // The old name, here for backwards compatibility and not documented.
+ sect == "can_run_as") section = &config.can_run_as;
else if (sect == "manages") section = &config.manages;
else throw_str("%s:%d Illegal section \"%s\"", path.c_str(), n, sect.c_str());
continue;
View
@@ -9,7 +9,7 @@
using namespace std;
struct master_config {
- map<string,vector<string> > runs_as;
+ map<string,vector<string> > can_run_as;
map<string,vector<string> > manages;
};
View
@@ -167,7 +167,7 @@ bool contains(vector<T> list, T value)
static vector<user*> user_list_from_config(struct master_config config)
{
vector<string> unique_users;
- for (config_it it = config.runs_as.begin(); it != config.runs_as.end(); it++)
+ for (config_it it = config.can_run_as.begin(); it != config.can_run_as.end(); it++)
unique_users.push_back(it->first);
for (config_it it = config.manages.begin(); it != config.manages.end(); it++)
unique_users.push_back(it->first);
@@ -195,8 +195,8 @@ static vector<user*> user_list_from_config(struct master_config config)
foreach(user *u, user_list) {
u->can_run_as_uid[u->uid] = true; // You can always run as yourself, however ill-advised.
- if (config.runs_as.find(u->name) != config.runs_as.end()) {
- for (config_list_it name = config.runs_as[u->name].begin(); name != config.runs_as[u->name].end(); name++) {
+ if (config.can_run_as.find(u->name) != config.can_run_as.end()) {
+ for (config_list_it name = config.can_run_as[u->name].begin(); name != config.can_run_as[u->name].end(); name++) {
uid_t uid = uid_from_name(*name);
if (uid == (uid_t)-1)
log(LOG_ERR, "%s can't run as non-existant user \"%s\"\n", u->name.c_str(), name->c_str());
@@ -612,8 +612,8 @@ static string do_command(string command_line, user *user, vector<class daemon*>
static void dump_config(struct master_config config)
{
log(LOG_DEBUG, "Config:\n");
- log(LOG_DEBUG, " Runs as:\n");
- for (config_it it = config.runs_as.begin(); it != config.runs_as.end(); it++) {
+ log(LOG_DEBUG, " Can run as:\n");
+ for (config_it it = config.can_run_as.begin(); it != config.can_run_as.end(); it++) {
string s = " "+it->first+": ";
for (config_list_it lit = it->second.begin(); lit != it->second.end(); lit++) {
s += " \""+*lit+"\"";
@@ -11,7 +11,7 @@ daemon-manager.conf - Master configuration file for Daemon Manager
SYNOPSIS
--------
# Example configuration file
- [runs_as]
+ [can_run_as]
user1: www-data
# user2 is allowed to launch daemons but only as itself
user2
@@ -37,13 +37,13 @@ line. Blank lines are ignored.
The file consists of two sections designated by
- [runs_as]
+ [can_run_as]
and
[manages]
-The 'runs_as' section identifes which users are allowed to launch daemons. It
+The 'can_run_as' section identifes which users are allowed to launch daemons. It
looks like this:
bob: mary, bruce, rhonda
@@ -63,7 +63,7 @@ A trailing `:' is also acceptable:
The 'manages' section allows the system administrator to appoint users that
can start and stop daemons on behalf of other users. It has the same syntax as
-the 'runs_as' section:
+the 'can_run_as' section:
larry: bob, martha
@@ -1,6 +1,6 @@
# See daemon-manager.conf(5) for details on the format of this file.
-[runs_as]
+[can_run_as]
# List all the users you want to be able to launch daemons in a list here
# followed by an optional comma separated list of users they are allowed to
# start their daemons as.

0 comments on commit 720908f

Please sign in to comment.