Exemple #1
0
int
main(int argc, char *argv[])
{
    debug("ntlm_auth build " __DATE__ ", " __TIME__ " starting up...\n");

    my_program_name = argv[0];
    process_options(argc, argv);

    debug("options processed OK\n");

    /* initialize FDescs */
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);

    /* select the first domain controller we're going to use */
    current_dc = controllers;
    if (load_balance != 0 && numcontrollers > 1) {
        int n;
        pid_t pid = getpid();
        n = pid % numcontrollers;
        debug("load balancing. Selected controller #%d\n", n);
        while (n > 0) {
            current_dc = current_dc->next;
            n--;
        }
    }
    while (1) {
        manage_request();
    }
    return 0;
}
Exemple #2
0
int
main(int argc, char *argv[])
{
    my_program_name = argv[0];

    process_options(argc, argv);

    debug("%s build " __DATE__ ", " __TIME__ " starting up...\n", my_program_name);

    if (LoadSecurityDll(SSP_NTLM, NEGOTIATE_PACKAGE_NAME) == NULL) {
        fprintf(stderr, "FATAL, can't initialize SSPI, exiting.\n");
        exit(1);
    }
    debug("SSPI initialized OK\n");

    atexit(UnloadSecurityDll);

    /* initialize FDescs */
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);

    while (manage_request()) {
        /* everything is done within manage_request */
    }
    exit(0);
}
Exemple #3
0
int
main(int argc, char **argv)
{
    char *target_domain;
    if (argc > 0) {		/* should always be true */
	myname = strrchr(argv[0], '/');
	if (myname == NULL)
	    myname = argv[0];
	else
	    myname++;
    } else {
	myname = "(unknown)";
    }
    mypid = getpid();
    target_domain = process_options(argc, argv);
    debug("ntlm winbindd auth helper build " __DATE__ ", " __TIME__
	" starting up...\n");

    check_winbindd();

    if (target_domain == NULL) {
	target_domain = get_winbind_domain();
    }

    /* initialize FDescs */
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
    init_random();
    while (manage_request(target_domain)) {
	/* everything is done within manage_request */
    }
    return 0;
}
Exemple #4
0
int 
read_all(struct tcp_socket_queue *all, struct tcp_socket_queue *rcv_queue)
{
    struct tcp_socket *sk_ptr;
    
    
    while ( ( sk_ptr = dequeue_rdy_recv(rcv_queue) ) != NULL )
    {
	if (sk_ptr->kind == SOCKET_SERVER)
	{
	    if (accept_proxy_client(sk_ptr, all) == -1)
	    {
		perror("2.1");
		return -1;
	    }
	}
	else
	{
	    if (sk_ptr->state == WAITING_METHODS)
	    {
		if (manage_methods(sk_ptr, 0) == -1)
		{
		    perror("2.2");
		    return -1;
		}
	    }
	    else if (sk_ptr->state == CONNECTING || sk_ptr->state == WAITING_CONNECTION)
	    {
		if (manage_connect(sk_ptr) == -1)
		{
		    perror("2.3");
		    return -1;
		}
	    }
	    else if (sk_ptr->state == WAITING_REQUEST)
	    {
		if (manage_request(sk_ptr, all) == -1)
		{
		    perror("2.4");
		    return -1;
		}
	    }
	    else if (sk_ptr->state == PIPELINE)
	    {
		if (manage_pipeline(sk_ptr) == -1)
		{
		    perror("2.5");
		    return -1;
		}
	    }
	}
    }
    return 0;
}	
Exemple #5
0
/* child_main()
 * 
 * Main child process.
 * */
void *
child_main				(void * arg)
{
    int client_sd;
    int pos;
    socklen_t client_len;
    struct sockaddr_in client_addr;
    char * add_info;
	
    pos = (int)arg;
    client_len = sizeof(struct sockaddr_in);
	
    /* Initialize MySQL threaded interaction. */
    mysql_thread_init();
	
    asprintf(&add_info, "Thread ID: %d\n", pos);
    log_message(MESSAGE, IMSG_THREADINIT, add_info);
    free(add_info);
	
    while (alive_flag > 0)
    {
	pthread_mutex_lock(&conn_lock);
	client_sd = accept(server_sd, (struct sockaddr *) &client_addr, &client_len);
	pthread_mutex_unlock(&conn_lock);
		
	/* Abort connection without waiting to send remaining data. */
	setsockopt(client_sd, SOL_SOCKET, SO_LINGER, &close_timeout, sizeof(struct linger));
	children[pos].conn_count++;
		
	/* Process request */
	manage_request(client_sd);
	close(client_sd);
    }
	
    /* End MySQL threaded interaction . */
    mysql_thread_end();
    return (NULL);
}
void
manage_response(struct mqtt_sn_connection *mqc, const uip_ipaddr_t *source_addr,
                 const uint8_t *data, uint16_t datalen)
{
  uint8_t msg_type;
  uint16_t msg_id = 0;
  uint8_t return_code = 0;
  uint16_t topic_id = 0;
  struct mqtt_sn_request *req;
  msg_type = data[1];
  if (msg_type == MQTT_SN_TYPE_REGACK) {
    regack_packet_t incoming_regack;
    memcpy(&incoming_regack, data, datalen);
    msg_id = incoming_regack.message_id;
    return_code = incoming_regack.return_code;
    topic_id = uip_htons(incoming_regack.topic_id);
  }
  else if ( msg_type == MQTT_SN_TYPE_SUBACK) {
    suback_packet_t incoming_suback;
    memcpy(&incoming_suback, data, datalen);
    msg_id = incoming_suback.message_id;
    return_code = incoming_suback.return_code;
    topic_id = uip_htons(incoming_suback.topic_id);
  }
  for(req = list_head(mqc->requests); req != NULL; req = req->next) {
    if(req->msg_id == msg_id) {
      req->topic_id = topic_id;
      req->return_code = return_code;
      if (return_code == 0){
        req->state = MQTTSN_REQUEST_COMPLETE;
      }
      else {
        req->state = MQTTSN_REQUEST_FAILED;
      }
      manage_request(req,mqc,NULL,0,0);
    }
  }
}
uint16_t mqtt_sn_subscribe_try(mqtt_sn_subscribe_request *req, struct mqtt_sn_connection *mqc,
                               const char* topic_name, uint8_t qos, clock_time_t time_out) {
  req->request_type = MQTTSN_SUBSCRIBE_REQUEST;
  manage_request(req,mqc,topic_name,qos,time_out);
  return req->msg_id;
}
uint16_t mqtt_sn_register_try(mqtt_sn_register_request *req, struct mqtt_sn_connection *mqc,
                              const char* topic_name,clock_time_t time_out) {
  req->request_type = MQTTSN_REGISTER_REQUEST;
  manage_request(req,mqc,topic_name,0,time_out);
  return req->msg_id;
}
static void request_timer_callback(void *req)
{
  struct mqtt_sn_request *req2 = (struct mqtt_sn_request *)req;
  manage_request(req2,NULL,NULL,0,0);
}