/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: Teddy Hogeborn
  • Date: 2009-09-17 11:42:12 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090917114212-bmb2eq0c3modtgme
* TODO: Updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
  
43
43
  /* Create FIFO */
44
44
  const char passfifo[] = "/lib/cryptsetup/passfifo";
45
 
  ret = (int)TEMP_FAILURE_RETRY(mkfifo(passfifo, S_IRUSR | S_IWUSR));
 
45
  ret = mkfifo(passfifo, S_IRUSR | S_IWUSR);
46
46
  if(ret == -1 and errno != EEXIST){
47
47
    perror("mkfifo");
48
48
    return EXIT_FAILURE;
49
49
  }
50
50
  
51
51
  /* Open FIFO */
52
 
  int fifo_fd = (int)TEMP_FAILURE_RETRY(open(passfifo, O_RDONLY));
 
52
  int fifo_fd = open(passfifo, O_RDONLY);
53
53
  if(fifo_fd == -1){
54
54
    perror("open");
55
55
    return EXIT_FAILURE;
72
72
        buf = tmp;
73
73
        buf_allocated += blocksize;
74
74
      }
75
 
      sret = TEMP_FAILURE_RETRY(read(fifo_fd, buf + buf_len,
76
 
                                     buf_allocated - buf_len));
 
75
      sret = read(fifo_fd, buf + buf_len, buf_allocated - buf_len);
77
76
      if(sret == -1){
78
77
        perror("read");
79
78
        free(buf);
84
83
  }
85
84
  
86
85
  /* Close FIFO */
87
 
  TEMP_FAILURE_RETRY(close(fifo_fd));
 
86
  close(fifo_fd);
88
87
  
89
88
  /* Print password to stdout */
90
89
  size_t written = 0;
91
90
  while(written < buf_len){
92
 
    sret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, buf + written,
93
 
                                    buf_len - written));
 
91
    sret = write(STDOUT_FILENO, buf + written, buf_len - written);
94
92
    if(sret == -1){
95
93
      perror("write");
96
94
      free(buf);