to buildtop and thisconfigdir, respectively.)
configure.in: Remove KRB5_POSIX_LOCKS test.
win_store.c (krb__get_srvtabname):
g_cnffile.c: Use krb5__krb4_context instead of init'ing and free'ing a
krb5_context each time we need to read data from the configuration
file. We also define krb5__krb4_context in g_cnnfile.c, since it's a
likely that any use of the krb4 library will pull in that file.
tf_util.c (tf_init): Use krb5_lock_file instead of trying to roll our
own flock emulation.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11026
dc483132-0cff-0310-8789-
dd5450dbe970
thisconfigdir=.
+myfulldir=lib/krb4
+mydir=.
BUILDTOP=$(REL)$(U)$(S)$(U)
CFLAGS = $(CCOPTS) $(DEFS) $(DEFINES)
DEFINES=-I$(srcdir)/../../include/kerberosIV
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_CONST
-KRB5_POSIX_LOCKS
AC_CHECK_HEADERS(sys/select.h time.h unistd.h)
dnl Could check for full stdc environment, but will only test
dnl for stdlib.h
#include "krb.h"
#include "k5-int.h"
+krb5_context krb5__krb4_context = 0;
+
static FILE*
krb__v5_get_file(s)
char *s;
{
FILE *cnffile = 0;
- krb5_context context;
const char* names[3];
char **full_name = 0, **cpp;
krb5_error_code retval;
- krb5_init_context(&context);
+ if (!krb5__krb4_context)
+ krb5_init_context(&krb5__krb4_context);
names[0] = "libdefaults";
names[1] = s;
names[2] = 0;
- if (context) {
- retval = profile_get_values(context->profile, names, &full_name);
+ if (krb5__krb4_context) {
+ retval = profile_get_values(krb5__krb4_context->profile, names,
+ &full_name);
if (retval == 0 && full_name && full_name[0]) {
cnffile = fopen(full_name[0],"r");
for (cpp = full_name; *cpp; cpp++)
krb5_xfree(*cpp);
krb5_xfree(full_name);
}
- krb5_free_context(context);
}
return cnffile;
}
krb__get_srvtabname(default_srvtabname)
char *default_srvtabname;
{
- krb5_context context;
const char* names[3];
char **full_name = 0, **cpp;
krb5_error_code retval;
char *retname;
- krb5_init_context(&context);
+ if (!krb5__krb4_context)
+ krb5_init_context(&krb5__krb4_context);
names[0] = "libdefaults";
names[1] = "krb4_srvtab";
names[2] = 0;
- if (context &&
- (retval = profile_get_values(context->profile, names, &full_name))
+ if (krb5__krb4_context &&
+ (retval = profile_get_values(krb5__krb4_context->profile, names,
+ &full_name))
&& retval == 0 && full_name && full_name[0]) {
retname = strdup(full_name[0]);
for (cpp = full_name; *cpp; cpp++)
}else {
retname = strdup(default_srvtabname);
}
- if (context != NULL)
- krb5_free_context(context);
return retname;
}
#include "mit-copyright.h"
#include "krb.h"
+#include "k5-int.h"
#include <stdio.h>
#include <string.h>
extern int errno;
extern int krb_debug;
+void tf_close();
+
#ifdef TKT_SHMEM
char *krb_shm_addr;
static char *tmp_shm_addr;
return utime(path,&tv);
}
#endif
-#ifndef LOCK_SH
-#define LOCK_SH 1 /* shared lock */
-#define LOCK_EX 2 /* exclusive lock */
-#define LOCK_NB 4 /* don't block when locking */
-#define LOCK_UN 8 /* unlock */
-#endif
-
-
-#ifdef POSIX_FILE_LOCKS
-
-/*
- * This function emulates a subset of flock()
- */
-int emul_flock(fd, cmd)
- int fd, cmd;
-{
- static struct flock flock_zero;
- struct flock f;
-
- f = flock_zero;
-
- memset(&f, 0, sizeof (f));
-
- if (cmd & LOCK_UN)
- f.l_type = F_UNLCK;
- if (cmd & LOCK_SH)
- f.l_type = F_RDLCK;
- if (cmd & LOCK_EX)
- f.l_type = F_WRLCK;
-
- return fcntl(fd, (cmd & LOCK_NB) ? F_SETLK : F_SETLKW, &f);
-}
-
-#define flock(f,c) emul_flock(f,c)
-#endif
-
/*
* fd must be initialized to something that won't ever occur as a real
int shmid;
#endif
+ if (!krb5__krb4_context) {
+ if (krb5_init_context(&krb5__krb4_context))
+ return TKT_FIL_LCK;
+ }
+
me = getuid();
switch (rw) {
fd = -1;
return TKT_FIL_ACC;
}
- if (flock(fd, LOCK_EX | LOCK_NB) < 0) {
+ if (krb5_lock_file(krb5__krb4_context, fd,
+ KRB5_LOCKMODE_EXCLUSIVE |
+ KRB5_LOCKMODE_DONTBLOCK) < 0) {
sleep(TF_LCK_RETRY);
- if (flock(fd, LOCK_EX | LOCK_NB) < 0) {
+ if (krb5_lock_file(krb5__krb4_context, fd,
+ KRB5_LOCKMODE_EXCLUSIVE |
+ KRB5_LOCKMODE_DONTBLOCK) < 0) {
(void) close(fd);
fd = -1;
return TKT_FIL_LCK;
fd = -1;
return TKT_FIL_ACC;
}
- if (flock(fd, LOCK_SH | LOCK_NB) < 0) {
+ if (krb5_lock_file(krb5__krb4_context, fd,
+ KRB5_LOCKMODE_SHARED |
+ KRB5_LOCKMODE_DONTBLOCK) < 0) {
sleep(TF_LCK_RETRY);
- if (flock(fd, LOCK_SH | LOCK_NB) < 0) {
+ if (krb5_lock_file(krb5__krb4_context, fd,
+ KRB5_LOCKMODE_SHARED |
+ KRB5_LOCKMODE_DONTBLOCK) < 0) {
(void) close(fd);
fd = -1;
return TKT_FIL_LCK;
* The return value is not defined.
*/
-tf_close()
+void tf_close()
{
if (!(fd < 0)) {
#ifdef TKT_SHMEM
krb_shm_addr = 0;
}
#endif /* TKT_SHMEM */
- (void) flock(fd, LOCK_UN);
+ if (!krb5__krb4_context)
+ krb5_init_context(&krb5__krb4_context);
+ (void) krb5_lock_file(krb5__krb4_context, fd, KRB5_LOCKMODE_UNLOCK);
(void) close(fd);
fd = -1; /* see declaration of fd above */
}
krb__get_srvtabname(default_srvtabname)
char *default_srvtabname;
{
- krb5_context context;
const char* names[3];
char **full_name = 0, **cpp;
krb5_error_code retval;
char *retname;
- krb5_init_context(&context);
+ if (!krb5__krb4_context) {
+ retval = krb5_init_context(&krb5__krb4_context);
+ if (!retval)
+ return NULL;
+ }
names[0] = "libdefaults";
names[1] = "krb4_srvtab";
names[2] = 0;
- retval = profile_get_values(context->profile, names, &full_name);
+ retval = profile_get_values(krb5__krb4_context->profile, names,
+ &full_name);
if (retval == 0 && full_name && full_name[0]) {
retname = strdup(full_name[0]);
for (cpp = full_name; *cpp; cpp++)
} else {
retname = strdup(default_srvtabname);
}
- krb5_free_context(context);
return retname;
}