diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/account_pol.c | 4 | ||||
-rw-r--r-- | source3/lib/sharesec.c | 4 | ||||
-rw-r--r-- | source3/lib/util.c | 33 | ||||
-rw-r--r-- | source3/lib/util_unistr.c | 6 |
4 files changed, 40 insertions, 7 deletions
diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c index 96a471cf06..2540b49314 100644 --- a/source3/lib/account_pol.c +++ b/source3/lib/account_pol.c @@ -212,9 +212,9 @@ bool init_account_policy(void) return True; } - tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); + tdb = tdb_open_log(state_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); if (!tdb) { /* the account policies files does not exist or open failed, try to create a new one */ - tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + tdb = tdb_open_log(state_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); if (!tdb) { DEBUG(0,("Failed to open account policy database\n")); return False; diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 244a6d7285..e2320b2953 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -46,10 +46,10 @@ bool share_info_db_init(void) return True; } - share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + share_tdb = tdb_open_log(state_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); if (!share_tdb) { DEBUG(0,("Failed to open share info database %s (%s)\n", - lock_path("share_info.tdb"), strerror(errno) )); + state_path("share_info.tdb"), strerror(errno) )); return False; } diff --git a/source3/lib/util.c b/source3/lib/util.c index 53200ad02a..c8f0c3121f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2435,6 +2435,39 @@ char *lib_path(const char *name) } /** + * @brief Returns an absolute path to a file in the Samba data directory. + * + * @param name File to find, relative to CODEPAGEDIR. + * + * @retval Pointer to a talloc'ed string containing the full path. + **/ + +char *data_path(const char *name) +{ + return talloc_asprintf(talloc_tos(), "%s/%s", dyn_CODEPAGEDIR, name); +} + +/***************************************************************** +a useful function for returning a path in the Samba state directory + *****************************************************************/ +char *state_path(char *name) +{ + pstring fname; + + pstrcpy(fname,dyn_STATEDIR()); + trim_string(fname,"","/"); + + if (!directory_exist(fname,NULL)) { + mkdir(fname,0755); + } + + pstrcat(fname,"/"); + pstrcat(fname,name); + + return talloc_strdup(talloc_tos(), fname); +} + +/** * @brief Returns the platform specific shared library extension. * * @retval Pointer to a static #fstring containing the extension. diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 2b91ea9c80..e9e2c33fb3 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -87,11 +87,11 @@ void load_case_tables(void) } initialised = 1; - upcase_table = (smb_ucs2_t *)map_file(lib_path("upcase.dat"), + upcase_table = (smb_ucs2_t *)map_file(data_path("upcase.dat"), 0x20000); upcase_table_use_unmap = ( upcase_table != NULL ); - lowcase_table = (smb_ucs2_t *)map_file(lib_path("lowcase.dat"), + lowcase_table = (smb_ucs2_t *)map_file(data_path("lowcase.dat"), 0x20000); lowcase_table_use_unmap = ( lowcase_table != NULL ); @@ -229,7 +229,7 @@ void init_valid_table(void) return; } - valid_file = (uint8 *)map_file(lib_path("valid.dat"), 0x10000); + valid_file = (uint8 *)map_file(data_path("valid.dat"), 0x10000); if (valid_file) { valid_table = valid_file; mapped_file = 1; |