summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1990-01-22 13:29:40 +0000
committerJohn Kohl <jtkohl@mit.edu>1990-01-22 13:29:40 +0000
commit2cfa3722090c0290284aaef91bdc1963b6aa779a (patch)
tree2faffd5523f13241d62f244851401d142ce412c3 /src/lib/krb5
parentcc1c8c43b25c226d63a43d49e12eebb75dd8d4d4 (diff)
downloadkrb5-2cfa3722090c0290284aaef91bdc1963b6aa779a.tar.gz
krb5-2cfa3722090c0290284aaef91bdc1963b6aa779a.tar.xz
krb5-2cfa3722090c0290284aaef91bdc1963b6aa779a.zip
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@164 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5')
-rw-r--r--src/lib/krb5/os/def_realm.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/lib/krb5/os/def_realm.c b/src/lib/krb5/os/def_realm.c
new file mode 100644
index 000000000..a4a45e0ee
--- /dev/null
+++ b/src/lib/krb5/os/def_realm.c
@@ -0,0 +1,73 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * krb5_get_default_realm() function.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_def_realm_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+
+#include <krb5/krb5.h>
+#include <krb5/krb5_err.h>
+
+#include <stdio.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#else
+extern char *malloc(), *index(), *calloc();
+#endif /* __STDC__ */
+
+/*
+ Retrieves the default realm to be used if no user-specified realm is
+ available. [e.g. to interpret a user-typed principal name with the
+ realm omitted for convenience]
+
+ lnsize specifies the maximum length name that is to be filled into
+ lrealm.
+
+ returns system errors, NOT_ENOUGH_SPACE
+*/
+
+/*
+ * Implementation: the default realm is stored in a configuration file,
+ * named by krb5_config_file; the first token in this file is taken as
+ * the default local realm name.
+ */
+
+extern char *krb5_config_file; /* extern so can be set at
+ load/runtime */
+krb5_error_code
+krb5_get_default_realm(lnsize, lrealm)
+int lnsize;
+char *lrealm;
+{
+ FILE *config_file;
+ char realmbuf[BUFSIZ];
+ krb5_error_code retval;
+
+ if (!(config_file = fopen(krb5_config_file, "r")))
+ /* can't open */
+ return KRB5_CONFIG_CANTOPEN;
+
+ if (fscanf(config_file, "%s", realmbuf) != 1)
+ retval = KRB5_CONFIG_BADFORMAT;
+ else {
+ strncpy(lrealm, realmbuf, lnsize);
+ if (lnsize < strlen(realmbuf))
+ retval = KRB5_CONFIG_NOTENUFSPACE;
+ else
+ retval = 0;
+ }
+ (void) fclose(config_file);
+ return retval;
+}