Patch from Debian Samba package maintainers:
authorGerald (Jerry) Carter <jerry@samba.org>
Thu, 1 Nov 2007 17:00:10 +0000 (13:00 -0400)
committerGerald (Jerry) Carter <jerry@samba.org>
Thu, 1 Nov 2007 17:00:10 +0000 (13:00 -0400)
Patch 1 of 3:

- Patch 1 adds the new variables
- Patch 2 makes uses of them for files belonging to the "state" path
  and the "code pages" path
  This patch seemed more easily acceptable, which explains why we
  separated it from patch 3
- Patch 3 reassigns files to the "cache" path. Indeed all "debatable"
  changes have been moved to that one

The point is adding:

- a path for non discardable state data: basically all TDB files
  that may need to be backed up
- a path for shared data: mostly codepage stuff
- a path for cache data to host files such as
  browse.dat, printers.tbd, <printer>.tdb

All these are currently mixed in "libdir" (${prefix}/lib/samba by default).
The patch keeps these new paths to point to ${prefix}/lib/samba by default
and does therefore not change the software behaviour.  Used alone, it just
adds unused variables...so it can safely be used in sources without any
behaviour change and no impact on Samba developers work.

source/Makefile.in
source/configure.in
source/dynconfig.c
source/include/dynconfig.h
source/lib/util.c

index a1da65a507c0e72593679e9d3ec3d7cdadc8dd99..baa18283d4d821d6479ef68454589be55cdf90c5 100644 (file)
@@ -127,6 +127,13 @@ SWATDIR = @swatdir@
 # the directory where lock files go
 LOCKDIR = @lockdir@
 
+# FHS directories; equal to LOCKDIR if not using --with-fhs
+CACHEDIR = @cachedir@
+STATEDIR = @statedir@
+
+# Where to look for (and install) codepage databases.
+CODEPAGEDIR = @codepagedir@
+
 # the directory where pid files go
 PIDDIR = @piddir@
 
@@ -154,7 +161,10 @@ PATH_FLAGS = -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\" \
        -DLOGFILEBASE=\"$(LOGFILEBASE)\" \
        -DSHLIBEXT=\"@SHLIBEXT@\" \
        -DCTDBDIR=\"$(CTDBDIR)\" \
-       -DCONFIGDIR=\"$(CONFIGDIR)\"
+       -DCONFIGDIR=\"$(CONFIGDIR)\" \
+       -DCODEPAGEDIR=\"$(CODEPAGEDIR)\" \
+       -DCACHEDIR=\"$(CACHEDIR)\" \
+       -DSTATEDIR=\"$(STATEDIR)\"
 
 # Note that all executable programs now provide for an optional executable suffix.
 
@@ -1761,10 +1771,10 @@ installscripts: installdirs
        @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS_BIN) $(DESTDIR)$(BINDIR) $(SCRIPTS)
 
 installdat: installdirs
-       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR) $(LIBDIR) $(srcdir)
+       @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR) $(CODEPAGEDIR) $(srcdir)
 
 installmsg: installdirs
-       @$(SHELL) $(srcdir)/script/installmsg.sh $(DESTDIR) $(LIBDIR) $(srcdir)
+       @$(SHELL) $(srcdir)/script/installmsg.sh $(DESTDIR) $(CODEPAGEDIR) $(srcdir)
 
 installswat: installdirs installmsg
        @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR) $(SWATDIR) $(srcdir)
index 9e1ebeffe7f07b31cd2df7d1227b26d0242674af..227ab4033db0ff169abdfa473aa61d181d878e6b 100644 (file)
@@ -65,6 +65,10 @@ AC_ARG_WITH(fhs,
     libdir="\${prefix}/lib/samba"
     configdir="\${sysconfdir}/samba"
     swatdir="\${DATADIR}/samba/swat"
+    codepagedir="\${prefix}/lib/samba"
+    statedir="\${VARDIR}/lib/samba"
+    cachedir="\${VARDIR}/lib/samba"
+    AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths])
     ;;
   esac])
 
