/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/password-prompt.c

  • Committer: Teddy Hogeborn
  • Date: 2008-08-19 23:44:17 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080819234417-8dz5prw19ihrklx6
* Makefile (DOCBOOKTOMAN): Include all DocBook-to-manpage-related
                           commands here, and use it everywhere.
  (mandos.8, mandos.conf.5): New; also depend on "mandos-options.xml".

* mandos-keygen.xml: Removed OVERVIEW entity.  Add XInclude namespace.
  (OVERVIEW): Changed to do <xi:include/>.

* mandos-options.xml (<simplesect>): Changed to a <section>.
  ([@id="address"]): Reordered sentences.

* mandos.conf.xml (OPTIONS): Removed illegal <arg> tags.
  (EXAMPLE): Added empty example.

* mandos.xml (NETWORK PROTOCOL): Bug fix: Changed "1\r\en" back to
                                 "1\r\n".
  (CHECKING): Do not refer to the non-relevant mandos.conf(5) manual.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <stddef.h>             /* NULL, size_t, ssize_t */
37
37
#include <sys/types.h>          /* ssize_t */
38
38
#include <stdlib.h>             /* EXIT_SUCCESS, EXIT_FAILURE,
39
 
                                   getopt_long */
 
39
                                   getopt_long, getenv() */
40
40
#include <stdio.h>              /* fprintf(), stderr, getline(),
41
41
                                   stdin, feof(), perror(), fputc(),
42
42
                                   stdout, getopt_long */
52
52
 
53
53
volatile bool quit_now = false;
54
54
bool debug = false;
55
 
const char *argp_program_version = "passprompt 0.9";
 
55
const char *argp_program_version = "password-prompt 1.0";
56
56
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
57
57
 
58
58
static void termination_handler(__attribute__((unused))int signum){
105
105
                         .doc = "Mandos Passprompt -- Provides a passprompt" };
106
106
    ret = argp_parse (&argp, argc, argv, 0, 0, NULL);
107
107
    if (ret == ARGP_ERR_UNKNOWN){
108
 
      perror("argp_parse");
 
108
      fprintf(stderr, "Unknown error while parsing arguments\n");
109
109
      return EXIT_FAILURE;
110
110
    }
111
111
  }
184
184
    }
185
185
 
186
186
    if(prefix){
187
 
      fprintf(stderr, "%s Password: ", prefix);
188
 
    } else {
189
 
      fprintf(stderr, "Password: ");
190
 
    }      
 
187
      fprintf(stderr, "%s ", prefix);
 
188
    }
 
189
    {
 
190
      const char *cryptsource = getenv("cryptsource");
 
191
      const char *crypttarget = getenv("crypttarget");
 
192
      const char *const prompt
 
193
        = "Enter passphrase to unlock the disk";
 
194
      if(cryptsource == NULL){
 
195
        if(crypttarget == NULL){
 
196
          fprintf(stderr, "%s: ", prompt);
 
197
        } else {
 
198
          fprintf(stderr, "%s (%s): ", prompt, crypttarget);
 
199
        }
 
200
      } else {
 
201
        if(crypttarget == NULL){
 
202
          fprintf(stderr, "%s %s: ", prompt, cryptsource);
 
203
        } else {
 
204
          fprintf(stderr, "%s %s (%s): ", prompt, cryptsource,
 
205
                  crypttarget);
 
206
        }
 
207
      }
 
208
    }
191
209
    ret = getline(&buffer, &n, stdin);
192
210
    if (ret > 0){
193
211
      fprintf(stdout, "%s", buffer);