"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "source3/lib/gencache.c" between
samba-4.12.3.tar.gz and samba-4.12.5.tar.gz

About: Samba is the standard Windows interoperability suite of programs for Linux and Unix providing secure, stable and fast file and print services for all clients using the SMB/CIFS protocol. 4.12 series.

gencache.c  (samba-4.12.3):gencache.c  (samba-4.12.5)
skipping to change at line 32 skipping to change at line 32
*/ */
#include "includes.h" #include "includes.h"
#include "lib/gencache.h" #include "lib/gencache.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/glob.h" #include "system/glob.h"
#include "util_tdb.h" #include "util_tdb.h"
#include "tdb_wrap/tdb_wrap.h" #include "tdb_wrap/tdb_wrap.h"
#include "zlib.h" #include "zlib.h"
#include "lib/util/strv.h" #include "lib/util/strv.h"
#include "lib/util/util_paths.h"
#undef DBGC_CLASS #undef DBGC_CLASS
#define DBGC_CLASS DBGC_TDB #define DBGC_CLASS DBGC_TDB
#define GENCACHE_USER_PATH "~/.cache/samba/gencache.tdb"
static struct tdb_wrap *cache; static struct tdb_wrap *cache;
/** /**
* @file gencache.c * @file gencache.c
* @brief Generic, persistent and shared between processes cache mechanism * @brief Generic, persistent and shared between processes cache mechanism
* for use by various parts of the Samba code * for use by various parts of the Samba code
* *
**/ **/
static bool gencache_pull_timeout(TDB_DATA key, static bool gencache_pull_timeout(TDB_DATA key,
skipping to change at line 71 skipping to change at line 74
* it if does not exist. * it if does not exist.
* *
* @return true on successful initialisation of the cache or * @return true on successful initialisation of the cache or
* false on failure * false on failure
**/ **/
static bool gencache_init(void) static bool gencache_init(void)
{ {
char* cache_fname = NULL; char* cache_fname = NULL;
int open_flags = O_RDWR|O_CREAT; int open_flags = O_RDWR|O_CREAT;
int tdb_flags = TDB_INCOMPATIBLE_HASH|TDB_NOSYNC|TDB_MUTEX_LOCKING;
int hash_size; int hash_size;
/* skip file open if it's already opened */ /* skip file open if it's already opened */
if (cache) { if (cache) {
return true; return true;
} }
hash_size = lp_parm_int(-1, "gencache", "hash_size", 10000); hash_size = lp_parm_int(-1, "gencache", "hash_size", 10000);
cache_fname = lock_path(talloc_tos(), "gencache.tdb"); cache_fname = lock_path(talloc_tos(), "gencache.tdb");
if (cache_fname == NULL) { if (cache_fname == NULL) {
return false; return false;
} }
DEBUG(5, ("Opening cache file at %s\n", cache_fname)); DEBUG(5, ("Opening cache file at %s\n", cache_fname));
cache = tdb_wrap_open(NULL, cache_fname, hash_size, cache = tdb_wrap_open(NULL, cache_fname, hash_size,
TDB_INCOMPATIBLE_HASH| tdb_flags,
TDB_NOSYNC|
TDB_MUTEX_LOCKING,
open_flags, 0644); open_flags, 0644);
/*
* Allow client tools to create a gencache in the home directory
* as a normal user.
*/
if (cache == NULL && errno == EACCES && geteuid() != 0) {
char *cache_dname = NULL, *tmp = NULL;
bool ok;
TALLOC_FREE(cache_fname);
cache_fname = path_expand_tilde(talloc_tos(),
GENCACHE_USER_PATH);
if (cache_fname == NULL) {
DBG_ERR("Failed to expand path: %s\n",
GENCACHE_USER_PATH);
return false;
}
tmp = talloc_strdup(talloc_tos(), cache_fname);
if (tmp == NULL) {
DBG_ERR("No memory!\n");
TALLOC_FREE(cache_fname);
return false;
}
cache_dname = dirname(tmp);
if (cache_dname == NULL) {
DBG_ERR("Invalid path: %s\n", cache_fname);
TALLOC_FREE(tmp);
TALLOC_FREE(cache_fname);
return false;
}
ok = directory_create_or_exist(cache_dname, 0700);
if (!ok) {
DBG_ERR("Failed to create directory: %s - %s\n",
cache_dname, strerror(errno));
TALLOC_FREE(tmp);
TALLOC_FREE(cache_fname);
return false;
}
TALLOC_FREE(tmp);
cache = tdb_wrap_open(NULL,
cache_fname,
hash_size,
tdb_flags,
open_flags,
0644);
if (cache != NULL) {
DBG_INFO("Opening user cache file %s.\n",
cache_fname);
}
}
if (cache == NULL) { if (cache == NULL) {
DEBUG(5, ("Opening %s failed: %s\n", cache_fname, DEBUG(5, ("Opening %s failed: %s\n", cache_fname,
strerror(errno))); strerror(errno)));
TALLOC_FREE(cache_fname); TALLOC_FREE(cache_fname);
return false; return false;
} }
TALLOC_FREE(cache_fname); TALLOC_FREE(cache_fname);
return true; return true;
} }
 End of changes. 5 change blocks. 
3 lines changed or deleted 60 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)