Merge Samba3 and Samba4 together
[amitay/samba.git] / packaging / Debian / debian-unstable / patches / fhs.patch
1 diff -uNr samba-3.0.10.orig/source/Makefile.in samba-3.0.10/source/Makefile.in
2 --- samba-3.0.10.orig/source/Makefile.in        2004-12-17 03:50:08.000000000 -0800
3 +++ samba-3.0.10/source/Makefile.in     2004-12-17 03:55:29.000000000 -0800
4 @@ -90,6 +90,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 +121,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 @@ -1319,7 +1326,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  installmsg: installdirs
35         @$(SHELL) $(srcdir)/script/installmsg.sh $(DESTDIR)$(LIBDIR) $(srcdir)
36 diff -uNr samba-3.0.10.orig/source/configure.in samba-3.0.10/source/configure.in
37 --- samba-3.0.10.orig/source/configure.in       2004-12-17 03:50:08.000000000 -0800
38 +++ samba-3.0.10/source/configure.in    2004-12-17 03:55:29.000000000 -0800
39 @@ -35,7 +35,7 @@
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      mandir="\${prefix}/share/man"
47      logfilebase="\${VARDIR}/log/samba"
48 @@ -43,6 +43,10 @@
49      libdir="\${prefix}/lib/samba"
50      configdir="${sysconfdir}/samba"
51      swatdir="\${DATADIR}/samba/swat"
52 +    codepagedir="\${DATADIR}/samba"
53 +    statedir="\${VARDIR}/lib/samba"
54 +    cachedir="\${VARDIR}/cache/samba"
55 +    AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths])
56      ;;
57    esac])
58  
59 @@ -201,6 +205,9 @@
60  AC_SUBST(swatdir)
61  AC_SUBST(bindir)
62  AC_SUBST(sbindir)
63 +AC_SUBST(codepagedir)
64 +AC_SUBST(statedir)
65 +AC_SUBST(cachedir)
66  
67  dnl Unique-to-Samba variables we'll be playing with.
68  AC_SUBST(SHELL)
69 diff -uNr samba-3.0.10.orig/source/dynconfig.c samba-3.0.10/source/dynconfig.c
70 --- samba-3.0.10.orig/source/dynconfig.c        2004-12-17 03:50:08.000000000 -0800
71 +++ samba-3.0.10/source/dynconfig.c     2004-12-17 03:55:29.000000000 -0800
72 @@ -53,6 +53,13 @@
73  pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
74  
75  /**
76 + * @brief Samba data directory.
77 + *
78 + * @sa data_path() to get the path to a file inside the CODEPAGEDIR.
79 + **/
80 +pstring dyn_CODEPAGEDIR = CODEPAGEDIR;
81 +
82 +/**
83   * @brief Samba library directory.
84   *
85   * @sa lib_path() to get the path to a file inside the LIBDIR.
86 @@ -70,3 +77,27 @@
87  
88  const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
89  const pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
90 +
91 +
92 +/* In non-FHS mode, these should be configurable using 'lock dir =';
93 +   but in FHS mode, they are their own directory.  Implement as wrapper
94 +   functions so that everything can still be kept in dynconfig.c.
95 + */
96 +
97 +char *dyn_STATEDIR(void)
98 +{
99 +#ifdef FHS_COMPATIBLE
100 +       return STATEDIR;
101 +#else
102 +       return lp_lockdir();
103 +#endif
104 +}
105 +
106 +char *dyn_CACHEDIR(void)
107 +{
108 +#ifdef FHS_COMPATIBLE
109 +       return CACHEDIR;
110 +#else
111 +       return lp_lockdir();
112 +#endif
113 +}
114 diff -uNr samba-3.0.10.orig/source/groupdb/mapping.c samba-3.0.10/source/groupdb/mapping.c
115 --- samba-3.0.10.orig/source/groupdb/mapping.c  2004-12-17 03:50:08.000000000 -0800
116 +++ samba-3.0.10/source/groupdb/mapping.c       2004-12-17 03:55:29.000000000 -0800
117 @@ -140,7 +140,7 @@
118         
119         if (tdb)
120                 return True;
121 -       tdb = tdb_open_log(lock_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
122 +       tdb = tdb_open_log(state_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
123         if (!tdb) {
124                 DEBUG(0,("Failed to open group mapping database\n"));
125                 return False;
126 diff -uNr samba-3.0.10.orig/source/include/dynconfig.h samba-3.0.10/source/include/dynconfig.h
127 --- samba-3.0.10.orig/source/include/dynconfig.h        2004-12-17 03:50:08.000000000 -0800
128 +++ samba-3.0.10/source/include/dynconfig.h     2004-12-17 03:55:29.000000000 -0800
129 @@ -31,8 +31,12 @@
130  extern pstring dyn_CONFIGFILE;
131  extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
132  extern pstring dyn_LIBDIR;
133 +extern pstring dyn_CODEPAGEDIR;
134  extern const fstring dyn_SHLIBEXT;
135  extern const pstring dyn_LOCKDIR; 
136  extern const pstring dyn_PIDDIR;
137  extern const pstring dyn_SMB_PASSWD_FILE;
138  extern const pstring dyn_PRIVATE_DIR;
139 +
140 +char *dyn_STATEDIR(void);
141 +char *dyn_CACHEDIR(void);
142 diff -uNr samba-3.0.10.orig/source/intl/lang_tdb.c samba-3.0.10/source/intl/lang_tdb.c
143 --- samba-3.0.10.orig/source/intl/lang_tdb.c    2004-12-17 03:50:08.000000000 -0800
144 +++ samba-3.0.10/source/intl/lang_tdb.c 2004-12-17 03:55:29.000000000 -0800
145 @@ -128,7 +128,7 @@
146         if (!lang) 
147                 return True;
148  
149 -       asprintf(&msg_path, "%s.msg", lib_path((const char *)lang));
150 +       asprintf(&msg_path, "%s.msg", data_path((const char *)lang));
151         if (stat(msg_path, &st) != 0) {
152                 /* the msg file isn't available */
153                 DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path, 
154 diff -uNr samba-3.0.10.orig/source/lib/account_pol.c samba-3.0.10/source/lib/account_pol.c
155 --- samba-3.0.10.orig/source/lib/account_pol.c  2004-12-17 03:50:08.000000000 -0800
156 +++ samba-3.0.10/source/lib/account_pol.c       2004-12-17 03:55:29.000000000 -0800
157 @@ -35,7 +35,7 @@
158  
159         if (tdb)
160                 return True;
161 -       tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
162 +       tdb = tdb_open_log(state_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
163         if (!tdb) {
164                 DEBUG(0,("Failed to open account policy database\n"));
165                 return False;
166 diff -uNr samba-3.0.10.orig/source/lib/util.c samba-3.0.10/source/lib/util.c
167 --- samba-3.0.10.orig/source/lib/util.c 2004-12-17 03:50:08.000000000 -0800
168 +++ samba-3.0.10/source/lib/util.c      2004-12-17 03:55:29.000000000 -0800
169 @@ -2362,6 +2362,61 @@
170  }
171  
172  /**
173 + * @brief Returns an absolute path to a file in the Samba data directory.
174 + *
175 + * @param name File to find, relative to CODEPAGEDIR.
176 + *
177 + * @retval Pointer to a static #pstring containing the full path.
178 + **/
179 +
180 +char *data_path(const char *name)
181 +{
182 +       static pstring fname;
183 +       snprintf(fname, sizeof(fname), "%s/%s", dyn_CODEPAGEDIR, name);
184 +       return fname;
185 +}
186 +
187 +/*****************************************************************
188 +a useful function for returning a path in the Samba state directory
189 + *****************************************************************/
190 +char *state_path(char *name)
191 +{
192 +       static pstring fname;
193 +
194 +       pstrcpy(fname,dyn_STATEDIR());
195 +       trim_string(fname,"","/");
196 +
197 +       if (!directory_exist(fname,NULL)) {
198 +               mkdir(fname,0755);
199 +       }
200 +
201 +       pstrcat(fname,"/");
202 +       pstrcat(fname,name);
203 +
204 +       return fname;
205 +}
206 +
207 +/*****************************************************************
208 +a useful function for returning a path in the Samba cache directory
209 + *****************************************************************/
210 +char *cache_path(char *name)
211 +{
212 +       static pstring fname;
213 +
214 +       pstrcpy(fname,dyn_CACHEDIR());
215 +       trim_string(fname,"","/");
216 +
217 +       if (!directory_exist(fname,NULL)) {
218 +                       mkdir(fname,0755);
219 +       }
220 +
221 +       pstrcat(fname,"/");
222 +       pstrcat(fname,name);
223 +
224 +       return fname;
225 +}
226 +
227 +/**
228   * @brief Returns the platform specific shared library extension.
229   *
230   * @retval Pointer to a static #fstring containing the extension.
231 diff -uNr samba-3.0.10.orig/source/lib/util_unistr.c samba-3.0.10/source/lib/util_unistr.c
232 --- samba-3.0.10.orig/source/lib/util_unistr.c  2004-12-17 03:50:08.000000000 -0800
233 +++ samba-3.0.10/source/lib/util_unistr.c       2004-12-17 03:55:29.000000000 -0800
234 @@ -54,8 +54,8 @@
235         if (initialised) return;
236         initialised = 1;
237  
238 -       upcase_table = map_file(lib_path("upcase.dat"), 0x20000);
239 -       lowcase_table = map_file(lib_path("lowcase.dat"), 0x20000);
240 +       upcase_table = map_file(data_path("upcase.dat"), 0x20000);
241 +       lowcase_table = map_file(data_path("lowcase.dat"), 0x20000);
242  
243         /* we would like Samba to limp along even if these tables are
244            not available */
245 @@ -161,7 +161,7 @@
246                 return;
247         }
248  
249 -       valid_file = map_file(lib_path("valid.dat"), 0x10000);
250 +       valid_file = map_file(data_path("valid.dat"), 0x10000);
251         if (valid_file) {
252                 valid_table = valid_file;
253                 mapped_file = 1;
254 diff -uNr samba-3.0.10.orig/source/libsmb/samlogon_cache.c samba-3.0.10/source/libsmb/samlogon_cache.c
255 --- samba-3.0.10.orig/source/libsmb/samlogon_cache.c    2004-12-17 03:50:08.000000000 -0800
256 +++ samba-3.0.10/source/libsmb/samlogon_cache.c 2004-12-17 03:55:29.000000000 -0800
257 @@ -34,7 +34,7 @@
258  BOOL netsamlogon_cache_init(void)
259  {
260         if (!netsamlogon_tdb) {
261 -               netsamlogon_tdb = tdb_open_log(lock_path(NETSAMLOGON_TDB), 0,
262 +               netsamlogon_tdb = tdb_open_log(cache_path(NETSAMLOGON_TDB), 0,
263                                                    TDB_DEFAULT, O_RDWR | O_CREAT, 0600);
264         }
265  
266 @@ -67,7 +67,7 @@
267             winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
268  
269         if (!tdb) {
270 -               tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000,
271 +               tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000,
272                                    TDB_DEFAULT, O_RDWR, 0600);
273                 if (!tdb) {
274                         DEBUG(5, ("netsamlogon_clear_cached_user: failed to open cache\n"));
275 diff -uNr samba-3.0.10.orig/source/nmbd/nmbd_serverlistdb.c samba-3.0.10/source/nmbd/nmbd_serverlistdb.c
276 --- samba-3.0.10.orig/source/nmbd/nmbd_serverlistdb.c   2004-12-17 03:50:09.000000000 -0800
277 +++ samba-3.0.10/source/nmbd/nmbd_serverlistdb.c        2004-12-17 03:55:29.000000000 -0800
278 @@ -327,7 +327,7 @@
279  
280         updatecount++;
281      
282 -       pstrcpy(fname,lp_lockdir());
283 +       pstrcpy(fname,dyn_CACHEDIR());
284         trim_char(fname,'\0' ,'/');
285         pstrcat(fname,"/");
286         pstrcat(fname,SERVER_LIST);
287 diff -uNr samba-3.0.10.orig/source/nmbd/nmbd_winsserver.c samba-3.0.10/source/nmbd/nmbd_winsserver.c
288 --- samba-3.0.10.orig/source/nmbd/nmbd_winsserver.c     2004-12-17 03:50:09.000000000 -0800
289 +++ samba-3.0.10/source/nmbd/nmbd_winsserver.c  2004-12-17 03:55:30.000000000 -0800
290 @@ -234,7 +234,7 @@
291  
292         add_samba_names_to_subnet(wins_server_subnet);
293  
294 -       if((fp = x_fopen(lock_path(WINS_LIST),O_RDONLY,0)) == NULL) {
295 +       if((fp = x_fopen(state_path(WINS_LIST),O_RDONLY,0)) == NULL) {
296                 DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
297                         WINS_LIST, strerror(errno) ));
298                 return True;
299 @@ -1810,7 +1810,7 @@
300                 }
301         }
302  
303 -       slprintf(fname,sizeof(fname)-1,"%s/%s", lp_lockdir(), WINS_LIST);
304 +       slprintf(fname,sizeof(fname)-1,"%s/%s", dyn_STATEDIR(), WINS_LIST);
305         all_string_sub(fname,"//", "/", 0);
306         slprintf(fnamenew,sizeof(fnamenew)-1,"%s.%u", fname, (unsigned int)sys_getpid());
307  
308 diff -uNr samba-3.0.20b.orig/source/passdb/login_cache.c samba-3.0.20b/source/passdb/login_cache.c
309 --- samba-3.0.20b.orig/source/passdb/login_cache.c
310 +++ samba-3.0.20b/source/passdb/login_cache.c
311 @@ -36,7 +36,7 @@
312         /* skip file open if it's already opened */
313         if (cache) return True;
314  
315 -       asprintf(&cache_fname, "%s/%s", lp_lockdir(), LOGIN_CACHE_FILE);
316 +       asprintf(&cache_fname, "%s/%s", dyn_CACHEDIR(), LOGIN_CACHE_FILE);
317         if (cache_fname)
318                 DEBUG(5, ("Opening cache file at %s\n", cache_fname));
319         else {
320 diff -uNr samba-3.0.20b.orig/source/nsswitch/winbindd_cache.c samba-3.0.20b/source/nsswitch/winbindd_cache.c
321 --- samba-3.0.20b.orig/source/nsswitch/winbindd_cache.c
322 +++ samba-3.0.20b/source/nsswitch/winbindd_cache.c
323 @@ -57,7 +57,7 @@
324         if (opt_nocache)
325                 return;
326  
327 -       wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000, 
328 +       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000, 
329                                    TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
330  
331         if (!wcache->tdb) {
332 @@ -1471,7 +1471,7 @@
333         if (wcache->tdb != NULL)
334                 return True;
335  
336 -       wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000, 
337 +       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000, 
338                                    TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
339  
340         if (wcache->tdb == NULL) {
341 diff -uNr samba-3.0.10.orig/source/nsswitch/winbindd_util.c samba-3.0.10/source/nsswitch/winbindd_util.c
342 --- samba-3.0.10.orig/source/nsswitch/winbindd_util.c   2004-12-17 03:50:09.000000000 -0800
343 +++ samba-3.0.10/source/nsswitch/winbindd_util.c        2004-12-17 03:55:30.000000000 -0800
344 @@ -957,7 +957,7 @@
345         SMB_STRUCT_STAT stbuf;
346         TDB_CONTEXT *idmap_tdb;
347  
348 -       pstrcpy(idmap_name, lock_path("winbindd_idmap.tdb"));
349 +       pstrcpy(idmap_name, state_path("winbindd_idmap.tdb"));
350  
351         if (!file_exist(idmap_name, &stbuf)) {
352                 /* nothing to convert return */
353 diff -uNr samba-3.0.10.orig/source/param/loadparm.c samba-3.0.10/source/param/loadparm.c
354 --- samba-3.0.10.orig/source/param/loadparm.c   2004-12-17 03:50:09.000000000 -0800
355 +++ samba-3.0.10/source/param/loadparm.c        2004-12-17 03:55:30.000000000 -0800
356 @@ -104,6 +104,9 @@
357         char *szAddPrinterCommand;
358         char *szDeletePrinterCommand;
359         char *szOs2DriverMap;
360 +#ifdef FHS_COMPATIBLE
361 +       char *szLockDirStub;
362 +#endif
363         char *szLockDir;
364         char *szPidDir;
365         char *szRootdir;
366 @@ -1105,8 +1108,13 @@
367         {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE}, 
368         {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
369         {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
370 +#ifdef FHS_COMPATIBLE
371 +       {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0}, 
372 +       {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0},
373 +#else
374         {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED}, 
375         {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE}, 
376 +#endif
377         {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED}, 
378  #ifdef WITH_UTMP
379         {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED}, 
380 diff -uNr samba-3.0.10.orig/source/passdb/pdb_tdb.c samba-3.0.10/source/passdb/pdb_tdb.c
381 --- samba-3.0.10.orig/source/passdb/pdb_tdb.c   2004-12-17 03:50:09.000000000 -0800
382 +++ samba-3.0.10/source/passdb/pdb_tdb.c        2004-12-17 03:55:30.000000000 -0800
383 @@ -734,10 +734,7 @@
384         if (location) {
385                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, location);
386         } else {
387 -               pstring tdbfile;
388 -               get_private_directory(tdbfile);
389 -               pstrcat(tdbfile, "/");
390 -               pstrcat(tdbfile, PASSDB_FILE_NAME);
391 +               char *tdbfile = state_path(PASSDB_FILE_NAME);
392                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, tdbfile);
393         }
394  
395 diff -uNr samba-3.0.10.orig/source/passdb/secrets.c samba-3.0.10/source/passdb/secrets.c
396 --- samba-3.0.10.orig/source/passdb/secrets.c   2004-12-17 03:50:09.000000000 -0800
397 +++ samba-3.0.10/source/passdb/secrets.c        2004-12-17 03:55:30.000000000 -0800
398 @@ -55,8 +55,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.10.orig/source/printing/nt_printing.c samba-3.0.10/source/printing/nt_printing.c
409 --- samba-3.0.10.orig/source/printing/nt_printing.c     2004-12-17 03:50:09.000000000 -0800
410 +++ samba-3.0.10/source/printing/nt_printing.c  2004-12-17 03:55:31.000000000 -0800
411 @@ -298,28 +298,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.10.orig/source/printing/printing.c samba-3.0.10/source/printing/printing.c
447 --- samba-3.0.10.orig/source/printing/printing.c        2004-12-17 03:50:09.000000000 -0800
448 +++ samba-3.0.10/source/printing/printing.c     2004-12-17 03:55:31.000000000 -0800
449 @@ -177,8 +177,8 @@
450         int services = lp_numservices();
451         int snum;
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         /* handle a Samba upgrade */
460 diff -uNr samba-3.0.10.orig/source/printing/printing_db.c samba-3.0.10/source/printing/printing_db.c
461 --- samba-3.0.10.orig/source/printing/printing_db.c     2004-12-17 03:50:09.000000000 -0800
462 +++ samba-3.0.10/source/printing/printing_db.c  2004-12-17 03:55:31.000000000 -0800
463 @@ -89,7 +89,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.10.orig/source/registry/reg_db.c samba-3.0.10/source/registry/reg_db.c
473 --- samba-3.0.10.orig/source/registry/reg_db.c  2004-12-17 03:50:09.000000000 -0800
474 +++ samba-3.0.10/source/registry/reg_db.c       2004-12-17 03:55:31.000000000 -0800
475 @@ -198,12 +198,12 @@
476         if ( tdb_reg )
477                 return True;
478
479 -       if ( !(tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
480 +       if ( !(tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
481         {
482 -               tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
483 +               tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
484                 if ( !tdb_reg ) {
485                         DEBUG(0,("init_registry: Failed to open registry %s (%s)\n",
486 -                               lock_path("registry.tdb"), strerror(errno) ));
487 +                               state_path("registry.tdb"), strerror(errno) ));
488                         return False;
489                 }
490
491 diff -uNr samba-3.0.10.orig/source/rpc_server/srv_srvsvc_nt.c samba-3.0.10/source/rpc_server/srv_srvsvc_nt.c
492 --- samba-3.0.10.orig/source/rpc_server/srv_srvsvc_nt.c 2004-12-17 03:50:09.000000000 -0800
493 +++ samba-3.0.10/source/rpc_server/srv_srvsvc_nt.c      2004-12-17 03:55:31.000000000 -0800
494 @@ -133,10 +133,10 @@
495   
496         if (share_tdb && local_pid == sys_getpid())
497                 return True;
498 -       share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
499 +       share_tdb = tdb_open_log(state_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
500         if (!share_tdb) {
501                 DEBUG(0,("Failed to open share info database %s (%s)\n",
502 -                       lock_path("share_info.tdb"), strerror(errno) ));
503 +                       state_path("share_info.tdb"), strerror(errno) ));
504                 return False;
505         }
506   
507 diff -uNr samba-3.0.10.orig/source/sam/idmap_tdb.c samba-3.0.10/source/sam/idmap_tdb.c
508 --- samba-3.0.10.orig/source/sam/idmap_tdb.c    2004-12-17 03:50:09.000000000 -0800
509 +++ samba-3.0.10/source/sam/idmap_tdb.c 2004-12-17 03:55:31.000000000 -0800
510 @@ -487,7 +487,7 @@
511         BOOL tdb_is_new = False;
512  
513         /* use the old database if present */
514 -       tdbfile = SMB_STRDUP(lock_path("winbindd_idmap.tdb"));
515 +       tdbfile = SMB_STRDUP(state_path("winbindd_idmap.tdb"));
516         if (!tdbfile) {
517                 DEBUG(0, ("idmap_init: out of memory!\n"));
518                 return NT_STATUS_NO_MEMORY;
519 diff -uNr samba-3.0.10.orig/source/smbd/lanman.c samba-3.0.10/source/smbd/lanman.c
520 --- samba-3.0.10.orig/source/smbd/lanman.c      2004-12-17 03:50:10.000000000 -0800
521 +++ samba-3.0.10/source/smbd/lanman.c   2004-12-17 03:55:31.000000000 -0800
522 @@ -969,9 +969,9 @@
523    BOOL local_list_only;
524    int i;
525  
526 -  lines = file_lines_load(lock_path(SERVER_LIST), NULL);
527 +  lines = file_lines_load(cache_path(SERVER_LIST), NULL);
528    if (!lines) {
529 -    DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno)));
530 +    DEBUG(4,("Can't open %s - %s\n",cache_path(SERVER_LIST),strerror(errno)));
531      return(0);
532    }
533  
534 diff -uNr samba-3.0.10.orig/source/utils/net_idmap.c samba-3.0.10/source/utils/net_idmap.c
535 --- samba-3.0.10.orig/source/utils/net_idmap.c  2004-12-17 03:50:10.000000000 -0800
536 +++ samba-3.0.10/source/utils/net_idmap.c       2004-12-17 03:55:32.000000000 -0800
537 @@ -126,7 +126,7 @@
538                 return NT_STATUS_UNSUCCESSFUL;
539         }
540  
541 -       tdbfile = SMB_STRDUP(lock_path("winbindd_idmap.tdb"));
542 +       tdbfile = SMB_STRDUP(state_path("winbindd_idmap.tdb"));
543         if (!tdbfile) {
544                 DEBUG(0, ("idmap_init: out of memory!\n"));
545                 return NT_STATUS_NO_MEMORY;
546 diff -uNr samba-3.0.10.orig/source/wrepld/process.c samba-3.0.10/source/wrepld/process.c
547 --- samba-3.0.10.orig/source/wrepld/process.c   2004-12-17 03:50:10.000000000 -0800
548 +++ samba-3.0.10/source/wrepld/process.c        2004-12-17 03:55:32.000000000 -0800
549 @@ -197,7 +197,7 @@
550  {
551         TDB_CONTEXT *tdb;
552  
553 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
554 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
555         if (!tdb) {
556                 DEBUG(2,("get_our_last_id: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
557                 return;
558 @@ -489,7 +489,7 @@
559                 }
560  
561  
562 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
563 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
564         if (!tdb) {
565                 DEBUG(2,("send_entry_request: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
566                 return;
567 diff -uNr samba-3.0.11.orig/source/printing/nt_printing.c samba-3.0.11/source/printing/nt_printing.c
568 --- samba-3.0.11.orig/source/printing/nt_printing.c     2005-03-23 02:51:08.000000000 -0800
569 +++ samba-3.0.11/source/printing/nt_printing.c  2005-03-23 02:54:33.000000000 -0800
570 @@ -2065,7 +2065,7 @@
571         close_all_print_db();
572  
573         if (geteuid() == 0) {
574 -               pstrcpy(printdb_path, lock_path("printing/"));
575 +               pstrcpy(printdb_path, cache_path("printing/"));
576                 pstrcat(printdb_path, sharename);
577                 pstrcat(printdb_path, ".tdb");
578