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