/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 at bsnet
  • Date: 2011-12-24 23:17:02 UTC
  • Revision ID: teddy@fukt.bsnet.se-20111224231702-1ffgu6r02p0bz9co
* plugins.d/splashy.c (error_plus): Check format string.
* plugins.d/askpass-fifo.c (error_plus): - '' -
* plugins.d/plymouth.c (error_plus): - '' -
* plugins.d/password-prompt.c (error_plus): - '' -
* plugins.d/usplash.c (error_plus): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
  perror(print_text);
176
176
}
177
177
 
 
178
__attribute__((format (gnu_printf, 2, 3)))
178
179
int fprintf_plus(FILE *stream, const char *format, ...){
179
180
  va_list ap;
180
181
  va_start (ap, format);
202
203
}
203
204
 
204
205
/* Add server to set of servers to retry periodically */
205
 
int add_server(const char *ip, uint16_t port, AvahiIfIndex if_index,
206
 
               int af){
 
206
bool add_server(const char *ip, uint16_t port, AvahiIfIndex if_index,
 
207
                int af){
207
208
  int ret;
208
209
  server *new_server = malloc(sizeof(server));
209
210
  if(new_server == NULL){
210
211
    perror_plus("malloc");
211
 
    return -1;
 
212
    return false;
212
213
  }
213
214
  *new_server = (server){ .ip = strdup(ip),
214
215
                          .port = port,
216
217
                          .af = af };
217
218
  if(new_server->ip == NULL){
218
219
    perror_plus("strdup");
219
 
    return -1;
 
220
    return false;
220
221
  }
221
222
  /* Special case of first server */
222
223
  if (mc.current_server == NULL){
233
234
  ret = clock_gettime(CLOCK_MONOTONIC, &mc.current_server->last_seen);
234
235
  if(ret == -1){
235
236
    perror_plus("clock_gettime");
236
 
    return -1;
 
237
    return false;
237
238
  }
238
 
  return 0;
 
239
  return true;
239
240
}
240
241
 
241
242
/* 
1030
1031
      if(ret == 0){
1031
1032
        avahi_simple_poll_quit(mc.simple_poll);
1032
1033
      } else {
1033
 
        ret = add_server(ip, port, interface,
1034
 
                         avahi_proto_to_af(proto));
 
1034
        if(not add_server(ip, port, interface,
 
1035
                          avahi_proto_to_af(proto))){
 
1036
          fprintf_plus(stderr, "Failed to add server \"%s\" to server"
 
1037
                       " list\n", name);
 
1038
        }
1035
1039
      }
1036
1040
    }
1037
1041
  }
1467
1471
          _exit(EX_OSERR);
1468
1472
        }
1469
1473
        free(delaystring);
1470
 
        ret = execl(fullname, direntry->d_name, mode, NULL);
1471
 
        perror_plus("execl");
 
1474
        if(execl(fullname, direntry->d_name, mode, NULL) == -1){
 
1475
          perror_plus("execl");
 
1476
          _exit(EXIT_FAILURE);
 
1477
        }
1472
1478
      } else {
1473
1479
        int status;
1474
1480
        if(TEMP_FAILURE_RETRY(waitpid(hook_pid, &status, 0)) == -1){
1671
1677
        argp_state_help(state, state->out_stream,
1672
1678
                        ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
1673
1679
      case 'V':                 /* --version */
1674
 
        fprintf_plus(state->out_stream,
1675
 
                     "Mandos plugin mandos-client: ");
1676
1680
        fprintf_plus(state->out_stream, "%s\n", argp_program_version);
1677
1681
        exit(argp_err_exit_status);
1678
1682
        break;