003 File Manager
Current Path:
/usr/src/crypto/heimdal/lib/krb5
usr
/
src
/
crypto
/
heimdal
/
lib
/
krb5
/
📁
..
📄
Makefile.am
(7.68 KB)
📄
Makefile.in
(224.98 KB)
📄
acache.c
(26.87 KB)
📄
acl.c
(7.58 KB)
📄
add_et_list.c
(2.2 KB)
📄
addr_families.c
(38.89 KB)
📄
aes-test.c
(22.56 KB)
📄
aname_to_localname.c
(2.83 KB)
📄
appdefault.c
(4.41 KB)
📄
asn1_glue.c
(2.37 KB)
📄
auth_context.c
(14.97 KB)
📄
build_ap_req.c
(2.77 KB)
📄
build_auth.c
(5.5 KB)
📄
cache.c
(41.88 KB)
📄
ccache_plugin.h
(1.67 KB)
📄
changepw.c
(20.59 KB)
📄
codec.c
(6.1 KB)
📄
config_file.c
(31.7 KB)
📄
constants.c
(2.51 KB)
📄
context.c
(37.71 KB)
📄
convert_creds.c
(3.46 KB)
📄
copy_host_realm.c
(2.66 KB)
📄
crc.c
(2.19 KB)
📄
creds.c
(8.75 KB)
📄
crypto-aes.c
(4.62 KB)
📄
crypto-algs.c
(3.04 KB)
📄
crypto-arcfour.c
(8.78 KB)
📄
crypto-des-common.c
(4.37 KB)
📄
crypto-des.c
(8.8 KB)
📄
crypto-des3.c
(5.36 KB)
📄
crypto-evp.c
(5.45 KB)
📄
crypto-null.c
(2.55 KB)
📄
crypto-pk.c
(8.4 KB)
📄
crypto-rand.c
(3.43 KB)
📄
crypto-stubs.c
(3.1 KB)
📄
crypto.c
(66.51 KB)
📄
crypto.h
(6.5 KB)
📄
data.c
(5.66 KB)
📄
deprecated.c
(14.72 KB)
📄
derived-key-test.c
(6.48 KB)
📄
digest.c
(31.6 KB)
📄
doxygen.c
(25.72 KB)
📄
eai_to_heim_errno.c
(3.46 KB)
📄
error_string.c
(8.93 KB)
📄
expand_hostname.c
(5.59 KB)
📄
expand_path.c
(12.35 KB)
📄
fcache.c
(25.36 KB)
📄
free.c
(2.01 KB)
📄
free_host_realm.c
(2.1 KB)
📄
generate_seq_number.c
(2.03 KB)
📄
generate_subkey.c
(2.6 KB)
📄
get_addrs.c
(8.2 KB)
📄
get_cred.c
(38.45 KB)
📄
get_default_principal.c
(4.47 KB)
📄
get_default_realm.c
(2.74 KB)
📄
get_for_creds.c
(13.48 KB)
📄
get_host_realm.c
(7.06 KB)
📄
get_in_tkt.c
(14.45 KB)
📄
get_port.c
(2.04 KB)
📄
heim_err.et
(1.7 KB)
📄
init_creds.c
(12.11 KB)
📄
init_creds_pw.c
(52.57 KB)
📄
k524_err.et
(577 B)
📄
kcm.c
(26.55 KB)
📄
kcm.h
(2.83 KB)
📄
kerberos.8
(4.14 KB)
📄
keyblock.c
(5.31 KB)
📄
keytab.c
(23.88 KB)
📄
keytab_any.c
(6.48 KB)
📄
keytab_file.c
(19.7 KB)
📄
keytab_keyfile.c
(10.74 KB)
📄
keytab_memory.c
(6.29 KB)
📄
krb5-private.h
(12.91 KB)
📄
krb5-protos.h
(113.43 KB)
📄
krb5-v4compat.h
(4.44 KB)
📄
krb5.conf.5
(18.31 KB)
📄
krb5.h
(29.75 KB)
📄
krb5.moduli
(1.11 KB)
📄
krb524_convert_creds_kdc.3
(3.12 KB)
📄
krb5_425_conv_principal.3
(7.02 KB)
📄
krb5_acl_match_file.3
(3.49 KB)
📄
krb5_aname_to_localname.3
(2.87 KB)
📄
krb5_appdefault.3
(3.08 KB)
📄
krb5_auth_context.3
(10.8 KB)
📄
krb5_c_make_checksum.3
(6.92 KB)
📄
krb5_ccapi.h
(7.52 KB)
📄
krb5_check_transited.3
(3.28 KB)
📄
krb5_create_checksum.3
(6.02 KB)
📄
krb5_creds.3
(3.31 KB)
📄
krb5_digest.3
(6.57 KB)
📄
krb5_eai_to_heim_errno.3
(2.4 KB)
📄
krb5_encrypt.3
(7 KB)
📄
krb5_err.et
(12.86 KB)
📄
krb5_find_padata.3
(2.53 KB)
📄
krb5_generate_random_block.3
(2.1 KB)
📄
krb5_get_all_client_addrs.3
(2.83 KB)
📄
krb5_get_credentials.3
(5.03 KB)
📄
krb5_get_creds.3
(5.28 KB)
📄
krb5_get_forwarded_creds.3
(2.74 KB)
📄
krb5_get_in_cred.3
(7.46 KB)
📄
krb5_get_init_creds.3
(11.03 KB)
📄
krb5_get_krbhst.3
(3.26 KB)
📄
krb5_getportbyname.3
(2.32 KB)
📄
krb5_init_context.3
(7.88 KB)
📄
krb5_is_thread_safe.3
(2.24 KB)
📄
krb5_krbhst_init.3
(5.67 KB)
📄
krb5_locl.h
(8.47 KB)
📄
krb5_mk_req.3
(5.18 KB)
📄
krb5_mk_safe.3
(2.78 KB)
📄
krb5_openlog.3
(7.96 KB)
📄
krb5_parse_name.3
(2.57 KB)
📄
krb5_principal.3
(11.85 KB)
📄
krb5_rcache.3
(4.21 KB)
📄
krb5_rd_error.3
(3.33 KB)
📄
krb5_rd_safe.3
(2.77 KB)
📄
krb5_set_default_realm.3
(4.29 KB)
📄
krb5_set_password.3
(4.11 KB)
📄
krb5_string_to_key.3
(4.39 KB)
📄
krb5_timeofday.3
(3.33 KB)
📄
krb5_verify_init_creds.3
(3.51 KB)
📄
krb5_verify_user.3
(6.71 KB)
📄
krb_err.et
(2.55 KB)
📄
krbhst-test.c
(3.02 KB)
📄
krbhst.c
(26.94 KB)
📄
kuserok.c
(8.14 KB)
📄
locate_plugin.h
(2.36 KB)
📄
log.c
(11.94 KB)
📄
mcache.c
(11.54 KB)
📄
misc.c
(3.9 KB)
📄
mit_glue.c
(11.14 KB)
📄
mk_error.c
(3.23 KB)
📄
mk_priv.c
(4.54 KB)
📄
mk_rep.c
(3.99 KB)
📄
mk_req.c
(3.58 KB)
📄
mk_req_ext.c
(4.78 KB)
📄
mk_safe.c
(4.36 KB)
📄
n-fold-test.c
(4.14 KB)
📄
n-fold.c
(3.8 KB)
📄
net_read.c
(1.86 KB)
📄
net_write.c
(3.05 KB)
📄
pac.c
(28.37 KB)
📄
padata.c
(2.35 KB)
📄
parse-name-test.c
(5.81 KB)
📄
pcache.c
(2.33 KB)
📄
pkinit.c
(63.8 KB)
📄
plugin.c
(13.71 KB)
📄
principal.c
(28.4 KB)
📄
prog_setup.c
(2.34 KB)
📄
prompter_posix.c
(2.45 KB)
📄
rd_cred.c
(9.44 KB)
📄
rd_error.c
(3.83 KB)
📄
rd_priv.c
(5.38 KB)
📄
rd_rep.c
(3.72 KB)
📄
rd_req.c
(25.6 KB)
📄
rd_safe.c
(6.34 KB)
📄
read_message.c
(3.22 KB)
📄
recvauth.c
(6.16 KB)
📄
replay.c
(8.24 KB)
📄
salt-aes.c
(3.34 KB)
📄
salt-arcfour.c
(3.24 KB)
📄
salt-des.c
(6.68 KB)
📄
salt-des3.c
(4.36 KB)
📄
salt.c
(9 KB)
📄
scache.c
(32.86 KB)
📄
send_to_kdc.c
(16.06 KB)
📄
send_to_kdc_plugin.h
(2.22 KB)
📄
sendauth.c
(6.12 KB)
📄
set_default_realm.c
(3.01 KB)
📄
sock_principal.c
(2.52 KB)
📄
store-int.c
(2.14 KB)
📄
store-int.h
(2.07 KB)
📄
store-test.c
(3.63 KB)
📄
store.c
(35.77 KB)
📄
store_emem.c
(5.06 KB)
📄
store_fd.c
(3.4 KB)
📄
store_mem.c
(5.42 KB)
📄
string-to-key-test.c
(5.75 KB)
📄
test_acl.c
(4.56 KB)
📄
test_addr.c
(7.27 KB)
📄
test_alname.c
(4.28 KB)
📄
test_cc.c
(19.39 KB)
📄
test_config.c
(7.92 KB)
📄
test_crypto.c
(5.68 KB)
📄
test_crypto_wrapping.c
(4.48 KB)
📄
test_forward.c
(3.64 KB)
📄
test_get_addrs.c
(3.21 KB)
📄
test_hostname.c
(3.82 KB)
📄
test_keytab.c
(7.42 KB)
📄
test_kuserok.c
(2.9 KB)
📄
test_mem.c
(2.21 KB)
📄
test_pac.c
(15.1 KB)
📄
test_pkinit_dh2key.c
(6.9 KB)
📄
test_plugin.c
(3.4 KB)
📄
test_prf.c
(3.21 KB)
📄
test_princ.c
(10.44 KB)
📄
test_renew.c
(3.22 KB)
📄
test_store.c
(7.96 KB)
📄
test_time.c
(2.57 KB)
📄
ticket.c
(21.91 KB)
📄
time.c
(3.84 KB)
📄
transited.c
(11.11 KB)
📄
verify_init.c
(6.47 KB)
📄
verify_krb5_conf.8
(3.41 KB)
📄
verify_krb5_conf.c
(20.63 KB)
📄
verify_user.c
(7 KB)
📄
version-script.map
(18.82 KB)
📄
version.c
(1.71 KB)
📄
warn.c
(8.98 KB)
📄
write_message.c
(2.87 KB)
Editing: expand_path.c
/*********************************************************************** * Copyright (c) 2009, Secure Endpoints Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * **********************************************************************/ #include "krb5_locl.h" typedef int PTYPE; #ifdef _WIN32 #include <shlobj.h> #include <sddl.h> /* * Expand a %{TEMP} token * * The %{TEMP} token expands to the temporary path for the current * user as returned by GetTempPath(). * * @note: Since the GetTempPath() function relies on the TMP or TEMP * environment variables, this function will failover to the system * temporary directory until the user profile is loaded. In addition, * the returned path may or may not exist. */ static int _expand_temp_folder(krb5_context context, PTYPE param, const char *postfix, char **ret) { TCHAR tpath[MAX_PATH]; size_t len; if (!GetTempPath(sizeof(tpath)/sizeof(tpath[0]), tpath)) { if (context) krb5_set_error_message(context, EINVAL, "Failed to get temporary path (GLE=%d)", GetLastError()); return EINVAL; } len = strlen(tpath); if (len > 0 && tpath[len - 1] == '\\') tpath[len - 1] = '\0'; *ret = strdup(tpath); if (*ret == NULL) { if (context) krb5_set_error_message(context, ENOMEM, "strdup - Out of memory"); return ENOMEM; } return 0; } extern HINSTANCE _krb5_hInstance; /* * Expand a %{BINDIR} token * * This is also used to expand a few other tokens on Windows, since * most of the executable binaries end up in the same directory. The * "bin" directory is considered to be the directory in which the * krb5.dll is located. */ static int _expand_bin_dir(krb5_context context, PTYPE param, const char *postfix, char **ret) { TCHAR path[MAX_PATH]; TCHAR *lastSlash; DWORD nc; nc = GetModuleFileName(_krb5_hInstance, path, sizeof(path)/sizeof(path[0])); if (nc == 0 || nc == sizeof(path)/sizeof(path[0])) { return EINVAL; } lastSlash = strrchr(path, '\\'); if (lastSlash != NULL) { TCHAR *fslash = strrchr(lastSlash, '/'); if (fslash != NULL) lastSlash = fslash; *lastSlash = '\0'; } if (postfix) { if (strlcat(path, postfix, sizeof(path)/sizeof(path[0])) >= sizeof(path)/sizeof(path[0])) return EINVAL; } *ret = strdup(path); if (*ret == NULL) return ENOMEM; return 0; } /* * Expand a %{USERID} token * * The %{USERID} token expands to the string representation of the * user's SID. The user account that will be used is the account * corresponding to the current thread's security token. This means * that: * * - If the current thread token has the anonymous impersonation * level, the call will fail. * * - If the current thread is impersonating a token at * SecurityIdentification level the call will fail. * */ static int _expand_userid(krb5_context context, PTYPE param, const char *postfix, char **ret) { int rv = EINVAL; HANDLE hThread = NULL; HANDLE hToken = NULL; PTOKEN_OWNER pOwner = NULL; DWORD len = 0; LPTSTR strSid = NULL; hThread = GetCurrentThread(); if (!OpenThreadToken(hThread, TOKEN_QUERY, FALSE, /* Open the thread token as the current thread user. */ &hToken)) { DWORD le = GetLastError(); if (le == ERROR_NO_TOKEN) { HANDLE hProcess = GetCurrentProcess(); le = 0; if (!OpenProcessToken(hProcess, TOKEN_QUERY, &hToken)) le = GetLastError(); } if (le != 0) { if (context) krb5_set_error_message(context, rv, "Can't open thread token (GLE=%d)", le); goto _exit; } } if (!GetTokenInformation(hToken, TokenOwner, NULL, 0, &len)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { if (context) krb5_set_error_message(context, rv, "Unexpected error reading token information (GLE=%d)", GetLastError()); goto _exit; } if (len == 0) { if (context) krb5_set_error_message(context, rv, "GetTokenInformation() returned truncated buffer"); goto _exit; } pOwner = malloc(len); if (pOwner == NULL) { if (context) krb5_set_error_message(context, rv, "Out of memory"); goto _exit; } } else { if (context) krb5_set_error_message(context, rv, "GetTokenInformation() returned truncated buffer"); goto _exit; } if (!GetTokenInformation(hToken, TokenOwner, pOwner, len, &len)) { if (context) krb5_set_error_message(context, rv, "GetTokenInformation() failed. GLE=%d", GetLastError()); goto _exit; } if (!ConvertSidToStringSid(pOwner->Owner, &strSid)) { if (context) krb5_set_error_message(context, rv, "Can't convert SID to string. GLE=%d", GetLastError()); goto _exit; } *ret = strdup(strSid); if (*ret == NULL && context) krb5_set_error_message(context, rv, "Out of memory"); rv = 0; _exit: if (hToken != NULL) CloseHandle(hToken); if (pOwner != NULL) free (pOwner); if (strSid != NULL) LocalFree(strSid); return rv; } /* * Expand a folder identified by a CSIDL */ static int _expand_csidl(krb5_context context, PTYPE folder, const char *postfix, char **ret) { TCHAR path[MAX_PATH]; size_t len; if (SHGetFolderPath(NULL, folder, NULL, SHGFP_TYPE_CURRENT, path) != S_OK) { if (context) krb5_set_error_message(context, EINVAL, "Unable to determine folder path"); return EINVAL; } len = strlen(path); if (len > 0 && path[len - 1] == '\\') path[len - 1] = '\0'; if (postfix && strlcat(path, postfix, sizeof(path)/sizeof(path[0])) >= sizeof(path)/sizeof(path[0])) { return ENOMEM; } *ret = strdup(path); if (*ret == NULL) { if (context) krb5_set_error_message(context, ENOMEM, "Out of memory"); return ENOMEM; } return 0; } #else static int _expand_path(krb5_context context, PTYPE param, const char *postfix, char **ret) { *ret = strdup(postfix); if (*ret == NULL) { krb5_set_error_message(context, ENOMEM, "malloc - out of memory"); return ENOMEM; } return 0; } static int _expand_temp_folder(krb5_context context, PTYPE param, const char *postfix, char **ret) { const char *p = NULL; if (issuid()) p = getenv("TEMP"); if (p) *ret = strdup(p); else *ret = strdup("/tmp"); if (*ret == NULL) return ENOMEM; return 0; } static int _expand_userid(krb5_context context, PTYPE param, const char *postfix, char **str) { int ret = asprintf(str, "%ld", (unsigned long)getuid()); if (ret < 0 || *str == NULL) return ENOMEM; return 0; } #endif /* _WIN32 */ /** * Expand a %{null} token * * The expansion of a %{null} token is always the empty string. */ static int _expand_null(krb5_context context, PTYPE param, const char *postfix, char **ret) { *ret = strdup(""); if (*ret == NULL) { if (context) krb5_set_error_message(context, ENOMEM, "Out of memory"); return ENOMEM; } return 0; } static const struct token { const char * tok; int ftype; #define FTYPE_CSIDL 0 #define FTYPE_SPECIAL 1 PTYPE param; const char * postfix; int (*exp_func)(krb5_context, PTYPE, const char *, char **); #define SPECIALP(f, P) FTYPE_SPECIAL, 0, P, f #define SPECIAL(f) SPECIALP(f, NULL) } tokens[] = { #ifdef _WIN32 #define CSIDLP(C,P) FTYPE_CSIDL, C, P, _expand_csidl #define CSIDL(C) CSIDLP(C, NULL) {"APPDATA", CSIDL(CSIDL_APPDATA)}, /* Roaming application data (for current user) */ {"COMMON_APPDATA", CSIDL(CSIDL_COMMON_APPDATA)}, /* Application data (all users) */ {"LOCAL_APPDATA", CSIDL(CSIDL_LOCAL_APPDATA)}, /* Local application data (for current user) */ {"SYSTEM", CSIDL(CSIDL_SYSTEM)}, /* Windows System folder (e.g. %WINDIR%\System32) */ {"WINDOWS", CSIDL(CSIDL_WINDOWS)}, /* Windows folder */ {"USERCONFIG", CSIDLP(CSIDL_APPDATA, "\\" PACKAGE)}, /* Per user Heimdal configuration file path */ {"COMMONCONFIG", CSIDLP(CSIDL_COMMON_APPDATA, "\\" PACKAGE)}, /* Common Heimdal configuration file path */ {"LIBDIR", SPECIAL(_expand_bin_dir)}, {"BINDIR", SPECIAL(_expand_bin_dir)}, {"LIBEXEC", SPECIAL(_expand_bin_dir)}, {"SBINDIR", SPECIAL(_expand_bin_dir)}, #else {"LIBDIR", FTYPE_SPECIAL, 0, LIBDIR, _expand_path}, {"BINDIR", FTYPE_SPECIAL, 0, BINDIR, _expand_path}, {"LIBEXEC", FTYPE_SPECIAL, 0, LIBEXECDIR, _expand_path}, {"SBINDIR", FTYPE_SPECIAL, 0, SBINDIR, _expand_path}, #endif {"TEMP", SPECIAL(_expand_temp_folder)}, {"USERID", SPECIAL(_expand_userid)}, {"uid", SPECIAL(_expand_userid)}, {"null", SPECIAL(_expand_null)} }; static int _expand_token(krb5_context context, const char *token, const char *token_end, char **ret) { size_t i; *ret = NULL; if (token[0] != '%' || token[1] != '{' || token_end[0] != '}' || token_end - token <= 2) { if (context) krb5_set_error_message(context, EINVAL,"Invalid token."); return EINVAL; } for (i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++) { if (!strncmp(token+2, tokens[i].tok, (token_end - token) - 2)) return tokens[i].exp_func(context, tokens[i].param, tokens[i].postfix, ret); } if (context) krb5_set_error_message(context, EINVAL, "Invalid token."); return EINVAL; } KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL _krb5_expand_path_tokens(krb5_context context, const char *path_in, char **ppath_out) { char *tok_begin, *tok_end, *append; const char *path_left; size_t len = 0; if (path_in == NULL || *path_in == '\0') { *ppath_out = strdup(""); return 0; } *ppath_out = NULL; for (path_left = path_in; path_left && *path_left; ) { tok_begin = strstr(path_left, "%{"); if (tok_begin && tok_begin != path_left) { append = malloc((tok_begin - path_left) + 1); if (append) { memcpy(append, path_left, tok_begin - path_left); append[tok_begin - path_left] = '\0'; } path_left = tok_begin; } else if (tok_begin) { tok_end = strchr(tok_begin, '}'); if (tok_end == NULL) { if (*ppath_out) free(*ppath_out); *ppath_out = NULL; if (context) krb5_set_error_message(context, EINVAL, "variable missing }"); return EINVAL; } if (_expand_token(context, tok_begin, tok_end, &append)) { if (*ppath_out) free(*ppath_out); *ppath_out = NULL; return EINVAL; } path_left = tok_end + 1; } else { append = strdup(path_left); path_left = NULL; } if (append == NULL) { if (*ppath_out) free(*ppath_out); *ppath_out = NULL; if (context) krb5_set_error_message(context, ENOMEM, "malloc - out of memory"); return ENOMEM; } { size_t append_len = strlen(append); char * new_str = realloc(*ppath_out, len + append_len + 1); if (new_str == NULL) { free(append); if (*ppath_out) free(*ppath_out); *ppath_out = NULL; if (context) krb5_set_error_message(context, ENOMEM, "malloc - out of memory"); return ENOMEM; } *ppath_out = new_str; memcpy(*ppath_out + len, append, append_len + 1); len = len + append_len; free(append); } } #ifdef _WIN32 /* Also deal with slashes */ if (*ppath_out) { char * c; for (c = *ppath_out; *c; c++) if (*c == '/') *c = '\\'; } #endif return 0; }
Upload File
Create Folder