/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/usplash.c

  • Committer: Teddy Hogeborn
  • Date: 2009-02-13 05:38:21 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090213053821-03e696gckk4nbjps
Support not using IPv6 in server:

* mandos (AvahiService.__init__): Take new "protocol" parameter.  All
                                  callers changed.
  (IPv6_TCPServer.__init__): Take new "use_ipv6" parameter.  All
                             callers changed.
  (IPv6_TCPServer.server_bind): Create IPv4 socket if not using IPv6.
  (main): New "--no-ipv6" command line option.  New "use_ipv6" config
          option.
* mandos-options.xml ([@id="address"]): Document conditional IPv4
                                        address support.
  ([@id="ipv6"]): New paragraph.
* mandos.conf (use_ipv6): New config option.
* mandos.conf.xml (OPTIONS): Document new "use_dbus" option.
  (EXAMPLE): Changed to use IPv6 link-local address.  Added "use_ipv6"
             option.
* mandos.xml (SYNOPSIS): New "--no-ipv6" option.
  (OPTIONS): Document new "--no-ipv6" option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * along with this program.  If not, see
20
20
 * <http://www.gnu.org/licenses/>.
21
21
 * 
22
 
 * Contact the authors at <mandos@fukt.bsnet.se>.
 
22
 * Contact the authors at <https://www.fukt.bsnet.se/~belorn/> and
 
23
 * <https://www.fukt.bsnet.se/~teddy/>.
23
24
 */
24
25
 
25
26
#define _GNU_SOURCE             /* asprintf() */
63
64
   */
64
65
  int ret;
65
66
  int fifo_fd;
66
 
  do {
 
67
  do{
67
68
    fifo_fd = open("/dev/.initramfs/usplash_fifo", O_WRONLY);
68
69
    if(fifo_fd == -1 and (errno != EINTR or interrupted_by_signal)){
69
70
      return false;
70
71
    }
71
 
  } while(fifo_fd == -1);
 
72
  }while(fifo_fd == -1);
72
73
  
73
74
  const char *cmd_line;
74
75
  size_t cmd_line_len;
76
77
  if(arg == NULL){
77
78
    cmd_line = cmd;
78
79
    cmd_line_len = strlen(cmd);
79
 
  } else {
80
 
    do {
 
80
  }else{
 
81
    do{
81
82
      ret = asprintf(&cmd_line_alloc, "%s %s", cmd, arg);
82
83
      if(ret == -1 and (errno != EINTR or interrupted_by_signal)){
83
84
        int e = errno;
85
86
        errno = e;
86
87
        return false;
87
88
      }
88
 
    } while(ret == -1);
 
89
    }while(ret == -1);
89
90
    cmd_line = cmd_line_alloc;
90
91
    cmd_line_len = (size_t)ret + 1;
91
92
  }
109
110
    written += (size_t)sret;
110
111
  }
111
112
  free(cmd_line_alloc);
112
 
  do {
 
113
  do{
113
114
    ret = close(fifo_fd);
114
115
    if(ret == -1 and (errno != EINTR or interrupted_by_signal)){
115
116
      return false;
116
117
    }
117
 
  } while(ret == -1);
 
118
  }while(ret == -1);
118
119
  if(interrupted_by_signal){
119
120
    return false;
120
121
  }
251
252
          size_t cmdline_allocated = 0;
252
253
          char *tmp;
253
254
          const size_t blocksize = 1024;
254
 
          do {
 
255
          do{
255
256
            if(cmdline_len + blocksize > cmdline_allocated){
256
257
              tmp = realloc(cmdline, cmdline_allocated + blocksize);
257
258
              if(tmp == NULL){
365
366
    
366
367
    /* Open FIFO */
367
368
    int fifo_fd;
368
 
    do {
 
369
    do{
369
370
      fifo_fd = open("/dev/.initramfs/usplash_outfifo", O_RDONLY);
370
371
      if(fifo_fd == -1){
371
372
        if(errno != EINTR){
377
378
          break;
378
379
        }
379
380
      }
380
 
    } while(fifo_fd == -1);
 
381
    }while(fifo_fd == -1);
381
382
    if(interrupted_by_signal or an_error_occured){
382
383
      break;                    /* Big */
383
384
    }
385
386
    /* Read from FIFO */
386
387
    size_t buf_allocated = 0;
387
388
    const size_t blocksize = 1024;
388
 
    do {
 
389
    do{
389
390
      if(buf_len + blocksize > buf_allocated){
390
391
        char *tmp = realloc(buf, buf_allocated + blocksize);
391
392
        if(tmp == NULL){
396
397
        buf = tmp;
397
398
        buf_allocated += blocksize;
398
399
      }
399
 
      do {
 
400
      do{
400
401
        sret = read(fifo_fd, buf + buf_len, buf_allocated - buf_len);
401
402
        if(sret == -1){
402
403
          if(errno != EINTR){
408
409
            break;
409
410
          }
410
411
        }
411
 
      } while(sret == -1);
 
412
      }while(sret == -1);
412
413
      if(interrupted_by_signal or an_error_occured){
413
414
        break;
414
415
      }
415
416
      
416
417
      buf_len += (size_t)sret;
417
 
    } while(sret != 0);
 
418
    }while(sret != 0);
418
419
    close(fifo_fd);
419
420
    if(interrupted_by_signal or an_error_occured){
420
421
      break;                    /* Big */
432
433
    /* Print password to stdout */
433
434
    size_t written = 0;
434
435
    while(written < buf_len){
435
 
      do {
 
436
      do{
436
437
        sret = write(STDOUT_FILENO, buf + written, buf_len - written);
437
438
        if(sret == -1){
438
439
          if(errno != EINTR){
444
445
            break;
445
446
          }
446
447
        }
447
 
      } while(sret == -1);
 
448
      }while(sret == -1);
448
449
      if(interrupted_by_signal or an_error_occured){
449
450
        break;
450
451
      }