Initial import
[samba] / debian / patches / fhs.patch
1 Index: samba-3.0.21c/source/Makefile.in
2 ===================================================================
3 --- samba-3.0.21c.orig/source/Makefile.in       2006-02-25 11:57:11.584360975 +0100
4 +++ samba-3.0.21c/source/Makefile.in    2006-02-25 11:58:15.760412374 +0100
5 @@ -91,6 +91,13 @@
6  # the directory where lock files go
7  LOCKDIR = @lockdir@
8  
9 +# FHS directories; equal to LOCKDIR if not using --with-fhs
10 +CACHEDIR = @cachedir@
11 +STATEDIR = @statedir@
12 +
13 +# Where to look for (and install) codepage databases.
14 +CODEPAGEDIR = @codepagedir@
15 +
16  # the directory where pid files go
17  PIDDIR = @piddir@
18  
19 @@ -120,7 +127,7 @@
20  PATH_FLAGS4 = $(PATH_FLAGS3) -DSWATDIR=\"$(SWATDIR)\"  -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\"
21  PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\"$(LIBDIR)\" \
22               -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\"
23 -PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\"
24 +PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\" -DCACHEDIR=\"$(CACHEDIR)\" -DSTATEDIR=\"$(STATEDIR)\"
25  PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
26  
27  # Note that all executable programs now provide for an optional executable suffix.
28 @@ -1432,7 +1439,7 @@
29         @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS)
30  
31  installdat: installdirs
32 -       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(LIBDIR) $(srcdir)
33 +       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(CODEPAGEDIR) $(srcdir)
34  
35  installmsg: installdirs
36         @$(SHELL) $(srcdir)/script/installmsg.sh $(DESTDIR)$(LIBDIR) $(srcdir)
37 Index: samba-3.0.21c/source/configure.in
38 ===================================================================
39 --- samba-3.0.21c.orig/source/configure.in      2006-02-25 11:57:11.585360773 +0100
40 +++ samba-3.0.21c/source/configure.in   2006-02-25 11:58:15.771410155 +0100
41 @@ -35,7 +35,7 @@
42  [  --with-fhs              Use FHS-compliant paths (default=no)],
43  [ case "$withval" in
44    yes)
45 -    lockdir="\${VARDIR}/lib/samba"
46 +    lockdir="\${VARDIR}/run/samba"
47      piddir="\${VARDIR}/run"
48      mandir="\${prefix}/share/man"
49      logfilebase="\${VARDIR}/log/samba"
50 @@ -43,6 +43,10 @@
51      libdir="\${prefix}/lib/samba"
52      configdir="${sysconfdir}/samba"
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 @@ -201,6 +205,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 Index: samba-3.0.21c/source/dynconfig.c
72 ===================================================================
73 --- samba-3.0.21c.orig/source/dynconfig.c       2006-02-25 11:57:11.586360572 +0100
74 +++ samba-3.0.21c/source/dynconfig.c    2006-02-25 11:58:15.772409953 +0100
75 @@ -53,6 +53,13 @@
76  pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
77  
78  /**
79 + * @brief Samba data directory.
80 + *
81 + * @sa data_path() to get the path to a file inside the CODEPAGEDIR.
82 + **/
83 +pstring dyn_CODEPAGEDIR = CODEPAGEDIR;
84 +
85 +/**
86   * @brief Samba library directory.
87   *
88   * @sa lib_path() to get the path to a file inside the LIBDIR.
89 @@ -70,3 +77,27 @@
90  
91  const pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
92  const pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
93 +
94 +
95 +/* In non-FHS mode, these should be configurable using 'lock dir =';
96 +   but in FHS mode, they are their own directory.  Implement as wrapper
97 +   functions so that everything can still be kept in dynconfig.c.
98 + */
99 +
100 +char *dyn_STATEDIR(void)
101 +{
102 +#ifdef FHS_COMPATIBLE
103 +       return STATEDIR;
104 +#else
105 +       return lp_lockdir();
106 +#endif
107 +}
108 +
109 +char *dyn_CACHEDIR(void)
110 +{
111 +#ifdef FHS_COMPATIBLE
112 +       return CACHEDIR;
113 +#else
114 +       return lp_lockdir();
115 +#endif
116 +}
117 Index: samba-3.0.21c/source/groupdb/mapping.c
118 ===================================================================
119 --- samba-3.0.21c.orig/source/groupdb/mapping.c 2006-02-25 11:57:11.587360370 +0100
120 +++ samba-3.0.21c/source/groupdb/mapping.c      2006-02-25 11:58:15.776409146 +0100
121 @@ -129,7 +129,7 @@
122         
123         if (tdb)
124                 return True;
125 -       tdb = tdb_open_log(lock_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
126 +       tdb = tdb_open_log(state_path("group_mapping.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
127         if (!tdb) {
128                 DEBUG(0,("Failed to open group mapping database\n"));
129                 return False;
130 Index: samba-3.0.21c/source/include/dynconfig.h
131 ===================================================================
132 --- samba-3.0.21c.orig/source/include/dynconfig.h       2006-02-25 11:57:11.588360168 +0100
133 +++ samba-3.0.21c/source/include/dynconfig.h    2006-02-25 11:58:15.777408944 +0100
134 @@ -31,8 +31,12 @@
135  extern pstring dyn_CONFIGFILE;
136  extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
137  extern pstring dyn_LIBDIR;
138 +extern pstring dyn_CODEPAGEDIR;
139  extern const fstring dyn_SHLIBEXT;
140  extern const pstring dyn_LOCKDIR; 
141  extern const pstring dyn_PIDDIR;
142  extern const pstring dyn_SMB_PASSWD_FILE;
143  extern const pstring dyn_PRIVATE_DIR;
144 +
145 +char *dyn_STATEDIR(void);
146 +char *dyn_CACHEDIR(void);
147 Index: samba-3.0.21c/source/intl/lang_tdb.c
148 ===================================================================
149 --- samba-3.0.21c.orig/source/intl/lang_tdb.c   2006-02-25 11:57:11.589359967 +0100
150 +++ samba-3.0.21c/source/intl/lang_tdb.c        2006-02-25 11:58:15.779408541 +0100
151 @@ -128,7 +128,7 @@
152         if (!lang) 
153                 return True;
154  
155 -       asprintf(&msg_path, "%s.msg", lib_path((const char *)lang));
156 +       asprintf(&msg_path, "%s.msg", data_path((const char *)lang));
157         if (stat(msg_path, &st) != 0) {
158                 /* the msg file isn't available */
159                 DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path, 
160 Index: samba-3.0.21c/source/lib/util.c
161 ===================================================================
162 --- samba-3.0.21c.orig/source/lib/util.c        2006-02-25 11:57:11.590359765 +0100
163 +++ samba-3.0.21c/source/lib/util.c     2006-02-25 11:58:15.784407532 +0100
164 @@ -2410,6 +2410,61 @@
165  }
166  
167  /**
168 + * @brief Returns an absolute path to a file in the Samba data directory.
169 + *
170 + * @param name File to find, relative to CODEPAGEDIR.
171 + *
172 + * @retval Pointer to a static #pstring containing the full path.
173 + **/
174 +
175 +char *data_path(const char *name)
176 +{
177 +       static pstring fname;
178 +       snprintf(fname, sizeof(fname), "%s/%s", dyn_CODEPAGEDIR, name);
179 +       return fname;
180 +}
181 +
182 +/*****************************************************************
183 +a useful function for returning a path in the Samba state directory
184 + *****************************************************************/
185 +char *state_path(char *name)
186 +{
187 +       static pstring fname;
188 +
189 +       pstrcpy(fname,dyn_STATEDIR());
190 +       trim_string(fname,"","/");
191 +
192 +       if (!directory_exist(fname,NULL)) {
193 +               mkdir(fname,0755);
194 +       }
195 +
196 +       pstrcat(fname,"/");
197 +       pstrcat(fname,name);
198 +
199 +       return fname;
200 +}
201 +
202 +/*****************************************************************
203 +a useful function for returning a path in the Samba cache directory
204 + *****************************************************************/
205 +char *cache_path(char *name)
206 +{
207 +       static pstring fname;
208 +
209 +       pstrcpy(fname,dyn_CACHEDIR());
210 +       trim_string(fname,"","/");
211 +
212 +       if (!directory_exist(fname,NULL)) {
213 +                       mkdir(fname,0755);
214 +       }
215 +
216 +       pstrcat(fname,"/");
217 +       pstrcat(fname,name);
218 +
219 +       return fname;
220 +}
221 +
222 +/**
223   * @brief Returns the platform specific shared library extension.
224   *
225   * @retval Pointer to a static #fstring containing the extension.
226 Index: samba-3.0.21c/source/lib/util_unistr.c
227 ===================================================================
228 --- samba-3.0.21c.orig/source/lib/util_unistr.c 2006-02-25 11:57:11.591359563 +0100
229 +++ samba-3.0.21c/source/lib/util_unistr.c      2006-02-25 11:58:15.787406927 +0100
230 @@ -58,8 +58,8 @@
231         }
232         initialised = 1;
233  
234 -       upcase_table = map_file(lib_path("upcase.dat"), 0x20000);
235 -       lowcase_table = map_file(lib_path("lowcase.dat"), 0x20000);
236 +       upcase_table = map_file(data_path("upcase.dat"), 0x20000);
237 +       lowcase_table = map_file(data_path("lowcase.dat"), 0x20000);
238  
239         /* we would like Samba to limp along even if these tables are
240            not available */
241 @@ -174,7 +174,7 @@
242                 return;
243         }
244  
245 -       valid_file = map_file(lib_path("valid.dat"), 0x10000);
246 +       valid_file = map_file(data_path("valid.dat"), 0x10000);
247         if (valid_file) {
248                 valid_table = valid_file;
249                 mapped_file = 1;
250 Index: samba-3.0.21c/source/libsmb/samlogon_cache.c
251 ===================================================================
252 --- samba-3.0.21c.orig/source/libsmb/samlogon_cache.c   2006-02-25 11:57:11.593359160 +0100
253 +++ samba-3.0.21c/source/libsmb/samlogon_cache.c        2006-02-25 11:58:15.788406725 +0100
254 @@ -34,7 +34,7 @@
255  BOOL netsamlogon_cache_init(void)
256  {
257         if (!netsamlogon_tdb) {
258 -               netsamlogon_tdb = tdb_open_log(lock_path(NETSAMLOGON_TDB), 0,
259 +               netsamlogon_tdb = tdb_open_log(cache_path(NETSAMLOGON_TDB), 0,
260                                                    TDB_DEFAULT, O_RDWR | O_CREAT, 0600);
261         }
262  
263 @@ -67,7 +67,7 @@
264             winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
265  
266         if (!tdb) {
267 -               tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000,
268 +               tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000,
269                                    TDB_DEFAULT, O_RDWR, 0600);
270                 if (!tdb) {
271                         DEBUG(5, ("netsamlogon_clear_cached_user: failed to open cache\n"));
272 Index: samba-3.0.21c/source/nmbd/nmbd_serverlistdb.c
273 ===================================================================
274 --- samba-3.0.21c.orig/source/nmbd/nmbd_serverlistdb.c  2006-02-25 11:57:11.594358958 +0100
275 +++ samba-3.0.21c/source/nmbd/nmbd_serverlistdb.c       2006-02-25 11:58:15.790406322 +0100
276 @@ -327,7 +327,7 @@
277  
278         updatecount++;
279      
280 -       pstrcpy(fname,lp_lockdir());
281 +       pstrcpy(fname,dyn_CACHEDIR());
282         trim_char(fname,'\0' ,'/');
283         pstrcat(fname,"/");
284         pstrcat(fname,SERVER_LIST);
285 Index: samba-3.0.21c/source/nmbd/nmbd_winsserver.c
286 ===================================================================
287 --- samba-3.0.21c.orig/source/nmbd/nmbd_winsserver.c    2006-02-25 11:57:11.603357143 +0100
288 +++ samba-3.0.21c/source/nmbd/nmbd_winsserver.c 2006-02-25 11:58:15.795405313 +0100
289 @@ -244,7 +244,7 @@
290  
291         add_samba_names_to_subnet(wins_server_subnet);
292  
293 -       if((fp = x_fopen(lock_path(WINS_LIST),O_RDONLY,0)) == NULL) {
294 +       if((fp = x_fopen(state_path(WINS_LIST),O_RDONLY,0)) == NULL) {
295                 DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
296                         WINS_LIST, strerror(errno) ));
297                 return True;
298 @@ -1838,7 +1838,7 @@
299                 }
300         }
301  
302 -       slprintf(fname,sizeof(fname)-1,"%s/%s", lp_lockdir(), WINS_LIST);
303 +       slprintf(fname,sizeof(fname)-1,"%s/%s", dyn_STATEDIR(), WINS_LIST);
304         all_string_sub(fname,"//", "/", 0);
305         slprintf(fnamenew,sizeof(fnamenew)-1,"%s.%u", fname, (unsigned int)sys_getpid());
306  
307 Index: samba-3.0.21c/source/passdb/login_cache.c
308 ===================================================================
309 --- samba-3.0.21c.orig/source/passdb/login_cache.c      2006-02-25 11:57:11.604356941 +0100
310 +++ samba-3.0.21c/source/passdb/login_cache.c   2006-02-25 11:58:15.797404910 +0100
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 Index: samba-3.0.21c/source/nsswitch/winbindd_cache.c
321 ===================================================================
322 --- samba-3.0.21c.orig/source/nsswitch/winbindd_cache.c 2006-02-25 11:57:11.606356537 +0100
323 +++ samba-3.0.21c/source/nsswitch/winbindd_cache.c      2006-02-25 11:58:15.800404304 +0100
324 @@ -58,7 +58,7 @@
325         if (opt_nocache)
326                 return;
327  
328 -       wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000, 
329 +       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000, 
330                                    TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
331  
332         if (!wcache->tdb) {
333 @@ -1472,7 +1472,7 @@
334         if (wcache->tdb != NULL)
335                 return True;
336  
337 -       wcache->tdb = tdb_open_log(lock_path("winbindd_cache.tdb"), 5000, 
338 +       wcache->tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 5000, 
339                                    TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT, 0600);
340  
341         if (wcache->tdb == NULL) {
342 Index: samba-3.0.21c/source/nsswitch/winbindd_util.c
343 ===================================================================
344 --- samba-3.0.21c.orig/source/nsswitch/winbindd_util.c  2006-02-25 11:57:11.607356336 +0100
345 +++ samba-3.0.21c/source/nsswitch/winbindd_util.c       2006-02-25 11:58:15.803403699 +0100
346 @@ -1172,7 +1172,7 @@
347         SMB_STRUCT_STAT stbuf;
348         TDB_CONTEXT *idmap_tdb;
349  
350 -       pstrcpy(idmap_name, lock_path("winbindd_idmap.tdb"));
351 +       pstrcpy(idmap_name, state_path("winbindd_idmap.tdb"));
352  
353         if (!file_exist(idmap_name, &stbuf)) {
354                 /* nothing to convert return */
355 Index: samba-3.0.21c/source/param/loadparm.c
356 ===================================================================
357 --- samba-3.0.21c.orig/source/param/loadparm.c  2006-02-25 11:57:11.608356134 +0100
358 +++ samba-3.0.21c/source/param/loadparm.c       2006-02-25 11:58:15.994365168 +0100
359 @@ -105,6 +105,9 @@
360         char *szAddPrinterCommand;
361         char *szDeletePrinterCommand;
362         char *szOs2DriverMap;
363 +#ifdef FHS_COMPATIBLE
364 +       char *szLockDirStub;
365 +#endif
366         char *szLockDir;
367         char *szPidDir;
368         char *szRootdir;
369 @@ -1174,8 +1177,13 @@
370         {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE}, 
371         {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
372         {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_ADVANCED}, 
373 +#ifdef FHS_COMPATIBLE
374 +       {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0}, 
375 +       {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDirStub, NULL, NULL, 0},
376 +#else
377         {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_ADVANCED}, 
378         {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, FLAG_HIDE}, 
379 +#endif
380         {"pid directory", P_STRING, P_GLOBAL, &Globals.szPidDir, NULL, NULL, FLAG_ADVANCED}, 
381  #ifdef WITH_UTMP
382         {"utmp directory", P_STRING, P_GLOBAL, &Globals.szUtmpDir, NULL, NULL, FLAG_ADVANCED}, 
383 Index: samba-3.0.21c/source/passdb/pdb_tdb.c
384 ===================================================================
385 --- samba-3.0.21c.orig/source/passdb/pdb_tdb.c  2006-02-25 11:57:11.605356739 +0100
386 +++ samba-3.0.21c/source/passdb/pdb_tdb.c       2006-02-25 11:58:15.997364563 +0100
387 @@ -918,10 +918,7 @@
388         if (location) {
389                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, location);
390         } else {
391 -               pstring tdbfile;
392 -               get_private_directory(tdbfile);
393 -               pstrcat(tdbfile, "/");
394 -               pstrcat(tdbfile, PASSDB_FILE_NAME);
395 +               char *tdbfile = state_path(PASSDB_FILE_NAME);
396                 tdb_state->tdbsam_location = talloc_strdup(pdb_context->mem_ctx, tdbfile);
397         }
398  
399 Index: samba-3.0.21c/source/passdb/secrets.c
400 ===================================================================
401 --- samba-3.0.21c.orig/source/passdb/secrets.c  2006-02-25 11:57:11.605356739 +0100
402 +++ samba-3.0.21c/source/passdb/secrets.c       2006-02-25 11:58:15.999364159 +0100
403 @@ -58,8 +58,7 @@
404         if (tdb)
405                 return True;
406  
407 -       pstrcpy(fname, lp_private_dir());
408 -       pstrcat(fname,"/secrets.tdb");
409 +       pstrcpy(fname, state_path("secrets.tdb"));
410  
411         tdb = tdb_open_log(fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
412  
413 Index: samba-3.0.21c/source/printing/nt_printing.c
414 ===================================================================
415 --- samba-3.0.21c.orig/source/printing/nt_printing.c    2006-02-25 11:57:11.609355932 +0100
416 +++ samba-3.0.21c/source/printing/nt_printing.c 2006-02-25 11:58:16.008362344 +0100
417 @@ -530,28 +530,28 @@
418   
419         if (tdb_drivers)
420                 tdb_close(tdb_drivers);
421 -       tdb_drivers = tdb_open_log(lock_path("ntdrivers.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
422 +       tdb_drivers = tdb_open_log(state_path("ntdrivers.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
423         if (!tdb_drivers) {
424                 DEBUG(0,("nt_printing_init: Failed to open nt drivers database %s (%s)\n",
425 -                       lock_path("ntdrivers.tdb"), strerror(errno) ));
426 +                       state_path("ntdrivers.tdb"), strerror(errno) ));
427                 return False;
428         }
429   
430         if (tdb_printers)
431                 tdb_close(tdb_printers);
432 -       tdb_printers = tdb_open_log(lock_path("ntprinters.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
433 +       tdb_printers = tdb_open_log(state_path("ntprinters.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
434         if (!tdb_printers) {
435                 DEBUG(0,("nt_printing_init: Failed to open nt printers database %s (%s)\n",
436 -                       lock_path("ntprinters.tdb"), strerror(errno) ));
437 +                       state_path("ntprinters.tdb"), strerror(errno) ));
438                 return False;
439         }
440   
441         if (tdb_forms)
442                 tdb_close(tdb_forms);
443 -       tdb_forms = tdb_open_log(lock_path("ntforms.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
444 +       tdb_forms = tdb_open_log(state_path("ntforms.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
445         if (!tdb_forms) {
446                 DEBUG(0,("nt_printing_init: Failed to open nt forms database %s (%s)\n",
447 -                       lock_path("ntforms.tdb"), strerror(errno) ));
448 +                       state_path("ntforms.tdb"), strerror(errno) ));
449                 return False;
450         }
451   
452 @@ -2325,7 +2325,7 @@
453         close_all_print_db();
454  
455         if (geteuid() == 0) {
456 -               pstrcpy(printdb_path, lock_path("printing/"));
457 +               pstrcpy(printdb_path, cache_path("printing/"));
458                 pstrcat(printdb_path, sharename);
459                 pstrcat(printdb_path, ".tdb");
460  
461 Index: samba-3.0.21c/source/printing/printing.c
462 ===================================================================
463 --- samba-3.0.21c.orig/source/printing/printing.c       2006-02-25 11:57:11.627352301 +0100
464 +++ samba-3.0.21c/source/printing/printing.c    2006-02-25 11:58:16.013361335 +0100
465 @@ -183,8 +183,8 @@
466         int services = lp_numservices();
467         int snum;
468  
469 -       unlink(lock_path("printing.tdb"));
470 -       pstrcpy(printing_path,lock_path("printing"));
471 +       unlink(cache_path("printing.tdb"));
472 +       pstrcpy(printing_path,cache_path("printing"));
473         mkdir(printing_path,0755);
474  
475         /* handle a Samba upgrade */
476 Index: samba-3.0.21c/source/printing/printing_db.c
477 ===================================================================
478 --- samba-3.0.21c.orig/source/printing/printing_db.c    2006-02-25 11:57:11.628352100 +0100
479 +++ samba-3.0.21c/source/printing/printing_db.c 2006-02-25 11:58:16.015360931 +0100
480 @@ -89,7 +89,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 Index: samba-3.0.21c/source/rpc_server/srv_srvsvc_nt.c
490 ===================================================================
491 --- samba-3.0.21c.orig/source/rpc_server/srv_srvsvc_nt.c        2006-02-25 11:57:11.630351696 +0100
492 +++ samba-3.0.21c/source/rpc_server/srv_srvsvc_nt.c     2006-02-25 11:58:16.019360125 +0100
493 @@ -158,10 +158,10 @@
494   
495         if (share_tdb && local_pid == sys_getpid())
496                 return True;
497 -       share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
498 +       share_tdb = tdb_open_log(state_path("share_info.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
499         if (!share_tdb) {
500                 DEBUG(0,("Failed to open share info database %s (%s)\n",
501 -                       lock_path("share_info.tdb"), strerror(errno) ));
502 +                       state_path("share_info.tdb"), strerror(errno) ));
503                 return False;
504         }
505   
506 Index: samba-3.0.21c/source/sam/idmap_tdb.c
507 ===================================================================
508 --- samba-3.0.21c.orig/source/sam/idmap_tdb.c   2006-02-25 11:57:11.631351494 +0100
509 +++ samba-3.0.21c/source/sam/idmap_tdb.c        2006-02-25 11:58:16.022359519 +0100
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 Index: samba-3.0.21c/source/smbd/lanman.c
520 ===================================================================
521 --- samba-3.0.21c.orig/source/smbd/lanman.c     2006-02-25 11:57:11.633351091 +0100
522 +++ samba-3.0.21c/source/smbd/lanman.c  2006-02-25 11:58:16.028358309 +0100
523 @@ -1040,9 +1040,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 Index: samba-3.0.21c/source/utils/net_idmap.c
536 ===================================================================
537 --- samba-3.0.21c.orig/source/utils/net_idmap.c 2006-02-25 11:57:11.633351091 +0100
538 +++ samba-3.0.21c/source/utils/net_idmap.c      2006-02-25 11:58:16.071349634 +0100
539 @@ -136,7 +136,7 @@
540                 return NT_STATUS_UNSUCCESSFUL;
541         }
542  
543 -       tdbfile = SMB_STRDUP(lock_path("winbindd_idmap.tdb"));
544 +       tdbfile = SMB_STRDUP(state_path("winbindd_idmap.tdb"));
545         if (!tdbfile) {
546                 DEBUG(0, ("idmap_init: out of memory!\n"));
547                 return NT_STATUS_NO_MEMORY;
548 Index: samba-3.0.21c/source/wrepld/process.c
549 ===================================================================
550 --- samba-3.0.21c.orig/source/wrepld/process.c  2006-02-25 11:57:11.634350889 +0100
551 +++ samba-3.0.21c/source/wrepld/process.c       2006-02-25 11:58:16.073349231 +0100
552 @@ -197,7 +197,7 @@
553  {
554         TDB_CONTEXT *tdb;
555  
556 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
557 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
558         if (!tdb) {
559                 DEBUG(2,("get_our_last_id: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
560                 return;
561 @@ -489,7 +489,7 @@
562                 }
563  
564  
565 -       tdb = tdb_open_log(lock_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
566 +       tdb = tdb_open_log(state_path(WINS_LIST), 0, TDB_DEFAULT, O_RDONLY, 0600);
567         if (!tdb) {
568                 DEBUG(2,("send_entry_request: Can't open wins database file %s. Error was %s\n", WINS_LIST, strerror(errno) ));
569                 return;
570 Index: samba-3.0.21c/source/registry/reg_db.c
571 ===================================================================
572 --- samba-3.0.21c.orig/source/registry/reg_db.c 2006-02-25 11:57:11.635350688 +0100
573 +++ samba-3.0.21c/source/registry/reg_db.c      2006-02-25 11:58:16.076348626 +0100
574 @@ -205,12 +205,12 @@
575         if ( tdb_reg )
576                 return True;
577  
578 -       if ( !(tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
579 +       if ( !(tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
580         {
581 -               tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
582 +               tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
583                 if ( !tdb_reg ) {
584                         DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
585 -                               lock_path("registry.tdb"), strerror(errno) ));
586 +                               state_path("registry.tdb"), strerror(errno) ));
587                         return False;
588                 }
589                 
590 @@ -252,11 +252,11 @@
591         
592         become_root();
593  
594 -       tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
595 +       tdb_reg = tdb_open_log(state_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
596         if ( !tdb_reg ) {
597                 result = ntstatus_to_werror( map_nt_error_from_unix( errno ) );
598                 DEBUG(0,("regdb_open: Failed to open %s! (%s)\n", 
599 -                       lock_path("registry.tdb"), strerror(errno) ));
600 +                       state_path("registry.tdb"), strerror(errno) ));
601         }
602  
603         unbecome_root();
604 Index: samba-3.0.21c/source/lib/account_pol.c
605 ===================================================================
606 --- samba-3.0.21c.orig/source/lib/account_pol.c 2006-02-25 11:57:11.592359361 +0100
607 +++ samba-3.0.21c/source/lib/account_pol.c      2006-02-25 11:58:16.078348222 +0100
608 @@ -262,7 +262,7 @@
609                 return True;
610         }
611  
612 -       tdb = tdb_open_log(lock_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
613 +       tdb = tdb_open_log(state_path("account_policy.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
614         if (!tdb) {
615                 DEBUG(0,("Failed to open account policy database\n"));
616                 return False;
617 Index: samba-3.0.21c/source/registry/reg_perfcount.c
618 ===================================================================
619 --- samba-3.0.21c.orig/source/registry/reg_perfcount.c  2006-02-25 11:57:11.636350486 +0100
620 +++ samba-3.0.21c/source/registry/reg_perfcount.c       2006-02-25 11:58:16.081347617 +0100
621 @@ -44,7 +44,7 @@
622         
623         fstr_sprintf( path, "%s/%s", PERFCOUNTDIR, dbname );
624         
625 -       pstrcpy( fname, lock_path( path ) );
626 +       pstrcpy( fname, state_path( path ) );
627         
628         return fname;
629  }
630 @@ -54,7 +54,7 @@
631  
632  void perfcount_init_keys( void )
633  {
634 -       char *p = lock_path(PERFCOUNTDIR);
635 +       char *p = state_path(PERFCOUNTDIR);
636  
637         /* no registry keys; just create the perfmon directory */
638         
639 Index: samba-3.0.21c/source/rpc_server/srv_eventlog_lib.c
640 ===================================================================
641 --- samba-3.0.21c.orig/source/rpc_server/srv_eventlog_lib.c     2006-02-25 11:57:11.630351696 +0100
642 +++ samba-3.0.21c/source/rpc_server/srv_eventlog_lib.c  2006-02-25 11:58:16.083347214 +0100
643 @@ -67,7 +67,7 @@
644  {
645         fstring path;
646         char *tdb_fullpath;
647 -       char *eventlogdir = lock_path( "eventlog" );
648 +       char *eventlogdir = state_path( "eventlog" );
649         
650         pstr_sprintf( path, "%s/%s.tdb", eventlogdir, name );
651         strlower_m( path );
652 @@ -343,7 +343,7 @@
653         
654         /* make sure that the eventlog dir exists */
655         
656 -       eventlogdir = lock_path( "eventlog" );
657 +       eventlogdir = state_path( "eventlog" );
658         if ( !directory_exist( eventlogdir, NULL ) )
659                 mkdir( eventlogdir, 0755 );     
660