2ea7d96103b0a8fded29061ffb32c7380495ad7a
[samba.git] / packaging / Debian / debian-unstable / patches / fhs.patch
1 diff -uNr samba-3.0.0beta2.orig/source/Makefile.in samba-3.0.0beta2/source/Makefile.in
2 --- samba-3.0.0beta2.orig/source/Makefile.in    2003-07-02 23:26:46.000000000 -0500
3 +++ samba-3.0.0beta2/source/Makefile.in 2003-07-02 23:19:46.000000000 -0500
4 @@ -92,6 +93,13 @@
5  # the directory where lock files go
6  LOCKDIR = @lockdir@
7  
8 +# FHS directories; equal to LOCKDIR if not using --with-fhs
9 +CACHEDIR = @cachedir@
10 +STATEDIR = @statedir@
11 +
12 +# Where to look for (and install) codepage databases.
13 +CODEPAGEDIR = @codepagedir@
14 +
15  # the directory where pid files go
16  PIDDIR = @piddir@
17  # man pages language(s)
18 @@ -116,7 +124,7 @@
19  PATH_FLAGS4 = $(PATH_FLAGS3) -DSWATDIR=\"$(SWATDIR)\"  -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\"
20  PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\"$(LIBDIR)\" \
21               -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\"
22 -PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\"
23 +PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\" -DCACHEDIR=\"$(CACHEDIR)\" -DSTATEDIR=\"$(STATEDIR)\"
24  PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
25  
26  # Note that all executable programs now provide for an optional executable suffix.
27 @@ -1234,7 +1242,7 @@
28         @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS)
29  
30  installdat: installdirs
31 -       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
32 +       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(CODEPAGEDIR) $(srcdir)
33  
34  installswat: installdirs
35         @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
36 --- samba-3.0.1/source/configure.in.orig        2003-12-17 11:05:40.000000000 -0500
37 +++ samba-3.0.1/source/configure.in     2003-12-17 11:05:42.000000000 -0500
38 @@ -17,19 +17,26 @@
39  AC_ARG_WITH(fhs, 
40  [  --with-fhs              Use FHS-compliant paths (default=no)],
41      configdir="${sysconfdir}/samba"
42 -    lockdir="\${VARDIR}/lib/samba"
43 +    lockdir="\${VARDIR}/run/samba"
44      piddir="\${VARDIR}/run"
45      mandir="\${prefix}/share/man"
46      logfilebase="\${VARDIR}/log/samba"
47      privatedir="\${CONFIGDIR}/private"
48      libdir="\${prefix}/lib/samba"
49 -    swatdir="\${DATADIR}/samba/swat",
50 +    swatdir="\${DATADIR}/samba/swat"
51 +    codepagedir="\${DATADIR}/samba"
52 +    statedir="\${VARDIR}/lib/samba"
53 +    cachedir="\${VARDIR}/cache/samba"
54 +    AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths]),
55      configdir="\${LIBDIR}"
56      logfilebase="\${VARDIR}"
57      lockdir="\${VARDIR}/locks"
58      piddir="\${VARDIR}/locks"
59      privatedir="\${prefix}/private"
60 -    swatdir="\${prefix}/swat")
61 +    codepagedir="\${LIBDIR}"
62 +    swatdir="\${prefix}/swat"
63 +    statedir="\${LOCKDIR}"
64 +    cachedir="\${LOCKDIR}")
65  
66  #################################################
67  # set private directory location
68 @@ -154,6 +161,9 @@
69  AC_SUBST(swatdir)
70  AC_SUBST(bindir)
71  AC_SUBST(sbindir)
72 +AC_SUBST(codepagedir)
73 +AC_SUBST(statedir)
74 +AC_SUBST(cachedir)
75  
76  dnl Unique-to-Samba variables we'll be playing with.
77  AC_SUBST(SHELL)
78 diff -uNr samba-3.0.0beta2.orig/source/dynconfig.c samba-3.0.0beta2/source/dynconfig.c
79 --- samba-3.0.0beta2.orig/source/dynconfig.c    2003-07-02 23:26:47.000000000 -0500
80 +++ samba-3.0.0beta2/source/dynconfig.c 2003-07-02 23:19:02.000000000 -0500
81 @@ -53,6 +53,13 @@
82  pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
83  
84  /**
85 + * @brief Samba data directory.
86 + *
87 + * @sa data_path() to get the path to a file inside the CODEPAGEDIR.
88 + **/
89 +pstring dyn_CODEPAGEDIR = CODEPAGEDIR;
90 +
91 +/**
92   * @brief Samba library directory.
93   *
94   * @sa lib_path() to get the path to a file inside the LIBDIR.
95 @@ -70,3 +77,27 @@
96  
97  const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
98  const pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
99 +
100 +
101 +/* In non-FHS mode, these should be configurable using 'lock dir =';
102 +   but in FHS mode, they are their own directory.  Implement as wrapper
103 +   functions so that everything can still be kept in dynconfig.c.
104 + */
105 +
106 +char *dyn_STATEDIR(void)
107 +{
108 +#ifdef FHS_COMPATIBLE
109 +       return STATEDIR;
110 +#else
111 +       return lp_lockdir();
112 +#endif
113 +}
114 +
115 +char *dyn_CACHEDIR(void)
116 +{
117 +#ifdef FHS_COMPATIBLE
118 +       return CACHEDIR;
119 +#else
120 +       return lp_lockdir();
121 +#endif
122 +}
123 diff -uNr samba-3.0.0beta2.orig/source/groupdb/mapping.c samba-3.0.0beta2/source/groupdb/mapping.c
124 --- samba-3.0.0beta2.orig/source/groupdb/mapping.c      2003-07-02 23:26:47.000000000 -0500
125 +++ samba-3.0.0beta2/source/groupdb/mapping.c   2003-07-02 23:19:02.000000000 -0500
126 @@ -134,7 +134,7 @@
127         
128         if (tdb && local_pid == sys_getpid())
129                 return True;
130 -       tdb = tdb_open_log(lock_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
131 +       tdb = tdb_open_log(state_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
132         if (!tdb) {
133                 DEBUG(0,("Failed to open group mapping database\n"));
134                 return False;
135 diff -uNr samba-3.0.0beta2.orig/source/include/dynconfig.h samba-3.0.0beta2/source/include/dynconfig.h
136 --- samba-3.0.0beta2.orig/source/include/dynconfig.h    2003-07-02 23:26:47.000000000 -0500
137 +++ samba-3.0.0beta2/source/include/dynconfig.h 2003-07-02 23:19:02.000000000 -0500
138 @@ -31,8 +31,12 @@
139  extern pstring dyn_CONFIGFILE;
140  extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
141  extern pstring dyn_LIBDIR;
142 +extern pstring dyn_CODEPAGEDIR;
143  extern const fstring dyn_SHLIBEXT;
144  extern const pstring dyn_LOCKDIR; 
145  extern const pstring dyn_PIDDIR;
146  extern const pstring dyn_SMB_PASSWD_FILE;
147  extern const pstring dyn_PRIVATE_DIR;
148 +
149 +char *dyn_STATEDIR(void);
150 +char *dyn_CACHEDIR(void);
151 diff -uNr samba-3.0.0beta2.orig/source/intl/lang_tdb.c samba-3.0.0beta2/source/intl/lang_tdb.c
152 --- samba-3.0.0beta2.orig/source/intl/lang_tdb.c        2003-07-02 23:26:47.000000000 -0500
153 +++ samba-3.0.0beta2/source/intl/lang_tdb.c     2003-07-02 23:19:02.000000000 -0500
154 @@ -128,7 +128,7 @@
155         /* if no lang then we don't translate */
156         if (!lang) return True;
157  
158 -       asprintf(&msg_path, "%s.msg", lib_path((const char *)lang));
159 +       asprintf(&msg_path, "%s.msg", data_path((const char *)lang));
160         if (stat(msg_path, &st) != 0) {
161                 /* the msg file isn't available */
162                 free(msg_path);
163 @@ -136,7 +136,7 @@
164         }
165         
166  
167 -       asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang);
168 +       asprintf(&path, "%s%s.tdb", state_path("lang_"), lang);
169  
170         tdb = tdb_open_log(path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
171         if (!tdb) {
172 diff -uNr samba-3.0.0beta2.orig/source/lib/account_pol.c samba-3.0.0beta2/source/lib/account_pol.c
173 --- samba-3.0.0beta2.orig/source/lib/account_pol.c      2003-07-02 23:26:47.000000000 -0500
174 +++ samba-3.0.0beta2/source/lib/account_pol.c   2003-07-02 23:19:02.000000000 -0500
175 @@ -36,7 +36,7 @@
176  
177         if (tdb && local_pid == sys_getpid())
178                 return True;
179 -       tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
180 +       tdb = tdb_open_log(state_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
181         if (!tdb) {
182                 DEBUG(0,("Failed to open account policy database\n"));
183                 return False;
184 diff -uNr samba-3.0.0beta2.orig/source/lib/util.c samba-3.0.0beta2/source/lib/util.c
185 --- samba-3.0.0beta2.orig/source/lib/util.c     2003-07-02 23:26:47.000000000 -0500
186 +++ samba-3.0.0beta2/source/lib/util.c  2003-07-02 23:19:02.000000000 -0500
187 @@ -2195,6 +2195,61 @@
188  }
189  
190  /**
191 + * @brief Returns an absolute path to a file in the Samba data directory.
192 + *
193 + * @param name File to find, relative to CODEPAGEDIR.
194 + *
195 + * @retval Pointer to a static #pstring containing the full path.
196 + **/
197 +
198 +char *data_path(const char *name)
199 +{
200 +       static pstring fname;
201 +       snprintf(fname, sizeof(fname), "%s/%s", dyn_CODEPAGEDIR, name);
202 +       return fname;
203 +}
204 +
205 +/*****************************************************************
206 +a useful function for returning a path in the Samba state directory
207 + *****************************************************************/
208 +char *state_path(char *name)
209 +{
210 +       static pstring fname;
211 +
212 +       pstrcpy(fname,dyn_STATEDIR());
213 +       trim_string(fname,"","/");
214 +
215 +       if (!directory_exist(fname,NULL)) {
216 +               mkdir(fname,0755);
217 +       }
218 +
219 +       pstrcat(fname,"/");
220 +       pstrcat(fname,name);
221 +
222 +       return fname;
223 +}
224 +
225 +/*****************************************************************
226 +a useful function for returning a path in the Samba cache directory
227 + *****************************************************************/
228 +char *cache_path(char *name)
229 +{
230 +       static pstring fname;
231 +
232 +       pstrcpy(fname,dyn_CACHEDIR());
233 +       trim_string(fname,"","/");
234 +
235 +       if (!directory_exist(fname,NULL)) {
236 +                       mkdir(fname,0755);
237 +       }
238 +
239 +       pstrcat(fname,"/");
240 +       pstrcat(fname,name);
241 +
242 +       return fname;
243 +}
244 +
245 +/**
246   * @brief Returns the platform specific shared library extension.
247   *
248   * @retval Pointer to a static #fstring containing the extension.
249 diff -uNr samba-3.0.0beta2.orig/source/lib/util_unistr.c samba-3.0.0beta2/source/lib/util_unistr.c
250 --- samba-3.0.0beta2.orig/source/lib/util_unistr.c      2003-07-02 23:26:47.000000000 -0500
251 +++ samba-3.0.0beta2/source/lib/util_unistr.c   2003-07-02 23:19:02.000000000 -0500
252 @@ -54,8 +54,8 @@
253         if (initialised) return;
254         initialised = 1;
255  
256 -       upcase_table = map_file(lib_path("upcase.dat"), 0x20000);
257 -       lowcase_table = map_file(lib_path("lowcase.dat"), 0x20000);
258 +       upcase_table = map_file(data_path("upcase.dat"), 0x20000);
259 +       lowcase_table = map_file(data_path("lowcase.dat"), 0x20000);
260  
261         /* we would like Samba to limp along even if these tables are
262            not available */
263 @@ -161,7 +161,7 @@
264                 return;
265         }
266  
267 -       valid_file = map_file(lib_path("valid.dat"), 0x10000);
268 +       valid_file = map_file(data_path("valid.dat"), 0x10000);
269         if (valid_file) {
270                 valid_table = valid_file;
271                 mapped_file = 1;
272 diff -uNr samba-3.0.0beta2.orig/source/libsmb/samlogon_cache.c samba-3.0.0beta2/source/libsmb/samlogon_cache.c
273 --- samba-3.0.0beta2.orig/source/libsmb/samlogon_cache.c        2003-07-01 09:40:37.000000000 -0500
274 +++ samba-3.0.0beta2/source/libsmb/samlogon_cache.c     2003-07-02 23:19:02.000000000 -0500
275 @@ -34,7 +34,7 @@
276  BOOL netsamlogon_cache_init(void)
277  {
278         if (!netsamlogon_tdb) {
279 -               netsamlogon_tdb = tdb_open_log(lock_path(NETSAMLOGON_TDB), 0,
280 +               netsamlogon_tdb = tdb_open_log(cache_path(NETSAMLOGON_TDB), 0,
281                                                    TDB_DEFAULT, O_RDWR | O_CREAT, 0600);
282         }
283  
284 @@ -67,7 +67,7 @@
285             winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
286  
287         if (!tdb) {
288 -               tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000,
289 +               tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000,
290                                    TDB_DEFAULT, O_RDWR, 0600);
291                 if (!tdb) {
292                         DEBUG(5, ("netsamlogon_clear_cached_user: failed to open cache\n"));
293 --- samba_3_0/source/nmbd/nmbd_serverlistdb.c.orig      2003-09-08 10:53:13.000000000 -0400
294 +++ samba_3_0/source/nmbd/nmbd_serverlistdb.c   2003-09-08 11:22:03.000000000 -0400
295 @@ -327,7 +327,7 @@
296  
297         updatecount++;
298      
299 -       pstrcpy(fname,lp_lockdir());
300 +       pstrcpy(fname,dyn_CACHEDIR());
301         trim_char(fname,'\0' ,'/');
302         pstrcat(fname,"/");
303         pstrcat(fname,SERVER_LIST);
304 --- samba-3.0.0rc2/source/nmbd/nmbd_winsserver.c.orig   2003-08-28 17:42:44.000000000 -0400
305 +++ samba-3.0.0rc2/source/nmbd/nmbd_winsserver.c        2003-08-31 08:09:11.000000000 -0400
306 @@ -234,7 +234,7 @@
307  
308         add_samba_names_to_subnet(wins_server_subnet);
309  
310 -       if((fp = x_fopen(lock_path(WINS_LIST),O_RDONLY,0)) == NULL) {
311 +       if((fp = x_fopen(state_path(WINS_LIST),O_RDONLY,0)) == NULL) {
312                 DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
313                         WINS_LIST, strerror(errno) ));
314                 return True;
315 @@ -1765,7 +1765,7 @@
316                 }
317         }
318  
319 -       slprintf(fname,sizeof(fname)-1,"%s/%s", lp_lockdir(), WINS_LIST);
320 +       slprintf(fname,sizeof(fname)-1,"%s/%s", dyn_STATEDIR(), WINS_LIST);
321         all_string_sub(fname,"//", "/", 0);
322         slprintf(fnamenew,sizeof(fnamenew)-1,"%s.%u", fname, (unsigned int)sys_getpid());
323  
324 diff -uNr samba-3.0.0beta2.orig/source/nsswitch/winbindd_cache.c samba-3.0.0beta2/source/nsswitch/winbindd_cache.c
325 --- samba-3.0.0beta2.orig/source/nsswitch/winbindd_cache.c      2003-07-02 23:26:47.000000000 -0500
326 +++ samba-3.0.0beta2/source/nsswitch/winbindd_cache.c   2003-07-02 23:19:02.000000000 -0500
327 @@ -57,7 +57,7 @@
328         if (opt_nocache)
329                 return;
330  
331 -       wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000, 
332 +       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000, 
333                                    TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
334  
335         if (!wcache->tdb) {
336 diff -uNr samba-3.0.0beta2.orig/source/nsswitch/winbindd_util.c samba-3.0.0beta2/source/nsswitch/winbindd_util.c
337 --- samba-3.0.0beta2.orig/source/nsswitch/winbindd_util.c       2003-07-01 15:44:25.000000000 -0500
338 +++ samba-3.0.0beta2/source/nsswitch/winbindd_util.c    2003-07-02 23:19:02.000000000 -0500
339 @@ -874,7 +874,7 @@
340         SMB_STRUCT_STAT stbuf;
341         TDB_CONTEXT *idmap_tdb;
342  
343 -       pstrcpy(idmap_name, lock_path("winbindd_idmap.tdb"));
344 +       pstrcpy(idmap_name, state_path("winbindd_idmap.tdb"));
345  
346         if (!file_exist(idmap_name, &stbuf)) {
347                 /* nothing to convert return */
348 diff -uNr samba-3.0.0beta2.orig/source/param/loadparm.c samba-3.0.0beta2/source/param/loadparm.c
349 --- samba-3.0.0beta2.orig/source/param/loadparm.c       2003-07-02 23:26:47.000000000 -0500
350 +++ samba-3.0.0beta2/source/param/loadparm.c    2003-07-02 23:19:02.000000000 -0500
351 @@ -104,6 +104,9 @@
352         char *szAddPrinterCommand;
353         char *szDeletePrinterCommand;
354         char *szOs2DriverMap;
355 +#ifdef FHS_COMPATIBLE
356 +       char *szLockDirStub;
357 +#endif
358         char *szLockDir;
359         char *szPidDir;
360         char *szRootdir;
361 @@ -1083,8 +1083,13 @@
362         {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE}, 
363         {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
364         {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
365 +#ifdef FHS_COMPATIBLE
366 +       {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0}, 
367 +       {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0},
368 +#else
369         {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED}, 
370         {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE}, 
371 +#endif
372         {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED}, 
373  #ifdef WITH_UTMP
374         {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED}, 
375 diff -uNr samba-3.0.0beta2.orig/source/passdb/pdb_tdb.c samba-3.0.0beta2/source/passdb/pdb_tdb.c
376 --- samba-3.0.0beta2.orig/source/passdb/pdb_tdb.c       2003-07-02 23:26:47.000000000 -0500
377 +++ samba-3.0.0beta2/source/passdb/pdb_tdb.c    2003-07-02 23:19:02.000000000 -0500
378 @@ -501,10 +501,7 @@
379         if (location) {
380                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, location);
381         } else {
382 -               pstring tdbfile;
383 -               get_private_directory(tdbfile);
384 -               pstrcat(tdbfile, "/");
385 -               pstrcat(tdbfile, PASSDB_FILE_NAME);
386 +               char *tdbfile = state_path(PASSDB_FILE_NAME);
387                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, tdbfile);
388         }
389  
390 diff -uNr samba-3.0.0beta2.orig/source/passdb/privileges.c samba-3.0.0beta2/source/passdb/privileges.c
391 --- samba-3.0.0beta2.orig/source/passdb/privileges.c    2003-06-07 12:57:35.000000000 -0500
392 +++ samba-3.0.0beta2/source/passdb/privileges.c 2003-07-02 23:19:02.000000000 -0500
393 @@ -62,7 +62,7 @@
394  /* initialise the privilege database */
395  BOOL privilege_init(void)
396  {
397 -       tdb = tdb_open_log(lock_path("privilege.tdb"), 0, TDB_DEFAULT, 
398 +       tdb = tdb_open_log(state_path("privilege.tdb"), 0, TDB_DEFAULT, 
399                            O_RDWR|O_CREAT, 0600);
400         if (!tdb) {
401                 DEBUG(0,("Failed to open privilege database\n"));
402 diff -uNr samba-3.0.0beta2.orig/source/passdb/secrets.c samba-3.0.0beta2/source/passdb/secrets.c
403 --- samba-3.0.0beta2.orig/source/passdb/secrets.c       2003-07-02 23:26:47.000000000 -0500
404 +++ samba-3.0.0beta2/source/passdb/secrets.c    2003-07-02 23:19:02.000000000 -0500
405 @@ -38,8 +38,7 @@
406         if (tdb)
407                 return True;
408  
409 -       pstrcpy(fname, lp_private_dir());
410 -       pstrcat(fname,"/secrets.tdb");
411 +       pstrcpy(fname, state_path("secrets.tdb"));
412  
413         tdb = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
414  
415 diff -uNr samba-3.0.0beta2.orig/source/printing/nt_printing.c samba-3.0.0beta2/source/printing/nt_printing.c
416 --- samba-3.0.0beta2.orig/source/printing/nt_printing.c 2003-07-02 23:26:47.000000000 -0500
417 +++ samba-3.0.0beta2/source/printing/nt_printing.c      2003-07-02 23:19:02.000000000 -0500
418 @@ -293,28 +293,28 @@
419   
420         if (tdb_drivers)
421                 tdb_close(tdb_drivers);
422 -       tdb_drivers = tdb_open_log(lock_path("ntdrivers.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
423 +       tdb_drivers = tdb_open_log(state_path("ntdrivers.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
424         if (!tdb_drivers) {
425                 DEBUG(0,("nt_printing_init: Failed to open nt drivers database %s (%s)\n",
426 -                       lock_path("ntdrivers.tdb"), strerror(errno) ));
427 +                       state_path("ntdrivers.tdb"), strerror(errno) ));
428                 return False;
429         }
430   
431         if (tdb_printers)
432                 tdb_close(tdb_printers);
433 -       tdb_printers = tdb_open_log(lock_path("ntprinters.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
434 +       tdb_printers = tdb_open_log(state_path("ntprinters.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
435         if (!tdb_printers) {
436                 DEBUG(0,("nt_printing_init: Failed to open nt printers database %s (%s)\n",
437 -                       lock_path("ntprinters.tdb"), strerror(errno) ));
438 +                       state_path("ntprinters.tdb"), strerror(errno) ));
439                 return False;
440         }
441   
442         if (tdb_forms)
443                 tdb_close(tdb_forms);
444 -       tdb_forms = tdb_open_log(lock_path("ntforms.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
445 +       tdb_forms = tdb_open_log(state_path("ntforms.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
446         if (!tdb_forms) {
447                 DEBUG(0,("nt_printing_init: Failed to open nt forms database %s (%s)\n",
448 -                       lock_path("ntforms.tdb"), strerror(errno) ));
449 +                       state_path("ntforms.tdb"), strerror(errno) ));
450                 return False;
451         }
452   
453 diff -uNr samba-3.0.0beta2.orig/source/printing/printing.c samba-3.0.0beta2/source/printing/printing.c
454 --- samba-3.0.0beta2.orig/source/printing/printing.c    2003-07-02 23:26:47.000000000 -0500
455 +++ samba-3.0.0beta2/source/printing/printing.c 2003-07-02 23:19:02.000000000 -0500
456 @@ -175,8 +175,8 @@
457         if (local_pid == sys_getpid())
458                 return True;
459  
460 -       unlink(lock_path("printing.tdb"));
461 -       pstrcpy(printing_path,lock_path("printing"));
462 +       unlink(cache_path("printing.tdb"));
463 +       pstrcpy(printing_path,cache_path("printing"));
464         mkdir(printing_path,0755);
465  
466         local_pid = sys_getpid();
467 diff -uNr samba-3.0.0beta2.orig/source/printing/printing_db.c samba-3.0.0beta2/source/printing/printing_db.c
468 --- samba-3.0.0beta2.orig/source/printing/printing_db.c 2003-07-02 23:26:47.000000000 -0500
469 +++ samba-3.0.0beta2/source/printing/printing_db.c      2003-07-02 23:19:02.000000000 -0500
470 @@ -87,7 +87,7 @@
471                 DLIST_ADD(print_db_head, p);
472         }
473  
474 -       pstrcpy(printdb_path, lock_path("printing/"));
475 +       pstrcpy(printdb_path, cache_path("printing/"));
476         pstrcat(printdb_path, printername);
477         pstrcat(printdb_path, ".tdb");
478  
479 diff -uNr samba-3.0.0beta2.orig/source/registry/reg_db.c samba-3.0.0beta2/source/registry/reg_db.c
480 --- samba-3.0.0beta2.orig/source/registry/reg_db.c      2003-07-02 23:26:47.000000000 -0500
481 +++ samba-3.0.0beta2/source/registry/reg_db.c   2003-07-02 23:19:02.000000000 -0500
482 @@ -131,13 +131,13 @@
483          * if we need to init the data in the registry
484          */
485         
486 -       tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
487 +       tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
488         if ( !tdb_reg ) 
489         {
490 -               tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
491 +               tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
492                 if ( !tdb_reg ) {
493                         DEBUG(0,("init_registry: Failed to open registry %s (%s)\n",
494 -                               lock_path("registry.tdb"), strerror(errno) ));
495 +                               state_path("registry.tdb"), strerror(errno) ));
496                         return False;
497                 }
498                 
499 diff -uNr samba-3.0.0beta2.orig/source/rpc_server/srv_srvsvc_nt.c samba-3.0.0beta2/source/rpc_server/srv_srvsvc_nt.c
500 --- samba-3.0.0beta2.orig/source/rpc_server/srv_srvsvc_nt.c     2003-07-02 23:26:47.000000000 -0500
501 +++ samba-3.0.0beta2/source/rpc_server/srv_srvsvc_nt.c  2003-07-02 23:19:02.000000000 -0500
502 @@ -133,10 +133,10 @@
503   
504         if (share_tdb && local_pid == sys_getpid())
505                 return True;
506 -       share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
507 +       share_tdb = tdb_open_log(state_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
508         if (!share_tdb) {
509                 DEBUG(0,("Failed to open share info database %s (%s)\n",
510 -                       lock_path("share_info.tdb"), strerror(errno) ));
511 +                       state_path("share_info.tdb"), strerror(errno) ));
512                 return False;
513         }
514   
515 diff -uNr samba-3.0.0beta2.orig/source/sam/idmap_tdb.c samba-3.0.0beta2/source/sam/idmap_tdb.c
516 --- samba-3.0.0beta2.orig/source/sam/idmap_tdb.c        2003-07-01 15:44:26.000000000 -0500
517 +++ samba-3.0.0beta2/source/sam/idmap_tdb.c     2003-07-02 23:19:02.000000000 -0500
518 @@ -487,7 +487,7 @@
519         BOOL tdb_is_new = False;
520  
521         /* use the old database if present */
522 -       tdbfile = strdup(lock_path("winbindd_idmap.tdb"));
523 +       tdbfile = strdup(state_path("winbindd_idmap.tdb"));
524         if (!tdbfile) {
525                 DEBUG(0, ("idmap_init: out of memory!\n"));
526                 return NT_STATUS_NO_MEMORY;
527 diff -uNr samba-3.0.0beta2.orig/source/smbd/lanman.c samba-3.0.0beta2/source/smbd/lanman.c
528 --- samba-3.0.0beta2.orig/source/smbd/lanman.c  2003-07-02 23:26:47.000000000 -0500
529 +++ samba-3.0.0beta2/source/smbd/lanman.c       2003-07-02 23:19:02.000000000 -0500
530 @@ -970,9 +970,9 @@
531    BOOL local_list_only;
532    int i;
533  
534 -  lines = file_lines_load(lock_path(SERVER_LIST), NULL);
535 +  lines = file_lines_load(cache_path(SERVER_LIST), NULL);
536    if (!lines) {
537 -    DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno)));
538 +    DEBUG(4,("Can't open %s - %s\n",cache_path(SERVER_LIST),strerror(errno)));
539      return(0);
540    }
541  
542 diff -uNr samba-3.0.0beta2.orig/source/wrepld/process.c samba-3.0.0beta2/source/wrepld/process.c
543 --- samba-3.0.0beta2.orig/source/wrepld/process.c       2003-07-02 23:26:47.000000000 -0500
544 +++ samba-3.0.0beta2/source/wrepld/process.c    2003-07-02 23:19:02.000000000 -0500
545 @@ -197,7 +197,7 @@
546  {
547         TDB_CONTEXT *tdb;
548  
549 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
550 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
551         if (!tdb) {
552                 DEBUG(2,("get_our_last_id: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
553                 return;
554 @@ -489,7 +489,7 @@
555                 }
556  
557  
558 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
559 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
560         if (!tdb) {
561                 DEBUG(2,("send_entry_request: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
562                 return;