return 1;
}
-
int
-_afsconf_Check(struct afsconf_dir *adir)
+_afsconf_UpToDate(struct afsconf_dir *adir)
{
char tbuffer[256];
#ifdef AFS_NT40_ENV
#endif /* AFS_NT40_ENV */
code = stat(tbuffer, &tstat);
- if (code < 0) {
- return code;
- }
+ if (code < 0)
+ return 0; /* Can't throw the error, so just say we're not up to date */
+
/* did file change? */
- if (tstat.st_mtime == adir->timeRead) {
+ if (tstat.st_mtime == adir->timeRead)
+ return 1;
+
+ /* otherwise file has changed */
+ return 0;
+}
+
+int
+afsconf_UpToDate(void *rock)
+{
+ int code;
+
+ LOCK_GLOBAL_MUTEX;
+ code = _afsconf_UpToDate(rock);
+ UNLOCK_GLOBAL_MUTEX;
+
+ return code;
+}
+
+int
+_afsconf_Check(struct afsconf_dir *adir)
+{
+ /* did configuration change? */
+ if (_afsconf_UpToDate(adir))
return 0;
- }
+
/* otherwise file has changed, so reopen it */
return afsconf_Reopen(adir);
}
}
int
-afsconf_UpToDate(void *rock)
-{
- struct afsconf_dir *adir = rock;
- char tbuffer[256];
-#ifdef AFS_NT40_ENV
- char *p;
-#endif
- struct stat tstat;
- afs_int32 code = 0; /* default to not up to date */
- LOCK_GLOBAL_MUTEX;
-#ifdef AFS_NT40_ENV
- /* NT client config dir has no KeyFile; don't risk attempting open
- * because there might be a random file of this name if dir is shared.
- */
- if (_afsconf_IsClientConfigDirectory(adir->name)) {
- /* Not a server, nothing to reread */
- code = 1;
- } else {
-#endif
- strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL);
-
- /* did file change? */
- code = stat(tbuffer, &tstat);
- if ((code == 0) && (tstat.st_mtime <= adir->timeRead)) {
- code = 1;
- }
-#ifdef AFS_NT40_ENV
- }
-#endif
- UNLOCK_GLOBAL_MUTEX;
- return code;
-}
-
-int
afsconf_Close(struct afsconf_dir *adir)
{
LOCK_GLOBAL_MUTEX;
struct afsconf_dir *dir;
char *dirname;
struct rx_securityClass **classes;
+ struct rx_securityClass *secClass;
+ int secIndex;
int numClasses;
+ struct afsconf_typedKey *key;
- plan(3);
+ plan(9);
dirname = buildTestConfig();
dir = afsconf_Open(dirname);
afsconf_BuildServerSecurityObjects(dir, &classes, &numClasses);
is_int(4, numClasses, "When encryption is enabled, 4 classes are returned");
+ /* Up to date checks */
+
+ ok(afsconf_UpToDate(dir), "Newly opened directory is up to date");
+ is_int(0, afsconf_AddKey(dir,
+ 1, "\x19\x16\xfe\xe6\xba\x77\x2f\xfd", 0),
+ "Adding key worked");
+ ok(!afsconf_UpToDate(dir), "Directory with newly added key isn't");
+ afsconf_ClientAuth(dir, &secClass, &secIndex);
+ ok(afsconf_UpToDate(dir), "afsconf_ClientAuth() resets UpToDate check");
+ afsconf_DeleteKey(dir, 1);
+ ok(!afsconf_UpToDate(dir), "Directory with newly deleted key isn't");
+ afsconf_GetLatestKeyByTypes(dir, afsconf_rxkad, 0, &key);
+ ok(afsconf_UpToDate(dir), "afsconf_GetLatestKeyByTypes resest UpToDate");
+
return 0;
}