static Channel * server_request_session(void) { Channel *c; debug("input_session_request"); packet_check_eom(); if (no_more_sessions) { packet_disconnect("Possible attack: attempt to open a session " "after additional sessions disabled"); } /* * A server session has no fd to read or write until a * CHANNEL_REQUEST for a shell is made, so we set the type to * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all * CHANNEL_REQUEST messages is registered. */ c = channel_new("session", SSH_CHANNEL_LARVAL, -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT, 0, "server-session", 1); if (session_open(the_authctxt, c->self) != 1) { debug("session open failed, free channel %d", c->self); channel_free(c); return NULL; } channel_register_cleanup(c->self, session_close_by_channel, 0); return c; }
int main(int ac, char *av[]) { printf("Usage: echo2 [host|localhost [port|12345 [tcp|1 [ssl|0 [loops|10 [quiet|0 [threads:0]]]]]]]\n"); const char *host = ac>1?av[1]:"localhost"; unsigned short port = (short)(ac>2?atoi(av[2]):12345); int tcp = (ac>3?atoi(av[3]):1); int ssl = (ac>4?atoi(av[4]):0); g_loops = (ac>5?atoi(av[5]):10); g_quiet = (ac>6?atoi(av[6]):0); int threads = (ac>7?atoi(av[7]):0); session *s = session_open(host, port, tcp, ssl); if (!s) return 1; handler *h = handler_create(threads); handler_add_client(h, &on_session, NULL, s); // Start the loop... if (session_writemsg(s, hello) <= 0) { printf("write: %s\n", strerror(errno)); return 1; } handler_wait(h); printf("DONE\n"); handler_destroy(h); return 0; }
static Channel * server_request_session(struct ssh *ssh) { Channel *c; int r; debug("input_session_request"); if ((r = sshpkt_get_end(ssh)) != 0) fatal("%s: %s", __func__, ssh_err(r)); if (no_more_sessions) { ssh_packet_disconnect(ssh, "Possible attack: attempt to open a session " "after additional sessions disabled"); } /* * A server session has no fd to read or write until a * CHANNEL_REQUEST for a shell is made, so we set the type to * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all * CHANNEL_REQUEST messages is registered. */ c = channel_new(ssh, "session", SSH_CHANNEL_LARVAL, -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT, 0, "server-session", 1); if (session_open(ssh, c->self) != 1) { debug("session open failed, free channel %d", c->self); channel_free(c); return NULL; } channel_register_cleanup(c->self, session_close_by_channel, 0); return c; }
static session * session_alloc(grn_ctx *ctx, grn_slap_dest *dest) { session *s; while ((s = (session *)grn_com_queue_deque(ctx, &fsessions))) { if (s->n_query < 1000000 && !s->com->closed) { return s; } //session_close(ctx, s); } return session_open(ctx, dest); }
int32_t client_rescan(bthid_server_p srv) { static hid_device_p d; bthid_session_p s; assert(srv != NULL); if (connect_in_progress) return (0); /* another connect is still pending */ d = get_next_hid_device(d); if (d == NULL) return (0); /* XXX should not happen? empty config? */ if ((s = session_by_bdaddr(srv, &d->bdaddr)) != NULL) return (0); /* session already active */ if (!d->new_device) { if (d->reconnect_initiate) return (0); /* device will initiate reconnect */ } syslog(LOG_NOTICE, "Opening outbound session for %s " \ "(new_device=%d, reconnect_initiate=%d)", bt_ntoa(&d->bdaddr, NULL), d->new_device, d->reconnect_initiate); if ((s = session_open(srv, d)) == NULL) { syslog(LOG_CRIT, "Could not create outbound session for %s", bt_ntoa(&d->bdaddr, NULL)); return (-1); } /* Open control channel */ s->ctrl = client_socket(&s->bdaddr, d->control_psm); if (s->ctrl < 0) { syslog(LOG_ERR, "Could not open control channel to %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); session_close(s); return (-1); } s->state = W4CTRL; FD_SET(s->ctrl, &srv->wfdset); if (s->ctrl > srv->maxfd) srv->maxfd = s->ctrl; connect_in_progress = 1; return (0); }
ne_session *session_get(int with_lock) { ne_session *session; pthread_once(&session_once, session_tsd_key_init); if ((session = pthread_getspecific(session_tsd_key))) return session; session = session_open(with_lock); pthread_setspecific(session_tsd_key, session); return session; }
char *NetGuard_Command_Input_WH8::doquery(char *ip, char* oid){ struct snmp_session *snmp_sess; char *buffer, *tmpresult; char *result; struct snmp_pdu *pdu; buffer = NULL; result = NULL; snmp_sess = session_open(ip, community.c_str()); #ifdef debug printf("query: %s\n",oid); #endif pdu = (struct snmp_pdu*)session_create_pdu(SNMP_MSG_GET); session_add_null_var(pdu,oid); buffer = session_query(snmp_sess,pdu); session_free_pdu(pdu); #ifdef debug printf("query Result: %s\n",buffer); #endif if (buffer != NULL){ if (strstr(buffer,": ") != NULL) { //suche in der Antwort nach dem AntwortString tmpresult = buffer; while (tmpresult[0] != ':') { tmpresult++; } tmpresult++; tmpresult++; #ifdef debug printf("query Result: %s\n",buffer); #endif } else tmpresult = buffer; result = strdup(tmpresult); free(buffer); #ifdef debug printf("Result: %s \n", result); #endif } else { #ifdef debug printf("Cant Exec Command got null reply\n"); #endif }; session_close(snmp_sess); return result; }
void NetGuard_Command_Input_WH8::dowalkquery(char *ip, char* oid, char *results[]) { struct snmp_session *snmp_sess; char *buffer; int pos = 0; buffer = NULL; snmp_sess = session_open(ip, community.c_str()); #ifdef debug printf("query: %s\n",oid); #endif session_walk(snmp_sess,oid,results); buffer = results[pos]; session_close(snmp_sess); }
char *NetGuard_Command_Input_WH8::doset(char *ip, char* oid, char *value){ struct snmp_session *snmp_sess; char *buffer, *tmpresult; char *result; buffer = NULL; result = NULL; snmp_sess = session_open(ip, community.c_str()); #ifdef debug printf("query: %s\n",oid); printf("value: %s\n",value); #endif buffer = session_set(snmp_sess,oid,value); #ifdef debug printf("query Result: %s\n",buffer); #endif if (buffer != NULL){ if (strstr(buffer,": ") != NULL) { //suche in der Antwort nach dem AntwortString tmpresult = buffer; while (tmpresult[0] != ':') { tmpresult++; } tmpresult++; tmpresult++; #ifdef debug printf("query Result: %s\n",buffer); #endif } else tmpresult = buffer; result = strdup(tmpresult); free(buffer); #ifdef debug printf("Result: %s \n", result); #endif } else { #ifdef debug printf("Cant Exec Command got null reply\n"); #endif }; session_close(snmp_sess); return result; }
static Channel * server_request_session(char *ctype) { Channel *c; debug("input_session_request"); packet_check_eom(); /* * A server session has no fd to read or write until a * CHANNEL_REQUEST for a shell is made, so we set the type to * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all * CHANNEL_REQUEST messages is registered. */ c = channel_new(ctype, SSH_CHANNEL_LARVAL, -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT, 0, "server-session", 1); if (session_open(xxx_authctxt, c->self) != 1) { debug("session open failed, free channel %d", c->self); channel_free(c); return NULL; } channel_register_cleanup(c->self, session_close_by_channel); return c; }