/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/password-request.c

  • Committer: Teddy Hogeborn
  • Date: 2008-08-10 16:13:23 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080810161323-wrh1rbpdrq0otuhf
* mandos (console): Define handler globally.
  (main): If in debug mode, also reduce consol log level.  Remove
          console log handler before daemonizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include <string.h>             /* memset(), strcmp(), strlen(),
45
45
                                   strerror(), memcpy(), strcpy() */
46
46
#include <sys/ioctl.h>          /* ioctl */
 
47
#include <net/if.h>             /* ifreq, SIOCGIFFLAGS, SIOCSIFFLAGS,
 
48
                                   IFF_UP */
47
49
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
48
50
                                   sockaddr_in6, PF_INET6,
49
51
                                   SOCK_STREAM, INET6_ADDRSTRLEN,
485
487
    fprintf(stderr, "Bad address: %s\n", ip);
486
488
    return -1;
487
489
  }
488
 
  to.in6.sin6_port = htons(port); /* Spurious warning */
 
490
  to.in6.sin6_port = htons(port);       /* Spurious warning */
489
491
  
490
492
  to.in6.sin6_scope_id = (uint32_t)if_index;
491
493
  
891
893
    } else {
892
894
      gnutls_initalized = true;
893
895
    }
894
 
    
895
 
    /* If the interface is down, bring it up */
896
 
    {
897
 
      sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
898
 
      if(sd < 0) {
899
 
        perror("socket");
900
 
        exitcode = EXIT_FAILURE;
901
 
        goto end;
902
 
      }
903
 
      strcpy(network.ifr_name, interface); /* Spurious warning */
904
 
      ret = ioctl(sd, SIOCGIFFLAGS, &network);
905
 
      if(ret == -1){
906
 
        perror("ioctl SIOCGIFFLAGS");
907
 
        exitcode = EXIT_FAILURE;
908
 
        goto end;
909
 
      }
910
 
      if((network.ifr_flags & IFF_UP) == 0){
911
 
        network.ifr_flags |= IFF_UP;
912
 
        ret = ioctl(sd, SIOCSIFFLAGS, &network);
913
 
        if(ret == -1){
914
 
          perror("ioctl SIOCSIFFLAGS");
915
 
          exitcode = EXIT_FAILURE;
916
 
          goto end;
917
 
        }
918
 
      }
919
 
      close(sd);
920
 
    }
921
 
    
 
896
 
922
897
    uid = getuid();
923
898
    gid = getgid();
924
 
    
 
899
 
925
900
    ret = setuid(uid);
926
901
    if (ret == -1){
927
902
      perror("setuid");
965
940
      goto end;
966
941
    }
967
942
    
 
943
    /* If the interface is down, bring it up */
 
944
    {
 
945
      sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
 
946
      if(sd < 0) {
 
947
        perror("socket");
 
948
        exitcode = EXIT_FAILURE;
 
949
        goto end;
 
950
      }
 
951
      strcpy(network.ifr_name, interface); /* Spurious warning */
 
952
      ret = ioctl(sd, SIOCGIFFLAGS, &network);
 
953
      if(ret == -1){
 
954
        perror("ioctl SIOCGIFFLAGS");
 
955
        exitcode = EXIT_FAILURE;
 
956
        goto end;
 
957
      }
 
958
      if((network.ifr_flags & IFF_UP) == 0){
 
959
        network.ifr_flags |= IFF_UP;
 
960
        ret = ioctl(sd, SIOCSIFFLAGS, &network);
 
961
        if(ret == -1){
 
962
          perror("ioctl SIOCSIFFLAGS");
 
963
          exitcode = EXIT_FAILURE;
 
964
          goto end;
 
965
        }
 
966
      }
 
967
      close(sd);
 
968
    }
 
969
    
968
970
    if (not debug){
969
971
      avahi_set_log_function(empty_log);
970
972
    }