// Main int main(int argc, char *argv[]) { if (argc != 2) { usage( argv[0], NULL ); exit(0); } if (getprefix(argv[1]) ) { if (splitpref()) { if ( convert_left_right() ) { write_banner(); printf("\n%18s --> %s\n", MSG_TYPE, ident_type(w) ); write_8w_compr( w, MSG_COMPRESSED ); printf("/%d\n", preflen); write_8w( w, MSG_EXPANDED ); if (preflen != 128) { convb2t( w, tpref); genmask(preflen, tmask); genmask(128, tw); logic_xor(tmask, tw, tt); convt2b(tt, t); logic_and(tpref, tmask, tw); convt2b(tw, w); write_8w( w, MSG_BLOCK_BEGIN ); logic_or(tw, tt, tq); convt2b(tq, q); write_8w( q, MSG_BLOCK_END ); printf("\n"); line_centr_text(MSG_ZOOM_BLK_BIN, '~'); printf("\n\n"); write_area_zoom(tw,preflen); write_area_zoom(tq,preflen); write_ptr_zoom(tq,preflen); } printf("\n"); } else usage(argv[0], MSG_ERR_TOO_MANY_WORDS ); } else usage(argv[0], MSG_ERR_WRONG_USE ); } else usage(argv[0], MSG_ERR_INV_CHR ); return 0; }
/* * code_key2addr - convert the locational code to the octant address * * - check the level, which is the only source of error * - call code_morton2coord to convert to the coordinate * - extract the octant level and type from the last byte * the most significant bit of the least significant byte is 1 for leaf * and 0 for index * - return 0 if OK, -1 on error * */ int code_key2addr(etree_t *ep, void *key, etree_addr_t *paddr) { unsigned char LSB; int level; LSB = *(unsigned char *)key; level = LSB & 0x7F; if (level >= theMaxLevelP1) return -1; paddr->level = level; paddr->type = (LSB & 0x80) ? ETREE_LEAF : ETREE_INTERIOR; code_morton2coord(theMaxLevelP1, (char *)key + 1, &paddr->x, &paddr->y, &paddr->z); if (ep->dimensions == 4) { getprefix(ep, (char *)key + theTimeStepOffset, &paddr->t); } return 0; }
static cmd_type_t check_access(const char *arg, char *userbuf, size_t szuserbuf) { const char *subsys; char subsysbuf[128]; size_t subsyslen; char *ssh_client; const char *ip; char ipbuf[64]; size_t iplen; int rc; struct passwd pwdbuf, *pwd; char pwdstrs[512]; const char *user; size_t userlen; ssorecord_t *ssoaccess; unsigned iter; const ssoaccess_rec_t *rec; char rec_user[sizeof(rec->user) + 1]; char rec_subsys[sizeof(rec->subsys) + 1]; char rec_ip[sizeof(rec->ip) + 1]; /* Get subsys */ if (!(subsys = getprefix(arg, '/', subsysbuf, sizeof(subsysbuf)))) die("The subsysect name in [%s] is too long.", arg); subsyslen = strlen(subsys); /* Get ip address from environment SSH_CLIENT */ ssh_client = getenv("SSH_CLIENT"); if (ssh_client == NULL) ip = ""; else if (!(ip = getprefix(ssh_client, ' ', ipbuf, sizeof(ipbuf)))) die("IP address in [%s] is too long.", ssh_client); iplen = strlen(ip); /* Get username by getuid, getpwuid. */ rc = getpwuid_r(getuid(), &pwdbuf, pwdstrs, sizeof(pwdstrs), &pwd); if (rc != 0) die("getpwuid_r failed: %d(%s)", rc, strerror_r(rc, pwdstrs, sizeof(pwdstrs))); user = pwd->pw_name; userlen = strlen(user); if (userbuf) snprintf(userbuf, szuserbuf, "%s", user); if (!(ssoaccess = ssorecord_open(access_fn, sizeof(ssoaccess_rec_t), "rb"))) die("Open [%s] failed", access_fn); for (rec = (const ssoaccess_rec_t *)ssorecord_first(ssoaccess, &iter); rec; rec = (const ssoaccess_rec_t *)ssorecord_next(ssoaccess, &iter)) { ssofield_getstr(rec_user, rec->user, sizeof(rec->user)); ssofield_getstr(rec_subsys, rec->subsys, sizeof(rec->subsys)); ssofield_getstr(rec_ip, rec->ip, sizeof(rec->ip)); #ifdef WITH_LOG { FILE *logfp; int idx; if (!(logfp = fopen(logfn, "at"))) { idx = errno; die_errno("Can not open [%s]: %d(%s)", logfn, idx, strerror(idx)); } fprintf(logfp, "got -> type(%c), user(%s) subsys(%s) ip(%s)\n", rec->base.type, rec_user, rec_subsys, rec_ip); fprintf(logfp, "expect -> type(%c), user(%s) subsys(%s) ip(%s)\n", 'g', user, subsys, ip); fclose(logfp); } #endif if (rec->base.type != 'g') continue; if (strcmp(user, rec_user)) continue; if (strcmp(subsys, rec_subsys)) continue; if (*rec_ip != 0 && strcmp(rec_ip, ip)) continue; ssorecord_close(ssoaccess); return ct_gitshell; } ssorecord_close(ssoaccess); die("All auth failed"); return ct_gitshell; }
void CapturePacketThread::HttpPacketHandler(std::ext_string httpdatastr,IpPacket *ipobj,u_int httpdatalen) { vector<ext_string> linessplit = httpdatastr.split("\n"); ext_string url("") ; ext_string host(""); bool ispost = false; ext_string httppostdata(""); ext_string hostprefix("host:"); ext_string getprefix("get /"); ext_string postprefix("post /"); for (std::vector<ext_string>::iterator it = linessplit.begin() ; it != linessplit.end(); ++it) { ext_string currline = *it; currline.tolower(); if(currline.substr(0, hostprefix.size()) == hostprefix) { std::vector<ext_string> tmp = currline.split(" "); if(tmp.size()>=2) host = tmp[1].trim(); } else if(currline.substr(0, getprefix.size()) == getprefix) { std::vector<ext_string> tmp = currline.split(" "); if(tmp.size()>=2) url = tmp[1].trim(); } else if(currline.substr(0, postprefix.size()) == postprefix) { ispost = true; std::vector<ext_string> tmp = currline.split(" "); if(tmp.size()>=2) url = tmp[1].trim(); } } //int ByVarNum = url.length() + 1; //byte *ByVar; //ByVar = (byte *)malloc(sizeof(byte)*ByVarNum); //memset(ByVar,0,ByVarNum); //byte ByVar[255] = {0}; //for (int i=0;i<url.length();i++) //{ // ByVar[i] =(byte)url[i]; //} ext_string httpurl_ext = "http://"+host+url; //httpurl_ext.append((char *)ByVar); if(httpurl_ext.length()>7) { HttpPacket* httpobj = new HttpPacket(); httpobj->set_processname(ipobj->processname()); httpobj->set_processmd5(ipobj->processmd5()); httpobj->set_sip(ipobj->sip()); httpobj->set_dip(ipobj->dip()); httpobj->set_sport(ipobj->sport()); httpobj->set_dport(ipobj->dport()); httpobj->set_datetime(ipobj->datetime()); httpobj->set_httpurl(httpurl_ext.c_str()); pfthread->PostThreadMessage(PROTOBUF_HTTP_MESSAGE, 0, (LPARAM)httpobj); httpobj=NULL; } //CLogMod::SharedInstance()->LogInfo(httpurl_ext.c_str()); //#BUG print bug here // cout<<"httpurl_ext:"<<httpurl_ext<<endl; }