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

  • Committer: Teddy Hogeborn
  • Date: 2009-09-05 01:05:25 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090905010525-7qeq05ztwc2ddhuv
* plugins.d/mandos-client.c (main): Do not handle ignored signals.
                                    Bug fix: remove signal handler
                                    before re-raising signal.

* plugins.d/password-prompt.c (main): Check return values from
                                      "sigaddset()".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1055
1055
    exitcode = EXIT_FAILURE;
1056
1056
    goto end;
1057
1057
  }
1058
 
  ret = sigaction(SIGINT, &sigterm_action, &old_sigterm_action);
1059
 
  if(ret == -1){
1060
 
    perror("sigaction");
1061
 
    exitcode = EXIT_FAILURE;
1062
 
    goto end;
1063
 
  }
1064
 
  ret = sigaction(SIGHUP, &sigterm_action, NULL);
1065
 
  if(ret == -1){
1066
 
    perror("sigaction");
1067
 
    exitcode = EXIT_FAILURE;
1068
 
    goto end;
1069
 
  }
1070
 
  ret = sigaction(SIGTERM, &sigterm_action, NULL);
1071
 
  if(ret == -1){
1072
 
    perror("sigaction");
1073
 
    exitcode = EXIT_FAILURE;
1074
 
    goto end;
 
1058
  /* Need to check if the handler is SIG_IGN before handling:
 
1059
     | [[info:libc:Initial Signal Actions]] |
 
1060
     | [[info:libc:Basic Signal Handling]]  |
 
1061
  */
 
1062
  ret = sigaction(SIGINT, NULL, &old_sigterm_action);
 
1063
  if(ret == -1){
 
1064
    perror("sigaction");
 
1065
    return EXIT_FAILURE;
 
1066
  }
 
1067
  if(old_sigterm_action.sa_handler != SIG_IGN){
 
1068
    ret = sigaction(SIGINT, &sigterm_action, NULL);
 
1069
    if(ret == -1){
 
1070
      perror("sigaction");
 
1071
      exitcode = EXIT_FAILURE;
 
1072
      goto end;
 
1073
    }
 
1074
  }
 
1075
  ret = sigaction(SIGHUP, NULL, &old_sigterm_action);
 
1076
  if(ret == -1){
 
1077
    perror("sigaction");
 
1078
    return EXIT_FAILURE;
 
1079
  }
 
1080
  if(old_sigterm_action.sa_handler != SIG_IGN){
 
1081
    ret = sigaction(SIGHUP, &sigterm_action, NULL);
 
1082
    if(ret == -1){
 
1083
      perror("sigaction");
 
1084
      exitcode = EXIT_FAILURE;
 
1085
      goto end;
 
1086
    }
 
1087
  }
 
1088
  ret = sigaction(SIGTERM, NULL, &old_sigterm_action);
 
1089
  if(ret == -1){
 
1090
    perror("sigaction");
 
1091
    return EXIT_FAILURE;
 
1092
  }
 
1093
  if(old_sigterm_action.sa_handler != SIG_IGN){
 
1094
    ret = sigaction(SIGTERM, &sigterm_action, NULL);
 
1095
    if(ret == -1){
 
1096
      perror("sigaction");
 
1097
      exitcode = EXIT_FAILURE;
 
1098
      goto end;
 
1099
    }
1075
1100
  }
1076
1101
  
1077
1102
  /* If the interface is down, bring it up */
1434
1459
  }
1435
1460
  
1436
1461
  if(quit_now){
 
1462
    sigemptyset(&old_sigterm_action.sa_mask);
 
1463
    old_sigterm_action.sa_handler = SIG_DFL;
1437
1464
    ret = sigaction(signal_received, &old_sigterm_action, NULL);
1438
1465
    if(ret == -1){
1439
1466
      perror("sigaction");