clean up name handling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22380 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -82,7 +82,7 @@ OM_uint32 _gss_ntlm_acquire_cred
|
|||||||
if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) {
|
if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) {
|
||||||
ntlm_cred cred;
|
ntlm_cred cred;
|
||||||
|
|
||||||
*min_stat = _gss_ntlm_get_user_cred(name->domain, &cred);
|
*min_stat = _gss_ntlm_get_user_cred(name, &cred);
|
||||||
if (*min_stat)
|
if (*min_stat)
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
cred->usage = cred_usage;
|
cred->usage = cred_usage;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
from_file(const char *fn, const char *domain,
|
from_file(const char *fn, const char *user, const char *domain,
|
||||||
char **username, struct ntlm_buf *key)
|
char **username, struct ntlm_buf *key)
|
||||||
{
|
{
|
||||||
char *str, buf[1024];
|
char *str, buf[1024];
|
||||||
@@ -59,6 +59,9 @@ from_file(const char *fn, const char *domain,
|
|||||||
p = strtok_r(NULL, ":", &str);
|
p = strtok_r(NULL, ":", &str);
|
||||||
if (u == NULL || p == NULL)
|
if (u == NULL || p == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
if (user && strcasecmp(user, u) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
*username = strdup(u);
|
*username = strdup(u);
|
||||||
|
|
||||||
heim_ntlm_nt_key(p, key);
|
heim_ntlm_nt_key(p, key);
|
||||||
@@ -73,15 +76,19 @@ from_file(const char *fn, const char *domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_user_file(const ntlm_name *name, char **username, struct ntlm_buf *key)
|
get_user_file(const ntlm_name name, char **username, struct ntlm_buf *key)
|
||||||
{
|
{
|
||||||
const char *fn = NULL;
|
const char *fn;
|
||||||
|
|
||||||
|
if (issuid())
|
||||||
|
return ENOENT;
|
||||||
|
|
||||||
|
fn = getenv("NTLM_USER_FILE");
|
||||||
|
if (fn != NULL)
|
||||||
|
return ENOENT;
|
||||||
|
if (from_file(fn, name->domain, name->user, username, key) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!issuid()) {
|
|
||||||
fn = getenv("NTLM_USER_FILE");
|
|
||||||
if (fn != NULL && from_file(fn, name->domain, username, key) == 0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +97,7 @@ get_user_file(const ntlm_name *name, char **username, struct ntlm_buf *key)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_user_ccache(const ntlm_name *name, char **username, struct ntlm_buf *key)
|
get_user_ccache(const ntlm_name name, char **username, struct ntlm_buf *key)
|
||||||
{
|
{
|
||||||
krb5_principal client;
|
krb5_principal client;
|
||||||
krb5_context context = NULL;
|
krb5_context context = NULL;
|
||||||
@@ -166,7 +173,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_gss_ntlm_get_user_cred(const ntlm_name *name,
|
_gss_ntlm_get_user_cred(const ntlm_name name,
|
||||||
ntlm_cred *rcred)
|
ntlm_cred *rcred)
|
||||||
{
|
{
|
||||||
ntlm_cred cred;
|
ntlm_cred cred;
|
||||||
@@ -184,7 +191,7 @@ _gss_ntlm_get_user_cred(const ntlm_name *name,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cred->domain = strdup(domain);
|
cred->domain = strdup(name->domain);
|
||||||
*rcred = cred;
|
*rcred = cred;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -266,7 +273,7 @@ _gss_ntlm_init_sec_context
|
|||||||
ntlm_cred cred = (ntlm_cred)initiator_cred_handle;
|
ntlm_cred cred = (ntlm_cred)initiator_cred_handle;
|
||||||
ret = _gss_copy_cred(cred, &ctx->client);
|
ret = _gss_copy_cred(cred, &ctx->client);
|
||||||
} else
|
} else
|
||||||
ret = _gss_ntlm_get_user_cred(name->domain, &ctx->client);
|
ret = _gss_ntlm_get_user_cred(name, &ctx->client);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_gss_ntlm_delete_sec_context(minor_status, context_handle, NULL);
|
_gss_ntlm_delete_sec_context(minor_status, context_handle, NULL);
|
||||||
|
Reference in New Issue
Block a user