/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: Björn Påhlsson
  • Date: 2011-06-19 20:25:38 UTC
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: belorn@fukt.bsnet.se-20110619202538-0js072v8fso12u07
prepended mandos plugin to error messages in each plugin. Added a better way in TODO.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Password-prompt - Read a password from the terminal and print it
4
4
 * 
5
 
 * Copyright © 2008-2011 Teddy Hogeborn
6
 
 * Copyright © 2008-2011 Björn Påhlsson
 
5
 * Copyright © 2008-2010 Teddy Hogeborn
 
6
 * Copyright © 2008-2010 Björn Påhlsson
7
7
 * 
8
8
 * This program is free software: you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License as
19
19
 * along with this program.  If not, see
20
20
 * <http://www.gnu.org/licenses/>.
21
21
 * 
22
 
 * Contact the authors at <mandos@recompile.se>.
 
22
 * Contact the authors at <mandos@fukt.bsnet.se>.
23
23
 */
24
24
 
25
25
#define _GNU_SOURCE             /* getline(), asprintf() */
41
41
                                   getenv(), free() */
42
42
#include <dirent.h>             /* scandir(), alphasort() */
43
43
#include <stdio.h>              /* fprintf(), stderr, getline(),
44
 
                                   stdin, feof(), fputc(), vfprintf(),
45
 
                                   vasprintf() */
 
44
                                   stdin, feof(), fputc(), vfprintf(), vasprintf()
 
45
                                */
46
46
#include <errno.h>              /* errno, EBADF, ENOTTY, EINVAL,
47
47
                                   EFAULT, EFBIG, EIO, ENOSPC, EINTR
48
48
                                */
51
51
#include <stdbool.h>            /* bool, false, true */
52
52
#include <inttypes.h>           /* strtoumax() */
53
53
#include <sys/stat.h>           /* struct stat, lstat(), open() */
54
 
#include <string.h>             /* strlen, rindex, memcmp, strerror()
55
 
                                 */
 
54
#include <string.h>             /* strlen, rindex, memcmp, strerror() */
56
55
#include <argp.h>               /* struct argp_option, struct
57
56
                                   argp_state, struct argp,
58
57
                                   argp_parse(), error_t,
67
66
int signal_received;
68
67
bool debug = false;
69
68
const char *argp_program_version = "password-prompt " VERSION;
70
 
const char *argp_program_bug_address = "<mandos@recompile.se>";
 
69
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
71
70
 
72
71
/* Needed for conflict resolution */
73
72
const char plymouth_name[] = "plymouthd";
74
73
 
75
74
/* Function to use when printing errors */
76
 
void error_plus(int status, int errnum, const char *formatstring,
77
 
                ...){
 
75
void error_plus(int status, int errnum, const char *formatstring, ...){
78
76
  va_list ap;
79
77
  char *text;
80
78
  int ret;
82
80
  va_start(ap, formatstring);
83
81
  ret = vasprintf(&text, formatstring, ap);
84
82
  if (ret == -1){
85
 
    fprintf(stderr, "Mandos plugin %s: ",
86
 
            program_invocation_short_name);
 
83
    fprintf(stderr, "Mandos plugin %s: ", program_invocation_short_name);
87
84
    vfprintf(stderr, formatstring, ap);
88
85
    fprintf(stderr, ": ");
89
86
    fprintf(stderr, "%s\n", strerror(errnum));
208
205
    return 1;
209
206
  }
210
207
  
211
 
  struct dirent **direntries = NULL;
 
208
  struct dirent **direntries;
212
209
  int ret;
213
210
  ret = scandir("/proc", &direntries, is_plymouth, alphasort);
214
211
  if (ret == -1){
215
212
    error(1, errno, "scandir");
216
213
  }
217
 
  free(direntries);
218
214
  return ret > 0;
219
215
}
220
216