~ubuntu-branches/ubuntu/maverick/samba/maverick-security

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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/make -f

# This has to be exported to make some magic below work.
export DH_OPTIONS

# Set the host and build architectures for use with config.cache loading,
# cross-building, etc.
DEB_HOST_GNU_TYPE	:= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE	:= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH_OS	:= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

export DEB_HOST_GNU_TYPE
export DEB_BUILD_GNU_TYPE
export DEB_HOST_ARCH_OS

CFLAGS = -g -Wall

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif

# Enable BIND_NOW to maximize benefit of RELRO hardening
LDFLAGS += -Wl,-z,now

DESTDIR=`pwd`/debian/tmp

conf_args = \
		--cache-file=./config.cache \
		--with-fhs \
		--enable-shared \
		--enable-static \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib/samba \
		--with-privatedir=/etc/samba \
		--with-piddir=/var/run/samba \
		--localstatedir=/var \
		--with-rootsbindir=/sbin \
		--with-pammodulesdir=/lib/security \
		--with-pam \
		--with-syslog \
		--with-utmp \
		--with-readline \
		--with-pam_smbpass \
		--with-libsmbclient \
		--with-winbind \
		--with-shared-modules=idmap_rid,idmap_ad,idmap_adex,idmap_hash,idmap_ldap,idmap_tdb2 \
		--with-automount \
		--with-ldap \
		--with-ads \
		--with-dnsupdate \
		--without-libtdb \
		--without-libnetapi \
		--with-modulesdir=/usr/lib/samba \
		--datarootdir=/usr/share \
		--datadir=/usr/share/samba \
		--with-swatdir=/usr/share/samba/swat \
		--with-lockdir=/var/run/samba \
		--with-statedir=/var/lib/samba \
		--with-cachedir=/var/cache/samba \
		--with-codepagedir=/usr/share/samba \
		--enable-external-libtalloc \
		--without-libtalloc \
		--disable-avahi

ifeq ($(DEB_HOST_ARCH_OS),linux)
  conf_args += \
		--with-acl-support \
		--with-quotas \
		--without-cifsmount \
		--without-cifsupcall          
	  else
  conf_args +=	--without-quotas --without-cifsmount
endif

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  conf_args += --build $(DEB_BUILD_GNU_TYPE)
else
  conf_args += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

