/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-18 20:21:33 UTC
  • mfrom: (483 trunk)
  • mto: This revision was merged to the branch mainline in revision 485.
  • Revision ID: belorn@fukt.bsnet.se-20110618202133-j9f1ibmcplwjkbce
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
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()
 
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 */
56
55
#include <argp.h>               /* struct argp_option, struct
57
56
                                   argp_state, struct argp,
58
57
                                   argp_parse(), error_t,
61
60
#include <sysexits.h>           /* EX_SOFTWARE, EX_OSERR,
62
61
                                   EX_UNAVAILABLE, EX_IOERR, EX_OK */
63
62
#include <fcntl.h>              /* open() */
64
 
#include <stdarg.h>             /* va_list, va_start(), ... */
65
63
 
66
64
volatile sig_atomic_t quit_now = 0;
67
65
int signal_received;
72
70
/* Needed for conflict resolution */
73
71
const char plymouth_name[] = "plymouthd";
74
72
 
75
 
/* Function to use when printing errors */
76
 
void error_plus(int status, int errnum, const char *formatstring,
77
 
                ...){
78
 
  va_list ap;
79
 
  char *text;
80
 
  int ret;
81
 
  
82
 
  va_start(ap, formatstring);
83
 
  ret = vasprintf(&text, formatstring, ap);
84
 
  if (ret == -1){
85
 
    fprintf(stderr, "Mandos plugin %s: ",
86
 
            program_invocation_short_name);
87
 
    vfprintf(stderr, formatstring, ap);
88
 
    fprintf(stderr, ": ");
89
 
    fprintf(stderr, "%s\n", strerror(errnum));
90
 
    error(status, errno, "vasprintf while printing error");
91
 
    return;
92
 
  }
93
 
  fprintf(stderr, "Mandos plugin ");
94
 
  error(status, errnum, "%s", text);
95
 
  free(text);
96
 
}
97
 
 
98
73
static void termination_handler(int signum){
99
74
  if(quit_now){
100
75
    return;
208
183
    return 1;
209
184
  }
210
185
  
211
 
  struct dirent **direntries = NULL;
 
186
  struct dirent **direntries;
212
187
  int ret;
213
188
  ret = scandir("/proc", &direntries, is_plymouth, alphasort);
214
189
  if (ret == -1){
215
190
    error(1, errno, "scandir");
216
191
  }
217
 
  free(direntries);
218
192
  return ret > 0;
219
193
}
220
194