/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 mandos-client.c

  • Committer: Björn Påhlsson
  • Date: 2008-08-10 19:14:12 UTC
  • mto: (237.7.1 mandos) (24.1.154 mandos)
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: belorn@braxen-20080810191412-0c8xxvnh5nalhdfq
updated mandos-client sections and added see also stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
  proc->completed = true;
171
171
}
172
172
 
173
 
bool print_out_password(const char *buffer, size_t length){
174
 
  size_t ret;
175
 
  for(size_t written = 0; written < length; written += ret){
176
 
    ret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, buffer + written,
177
 
                                   length - written));
178
 
    if(ret < 0){
179
 
      return false;
180
 
    }
181
 
  }
182
 
  return true;
183
 
}
184
 
 
185
173
int main(int argc, char *argv[]){
186
174
  const char *plugindir = "/conf/conf.d/mandos/plugins.d";
187
175
  size_t d_name_len;
595
583
  dir = NULL;
596
584
    
597
585
  if (process_list == NULL){
598
 
    fprintf(stderr, "No plugin processes started. Incorrect plugin"
599
 
            " directory?\n");
600
 
    process_list = NULL;
 
586
    fprintf(stderr, "No plugin processes started, exiting\n");
 
587
    exitstatus = EXIT_FAILURE;
 
588
    goto end;
601
589
  }
602
590
  while(process_list){
603
591
    fd_set rfds = rfds_all;
666
654
          break;
667
655
        }
668
656
        /* This process exited nicely, so print its buffer */
669
 
 
670
 
        bool bret = print_out_password(proc->buffer, proc->buffer_length);
671
 
        if(not bret){
672
 
          perror("print_out_password");
673
 
          exitstatus = EXIT_FAILURE;
 
657
        for(size_t written = 0; written < proc->buffer_length;
 
658
            written += (size_t)ret){
 
659
          ret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO,
 
660
                                         proc->buffer + written,
 
661
                                         proc->buffer_length
 
662
                                         - written));
 
663
          if(ret < 0){
 
664
            perror("write");
 
665
            exitstatus = EXIT_FAILURE;
 
666
            goto end;
 
667
          }
674
668
        }
675
669
        goto end;
676
670
      }
705
699
      }
706
700
    }
707
701
  }
708
 
  
709
702
  if(process_list == NULL){
710
 
    bool bret;
711
 
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
712
 
    char *passwordbuffer = getpass("Password: ");
713
 
    bret = print_out_password(passwordbuffer, strlen(passwordbuffer));
714
 
    if(not bret){
715
 
      perror("print_out_password");
716
 
      exitstatus = EXIT_FAILURE;
717
 
      goto end;
718
 
    }
719
 
    bret = print_out_password("\n", 1);
720
 
    if(not bret){
721
 
      perror("print_out_password");
722
 
      exitstatus = EXIT_FAILURE;
723
 
    }
 
703
    fprintf(stderr, "All plugin processes failed, exiting\n");
 
704
    exitstatus = EXIT_FAILURE;
724
705
  }
725
 
 
 
706
  
726
707
 end:
727
 
  
728
708
  /* Restore old signal handler */
729
709
  sigaction(SIGCHLD, &old_sigchld_action, NULL);
730
710