bzr branch
http://bzr.recompile.se/loggerhead/mandos/trunk
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 1 | /*  -*- coding: utf-8; mode: c; mode: orgtbl -*- */
 | 
| 21
by Teddy Hogeborn * Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and | 2 | /*
 | 
| 261
by Teddy Hogeborn * plugins.d/askpass-fifo.c: Fix name in header. | 3 |  * Password-prompt - Read a password from the terminal and print it
 | 
| 237.1.2
by Teddy Hogeborn Further steps towards a D-Bus server interface, plus minor syntax | 4 |  * 
 | 
| 246
by Teddy Hogeborn * README: Update copyright year; add "2009". | 5 |  * Copyright © 2008,2009 Teddy Hogeborn
 | 
| 6 |  * Copyright © 2008,2009 Björn Påhlsson
 | |
| 21
by Teddy Hogeborn * Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and | 7 |  * 
 | 
| 8 |  * This program is free software: you can redistribute it and/or
 | |
| 9 |  * modify it under the terms of the GNU General Public License as
 | |
| 10 |  * published by the Free Software Foundation, either version 3 of the
 | |
| 11 |  * License, or (at your option) any later version.
 | |
| 12 |  * 
 | |
| 13 |  * This program is distributed in the hope that it will be useful, but
 | |
| 14 |  * WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | |
| 16 |  * General Public License for more details.
 | |
| 17 |  * 
 | |
| 18 |  * You should have received a copy of the GNU General Public License
 | |
| 19 |  * along with this program.  If not, see
 | |
| 20 |  * <http://www.gnu.org/licenses/>.
 | |
| 21 |  * 
 | |
| 363
by Teddy Hogeborn * plugin-runner.c: Minor stylistic changes. | 22 |  * Contact the authors at <mandos@fukt.bsnet.se>.
 | 
| 21
by Teddy Hogeborn * Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and | 23 |  */
 | 
| 24 | ||
| 13
by Björn Påhlsson Added following support: | 25 | #define _GNU_SOURCE /* getline() */ | 
| 21
by Teddy Hogeborn * Makefile (CFLAGS): Changed to use $(WARN), $(DEBUG), $(COVERAGE) and | 26 | |
| 13
by Björn Påhlsson Added following support: | 27 | #include <termios.h> /* struct termios, tcsetattr(), | 
| 28 | TCSAFLUSH, tcgetattr(), ECHO */ | |
| 29 | #include <unistd.h> /* struct termios, tcsetattr(), | |
| 30 | STDIN_FILENO, TCSAFLUSH, | |
| 31 | tcgetattr(), ECHO */ | |
| 32 | #include <signal.h> /* sig_atomic_t, raise(), struct | |
| 33 | sigaction, sigemptyset(), | |
| 34 | sigaction(), sigaddset(), SIGINT, | |
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 35 | SIGQUIT, SIGHUP, SIGTERM, | 
| 36 | raise() */ | |
| 24.1.26
by Björn Påhlsson tally count of used symbols | 37 | #include <stddef.h> /* NULL, size_t, ssize_t */ | 
| 13
by Björn Påhlsson Added following support: | 38 | #include <sys/types.h> /* ssize_t */ | 
| 15.1.3
by Björn Påhlsson Added getopt_long support for mandosclient and passprompt | 39 | #include <stdlib.h> /* EXIT_SUCCESS, EXIT_FAILURE, | 
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 40 | getenv() */ | 
| 13
by Björn Påhlsson Added following support: | 41 | #include <stdio.h> /* fprintf(), stderr, getline(), | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 42 | stdin, feof(), fputc() | 
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 43 | */ | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 44 | #include <errno.h> /* errno, EBADF, ENOTTY, EINVAL, | 
| 45 | EFAULT, EFBIG, EIO, ENOSPC, EINTR | |
| 46 | */ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 47 | #include <error.h> /* error() */ | 
| 13
by Björn Påhlsson Added following support: | 48 | #include <iso646.h> /* or, not */ | 
| 49 | #include <stdbool.h> /* bool, false, true */ | |
| 24.1.141
by Björn Påhlsson fixed incorrect include comments | 50 | #include <string.h> /* strlen, rindex */ | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 51 | #include <argp.h> /* struct argp_option, struct | 
| 52 | argp_state, struct argp, | |
| 53 | argp_parse(), error_t, | |
| 54 | ARGP_KEY_ARG, ARGP_KEY_END, | |
| 55 | ARGP_ERR_UNKNOWN */ | |
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 56 | #include <sysexits.h> /* EX_SOFTWARE, EX_OSERR, | 
| 57 | EX_UNAVAILABLE, EX_IOERR, EX_OK */ | |
| 13
by Björn Påhlsson Added following support: | 58 | |
| 294
by Teddy Hogeborn * plugins.d/password-prompt.c (quit_now): Changed type to "volatile | 59 | volatile sig_atomic_t quit_now = 0; | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 60 | int signal_received; | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 61 | bool debug = false; | 
| 217
by Teddy Hogeborn * .bzrignore: Added "man" directory (created by "make install-html"). | 62 | const char *argp_program_version = "password-prompt " VERSION; | 
| 24.1.17
by Björn Påhlsson passprompt | 63 | const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>"; | 
| 13
by Björn Påhlsson Added following support: | 64 | |
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 65 | static void termination_handler(int signum){ | 
| 66 | if(quit_now){ | |
| 67 | return; | |
| 68 | } | |
| 294
by Teddy Hogeborn * plugins.d/password-prompt.c (quit_now): Changed type to "volatile | 69 | quit_now = 1; | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 70 | signal_received = signum; | 
| 13
by Björn Påhlsson Added following support: | 71 | }
 | 
