/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/askpass-fifo.c

  • Committer: Björn Påhlsson
  • Date: 2010-09-09 18:01:40 UTC
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: belorn@fukt.bsnet.se-20100909180140-3jupkc288hrb082s
fixed bug with local name collisions after a non-local name collision

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                                   ENOENT, EEXIST, EFAULT, EMFILE,
32
32
                                   ENFILE, ENOMEM, EBADF, EINVAL, EIO,
33
33
                                   EISDIR, EFBIG */
34
 
#include <stdio.h>              /* perror() */
 
34
#include <error.h>              /* error() */
35
35
#include <stdlib.h>             /* EXIT_FAILURE, NULL, size_t, free(),
36
36
                                   realloc(), EXIT_SUCCESS */
37
37
#include <fcntl.h>              /* open(), O_RDONLY */
51
51
  ret = mkfifo(passfifo, S_IRUSR | S_IWUSR);
52
52
  if(ret == -1){
53
53
    int e = errno;
54
 
    perror("mkfifo");
 
54
    error(0, errno, "mkfifo");
55
55
    switch(e){
56
56
    case EACCES:
57
57
    case ENOTDIR:
73
73
  int fifo_fd = open(passfifo, O_RDONLY);
74
74
  if(fifo_fd == -1){
75
75
    int e = errno;
76
 
    perror("open");
 
76
    error(0, errno, "open");
77
77
    switch(e){
78
78
    case EACCES:
79
79
    case ENOENT:
101
101
      if(buf_len + blocksize > buf_allocated){
102
102
        char *tmp = realloc(buf, buf_allocated + blocksize);
103
103
        if(tmp == NULL){
104
 
          perror("realloc");
 
104
          error(0, errno, "realloc");
105
105
          free(buf);
106
106
          return EX_OSERR;
107
107
        }
113
113
        int e = errno;
114
114
        free(buf);
115
115
        errno = e;
116
 
        perror("read");
 
116
        error(0, errno, "read");
117
117
        switch(e){
118
118
        case EBADF:
119
119
        case EFAULT:
141
141
      int e = errno;
142
142
      free(buf);
143
143
      errno = e;
144
 
      perror("write");
 
144
      error(0, errno, "write");
145
145
      switch(e){
146
146
      case EBADF:
147
147
      case EFAULT:
161
161
  ret = close(STDOUT_FILENO);
162
162
  if(ret == -1){
163
163
    int e = errno;
164
 
    perror("close");
 
164
    error(0, errno, "close");
165
165
    switch(e){
166
166
    case EBADF:
167
167
      return EX_OSFILE;