Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting RenewTickets does not respect existing cache file settings #268

Open
macsux opened this issue Nov 29, 2021 · 2 comments
Open

Setting RenewTickets does not respect existing cache file settings #268

macsux opened this issue Nov 29, 2021 · 2 comments

Comments

@macsux
Copy link
Contributor

macsux commented Nov 29, 2021

Setting RenewTickets seems to "forget" cache configuration of the client and revert back to default cache location. Code used:

            var client = new KerberosClient(config, loggerFactory);
            client.CacheInMemory = false;
            client.Cache = new Krb5TicketCache(options.CacheFile);
            client.RenewTickets = true;

after the last line runs, the cache is no longer pointing to what is specified in options.CacheFile.

@macsux macsux added the bug label Nov 29, 2021
@SteveSyfuhs
Copy link
Collaborator

That's certainly odd. The client.RenewTickets property just sets client.Cache.RenewTickets which is not used at all in Krb5TicketCache. I suspect that line is a red herring. I believe what's happening is KerberosClient.SetupCache() is being called when client.Cache is geted, which is querying the client-wide configuration for it's cache path.

var cachePath = Environment.ExpandEnvironmentVariables(this.Configuration.Defaults.DefaultCCacheName);
if (!string.IsNullOrWhiteSpace(cachePath) && this.CacheServiceTickets)
{
TicketCacheBase.TryParseCacheType(cachePath, out string cacheType, out string path);
switch (cacheType)
{
case null:
case "MEMORY":
case "API":
case "DIR":
case "KEYRING":
case "MSLSA":
// treat as memory
this.cacheSet = true;
break;
case "FILE":
default:
this.SetFileCache(path);
break;
}
}

private void SetFileCache(string cachePath)
{
if (this.Configuration.Defaults.CCacheType < 4)
{
throw new NotSupportedException(
$"A cache type of {this.Configuration.Defaults.CCacheType} is not supported. Only version 4 or higher is supported."
);
}
CreateFilePath(cachePath);
this.Cache = new Krb5TicketCache(cachePath, this.loggerFactory);
this.cacheSet = true;
}

@SteveSyfuhs
Copy link
Collaborator

I recently did an overhaul of how the client instantiates the cache. Can you see if this repros for you anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants