=== modified file 'TODO' --- TODO 2008-08-27 01:18:25 +0000 +++ TODO 2008-08-29 05:53:59 +0000 @@ -59,26 +59,7 @@ Must create in preinst if not pre-depending on cryptsetup * password-prompt -** [#A] Man page: man8/password-prompt.8mandos -*** SYNOPSIS - Document short options -*** DESCRIPTION - Note that this is more or less a simple getpass(3) wrapper, even - though actual use of getpass(3) is not guaranteed. -*** EXIT STATUS -*** ENVIRONMENT - Document use of "cryptsource" and "crypttarget". -*** FILES -*** BUGS -*** EXAMPLE - Examples of normal usage, debug usage, with a prefix, etc. -*** SECURITY - Not much to do here but it is noteworthy to state the danger of - not having a fallback option. -*** SEE ALSO - Refer to mandos-client(8mandos) and password-request(8mandos) - and also, perhaps, to cryptsetup(8)? -** Use getpass(3)? +** [#C] Use getpass(3)? Man page says "obsolete", but [[info:libc:getpass][GNU LibC Manual: Reading Passwords]] does not. See also [[http://sources.redhat.com/ml/libc-alpha/2003-05/msg00251.html][Marcus Brinkmann: Re: getpass obsolete?]] and [[http://article.gmane.org/gmane.comp.lib.glibc.alpha/4906][Petter Reinholdtsen: Re: getpass obsolete?]], and especially also === modified file 'mandos.xml' --- mandos.xml 2008-08-25 10:41:16 +0000 +++ mandos.xml 2008-08-29 05:53:59 +0000 @@ -448,7 +448,7 @@ Normal invocation needs no options: - mandos + &COMMANDNAME; @@ -461,7 +461,7 @@ -mandos --debug --configdir ~/mandos --servicename Test +&COMMANDNAME; --debug --configdir ~/mandos --servicename Test @@ -473,7 +473,7 @@ -mandos --interface eth7 --address fe80::aede:48ff:fe71:f6f2 +&COMMANDNAME; --interface eth7 --address fe80::aede:48ff:fe71:f6f2 === modified file 'plugins.d/password-prompt.c' --- plugins.d/password-prompt.c 2008-08-16 16:58:31 +0000 +++ plugins.d/password-prompt.c 2008-08-29 05:53:59 +0000 @@ -73,7 +73,7 @@ struct argp_option options[] = { { .name = "prefix", .key = 'p', .arg = "PREFIX", .flags = 0, - .doc = "Prefix used before the passprompt", .group = 2 }, + .doc = "Prefix shown before the prompt", .group = 2 }, { .name = "debug", .key = 128, .doc = "Debug mode", .group = 3 }, { .name = NULL } @@ -102,7 +102,8 @@ struct argp argp = { .options = options, .parser = parse_opt, .args_doc = "", - .doc = "Mandos Passprompt -- Provides a passprompt" }; + .doc = "Mandos password-prompt -- Read and" + " output a password" }; ret = argp_parse (&argp, argc, argv, 0, 0, NULL); if (ret == ARGP_ERR_UNKNOWN){ fprintf(stderr, "Unknown error while parsing arguments\n"); @@ -118,6 +119,7 @@ } if (tcgetattr(STDIN_FILENO, &t_old) != 0){ + perror("tcgetattr"); return EXIT_FAILURE; } @@ -179,6 +181,9 @@ } while(true){ if (quit_now){ + if(debug){ + fprintf(stderr, "Interrupted by signal, exiting.\n"); + } status = EXIT_FAILURE; break; } @@ -208,8 +213,19 @@ } ret = getline(&buffer, &n, stdin); if (ret > 0){ - fprintf(stdout, "%s", buffer); status = EXIT_SUCCESS; + /* Make n = data size instead of allocated buffer size */ + n = (size_t)ret; + size_t written = 0; + while(written < n){ + ret = write(STDOUT_FILENO, buffer + written, n - written); + if(ret < 0){ + perror("write"); + status = EXIT_FAILURE; + break; + } + written += (size_t)ret; + } break; } if (ret < 0){ @@ -222,6 +238,11 @@ /* if(ret == 0), then the only sensible thing to do is to retry to read from stdin */ fputc('\n', stderr); + if(debug and not quit_now){ + /* If quit_now is true, we were interrupted by a signal, and + will print that later, so no need to show this too. */ + fprintf(stderr, "getline() returned 0, retrying.\n"); + } } if (debug){ @@ -232,7 +253,8 @@ } if (debug){ - fprintf(stderr, "%s is exiting\n", argv[0]); + fprintf(stderr, "%s is exiting with status %d\n", argv[0], + status); } return status; === modified file 'plugins.d/password-prompt.xml' --- plugins.d/password-prompt.xml 2008-08-18 05:24:20 +0000 +++ plugins.d/password-prompt.xml 2008-08-29 05:53:59 +0000 @@ -1,18 +1,18 @@ - - + + ]> - &COMMANDNAME; - - &COMMANDNAME; + Mandos Manual + + Mandos &VERSION; + &TIMESTAMP; Björn @@ -31,7 +31,8 @@ 2008 - Teddy Hogeborn & Björn Påhlsson + Teddy Hogeborn + Björn Påhlsson @@ -41,7 +42,7 @@ either version 3 of the License, or (at your option) any later version. - + This manual page is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the @@ -49,7 +50,7 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; If not, see @@ -57,7 +58,7 @@ - + &COMMANDNAME; 8mandos @@ -65,146 +66,260 @@ &COMMANDNAME; - - Passprompt for luks during boot sequence - + Prompt for a password and output it. &COMMANDNAME; - --prefixPREFIX - --debug - - - &COMMANDNAME; - --help - - - &COMMANDNAME; - --usage - - - &COMMANDNAME; - --version + + + PREFIX + + + + + &COMMANDNAME; + + + + + + + &COMMANDNAME; + + + + &COMMANDNAME; + + + + - + DESCRIPTION - &COMMANDNAME; is a terminal program that ask for - passwords during boot sequence. It is a plugin to - mandos, and is used as a fallback and - alternative to retriving passwords from a mandos server. During - boot sequence the user is prompted for the disk password, and - when a password is given it then gets forwarded to - LUKS. + All &COMMANDNAME; does is prompt for a + password and output any given password to standard output. This + is not very useful on its own. This program is really meant to + run as a plugin in the Mandos + client-side system, where it is used as a fallback and + alternative to retriving passwords from a Mandos server. + + + This program is little more than a getpass3 + wrapper, although actual use of that function is not guaranteed + or implied. OPTIONS - Commonly not invoked as command lines but from configuration - file of plugin runner. + This program is commonly not invoked from the command line; it + is normally started by the Mandos + plugin runner, see plugin-runner8mandos + . Any command line options this program accepts + are therefore normally provided by the plugin runner, and not + directly. - + - -p, --prefix=PREFIX - - - - Prefix used before the passprompt - - - - - - --debug - - - Debug mode - - - - - - -?, --help - - - Gives a help message - - - - - - --usage - - - Gives a short usage message - - - - - - -V, --version - - - Prints the program version + PREFIX + PREFIX + + + Prefix string shown before the password prompt. + + + + + + + + + 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. + + + + + + + + + + Gives a help message about options and their meanings. + + + + + + + + + Gives a short usage message. + + + + + + + + + + Prints the program version. - + EXIT STATUS + If exit status is 0, the output from the program is the password + as it was read. Otherwise, if exit status is other than 0, the + program has encountered an error, and any output so far could be + corrupt and/or truncated, and should therefore be ignored. - + ENVIRONMENT - - - - - - FILES - - + + + cryptsource + crypttarget + + + If set, these environment variables will be assumed to + contain the source device name and the target device + mapper name, respectively, and will be shown as part of + the prompt. + + + These variables will normally be inherited from + plugin-runner + 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 + /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 + /usr/share/initramfs-tools/hooks/cryptroot, by + extracting the information of the root file system from + /etc/crypttab. + + + This behavior is meant to exactly mirror the behavior of + askpass, the default password prompter. + + + + BUGS + None are known at this time. - + EXAMPLE + Note that normally, command line options will not be given + directly, but via options for the Mandos plugin-runner + 8mandos. + + + Normal invocation needs no options: + + + &COMMANDNAME; + + + + + Show a prefix before the prompt; in this case, a host name. + It might be useful to be reminded of which host needs a + password, in case of KVM switches, etc. + + + + +&COMMANDNAME; --prefix=host.example.org: + + + + + + Run in debug mode. + + + + &COMMANDNAME; --debug + + - + SECURITY + On its own, this program is very simple, and does not exactly + present any security risks. The one thing that could be + considered worthy of note is this: This program is meant to be + run by plugin-runner8mandos + , and will, when run standalone, outside, in a + normal environment, immediately output on its standard output + any presumably secret password it just recieved. Therefore, + when running this program standalone (which should never + normally be done), take care not to type in any real secret + password by force of habit, since it would then immediately be + shown as output. + + + To further alleviate any risk of being locked out of a system, + the plugin-runner + 8mandos has a fallback + mode which does the same thing as this program, only with less + features. - + SEE ALSO - mandos - 8, - plugin-runner - 8mandos and - password-request + crypttab + 5 + password-request 8mandos + plugin-runner + 8mandos, - - + + + + + +