configure:
	dh_testdir

	if [ -f debian/config.cache ]; then \
		cp -f debian/config.cache source3/config.cache; \
	fi

	[ -f source3/Makefile ] || (cd source3 && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" ./configure $(conf_args))

	touch configure-stamp

build: configure build-stamp
build-stamp:
	dh_testdir

	$(MAKE) -C source3 # headers
	$(MAKE) -C source3 everything
	$(MAKE) -C source3 nsswitch

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	[ ! -f source3/Makefile ] || $(MAKE) -C source3 distclean

	# Delete stuff left after a build that is not deleted by 'make clean'
	rm -f source3/pkgconfig/*.pc \
	      source3/exports/libsmbclient.syms \
	      source3/exports/libsmbsharemodes.syms

	debconf-updatepo

	dh_clean

install: DH_OPTIONS=$(DH_EXTRAS)
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	mkdir -p $(DESTDIR)/usr/lib/cups/backend $(DESTDIR)/usr/share/samba \
	         $(DESTDIR)/etc/pam.d $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d \
	         $(DESTDIR)/etc/ufw/applications.d

	$(MAKE) -C source3 install DESTDIR=$(DESTDIR)

	# Rename to *.samba3 for alternatives
	mv $(DESTDIR)/usr/bin/smbstatus $(DESTDIR)/usr/bin/smbstatus.samba3
	mv $(DESTDIR)/usr/bin/nmblookup $(DESTDIR)/usr/bin/nmblookup.samba3
	mv $(DESTDIR)/usr/share/man/man1/nmblookup.1 $(DESTDIR)/usr/share/man/man1/nmblookup.samba3.1
	mv $(DESTDIR)/usr/share/man/man1/smbstatus.1 $(DESTDIR)/usr/share/man/man1/smbstatus.samba3.1
	mv $(DESTDIR)/usr/bin/net $(DESTDIR)/usr/bin/net.samba3
	mv $(DESTDIR)/usr/share/man/man8/net.8 $(DESTDIR)/usr/share/man/man8/net.samba3.8
	mv $(DESTDIR)/usr/bin/testparm $(DESTDIR)/usr/bin/testparm.samba3
	mv $(DESTDIR)/usr/share/man/man1/testparm.1 $(DESTDIR)/usr/share/man/man1/testparm.samba3.1

	# Starting with Samba 3.0.6 libsmbclient.so is installed in
	# /usr/lib/samba. We don't want it there since it is not in the
	# default library path. Here we move it to /usr/lib/.
	mv $(DESTDIR)/usr/lib/samba/libsmbclient* $(DESTDIR)/usr/lib/

	# same problem with libwbclient.
	mv $(DESTDIR)/usr/lib/samba/libwbclient* $(DESTDIR)/usr/lib/

	# Install other stuff not installed by "make install"
	install -m 0755 debian/mksmbpasswd.awk $(DESTDIR)/usr/sbin/mksmbpasswd
	install -m 0644 debian/mksmbpasswd.8 $(DESTDIR)/usr/share/man/man8/mksmbpasswd.8
	install -m 0644 nsswitch/libnss_winbind.so $(DESTDIR)/lib/libnss_winbind.so.2
	install -m 0644 nsswitch/libnss_wins.so $(DESTDIR)/lib/libnss_wins.so.2
	# Install torture stuff
	install -m 0755 source3/bin/smbtorture $(DESTDIR)/usr/bin/smbtorture
	install -m 0755 source3/bin/msgtest $(DESTDIR)/usr/bin/msgtest
	install -m 0755 source3/bin/masktest $(DESTDIR)/usr/bin/masktest
	install -m 0755 source3/bin/locktest $(DESTDIR)/usr/bin/locktest
	install -m 0755 source3/bin/locktest2 $(DESTDIR)/usr/bin/locktest2
	install -m 0755 source3/bin/nsstest $(DESTDIR)/usr/bin/nsstest
	install -m 0755 source3/bin/vfstest $(DESTDIR)/usr/bin/vfstest
	install -m 0755 source3/bin/pdbtest $(DESTDIR)/usr/bin/pdbtest
	install -m 0755 source3/bin/replacetort $(DESTDIR)/usr/bin/replacetort
	install -m 0755 source3/bin/tdbtorture $(DESTDIR)/usr/bin/tdbtorture
	install -m 0755 source3/bin/smbconftort $(DESTDIR)/usr/bin/smbconftort
	mkdir -p $(DESTDIR)/usr/share/pam-configs
	install -m 0644 debian/libpam-smbpass.pam-config $(DESTDIR)/usr/share/pam-configs/smbpasswd-migrate
	install -m 0644 debian/winbind.pam-config $(DESTDIR)/usr/share/pam-configs/winbind

	# For CUPS to support printing to samba printers, it's necessary
	#	to make the following symlink (according to
	#	Erich Schubert <debian@vitavonni.de> in #109509):
	ln -s ../../../bin/smbspool $(DESTDIR)/usr/lib/cups/backend/smb


	# ufw integration
	install -m644 debian/samba.ufw.profile $(DESTDIR)/etc/ufw/applications.d/samba

	cp debian/smb.conf* $(DESTDIR)/usr/share/samba/
	install -m755 debian/panic-action $(DESTDIR)/usr/share/samba/panic-action
	# Install samba-common's conffiles - they'll get moved later to their
	# correct place by dh_movefiles.
	cp debian/gdbcommands $(DESTDIR)/etc/samba/
	install -m755 debian/samba-common.dhcp $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d/samba
	mkdir -p $(DESTDIR)/etc/network/if-up.d
	install -o root -g root debian/samba.if-up $(DESTDIR)/etc/network/if-up.d/samba
	install -D -m 644 debian/source_samba.py $(DESTDIR)/usr/share/apport/package-hooks/source_samba.py

	dh_movefiles
	dh_installpam --name=samba

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: DH_OPTIONS=-i
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installdocs -A debian/README.build
	# Ignore COPYING. Otherwise, an extra copy of the GPL licence 
	# in smbldap-tools example is included in samba-doc
	dh_installexamples -Xsmbldap-tools-* -XCOPYING
	dh_installchangelogs
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
# Pass -a to all debhelper commands in this target to reduce clutter.

binary-arch: DH_OPTIONS=-a $(DH_EXTRAS)
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installdocs -A debian/README.build
	dh_installexamples
	dh_installlogrotate
	dh_installlogcheck
	DH_OPTIONS= dh_installinit -psamba --upstart-only --name smbd
	DH_OPTIONS= dh_installinit -psamba --upstart-only --name nmbd
	DH_OPTIONS= dh_installinit -pwinbind
	dh_installcron 
	dh_lintian
	dh_installchangelogs -Nlibpam-smbpass
	DH_OPTIONS= dh_installchangelogs -plibpam-smbpass source3/pam_smbpass/CHANGELOG
	DH_OPTIONS= dh_strip -psamba -psmbclient -pwinbind -psamba-common-bin --dbg-package=samba-dbg
	DH_OPTIONS= dh_strip -Nsamba -Nsmbclient -Nwinbind -Nsamba-common-bin
	dh_link
	dh_compress
	dh_fixperms

	# Upstream makefile installs this using "install" without -m, so
	# it becomes executable
	chmod a-x debian/libsmbclient-dev/usr/include/libsmbclient.h

	# Set some reasonable default perms for the samba logdir.
	chmod 0750 debian/samba-common/var/log/samba/
	chown root:adm debian/samba-common/var/log/samba/
	chmod 1777 debian/samba/var/spool/samba/

	DH_OPTIONS= dh_makeshlibs -plibsmbclient -V'libsmbclient (>= 2:3.2.0)'
	DH_OPTIONS= dh_makeshlibs -plibwbclient0
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

update-archs:
	sed -i -e "s/libacl1-dev\( ([^)]\+)\)* \[[^]]\+\]/libacl1-dev \1 [`type-handling any linux-gnu`]/g" \
	       -e "s/libkeyutils-dev\( ([^)]\+)\)* \[[^]]\+\]/libkeyutils-dev \1 [`type-handling any linux-gnu`]/g" \
	       -e "s/libcap2-dev\( ([^)]\+)\)* \[[^]]\+\]/libcap2-dev \1 [`type-handling any linux-gnu`]/g" \
		debian/control

.PHONY: build clean binary-indep binary-arch binary install configure update-archs