/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 plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2014-02-22 17:13:00 UTC
  • Revision ID: teddy@recompile.se-20140222171300-a1alb0w871t1f174
* mandos (ClientDBus.start_checker): Removed unused variable
                                     "old_checker".
* mandos-monitor: Remove import of unused module "signal"

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*
3
3
 * Mandos plugin runner - Run Mandos plugins
4
4
 *
5
 
 * Copyright © 2008-2011 Teddy Hogeborn
6
 
 * Copyright © 2008-2011 Björn Påhlsson
 
5
 * Copyright © 2008-2013 Teddy Hogeborn
 
6
 * Copyright © 2008-2013 Björn Påhlsson
7
7
 * 
8
8
 * This program is free software: you can redistribute it and/or
9
9
 * modify it under the terms of the GNU General Public License as
426
426
    errno = 0;
427
427
    switch(key){
428
428
      char *tmp;
429
 
      intmax_t tmpmax;
 
429
      intmax_t tmp_id;
430
430
    case 'g':                   /* --global-options */
431
431
      {
432
432
        char *plugin_option;
505
505
      /* This is already done by parse_opt_config_file() */
506
506
      break;
507
507
    case 130:                   /* --userid */
508
 
      tmpmax = strtoimax(arg, &tmp, 10);
 
508
      tmp_id = strtoimax(arg, &tmp, 10);
509
509
      if(errno != 0 or tmp == arg or *tmp != '\0'
510
 
         or tmpmax != (uid_t)tmpmax){
 
510
         or tmp_id != (uid_t)tmp_id){
511
511
        argp_error(state, "Bad user ID number: \"%s\", using %"
512
512
                   PRIdMAX, arg, (intmax_t)uid);
513
513
        break;
514
514
      }
515
 
      uid = (uid_t)tmpmax;
 
515
      uid = (uid_t)tmp_id;
516
516
      break;
517
517
    case 131:                   /* --groupid */
518
 
      tmpmax = strtoimax(arg, &tmp, 10);
 
518
      tmp_id = strtoimax(arg, &tmp, 10);
519
519
      if(errno != 0 or tmp == arg or *tmp != '\0'
520
 
         or tmpmax != (gid_t)tmpmax){
 
520
         or tmp_id != (gid_t)tmp_id){
521
521
        argp_error(state, "Bad group ID number: \"%s\", using %"
522
522
                   PRIdMAX, arg, (intmax_t)gid);
523
523
        break;
524
524
      }
525
 
      gid = (gid_t)tmpmax;
 
525
      gid = (gid_t)tmp_id;
526
526
      break;
527
527
    case 132:                   /* --debug */
528
528
      debug = true;
771
771
  }
772
772
  
773
773
  /* Lower permissions */
774
 
  setgid(gid);
 
774
  ret = setgid(gid);
775
775
  if(ret == -1){
776
776
    error(0, errno, "setgid");
777
777
  }
1071
1071
      goto fallback;
1072
1072
    }
1073
1073
    
 
1074
#if defined (__GNUC__) and defined (__GLIBC__)
 
1075
#if not __GLIBC_PREREQ(2, 16)
 
1076
#pragma GCC diagnostic push
 
1077
#pragma GCC diagnostic ignored "-Wsign-conversion"
 
1078
#endif
 
1079
#endif
1074
1080
    FD_SET(new_plugin->fd, &rfds_all); /* Spurious warning from
1075
 
                                          -Wconversion */
 
1081
                                          -Wconversion in GNU libc
 
1082
                                          before 2.16 */
 
1083
#if defined (__GNUC__) and defined (__GLIBC__)
 
1084
#if not __GLIBC_PREREQ(2, 16)
 
1085
#pragma GCC diagnostic pop
 
1086
#endif
 
1087
#endif
1076
1088
    
1077
1089
    if(maxfd < new_plugin->fd){
1078
1090
      maxfd = new_plugin->fd;
1132
1144
          }
1133
1145
          
1134
1146
          /* Remove the plugin */
 
1147
#if defined (__GNUC__) and defined (__GLIBC__)
 
1148
#if not __GLIBC_PREREQ(2, 16)
 
1149
#pragma GCC diagnostic push
 
1150
#pragma GCC diagnostic ignored "-Wsign-conversion"
 
1151
#endif
 
1152
#endif
1135
1153
          FD_CLR(proc->fd, &rfds_all); /* Spurious warning from
1136
 
                                          -Wconversion */
 
1154
                                          -Wconversion in GNU libc
 
1155
                                          before 2.16 */
 
1156
#if defined (__GNUC__) and defined (__GLIBC__)
 
1157
#if not __GLIBC_PREREQ(2, 16)
 
1158
#pragma GCC diagnostic pop
 
1159
#endif
 
1160
#endif
1137
1161
          
1138
1162
          /* Block signal while modifying process_list */
1139
1163
          ret = (int)TEMP_FAILURE_RETRY(sigprocmask
1179
1203
      }
1180
1204
      
1181
1205
      /* This process has not completed.  Does it have any output? */
 
1206
#if defined (__GNUC__) and defined (__GLIBC__)
 
1207
#if not __GLIBC_PREREQ(2, 16)
 
1208
#pragma GCC diagnostic push
 
1209
#pragma GCC diagnostic ignored "-Wsign-conversion"
 
1210
#endif
 
1211
#endif
1182
1212
      if(proc->eof or not FD_ISSET(proc->fd, &rfds)){ /* Spurious
1183
1213
                                                         warning from
1184
 
                                                         -Wconversion */
 
1214
                                                         -Wconversion
 
1215
                                                         in GNU libc
 
1216
                                                         before
 
1217
                                                         2.16 */
 
1218
#if defined (__GNUC__) and defined (__GLIBC__)
 
1219
#if not __GLIBC_PREREQ(2, 16)
 
1220
#pragma GCC diagnostic pop
 
1221
#endif
 
1222
#endif
1185
1223
        /* This process had nothing to say at this time */
1186
1224
        proc = proc->next;
1187
1225
        continue;