svn commit: samba r19054 - in branches: SAMBA_3_0/source/lib
SAMBA_3_0_23/source/lib
jra at samba.org
jra at samba.org
Mon Oct 2 23:34:04 GMT 2006
Author: jra
Date: 2006-10-02 23:34:03 +0000 (Mon, 02 Oct 2006)
New Revision: 19054
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19054
Log:
Callers of gencache may not have the rights to
open read/write. Allow them to fallback to read-only.
Jeremy
Modified:
branches/SAMBA_3_0/source/lib/gencache.c
branches/SAMBA_3_0_23/source/lib/gencache.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/gencache.c
===================================================================
--- branches/SAMBA_3_0/source/lib/gencache.c 2006-10-02 22:18:36 UTC (rev 19053)
+++ branches/SAMBA_3_0/source/lib/gencache.c 2006-10-02 23:34:03 UTC (rev 19054)
@@ -31,6 +31,7 @@
#define READ_CACHE_DATA_FMT_TEMPLATE "%%12u/%%%us"
static TDB_CONTEXT *cache;
+static BOOL cache_readonly;
/**
* @file gencache.c
@@ -66,6 +67,14 @@
cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT,
O_RDWR|O_CREAT, 0644);
+ if (!cache && (errno == EACCES)) {
+ cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, O_RDONLY, 0644);
+ if (cache) {
+ cache_readonly = True;
+ DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname));
+ }
+ }
+
SAFE_FREE(cache_fname);
if (!cache) {
DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
@@ -90,6 +99,7 @@
DEBUG(5, ("Closing cache file\n"));
ret = tdb_close(cache);
cache = NULL;
+ cache_readonly = False;
return ret != -1;
}
@@ -117,6 +127,10 @@
if (!gencache_init()) return False;
+ if (cache_readonly) {
+ return False;
+ }
+
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
return False;
@@ -155,6 +169,10 @@
if (!gencache_init()) return False;
+ if (cache_readonly) {
+ return False;
+ }
+
keybuf.dptr = CONST_DISCARD(char *, keystr);
keybuf.dsize = strlen(keystr)+1;
DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr));
Modified: branches/SAMBA_3_0_23/source/lib/gencache.c
===================================================================
--- branches/SAMBA_3_0_23/source/lib/gencache.c 2006-10-02 22:18:36 UTC (rev 19053)
+++ branches/SAMBA_3_0_23/source/lib/gencache.c 2006-10-02 23:34:03 UTC (rev 19054)
@@ -31,6 +31,7 @@
#define READ_CACHE_DATA_FMT_TEMPLATE "%%12u/%%%us"
static TDB_CONTEXT *cache;
+static BOOL cache_readonly;
/**
* @file gencache.c
@@ -66,6 +67,14 @@
cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT,
O_RDWR|O_CREAT, 0644);
+ if (!cache && (errno == EACCES)) {
+ cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, O_RDONLY, 0644);
+ if (cache) {
+ cache_readonly = True;
+ DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname));
+ }
+ }
+
SAFE_FREE(cache_fname);
if (!cache) {
DEBUG(5, ("Attempt to open gencache.tdb has failed.\n"));
@@ -90,6 +99,7 @@
DEBUG(5, ("Closing cache file\n"));
ret = tdb_close(cache);
cache = NULL;
+ cache_readonly = False;
return ret != -1;
}
@@ -117,6 +127,10 @@
if (!gencache_init()) return False;
+ if (cache_readonly) {
+ return False;
+ }
+
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
return False;
@@ -162,6 +176,10 @@
if (!gencache_init()) return False;
+ if (cache_readonly) {
+ return False;
+ }
+
/*
* Check whether entry exists in the cache
* Don't verify gencache_get exit code, since the entry may be expired
@@ -213,6 +231,10 @@
if (!gencache_init()) return False;
+ if (cache_readonly) {
+ return False;
+ }
+
keybuf.dptr = SMB_STRDUP(keystr);
keybuf.dsize = strlen(keystr)+1;
DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr));
@@ -431,5 +453,3 @@
tdb_unlock_bystring(cache, key);
return;
}
-
-
More information about the samba-cvs
mailing list