| 72 | ||
| 73 | int main(int argc, char **argv){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 74 | ssize_t sret; | 
| 75 | int ret; | |
| 13
by Björn Påhlsson Added following support: | 76 | size_t n; | 
| 77 | struct termios t_new, t_old; | |
| 78 | char *buffer = NULL; | |
| 15.1.3
by Björn Påhlsson Added getopt_long support for mandosclient and passprompt | 79 | char *prefix = NULL; | 
| 13
by Björn Påhlsson Added following support: | 80 | int status = EXIT_SUCCESS; | 
| 81 | struct sigaction old_action, | |
| 82 | new_action = { .sa_handler = termination_handler, | |
| 83 | .sa_flags = 0 }; | |
| 24.1.17
by Björn Påhlsson passprompt | 84 | { | 
| 85 | struct argp_option options[] = { | |
| 86 | { .name = "prefix", .key = 'p', | |
| 87 | .arg = "PREFIX", .flags = 0, | |
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 88 | .doc = "Prefix shown before the prompt", .group = 2 }, | 
| 24.1.17
by Björn Påhlsson passprompt | 89 | { .name = "debug", .key = 128, | 
| 90 | .doc = "Debug mode", .group = 3 }, | |
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 91 | /* | 
| 92 |        * These reproduce what we would get without ARGP_NO_HELP
 | |
| 93 |        */
 | |
| 94 | { .name = "help", .key = '?', | |
| 95 | .doc = "Give this help list", .group = -1 }, | |
| 96 | { .name = "usage", .key = -3, | |
| 97 | .doc = "Give a short usage message", .group = -1 }, | |
| 98 | { .name = "version", .key = 'V', | |
| 99 | .doc = "Print program version", .group = -1 }, | |
| 24.1.17
by Björn Påhlsson passprompt | 100 | { .name = NULL } | 
| 101 | }; | |
| 257
by Teddy Hogeborn Change the default value of the "checker" option command to make the | 102 |     
 | 
| 293
by Teddy Hogeborn * plugin-runner.c: Whitespace changes only. | 103 | error_t parse_opt (int key, char *arg, struct argp_state *state){ | 
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 104 | errno = 0; | 
| 293
by Teddy Hogeborn * plugin-runner.c: Whitespace changes only. | 105 | switch (key){ | 
| 24.1.17
by Björn Påhlsson passprompt | 106 | case 'p': | 
| 107 | prefix = arg; | |
| 108 | break; | |
| 109 | case 128: | |
| 110 | debug = true; | |
| 111 | break; | |
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 112 | /* | 
| 113 | 	 * These reproduce what we would get without ARGP_NO_HELP
 | |
| 114 | 	 */
 | |
| 115 | case '?': /* --help */ | |
| 116 | argp_state_help(state, state->out_stream, | |
| 117 | (ARGP_HELP_STD_HELP | ARGP_HELP_EXIT_ERR) | |
| 118 | & ~(unsigned int)ARGP_HELP_EXIT_OK); | |
| 119 | case -3: /* --usage */ | |
| 120 | argp_state_help(state, state->out_stream, | |
| 121 | ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR); | |
| 122 | case 'V': /* --version */ | |
| 123 | fprintf(state->out_stream, "%s\n", argp_program_version); | |
| 124 | exit(argp_err_exit_status); | |
| 24.1.17
by Björn Påhlsson passprompt | 125 | break; | 
| 126 | default: | |
| 127 | return ARGP_ERR_UNKNOWN; | |
| 128 | } | |
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 129 | return errno; | 
| 24.1.17
by Björn Påhlsson passprompt | 130 | } | 
| 257
by Teddy Hogeborn Change the default value of the "checker" option command to make the | 131 |     
 | 
| 24.1.17
by Björn Påhlsson passprompt | 132 | struct argp argp = { .options = options, .parser = parse_opt, | 
| 133 | .args_doc = "", | |
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 134 | .doc = "Mandos password-prompt -- Read and" | 
| 135 | " output a password" }; | |
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 136 | ret = argp_parse(&argp, argc, argv, | 
| 137 | ARGP_IN_ORDER | ARGP_NO_HELP, NULL, NULL); | |
| 138 | switch(ret){ | |
| 139 | case 0: | |
| 140 | break; | |
| 141 | case ENOMEM: | |
| 142 | default: | |
| 143 | errno = ret; | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 144 | error(0, errno, "argp_parse"); | 
| 394
by Teddy Hogeborn Convert some programs to use the exit codes from <sysexits.h>. Change | 145 | return EX_OSERR; | 
| 146 | case EINVAL: | |
| 147 | return EX_USAGE; | |
| 24.1.26
by Björn Påhlsson tally count of used symbols | 148 | } | 
| 15.1.3
by Björn Påhlsson Added getopt_long support for mandosclient and passprompt | 149 | } | 
| 257
by Teddy Hogeborn Change the default value of the "checker" option command to make the | 150 |   
 | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 151 | if(debug){ | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 152 | fprintf(stderr, "Starting %s\n", argv[0]); | 
| 153 | } | |
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 154 | if(debug){ | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 155 | fprintf(stderr, "Storing current terminal attributes\n"); | 
| 156 | } | |
| 13
by Björn Påhlsson Added following support: | 157 |   
 | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 158 | if(tcgetattr(STDIN_FILENO, &t_old) != 0){ | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 159 | int e = errno; | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 160 | error(0, errno, "tcgetattr"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 161 | switch(e){ | 
| 162 | case EBADF: | |
| 163 | case ENOTTY: | |
| 164 | return EX_UNAVAILABLE; | |
| 165 | default: | |
| 166 | return EX_OSERR; | |
| 167 | } | |
| 13
by Björn Påhlsson Added following support: | 168 | } | 
| 169 |   
 | |
| 170 | sigemptyset(&new_action.sa_mask); | |
| 357
by Teddy Hogeborn * plugins.d/mandos-client.c (main): Do not handle ignored signals. | 171 | ret = sigaddset(&new_action.sa_mask, SIGINT); | 
| 172 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 173 | error(0, errno, "sigaddset"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 174 | return EX_OSERR; | 
| 357
by Teddy Hogeborn * plugins.d/mandos-client.c (main): Do not handle ignored signals. | 175 | } | 
| 176 | ret = sigaddset(&new_action.sa_mask, SIGHUP); | |
| 177 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 178 | error(0, errno, "sigaddset"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 179 | return EX_OSERR; | 
| 357
by Teddy Hogeborn * plugins.d/mandos-client.c (main): Do not handle ignored signals. | 180 | } | 
| 181 | ret = sigaddset(&new_action.sa_mask, SIGTERM); | |
| 182 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 183 | error(0, errno, "sigaddset"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 184 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 185 | } | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 186 | /* Need to check if the handler is SIG_IGN before handling: | 
| 187 |      | [[info:libc:Initial Signal Actions]] |
 | |
| 188 |      | [[info:libc:Basic Signal Handling]]  |
 | |
| 189 |   */
 | |
| 357
by Teddy Hogeborn * plugins.d/mandos-client.c (main): Do not handle ignored signals. | 190 | ret = sigaction(SIGINT, NULL, &old_action); | 
| 191 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 192 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 193 | return EX_OSERR; | 
| 357
by Teddy Hogeborn * plugins.d/mandos-client.c (main): Do not handle ignored signals. | 194 | } | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 195 | if(old_action.sa_handler != SIG_IGN){ | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 196 | ret = sigaction(SIGINT, &new_action, NULL); | 
| 197 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 198 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 199 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 200 | } | 
| 201 | } | |
| 202 | ret = sigaction(SIGHUP, NULL, &old_action); | |
| 203 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 204 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 205 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 206 | } | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 207 | if(old_action.sa_handler != SIG_IGN){ | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 208 | ret = sigaction(SIGHUP, &new_action, NULL); | 
| 209 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 210 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 211 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 212 | } | 
| 213 | } | |
| 214 | ret = sigaction(SIGTERM, NULL, &old_action); | |
| 215 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 216 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 217 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 218 | } | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 219 | if(old_action.sa_handler != SIG_IGN){ | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 220 | ret = sigaction(SIGTERM, &new_action, NULL); | 
| 221 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 222 | error(0, errno, "sigaction"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 223 | return EX_OSERR; | 
| 24.1.26
by Björn Påhlsson tally count of used symbols | 224 | } | 
| 225 | } | |
| 226 |   
 | |
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 227 |   
 | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 228 | if(debug){ | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 229 | fprintf(stderr, "Removing echo flag from terminal attributes\n"); | 
| 230 | } | |
| 13
by Björn Påhlsson Added following support: | 231 |   
 | 
