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
|
#!/bin/sh -e
#
# Post-installation script for the Samba package for Debian GNU/Linux
#
#
# Handle debconf
. /usr/share/debconf/confmodule
INITCONFFILE=/etc/default/samba
# We generate several files during the postinst, and we don't want
# them to be readable only by root.
umask 022
# Generate configuration file if it does not exist, using default values.
[ -r "${INITCONFFILE}" ] || {
echo Generating ${INITCONFFILE}... >&2
cat >${INITCONFFILE} <<'EOFMAGICNUMBER1234'
# Defaults for samba initscript
# sourced by /etc/init.d/samba
# installed at /etc/default/samba by the maintainer scripts
#
#
# This is a POSIX shell fragment
#
# How should Samba (smbd) run? Possible values are "daemons"
# or "inetd".
RUN_MODE=""
EOFMAGICNUMBER1234
}
# ------------------------- Debconf questions start ---------------------
# Run Samba as daemons or from inetd?
db_get samba/run_mode || true
RUN_MODE="${RET}"
TMPFILE=/etc/default/samba.dpkg-tmp
sed -e "s/^[[:space:]]*RUN_MODE[[:space:]]*=.*/RUN_MODE=\"${RUN_MODE}\"/" \
< ${INITCONFFILE} >${TMPFILE}
chmod a+r ${TMPFILE}
mv -f ${TMPFILE} ${INITCONFFILE}
# Generate a smbpasswd file?
db_get samba/generate_smbpasswd || true
GENERATE_SMBPASSWD="${RET}"
# Done with debconf now.
db_stop
umask 066
# FIXME: disable if ldapsam support is enabled?
# FIXME: we don't want to pass these through the smbpasswd backend,
# some of the faking can cause us problems!
if [ "${GENERATE_SMBPASSWD}" = "true" -a ! -e /var/lib/samba/passdb.tdb -a ! -e /etc/samba/smbpasswd ]; then
getent passwd | mksmbpasswd > /etc/samba/smbpasswd
pdbedit -i smbpasswd -e tdbsam -d 0
rm /etc/samba/smbpasswd
fi
umask 022
# ------------------------- Debconf questions end ---------------------
# move a tdb that should have been in /var/lib all along
if dpkg --compare-versions "$2" lt-nl 3.0.25b-2 \
&& dpkg --compare-versions "$2" ge 3.0.23-1 \
&& [ -e /var/run/samba/share_info.tdb ] \
&& ! [ -e /var/lib/samba/share_info.tdb ]
then
mv /var/run/samba/share_info.tdb /var/lib/samba/share_info.tdb
fi
if dpkg --compare-versions "$2" lt-nl 2:3.5.4~dfsg-2 \
&& dpkg --compare-versions "$2" ge 2:3.5.0~rc1~dfsg-1 \
&& [ -e /etc/samba/schannel_store.tdb ] \
&& ! [ -e /var/lib/samba/schannel_store.tdb ]
then
mv /etc/samba/schannel_store.tdb /var/lib/samba/schannel_store.tdb
fi
# We want to add these entries to inetd.conf commented out. Otherwise
# UDP traffic could make inetd to start nmbd or smbd right during
# the configuration stage.
if [ -z "$2" ]; then
update-inetd --add "#<off># netbios-ssn stream tcp nowait root /usr/sbin/tcpd /usr/sbin/smbd"
fi
if [ "$RUN_MODE" = "daemons" ]; then
update-inetd --disable netbios-ssn
else
update-inetd --enable netbios-ssn
fi
# add the sambashare group
if ! getent group sambashare > /dev/null 2>&1
then
addgroup --system sambashare
# Only on Ubuntu, use the "admin" group as a template for the
# initial users for this group; Debian has no equivalent group,
# so leaving the sambashare group empty is the more secure default
if [ -x "`which lsb_release 2>/dev/null`" ] \
&& [ "`lsb_release -s -i`" = "Ubuntu" ]
then
OLDIFS="$IFS"
IFS=","
for USER in `getent group admin | cut -f4 -d:`; do
adduser "$USER" sambashare \
|| ! getent passwd "$USER" >/dev/null
done
IFS="$OLDIFS"
fi
fi
if [ ! -e /var/lib/samba/usershares ]
then
install -d -m 1770 -g sambashare /var/lib/samba/usershares
fi
update-alternatives --install /usr/bin/smbstatus smbstatus /usr/bin/smbstatus.samba3 10 \
--slave /usr/share/man/man1/smbstatus.1.gz smbstatus.1.gz /usr/share/man/man1/smbstatus.samba3.1.gz
#DEBHELPER#
exit 0
|