Skip to content

Commit

Permalink
Added functionality for windows to read default file locations from
Browse files Browse the repository at this point in the history
windows ini files.


git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5307 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information
keithv committed Mar 29, 1995
1 parent 2379b28 commit 60f80a3
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/lib/krb5/os/ChangeLog
@@ -1,3 +1,12 @@
Tue Mar 28 19:22:28 1995 Keith Vetter (keithv@fusion.com)

For Windows, added calls to get the default config, realms and
ccache files out of a windows ini file.
* ccdefname.c: does this for the credential cache.
* osconfig.c: does this for the config and realms files.
* get_krbh.c, realm_do.c, hst_real.c, def_real.c: added calls to
set the default values.

Tue Mar 28 18:35:20 1995 John Gilmore (gnu at toad.com)

* DNR.c: Add Apple MacTCP source file for domain name resolution.
Expand Down
15 changes: 12 additions & 3 deletions src/lib/krb5/os/ccdefname.c
Expand Up @@ -24,6 +24,7 @@
* Return default cred. cache name.
*/

#define NEED_WINDOWS
#include "k5-int.h"
#include <stdio.h>

Expand All @@ -36,10 +37,18 @@ krb5_cc_default_name(context)

if (name == 0) {
if (name_buf == 0)
name_buf = malloc (35);
name_buf = malloc (160);

#ifdef MSDOS_FILESYSTEM
strcpy (name_buf, "FILE:\\krb5cc");
#ifdef _WINDOWS
{
char defname[160]; /* Default value */

strcpy (defname, "FILE:");
GetWindowsDirectory (defname+5, 160-5-7);
strcat (defname, "\\krb5cc");
GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
name_buf, 160, KERBEROS_INI);
}
#else
sprintf(name_buf, "FILE:/tmp/krb5cc_%d", getuid());
#endif
Expand Down
1 change: 1 addition & 0 deletions src/lib/krb5/os/def_realm.c
Expand Up @@ -67,6 +67,7 @@ krb5_get_default_realm(context, lrealm)
else if (saved_realm)
realm = saved_realm;
else {
krb5_find_config_files();
if (!(config_file = fopen(krb5_config_file, "r")))
/* can't open */
return KRB5_CONFIG_CANTOPEN;
Expand Down
1 change: 1 addition & 0 deletions src/lib/krb5/os/get_krbhst.c
Expand Up @@ -75,6 +75,7 @@ krb5_get_krbhst(context, realm, hostlist)
* case.
*/

krb5_find_config_files();
if (!(config_file = fopen(krb5_config_file, "r")))
/* can't open */
return KRB5_CONFIG_CANTOPEN;
Expand Down
10 changes: 7 additions & 3 deletions src/lib/krb5/os/hst_realm.c
Expand Up @@ -178,6 +178,7 @@ krb5_get_host_realm(context, host, realmsp)
}
}

krb5_find_config_files();
if ((trans_file = fopen(krb5_trans_file, "r")) == (FILE *) 0) {
krb5_xfree(retrealms[0]);
krb5_xfree(retrealms);
Expand All @@ -186,12 +187,12 @@ krb5_get_host_realm(context, host, realmsp)
(void) sprintf(scanstring, "%%%ds %%%ds",
sizeof(trans_host)-1,sizeof(trans_realm)-1);
while (1) {
#ifdef _WINDOWS
#ifdef _WINDOWS
scanval = read_2str (trans_file, trans_host, sizeof(trans_host)-1,
trans_realm, sizeof(trans_realm)-1);
#else
#else
scanval = fscanf(trans_file, scanstring, trans_host, trans_realm);
#endif
#endif
if (scanval != 2) {
if (scanval == EOF) {
fclose(trans_file);
Expand Down Expand Up @@ -230,3 +231,6 @@ krb5_get_host_realm(context, host, realmsp)
*realmsp = retrealms;
return 0;
}



39 changes: 39 additions & 0 deletions src/lib/krb5/os/osconfig.c
Expand Up @@ -24,6 +24,7 @@
* Definition of default configuration parameters.
*/

#define NEED_WINDOWS
#include "k5-int.h"

char *krb5_config_file = DEFAULT_CONFIG_FILENAME;
Expand All @@ -49,3 +50,41 @@ char *krb5_kdc_sec_udp_portname = 0;

char *krb5_default_pwd_prompt1 = DEFAULT_PWD_STRING1;
char *krb5_default_pwd_prompt2 = DEFAULT_PWD_STRING2;

/*
* On Windows, we want to let the user specify in the kerberos.ini file
* where the config and realms files, krb.con and krb.rea, reside. If they
* aren't specified then we fall back to having them in the windows
* directory. We use the same format as the K4 version for compatability.
*
* Note: these values can change asynchronously so we can't cache the values.
*/
krb5_error_code
krb5_find_config_files ()
{
#ifdef _WINDOWS
static char cnfname[160]; /* For krb.con */
static char realmsname[160]; /* For krb.rea */
char defname[160]; /* Default value */

/* First locate krb.con file */
GetWindowsDirectory(defname, sizeof(defname));
strcat (defname, "\\");
strcat (defname, DEFAULT_CONFIG_FILENAME);
GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname,
cnfname, sizeof(cnfname), KERBEROS_INI);

/* Now locate krb.rea file */
GetWindowsDirectory(defname, sizeof(defname));
strcat (defname, "\\");
strcat (defname, DEFAULT_TRANS_FILENAME);
GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname,
realmsname, sizeof(realmsname), KERBEROS_INI);

krb5_config_file = cnfname;
krb5_trans_file = realmsname;

#endif /* _WINDOWS */

return 0;
}
7 changes: 4 additions & 3 deletions src/lib/krb5/os/realm_dom.c
Expand Up @@ -122,6 +122,7 @@ krb5_get_realm_domain(context, realm, domain)
return retval;
realm = realmlist[0];
}
krb5_find_config_files();
if ((trans_file = fopen(krb5_trans_file, "r")) == (FILE *) 0) {
if (realmlist != NULL) {
krb5_xfree(realmlist[0]);
Expand All @@ -132,12 +133,12 @@ krb5_get_realm_domain(context, realm, domain)
(void) sprintf(scanstring, "%%%ds %%%ds",
sizeof(trans_host)-1,sizeof(trans_realm)-1);
while (1) {
#ifdef _WINDOWS
#ifdef _WINDOWS
scanval = read_2str (trans_file, trans_host, sizeof(trans_host)-1,
trans_realm, sizeof(trans_realm)-1);
#else
#else
scanval = fscanf(trans_file, scanstring, trans_host, trans_realm);
#endif
#endif
if (scanval != 2) {
if (scanval == EOF) {
fclose(trans_file);
Expand Down

0 comments on commit 60f80a3

Please sign in to comment.