static void authenticateBasicDecodeAuth(auth_user_request_t * auth_user_request, const char *proxy_auth) { char *sent_auth; char *cleartext; basic_data *basic_auth, local_basic; auth_user_t *auth_user; dlink_node *node; /* decode the username */ /* trim BASIC from string */ while (xisgraph(*proxy_auth)) proxy_auth++; local_basic.passwd = NULL; /* Trim leading whitespace before decoding */ while (xisspace(*proxy_auth)) proxy_auth++; /* username and password */ sent_auth = xstrdup(proxy_auth); /* Trim trailing \n before decoding */ strtok(sent_auth, "\n"); cleartext = uudecode(sent_auth); xfree(sent_auth); /* * Don't allow NL or CR in the credentials. * Oezguer Kesim <*****@*****.**> */ debug(29, 9) ("authenticateBasicDecodeAuth: cleartext = '%s'\n", cleartext); if (strcspn(cleartext, "\r\n") != strlen(cleartext)) { debug(29, 1) ("authenticateBasicDecodeAuth: bad characters in authorization header '%s'\n", proxy_auth); xfree(cleartext); return; } local_basic.username = cleartext; if ((cleartext = strchr(local_basic.username, ':')) != NULL) *(cleartext)++ = '\0'; local_basic.passwd = cleartext; if (cleartext == NULL) { debug(29, 4) ("authenticateBasicDecodeAuth: no password in proxy authorization header '%s'\n", proxy_auth); local_basic.passwd = NULL; auth_user_request->message = xstrdup("no password was present in the HTTP [proxy-]authorization header. This is most likely a browser bug"); } else if (*cleartext == '\0' && !basicConfig->blankpassword) { debug(29, 4) ("authenticateBasicDecodeAuth: Disallowing empty password," "user is '%s'\n", local_basic.username); local_basic.passwd = NULL; auth_user_request->message = xstrdup("Request denied because you provided an empty password. Users MUST have a password."); } /* special case: we have to free the strings for user and password * if we are not returning a filled out structure */ if (local_basic.passwd == NULL) { if (local_basic.username) { /* log the username */ debug(29, 9) ("authBasicDecodeAuth: Creating new user for logging '%s'\n", local_basic.username); /* new auth_user */ auth_user = authenticateAuthUserNew("basic"); /* new scheme data */ basic_auth = authBasicDataNew(); /* save the credentials */ basic_auth->username = local_basic.username; /* link the scheme data in */ auth_user->scheme_data = basic_auth; /* set the auth_user type */ auth_user->auth_type = AUTH_BROKEN; /* link the request to the user */ auth_user_request->auth_user = auth_user; /* lock for the auth_user_request link */ authenticateAuthUserLock(auth_user); node = dlinkNodeNew(); dlinkAdd(auth_user_request, node, &auth_user->requests); } return; } else { local_basic.passwd = xstrndup(cleartext, USER_IDENT_SZ); } if (!basicConfig->casesensitive) Tolower(local_basic.username); /* now lookup and see if we have a matching auth_user structure in memory. */ if ((auth_user = authBasicAuthUserFindUsername(local_basic.username)) == NULL) { /* the user doesn't exist in the username cache yet */ debug(29, 9) ("authBasicDecodeAuth: Creating new user '%s'\n", local_basic.username); /* new auth_user */ auth_user = authenticateAuthUserNew("basic"); /* new scheme data */ basic_auth = authBasicDataNew(); /* save the credentials */ basic_auth->username = local_basic.username; basic_auth->passwd = local_basic.passwd; /* link the scheme data in */ auth_user->scheme_data = basic_auth; /* set the auth_user type */ auth_user->auth_type = AUTH_BASIC; /* current time for timeouts */ auth_user->expiretime = current_time.tv_sec; /* this auth_user struct is the 'lucky one' to get added to the username cache */ /* the requests after this link to the auth_user */ /* store user in hash */ authenticateUserNameCacheAdd(auth_user); } else { debug(29, 9) ("authBasicDecodeAuth: Found user '%s' in the user cache as '%p'\n", local_basic.username, auth_user); xfree(local_basic.username); basic_auth = auth_user->scheme_data; if (strcmp(local_basic.passwd, basic_auth->passwd)) { debug(29, 4) ("authBasicDecodeAuth: new password found. Updating in user master record and resetting auth state to unchecked\n"); basic_auth->flags.credentials_ok = 0; xfree(basic_auth->passwd); basic_auth->passwd = local_basic.passwd; } else xfree(local_basic.passwd); if (basic_auth->flags.credentials_ok == 3) { debug(29, 4) ("authBasicDecodeAuth: last attempt to authenticate this user failed, resetting auth state to unchecked\n"); basic_auth->flags.credentials_ok = 0; } } /* link the request to the user */ auth_user_request->auth_user = auth_user; /* lock for the auth_user_request link */ authenticateAuthUserLock(auth_user); node = dlinkNodeNew(); dlinkAdd(auth_user_request, node, &auth_user->requests); return; }
bool ColorCfgLoad::Parsing(const string& section, const string& var, const string& val) { int fcol = 0, bcol = 0; string::size_type p = val.find(','); LOG_WRITE("Parsing sSection [%s] var [%s] val [%s]", section.c_str(), var.c_str(), val.c_str()); try { if (p != string::npos) { fcol = strtoint(val.substr(0, p).c_str()); bcol = strtoint(val.substr(p+1).c_str()); } else { fcol = strtoint(val.c_str()); bcol = GetColorEntry("Default").back; } } catch(Exception& ex) { LOG_WRITE("Color File Loading Exception : %s", (char*)ex); return false; } ColorEntry cur(fcol, bcol); if (var.substr(0, 4) == "mask") { int num = strtol(getbetween(var, '[', ']').c_str(), NULL, 8); _mapMask[num] = cur; } else if(var.substr(0, 4) == "name") { StringToken st(getbetween(var, '[', ']'), ";"); while(st.Next()) { if (st.Get().empty()) continue; _mapName[Tolower(st.Get())] = cur; LOG_WRITE("_mapName [%s [%d:%d]]", Tolower(st.Get()).c_str(), cur.font, cur.back); } } else if (var.substr(0, 3) == "ext") { StringToken st(getbetween(var, '[', ']'), ";"); while(st.Next()) { if (st.Get().empty()) continue; _mapExt[st.Get()] = cur; LOG_WRITE("_mapExt [%s [%d:%d]]", st.Get().c_str(), cur.font, cur.back); } } else { _mapColor[Tolower(var)] = cur; LOG_WRITE("_mapColor [%s [%d:%d]]", var.c_str(), cur.font, cur.back); if (Tolower(var) == "default") _DefaultColor = cur; } return false; }
void ColorCfgLoad::Init() { _mapColor.clear(); _mapName.clear(); _mapExt.clear(); _mapMask.clear(); _DefaultColor = ColorEntry(7,0); _mapColor[Tolower("Default")] = ColorEntry(7,0); // 색지정안된 파일 기본색상 _mapColor[Tolower("MCD")] = ColorEntry(15,4); _mapColor[Tolower("MCDLine")] = ColorEntry(15,4); _mapColor[Tolower("MCDstat")] = ColorEntry(1,15); _mapColor[Tolower("Dir")] = ColorEntry(9,0); _mapColor[Tolower("Drive")] = ColorEntry(3,0); // 메인창 드라이브 색 _mapColor[Tolower("Line")] = ColorEntry(6,0); // 메인창 선 색 _mapColor[Tolower("Func")] = ColorEntry(15,6); // 펑션키 보통 _mapColor[Tolower("FuncA")] = ColorEntry(11,6); // 펑션키 강조 _mapColor[Tolower("Stat")] = ColorEntry(0,7); // 상태선 보통 _mapColor[Tolower("StatA")] = ColorEntry(15,7); // 상태선 강조 _mapColor[Tolower("Help")] = ColorEntry(11,6); // 도움말 _mapColor[Tolower("QCD")] = ColorEntry(15,4); // 빨리찾기 메인 _mapColor[Tolower("Dialog")] = ColorEntry(15,12); // 대화상자 색 _mapColor[Tolower("SelectBox")] = ColorEntry(11,6); // 대화상자 색 _mapColor[Tolower("Back")] = ColorEntry(0,0); _mapColor[Tolower("Edit")] = ColorEntry(7,4); // 에디터 화면 _mapColor[Tolower("EditInfo")] = ColorEntry(2,4); // 에디터 정보 보통 _mapColor[Tolower("EditInfoA")] = ColorEntry(10,4); // 에디터 정보 강조 }
/* t_pmatch(): * Return 2 on exact match, * Return 1 on substring match. * Return 0 on no match. * *estr will point to the end of the longest exact or substring match. */ int t_pmatch(const Char *string, const Char *pattern, const Char **estr, int cs) { Char stringc, patternc, rangec; int match, negate_range; const Char *pestr, *nstring; for (nstring = string;; string = nstring) { stringc = *nstring++ & TRIM; patternc = *pattern++ & TRIM; switch (patternc) { case '\0': *estr = string; return (stringc == '\0' ? 2 : 1); case '?': if (stringc == 0) return (0); break; case '*': if (!*pattern) { *estr = Strend(string); return (2); } pestr = NULL; for (;;) { switch(t_pmatch(string, pattern, estr, cs)) { case 0: break; case 1: pestr = *estr;/*FIXME: does not guarantee longest match */ break; case 2: return 2; default: abort(); /* Cannot happen */ } stringc = *string++ & TRIM; if (!stringc) break; } if (pestr) { *estr = pestr; return 1; } else return 0; case '[': match = 0; if ((negate_range = (*pattern == '^')) != 0) pattern++; while ((rangec = *pattern++ & TRIM) != '\0') { if (rangec == ']') break; if (match) continue; if (*pattern == '-' && pattern[1] != ']') { Char rangec2; pattern++; rangec2 = *pattern++ & TRIM; match = (globcharcoll(stringc, rangec2, 0) <= 0 && globcharcoll(rangec, stringc, 0) <= 0); } else match = (stringc == rangec); } if (rangec == '\0') stderror(ERR_NAME | ERR_MISSING, ']'); if ((!match) && (stringc == '\0')) return (0); if (match == negate_range) return (0); break; default: if (cs ? patternc != stringc : Tolower(patternc) != Tolower(stringc)) return (0); break; } } }