=== modified file 'plugin-runner.c' --- plugin-runner.c 2008-08-31 20:01:03 +0000 +++ plugin-runner.c 2008-09-01 16:19:32 +0000 @@ -132,7 +132,7 @@ } new_plugin->argv[0] = copy_name; new_plugin->argv[1] = NULL; - + new_plugin->environ = malloc(sizeof(char *)); if(new_plugin->environ == NULL){ free(copy_name); @@ -141,7 +141,7 @@ return NULL; } new_plugin->environ[0] = NULL; - + /* Append the new plugin to the list */ plugin_list = new_plugin; return new_plugin; @@ -183,6 +183,15 @@ if(p == NULL){ return false; } + /* namelen = length of name of environment variable */ + size_t namelen = (size_t)(strchrnul(def, '=') - def); + /* Search for this environment variable */ + for(char **e = p->environ; *e != NULL; e++){ + if(strncmp(*e, def, namelen+1) == 0){ + /* Refuse to add an existing variable */ + return true; + } + } return add_to_char_array(def, &(p->environ), &(p->envc)); } @@ -327,13 +336,13 @@ { .name = "global-options", .key = 'g', .arg = "OPTION[,OPTION[,...]]", .doc = "Options passed to all plugins" }, - { .name = "global-envs", .key = 'e', + { .name = "global-env", .key = 'e', .arg = "VAR=value", .doc = "Environment variable passed to all plugins" }, { .name = "options-for", .key = 'o', .arg = "PLUGIN:OPTION[,OPTION[,...]]", .doc = "Options passed only to specified plugin" }, - { .name = "envs-for", .key = 'f', + { .name = "env-for", .key = 'f', .arg = "PLUGIN:ENV=value", .doc = "Environment variable passed to specified plugin" }, { .name = "disable", .key = 'd', @@ -375,7 +384,7 @@ } } break; - case 'e': /* --global-envs */ + case 'e': /* --global-env */ if(arg == NULL){ break; } @@ -413,7 +422,7 @@ } } break; - case 'f': /* --envs-for */ + case 'f': /* --env-for */ if(arg == NULL){ break; } === modified file 'plugin-runner.xml' --- plugin-runner.xml 2008-09-01 08:29:23 +0000 +++ plugin-runner.xml 2008-09-01 16:19:32 +0000 @@ -53,7 +53,7 @@ &COMMANDNAME; - - @@ -159,6 +159,35 @@ OPTIONS + + + + + + + + + + + + + + + + + + + option. The plugins are started in parallel, and the first plugin to output - a password and exit with a successful exit code will make this - plugin-runner output that password, stop any other plugins, and - exit. + a password and exit with a successful exit + code will make this plugin-runner output the password from that + plugin, stop any other plugins, and exit. - + FALLBACK + If no plugins succeed, this program will, as a fallback, ask for + a password on the console using getpass3, + and output it. This is not meant to be the normal mode of + operation, as there is a separate plugin for getting a password + from the console. + EXIT STATUS - - - + Exit status of this program is zero if no errors were + encountered, and otherwise not. The fallback (see ) may or may not have succeeded in either + case. + + + + + ENVIRONMENT + + + + + FILES - - - - - NOTES - + + + /conf/conf.d/mandos/plugin-runner.conf + + + Since this program will be run as a keyscript, there is + little to no opportunity to pass command line arguments + to it. Therefore, it will also + read this file and use its contents as + whitespace-separated command line options. Also, + everything from a # character to the end + of a line is ignored. + + + + @@ -360,19 +418,19 @@ - + EXAMPLE - + SECURITY - + SEE ALSO @@ -386,7 +444,7 @@ 8mandos - +