@@ -284,6 +288,9 @@ AC_SUBST(privatedir)
 AC_SUBST(swatdir)
 AC_SUBST(bindir)
 AC_SUBST(sbindir)
+AC_SUBST(codepagedir)
+AC_SUBST(statedir)
+AC_SUBST(cachedir)
 AC_SUBST(rootsbindir)
 AC_SUBST(pammodulesdir)
 
index 6a40a07554bd941547cd802b4cfb71d7994e3129..01460b8363812106c745313b697bd75b23a56a6b 100644 (file)
@@ -51,6 +51,13 @@ pstring dyn_LOGFILEBASE = LOGFILEBASE;
 /** Statically configured LanMan hosts. **/
 pstring dyn_LMHOSTSFILE = LMHOSTSFILE;
 
+/**
+ * @brief Samba data directory.
+ *
+ * @sa data_path() to get the path to a file inside the CODEPAGEDIR.
+ **/
+pstring dyn_CODEPAGEDIR = CODEPAGEDIR;
+
 /**
  * @brief Samba library directory.
  *
@@ -69,3 +76,27 @@ pstring dyn_PIDDIR  = PIDDIR;
 
 pstring dyn_SMB_PASSWD_FILE = SMB_PASSWD_FILE;
 pstring dyn_PRIVATE_DIR = PRIVATE_DIR;
+
+
+/* In non-FHS mode, these should be configurable using 'lock dir =';
+   but in FHS mode, they are their own directory.  Implement as wrapper
+   functions so that everything can still be kept in dynconfig.c.
+ */
+
+char *dyn_STATEDIR(void)
+{
+#ifdef FHS_COMPATIBLE
+       return STATEDIR;
+#else
+       return lp_lockdir();
+#endif
+}
+
+char *dyn_CACHEDIR(void)
+{
+#ifdef FHS_COMPATIBLE
+       return CACHEDIR;
+#else
+       return lp_lockdir();
+#endif
+}
index 7091aa81b5694a84051b62d174c5834f380fa41b..996cf61492a2fa53f9963dfa7484c133673e5f3f 100644 (file)
@@ -30,8 +30,12 @@ extern char const *dyn_SBINDIR,
 extern pstring dyn_CONFIGFILE;
 extern pstring dyn_LOGFILEBASE, dyn_LMHOSTSFILE;
 extern pstring dyn_LIBDIR;
+extern pstring dyn_CODEPAGEDIR;
 extern fstring dyn_SHLIBEXT;
 extern pstring dyn_LOCKDIR;
 extern pstring dyn_PIDDIR;
 extern pstring dyn_SMB_PASSWD_FILE;
 extern pstring dyn_PRIVATE_DIR;
+
+char *dyn_STATEDIR(void);
+char *dyn_CACHEDIR(void);
index 53200ad02adde39cab7d5a6caba47f251e1f9d82..c8f0c3121f3d7050f4f0c68b505515b3629a10d2 100644 (file)
@@ -2434,6 +2434,39 @@ char *lib_path(const char *name)
        return talloc_asprintf(talloc_tos(), "%s/%s", dyn_LIBDIR, name);
 }
 
+/**
+ * @brief Returns an absolute path to a file in the Samba data directory.
+ *
+ * @param name File to find, relative to CODEPAGEDIR.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+
+char *data_path(const char *name)
+{
+       return talloc_asprintf(talloc_tos(), "%s/%s", dyn_CODEPAGEDIR, name);
+}
+
+/*****************************************************************
+a useful function for returning a path in the Samba state directory
+ *****************************************************************/
+char *state_path(char *name)
+{
+       pstring fname;
+
+       pstrcpy(fname,dyn_STATEDIR());
+       trim_string(fname,"","/");
+
+       if (!directory_exist(fname,NULL)) {
+               mkdir(fname,0755);
+       }
+
+       pstrcat(fname,"/");
+       pstrcat(fname,name);
+
+       return talloc_strdup(talloc_tos(), fname);
+}
+
 /**
  * @brief Returns the platform specific shared library extension.
  *