=== modified file 'mandos.xml' --- mandos.xml 2008-08-31 15:06:39 +0000 +++ mandos.xml 2008-09-01 08:29:23 +0000 @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ - + ]> @@ -240,7 +240,7 @@ This program is the server part. It is a normal server program and will run in a normal system environment, not in an initial - RAM disk environment. + RAM disk environment. @@ -521,9 +521,9 @@ restarting servers if it is suspected that a client has, in fact, been compromised by parties who may now be running a fake Mandos client with the keys from the non-encrypted - initial RAM image of the client host. What should be done in - that case (if restarting the server program really is - necessary) is to stop the server program, edit the + initial RAM image of the client host. What + should be done in that case (if restarting the server program + really is necessary) is to stop the server program, edit the configuration file to omit any suspect clients, and restart the server program. === modified file 'overview.xml' --- overview.xml 2008-08-31 15:06:39 +0000 +++ overview.xml 2008-09-01 08:29:23 +0000 @@ -5,11 +5,11 @@ This is part of the Mandos system for allowing computers to have encrypted root file systems and at the same time be capable of remote and/or unattended reboots. The computers run a small client - program in the initial RAM disk environment which will communicate - with a server over a network. The clients are identified by the - server using a OpenPGP key; each client has one unique to it. The - server sends the clients an encrypted password. The encrypted - password is decrypted by the clients using the same OpenPGP key, and - the password is then used to unlock the root file system, whereupon - the computers can continue booting normally. + program in the initial RAM disk environment which + will communicate with a server over a network. The clients are + identified by the server using a OpenPGP key; each client has one + unique to it. The server sends the clients an encrypted password. + The encrypted password is decrypted by the clients using the same + OpenPGP key, and the password is then used to unlock the root file + system, whereupon the computers can continue booting normally. === modified file 'plugin-runner.c' --- plugin-runner.c 2008-08-31 16:03:21 +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', @@ -356,7 +365,8 @@ { .name = NULL } }; - error_t parse_opt (int key, char *arg, __attribute__((unused)) struct argp_state *state) { + error_t parse_opt (int key, char *arg, __attribute__((unused)) + struct argp_state *state) { /* Get the INPUT argument from `argp_parse', which we know is a pointer to our plugin list pointer. */ switch (key) { @@ -374,7 +384,7 @@ } } break; - case 'e': /* --global-envs */ + case 'e': /* --global-env */ if(arg == NULL){ break; } @@ -412,7 +422,7 @@ } } break; - case 'f': /* --envs-for */ + case 'f': /* --env-for */ if(arg == NULL){ break; } @@ -507,7 +517,8 @@ custom_argv[0] = argv[0]; custom_argv[1] = NULL; - /* for each line in the config file, strip whitespace and ignore commented text */ + /* for each line in the config file, strip whitespace and ignore + commented text */ while(true){ sret = getline(&org_line, &size, conffp); if(sret == -1){ === modified file 'plugin-runner.xml' --- plugin-runner.xml 2008-08-31 15:06:39 +0000 +++ plugin-runner.xml 2008-09-01 16:19:32 +0000 @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ - + ]> @@ -53,7 +53,7 @@ &COMMANDNAME; - - @@ -125,43 +125,84 @@ - + DESCRIPTION - &COMMANDNAME; is a plugin runner that waits - for any of its plugins to return sucessfull with a password, and - passes it to cryptsetup as stdout message. This command is not - meant to be invoked directly, but is instead meant to be run by - cryptsetup by being specified in /etc/crypttab as a keyscript - and subsequlently started in the initrd environment. See - crypttab - 5 for more information on - keyscripts. - - - - plugins is looked for in the plugins directory which by default will be - /conf/conf.d/mandos/plugins.d if not changed by option --plugin-dir. - - + &COMMANDNAME; is a program which is meant to + be specified as keyscript in + crypttab + 5 for the root disk. The + aim of this program is therefore to output a password, which + then cryptsetup + 8 will use to try and + unlock the root disk. + + + This program is not meant to be invoked directly, but can be in + order to test it. Note that any password obtained will simply + be output on standard output. + + + + + PURPOSE + + The purpose of this is to enable remote and unattended + rebooting of client host computer with an + encrypted root file system. See for details. + + + OPTIONS + + + + + + + + + + + + + + + + + + + - Global options given to all plugins as additional start - arguments. Options are specified with a -o flag followed - by a comma separated string of options. - + Pass some options to all plugins. + OPTIONS is a comma separated + list of options. This is not a very useful option, except + for specifying the + for all plugins. + - + - Plugin specific options given to the plugin as additional - start arguments. Options are specified with a -o flag - followed by a comma separated string of options. - + Pass some options to a specific plugin. PLUGIN is the name (file basename) of a + plugin, and OPTIONS is a comma + separated list of options. + + + Note that since options are not split on whitespace, the + way to pass, to the plugin + foo, the option + with the option argument + baz is either + --options-for=foo:--bar=baz or + --options-for=foo:--bar,baz, but + not + --options-for="foo:--bar baz". + @@ -185,7 +238,9 @@ PLUGIN - Disable a specific plugin + Disable the plugin named + PLUGIN. The plugin will not be + started. @@ -195,7 +250,10 @@ ID - Group ID the plugins will run as + Change to group ID ID on + startup. The default is 65534. All plugins will be + started using this group ID. Note: + This must be a number, not a name. @@ -205,7 +263,10 @@ ID - User ID the plugins will run as + Change to user ID ID on + startup. The default is 65534. All plugins will be + started using this user ID. Note: + This must be a number, not a name. @@ -215,7 +276,10 @@ DIRECTORY - Specify a different plugin directory + Specify a different plugin directory. The default is + /lib/mandos/plugins.d, which will + exist in the initial RAM disk + environment. @@ -224,7 +288,17 @@ - Debug mode + Enable debug mode. This will enable a lot of output to + standard error about what the program is doing. The + program will still perform all other functions normally. + The default is to not run in debug + mode. + + + The plugins will not be affected by + this option. Use + + if complete debugging eruption is desired. @@ -234,7 +308,7 @@ - Gives a help message + Gives a help message about options and their meanings. @@ -243,7 +317,7 @@ - Gives a short usage message + Gives a short usage message. @@ -253,28 +327,89 @@ - Prints the program version + Prints the program version. + + OVERVIEW + + + This program will run on the client side in the initial + RAM disk environment, and is responsible for + getting a password. It does this by running plugins, one of + which will normally be the actual client program communicating + with the server. + + + + PLUGINS + + This program will get a password by running a number of + plugins, which are simply executable + programs in a directory in the initial RAM + disk environment. The default directory is + /lib/mandos/plugins.d, but this can be + changed with the 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 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. + + + + @@ -283,19 +418,19 @@ - + EXAMPLE - + SECURITY - + SEE ALSO @@ -309,7 +444,7 @@ 8mandos - + === modified file 'plugins.d/password-prompt.xml' --- plugins.d/password-prompt.xml 2008-08-31 15:06:39 +0000 +++ plugins.d/password-prompt.xml 2008-09-01 08:29:23 +0000 @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ - + ]> @@ -194,8 +194,8 @@ 8mandos, which will normally have inherited them from /scripts/local-top/cryptroot in the - initial RAM disk environment, which will have set them from - parsing kernel arguments and + initial RAM disk environment, which will + have set them from parsing kernel arguments and /conf/conf.d/cryptroot (also in the initial RAM disk environment), which in turn will have been created when the initial RAM disk image was created by