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