/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/askpass-fifo.c

  • Committer: teddy at bsnet
  • Date: 2010-08-10 19:08:24 UTC
  • mto: (237.2.182 mandos-local)
  • mto: This revision was merged to the branch mainline in revision 270.
  • Revision ID: teddy@fukt.bsnet.se-20100810190824-5yquozxy4kh6py3f
* plugins.d/mandos-client.c: An empty interface name now means to
                             autodetect an interface; to specify no
                             particular interface, use "none".
  (sys_class_net): New global variable for the "/sys/class/net" path.
  (good_interface): New function to determine the suitability of an
                    interface.  Used by a scandir() call in main().
  (main): Changed default value for "interface" to the empty string.
          Moved "connect_to" to be a global variable.  Only take down
          and up interface if its name is not "none".
* plugins.d/mandos-client.xml (OPTIONS): Update documentation for the
                                         "--interface" option.

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);