summaryrefslogtreecommitdiff
path: root/patches/fhs-newpaths.patch
blob: 92c00771764b062d75f5dcad1a19c36c428cc3a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Goal: Prepare the sources to better respect FHS
      This introduces new configurable paths so that fhs.patch can
      later change the values for the newly introduced paths

Fixes: #49011

Status wrt upstream: Mean to be forwarded upstream (a good rationale 
                     about FHS is probably recommended)

Note: See fhs-filespaths for rationale about the meaning of the new
      path variables

Index: samba-3.0.27a/source/Makefile.in
===================================================================
--- samba-3.0.27a.orig/source/Makefile.in
+++ samba-3.0.27a/source/Makefile.in
@@ -106,6 +106,13 @@
 # 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@
 
@@ -139,7 +146,7 @@
 PATH_FLAGS4 = $(PATH_FLAGS3) -DSWATDIR=\"$(SWATDIR)\"  -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\"
 PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\"$(LIBDIR)\" \
 	      -DLOGFILEBASE=\"$(LOGFILEBASE)\" -DSHLIBEXT=\"@SHLIBEXT@\"
-PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\"
+PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\"$(CONFIGDIR)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\" -DCACHEDIR=\"$(CACHEDIR)\" -DSTATEDIR=\"$(STATEDIR)\"
 PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
 
 # Note that all executable programs now provide for an optional executable suffix.
@@ -1613,10 +1620,10 @@
 	@$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(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: samba-3.0.27a/source/configure.in
===================================================================
--- samba-3.0.27a.orig/source/configure.in
+++ samba-3.0.27a/source/configure.in
@@ -59,6 +59,10 @@
     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])
 
@@ -263,6 +267,9 @@
 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: samba-3.0.27a/source/dynconfig.c
===================================================================
--- samba-3.0.27a.orig/source/dynconfig.c
+++ samba-3.0.27a/source/dynconfig.c
@@ -53,6 +53,13 @@
 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.
  *
  * @sa lib_path() to get the path to a file inside the LIBDIR.
@@ -70,3 +77,27 @@
 
 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: samba-3.0.27a/source/include/dynconfig.h
===================================================================
--- samba-3.0.27a.orig/source/include/dynconfig.h
+++ samba-3.0.27a/source/include/dynconfig.h
@@ -31,8 +31,12 @@
 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: samba-3.0.27a/source/lib/util.c
===================================================================
--- samba-3.0.27a.orig/source/lib/util.c
+++ samba-3.0.27a/source/lib/util.c
@@ -2633,6 +2633,61 @@
 }
 
 /**
+ * @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 static #pstring containing the full path.
+ **/
+
+char *data_path(const char *name)
+{
+	static pstring fname;
+	snprintf(fname, sizeof(fname), "%s/%s", dyn_CODEPAGEDIR, name);
+	return fname;
+}
+
+/*****************************************************************
+a useful function for returning a path in the Samba state directory
+ *****************************************************************/
+char *state_path(char *name)
+{
+	static pstring fname;
+
+	pstrcpy(fname,dyn_STATEDIR());
+	trim_string(fname,"","/");
+
+	if (!directory_exist(fname,NULL)) {
+		mkdir(fname,0755);
+	}
+
+	pstrcat(fname,"/");
+	pstrcat(fname,name);
+
+	return fname;
+}
+
+/*****************************************************************
+a useful function for returning a path in the Samba cache directory
+ *****************************************************************/
+char *cache_path(char *name)
+{
+	static pstring fname;
+
+	pstrcpy(fname,dyn_CACHEDIR());
+	trim_string(fname,"","/");
+
+	if (!directory_exist(fname,NULL)) {
+			mkdir(fname,0755);
+	}
+
+	pstrcat(fname,"/");
+	pstrcat(fname,name);
+
+	return fname;
+}
+
+/**
  * @brief Returns the platform specific shared library extension.
  *
  * @retval Pointer to a static #fstring containing the extension.