Репозитории ALT
S: | 4.17.11-alt1 |
5.1: | 3.0.37-alt5.M50P.1 |
4.1: | 3.0.30-alt3 |
4.0: | 3.0.33-alt1.M40.1 |
+updates: | 3.0.33-alt1.M40.1 |
3.0: | 3.0.14a-alt2 |
+backports: | 3.0.28-alt1 |
Группа :: Система/Серверы
Пакет: samba
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: samba-3.0-gencache-init-alt.patch
Скачать
Скачать
--- samba-3.0.9/source/lib/gencache.c.orig 2004-11-16 06:03:19 +0300
+++ samba-3.0.9/source/lib/gencache.c 2004-11-21 01:49:29 +0300
@@ -28,9 +28,13 @@
#define TIMEOUT_LEN 12
#define CACHE_DATA_FMT "%12u/%s"
+typedef enum {
+ GENCACHE_RDRW,
+ GENCACHE_RDONLY
+} gencache_access_t;
static TDB_CONTEXT *cache;
-
+static gencache_access_t cache_type;
/**
* @file gencache.c
* @brief Generic, persistent and shared between processes cache mechanism
@@ -64,6 +68,15 @@
cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT,
O_RDWR|O_CREAT, 0644);
+ cache_type = GENCACHE_RDRW;
+
+ if (!cache) {
+ DEBUG(5, ("Opening cache file at %s in read-write mode failed, try to open it read-only\n",
+ cache_fname));
+ cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT,
+ O_RDONLY, 0644);
+ cache_type = GENCACHE_RDONLY;
+ }
SAFE_FREE(cache_fname);
if (!cache) {
@@ -111,7 +124,7 @@
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr && value);
- if (!gencache_init()) return False;
+ if (!gencache_init() || (cache_type == GENCACHE_RDONLY)) return False;
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
@@ -156,7 +169,7 @@
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr && valstr);
- if (!gencache_init()) return False;
+ if (!gencache_init() || (cache_type == GENCACHE_RDONLY)) return False;
/*
* Check whether entry exists in the cache
@@ -207,7 +220,7 @@
/* fail completely if get null pointers passed */
SMB_ASSERT(keystr);
- if (!gencache_init()) return False;
+ if (!gencache_init() || (cache_type == GENCACHE_RDONLY)) return False;
keybuf.dptr = strdup(keystr);
keybuf.dsize = strlen(keystr)+1;