/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: 2009-01-13 04:29:35 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113042935-ztxe47n42q5z767b
* plugin-runner.c (main): Bug fix; do not accept a "d" character after
                          user ID or group ID numbers.  Bug fix: use
                          "%u" when printing PID of coredumped plugin,
                          not "%d".
* plugins.d/password-prompt.c (main): Remove comment which was copied
                                      from another program by mistake.
* plugins.d/splashy.c: Only comment changes.
* plugins.d/usplash.c: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  -*- coding: utf-8 -*- */
2
2
/*
3
 
 * Passprompt - Read a password from the terminal and print it
4
 
 *
5
 
 * Copyright © 2007-2008 Teddy Hogeborn & Björn Påhlsson
 
3
 * Password-prompt - Read a password from the terminal and print it
 
4
 * 
 
5
 * Copyright © 2008,2009 Teddy Hogeborn
 
6
 * Copyright © 2008,2009 Björn Påhlsson
6
7
 * 
7
8
 * This program is free software: you can redistribute it and/or
8
9
 * modify it under the terms of the GNU General Public License as
52
53
 
53
54
volatile bool quit_now = false;
54
55
bool debug = false;
55
 
const char *argp_program_version = "password-prompt 1.0";
 
56
const char *argp_program_version = "password-prompt " VERSION;
56
57
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
57
58
 
58
59
static void termination_handler(__attribute__((unused))int signum){
78
79
        .doc = "Debug mode", .group = 3 },
79
80
      { .name = NULL }
80
81
    };
81
 
  
 
82
    
82
83
    error_t parse_opt (int key, char *arg, struct argp_state *state) {
83
 
      /* Get the INPUT argument from `argp_parse', which we know is a
84
 
         pointer to our plugin list pointer. */
85
84
      switch (key) {
86
85
      case 'p':
87
86
        prefix = arg;
99
98
      }
100
99
      return 0;
101
100
    }
102
 
  
 
101
    
103
102
    struct argp argp = { .options = options, .parser = parse_opt,
104
103
                         .args_doc = "",
105
104
                         .doc = "Mandos password-prompt -- Read and"
110
109
      return EXIT_FAILURE;
111
110
    }
112
111
  }
113
 
    
 
112
  
114
113
  if (debug){
115
114
    fprintf(stderr, "Starting %s\n", argv[0]);
116
115
  }
216
215
      status = EXIT_SUCCESS;
217
216
      /* Make n = data size instead of allocated buffer size */
218
217
      n = (size_t)ret;
 
218
      /* Strip final newline */
 
219
      if(n>0 and buffer[n-1] == '\n'){
 
220
        buffer[n-1] = '\0';     /* not strictly necessary */
 
221
        n--;
 
222
      }
219
223
      size_t written = 0;
220
224
      while(written < n){
221
225
        ret = write(STDOUT_FILENO, buffer + written, n - written);
245
249
    }
246
250
  }
247
251
  
 
252
  free(buffer);
 
253
  
248
254
  if (debug){
249
255
    fprintf(stderr, "Restoring terminal attributes\n");
250
256
  }
256
262
    fprintf(stderr, "%s is exiting with status %d\n", argv[0],
257
263
            status);
258
264
  }
 
265
  if(status == EXIT_SUCCESS){
 
266
    fputc('\n', stderr);
 
267
  }
259
268
  
260
269
  return status;
261
270
}