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

  • Committer: Teddy Hogeborn
  • Date: 2015-07-05 21:38:01 UTC
  • mto: (237.7.307 trunk)
  • mto: This revision was merged to the branch mainline in revision 325.
  • Revision ID: teddy@recompile.se-20150705213801-pi8vk0ovlumuj826
plugin-helpers/mandos-client-iprouteadddel.c: Fix #include lines.
(main): Fix minor typo in error message.

Show diffs side-by-side

added added

removed removed

Lines of Context:
702
702
  return ret_errno;
703
703
}
704
704
 
705
 
/* Helper function to add_local_route() and delete_local_route() */
 
705
/* Helper function to add_local_route() and remove_local_route() */
706
706
__attribute__((nonnull, warn_unused_result))
707
 
static bool add_delete_local_route(const bool add,
 
707
static bool add_remove_local_route(const bool add,
708
708
                                   const char *address,
709
709
                                   AvahiIfIndex if_index){
710
710
  int ret;
711
711
  char helper[] = "mandos-client-iprouteadddel";
712
712
  char add_arg[] = "add";
713
713
  char delete_arg[] = "delete";
714
 
  char debug_flag[] = "--debug";
715
714
  char *pluginhelperdir = getenv("MANDOSPLUGINHELPERDIR");
716
715
  if(pluginhelperdir == NULL){
717
716
    if(debug){
793
792
#endif
794
793
    if(fexecve(helper_fd, (char *const [])
795
794
               { helper, add ? add_arg : delete_arg, (char *)address,
796
 
                   interface, debug ? debug_flag : NULL, NULL },
797
 
               environ) == -1){
 
795
                   interface, NULL }, environ) == -1){
798
796
#ifdef __GNUC__
799
797
#pragma GCC diagnostic pop
800
798
#endif
852
850
__attribute__((nonnull, warn_unused_result))
853
851
static bool add_local_route(const char *address,
854
852
                            AvahiIfIndex if_index){
855
 
  if(debug){
856
 
    fprintf_plus(stderr, "Adding route to %s\n", address);
857
 
  }
858
 
  return add_delete_local_route(true, address, if_index);
 
853
  return add_remove_local_route(true, address, if_index);
859
854
}
860
855
 
861
856
__attribute__((nonnull, warn_unused_result))
862
 
static bool delete_local_route(const char *address,
 
857
static bool remove_local_route(const char *address,
863
858
                               AvahiIfIndex if_index){
864
 
  if(debug){
865
 
    fprintf_plus(stderr, "Removing route to %s\n", address);
866
 
  }
867
 
  return add_delete_local_route(false, address, if_index);
 
859
  return add_remove_local_route(false, address, if_index);
868
860
}
869
861
 
870
862
/* Called when a Mandos server is found */
1073
1065
           http://lists.freedesktop.org/archives/avahi/2010-February/001833.html
1074
1066
           https://bugs.debian.org/587961
1075
1067
        */
1076
 
        if(debug){
1077
 
          fprintf_plus(stderr, "Mandos server unreachable, trying"
1078
 
                       " direct route\n");
1079
 
        }
1080
1068
        int e = errno;
1081
1069
        route_added = add_local_route(ip, if_index);
1082
1070
        if(route_added){
1286
1274
 mandos_end:
1287
1275
  {
1288
1276
    if(route_added){
1289
 
      if(not delete_local_route(ip, if_index)){
1290
 
        fprintf_plus(stderr, "Failed to delete local route to %s on"
 
1277
      if(not remove_local_route(ip, if_index)){
 
1278
        fprintf_plus(stderr, "Failed to remove local route to %s on"
1291
1279
                     " interface %d", ip, if_index);
1292
1280
      }
1293
1281
    }