| 232 | t_new = t_old; | |
| 377
by Teddy Hogeborn * plugins.d/password-prompt.c (main): Fix "-Wconversion" warning. | 233 | t_new.c_lflag &= ~(tcflag_t)ECHO; | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 234 | if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_new) != 0){ | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 235 | int e = errno; | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 236 | error(0, errno, "tcsetattr-echo"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 237 | switch(e){ | 
| 238 | case EBADF: | |
| 239 | case ENOTTY: | |
| 240 | return EX_UNAVAILABLE; | |
| 241 | case EINVAL: | |
| 242 | default: | |
| 243 | return EX_OSERR; | |
| 244 | } | |
| 13
by Björn Påhlsson Added following support: | 245 | } | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 246 |   
 | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 247 | if(debug){ | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 248 | fprintf(stderr, "Waiting for input from stdin \n"); | 
| 249 | } | |
| 13
by Björn Påhlsson Added following support: | 250 | while(true){ | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 251 | if(quit_now){ | 
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 252 | if(debug){ | 
| 253 | fprintf(stderr, "Interrupted by signal, exiting.\n"); | |
| 254 | } | |
| 13
by Björn Påhlsson Added following support: | 255 | status = EXIT_FAILURE; | 
| 256 | break; | |
| 257 | } | |
| 15.1.3
by Björn Påhlsson Added getopt_long support for mandosclient and passprompt | 258 | |
| 259 | if(prefix){ | |
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 260 | fprintf(stderr, "%s ", prefix); | 
| 261 | } | |
| 262 | { | |
| 397
by Teddy Hogeborn * plugins.d/password-prompt.c: Use environment variables and prompt | 263 | const char *cryptsource = getenv("CRYPTTAB_SOURCE"); | 
| 264 | const char *crypttarget = getenv("CRYPTTAB_NAME"); | |
| 265 | /* Before cryptsetup 1.1.0~rc2 */ | |
| 266 | if(cryptsource == NULL){ | |
| 267 | cryptsource = getenv("cryptsource"); | |
| 268 | } | |
| 269 | if(crypttarget == NULL){ | |
| 270 | crypttarget = getenv("crypttarget"); | |
| 271 | } | |
| 272 | const char *const prompt1 = "Unlocking the disk"; | |
| 273 | const char *const prompt2 = "Enter passphrase"; | |
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 274 | if(cryptsource == NULL){ | 
| 275 | if(crypttarget == NULL){ | |
| 397
by Teddy Hogeborn * plugins.d/password-prompt.c: Use environment variables and prompt | 276 | fprintf(stderr, "%s to unlock the disk: ", prompt2); | 
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 277 | } else { | 
| 397
by Teddy Hogeborn * plugins.d/password-prompt.c: Use environment variables and prompt | 278 | fprintf(stderr, "%s (%s)\n%s: ", prompt1, crypttarget, | 
| 279 | prompt2); | |
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 280 | } | 
| 281 | } else { | |
| 282 | if(crypttarget == NULL){ | |
| 397
by Teddy Hogeborn * plugins.d/password-prompt.c: Use environment variables and prompt | 283 | fprintf(stderr, "%s %s\n%s: ", prompt1, cryptsource, | 
| 284 | prompt2); | |
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 285 | } else { | 
| 397
by Teddy Hogeborn * plugins.d/password-prompt.c: Use environment variables and prompt | 286 | fprintf(stderr, "%s %s (%s)\n%s: ", prompt1, cryptsource, | 
| 287 | crypttarget, prompt2); | |
| 79
by Teddy Hogeborn * plugins.d/password-request.c (main): Include environment variables | 288 | } | 
| 289 | } | |
| 290 | } | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 291 | sret = getline(&buffer, &n, stdin); | 
| 292 | if(sret > 0){ | |
| 13
by Björn Påhlsson Added following support: | 293 | status = EXIT_SUCCESS; | 
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 294 | /* Make n = data size instead of allocated buffer size */ | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 295 | n = (size_t)sret; | 
| 168
by Teddy Hogeborn * initramfs-tools-hook: Use long options where available. Use only | 296 | /* Strip final newline */ | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 297 | if(n > 0 and buffer[n-1] == '\n'){ | 
| 168
by Teddy Hogeborn * initramfs-tools-hook: Use long options where available. Use only | 298 | buffer[n-1] = '\0'; /* not strictly necessary */ | 
| 299 | n--; | |
| 300 | } | |
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 301 | size_t written = 0; | 
| 302 | while(written < n){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 303 | sret = write(STDOUT_FILENO, buffer + written, n - written); | 
| 304 | if(sret < 0){ | |
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 305 | int e = errno; | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 306 | error(0, errno, "write"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 307 | switch(e){ | 
| 308 | case EBADF: | |
| 309 | case EFAULT: | |
| 310 | case EINVAL: | |
| 311 | case EFBIG: | |
| 312 | case EIO: | |
| 313 | case ENOSPC: | |
| 314 | default: | |
| 315 | status = EX_IOERR; | |
| 316 | break; | |
| 317 | case EINTR: | |
| 318 | status = EXIT_FAILURE; | |
| 319 | break; | |
| 320 | } | |
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 321 | break; | 
| 322 | } | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 323 | written += (size_t)sret; | 
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 324 | } | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 325 | sret = close(STDOUT_FILENO); | 
| 326 | if(sret == -1){ | |
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 327 | int e = errno; | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 328 | error(0, errno, "close"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 329 | switch(e){ | 
| 330 | case EBADF: | |
| 331 | status = EX_OSFILE; | |
| 332 | break; | |
| 333 | case EIO: | |
| 334 | default: | |
| 335 | status = EX_IOERR; | |
| 336 | break; | |
| 337 | } | |
| 338 | } | |
| 13
by Björn Påhlsson Added following support: | 339 | break; | 
| 340 | } | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 341 | if(sret < 0){ | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 342 | int e = errno; | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 343 | if(errno != EINTR and not feof(stdin)){ | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 344 | error(0, errno, "getline"); | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 345 | switch(e){ | 
| 346 | case EBADF: | |
| 347 | status = EX_UNAVAILABLE; | |
| 348 | case EIO: | |
| 349 | case EINVAL: | |
| 350 | default: | |
| 351 | status = EX_IOERR; | |
| 352 | break; | |
| 353 | } | |
| 13
by Björn Påhlsson Added following support: | 354 | break; | 
| 355 | } | |
| 356 | } | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 357 | /* if(sret == 0), then the only sensible thing to do is to retry to | 
| 41
by Teddy Hogeborn Merge. | 358 |        read from stdin */
 | 
| 13
by Björn Påhlsson Added following support: | 359 | fputc('\n', stderr); | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 360 | if(debug and not quit_now){ | 
| 294
by Teddy Hogeborn * plugins.d/password-prompt.c (quit_now): Changed type to "volatile | 361 | /* If quit_now is nonzero, we were interrupted by a signal, and | 
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 362 | 	 will print that later, so no need to show this too. */
 | 
| 363 | fprintf(stderr, "getline() returned 0, retrying.\n"); | |
| 364 | } | |
| 13
by Björn Påhlsson Added following support: | 365 | } | 
| 257
by Teddy Hogeborn Change the default value of the "checker" option command to make the | 366 |   
 | 
| 24.1.92
by Björn Påhlsson Several memory leaks detected by valgrind fixed | 367 | free(buffer); | 
| 41
by Teddy Hogeborn Merge. | 368 |   
 | 
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 369 | if(debug){ | 
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 370 | fprintf(stderr, "Restoring terminal attributes\n"); | 
| 371 | } | |
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 372 | if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_old) != 0){ | 
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 373 | error(0, errno, "tcsetattr+echo"); | 
| 13
by Björn Påhlsson Added following support: | 374 | } | 
| 41
by Teddy Hogeborn Merge. | 375 |   
 | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 376 | if(quit_now){ | 
| 377 | sigemptyset(&old_action.sa_mask); | |
| 378 | old_action.sa_handler = SIG_DFL; | |
| 379 | ret = sigaction(signal_received, &old_action, NULL); | |
| 380 | if(ret == -1){ | |
| 24.1.155
by Björn Påhlsson mandos server: Added debuglevel that adjust at what level information | 381 | error(0, errno, "sigaction"); | 
| 356
by Teddy Hogeborn * plugin-runner.c (main): When a plugin is killed by a signal, show | 382 | } | 
| 383 | raise(signal_received); | |
| 384 | } | |
| 385 |   
 | |
| 266
by Teddy Hogeborn * plugin-runner.c: Only space changes. | 386 | if(debug){ | 
| 110
by Teddy Hogeborn * mandos.xml (EXAMPLE): Replaced all occurences of command name with | 387 | fprintf(stderr, "%s is exiting with status %d\n", argv[0], | 
| 388 | status); | |
| 15.1.2
by Björn Påhlsson Added debug options from passprompt as --debug and --debug=passprompt | 389 | } | 
| 391
by Teddy Hogeborn * plugins.d/password-prompt.c: Use exit codes from <sysexits.h>. Do | 390 | if(status == EXIT_SUCCESS or status == EX_OK){ | 
| 167
by Teddy Hogeborn * plugins.d/password-prompt.c (main): If successful, output an extra | 391 | fputc('\n', stderr); | 
| 392 | } | |
| 13
by Björn Påhlsson Added following support: | 393 |   
 | 
| 394 | return status; | |
| 395 | }
 |