|
Lines 6-17
nmbd_error_handler() {
Link Here
|
| 6 |
if [ -d /sys/class/net/lo ] && ls /sys/class/net | grep -qv ^lo$; then |
6 |
if [ -d /sys/class/net/lo ] && ls /sys/class/net | grep -qv ^lo$; then |
| 7 |
# https://bugs.debian.org/893762 |
7 |
# https://bugs.debian.org/893762 |
| 8 |
echo 'WARNING: nmbd failed to start as there is no non-loopback interfaces available.' |
8 |
echo 'WARNING: nmbd failed to start as there is no non-loopback interfaces available.' |
| 9 |
echo 'Either add an interface or set "disable netbios = yes" in smb.conf' |
9 |
echo 'Either add an interface or set "disable netbios = yes" in smb.conf and run "systemctl mask nmbd"' |
| 10 |
return 0 |
10 |
return 0 |
| 11 |
elif command -v ip > /dev/null && ip a show | grep '^[[:space:]]*inet ' | grep -vq ' lo$'; then |
11 |
elif command -v ip > /dev/null && ip a show | grep '^[[:space:]]*inet ' | grep -vq ' lo$'; then |
| 12 |
# https://bugs.debian.org/859526 |
12 |
# https://bugs.debian.org/859526 |
| 13 |
echo 'WARNING: nmbd failed to start as there is no local IPv4 non-loopback interfaces available.' |
13 |
echo 'WARNING: nmbd failed to start as there is no local IPv4 non-loopback interfaces available.' |
| 14 |
echo 'Either add an IPv4 address or set "disable netbios = yes" in smb.conf' |
14 |
echo 'Either add an IPv4 address or set "disable netbios = yes" in smb.conf and run "systemctl mask nmbd"' |
| 15 |
return 0 |
15 |
return 0 |
| 16 |
else |
16 |
else |
| 17 |
echo 'ERROR: nmbd failed to start.' |
17 |
echo 'ERROR: nmbd failed to start.' |
|
Lines 19-24
nmbd_error_handler() {
Link Here
|
| 19 |
fi |
19 |
fi |
| 20 |
} |
20 |
} |
| 21 |
|
21 |
|
|
|
22 |
mask_services() { |
| 23 |
local reason="$1" |
| 24 |
shift |
| 25 |
local masked_count=0 |
| 26 |
mkdir -p /etc/systemd/system |
| 27 |
echo "${reason}: Masking $*" |
| 28 |
echo "Please ignore the following error about deb-systemd-helper not finding those services." |
| 29 |
while true; do |
| 30 |
local service_name="$1" |
| 31 |
if [ -z "$service_name" ]; then |
| 32 |
break |
| 33 |
fi |
| 34 |
shift |
| 35 |
if [ ! -e "/etc/systemd/system/${service_name}" ]; then |
| 36 |
ln -s /dev/null "/etc/systemd/system/${service_name}" |
| 37 |
echo "(${service_name} masked)" |
| 38 |
masked_count=$((masked_count+1)) |
| 39 |
elif [ -h "/etc/systemd/system/${service_name}" ] \ |
| 40 |
&& [ "$(realpath /etc/systemd/system/${service_name})" = /dev/null ] \ |
| 41 |
; then |
| 42 |
echo "(${service_name} already masked)" |
| 43 |
else |
| 44 |
echo "WARNING ${service_name} should be masked. The install may fail." |
| 45 |
fi |
| 46 |
done |
| 47 |
# In case this system is running systemd, we make systemd reload the unit files |
| 48 |
# to pick up changes. |
| 49 |
if [ "${masked_count}" -ge 1 -a -d /run/systemd/system ] ; then |
| 50 |
systemctl --system daemon-reload >/dev/null || true |
| 51 |
fi |
| 52 |
} |
| 53 |
|
| 22 |
# We generate several files during the postinst, and we don't want |
54 |
# We generate several files during the postinst, and we don't want |
| 23 |
# them to be readable only by root. |
55 |
# them to be readable only by root. |
| 24 |
umask 022 |
56 |
umask 022 |
|
Lines 31-45
then
Link Here
|
| 31 |
[ -d $dir ] || install -d -m 1770 -g sambashare $dir |
63 |
[ -d $dir ] || install -d -m 1770 -g sambashare $dir |
| 32 |
fi |
64 |
fi |
| 33 |
|
65 |
|
| 34 |
# in 4.17.4+dfsg-3 we stopped masking services, unmask them here |
66 |
mkdir -p /run/samba # shut up [samba-tool] testparm warning |
| 35 |
if [ configure = "$1" ] && dpkg --compare-versions "$2" lt-nl 2:4.17.4+dfsg-3~ |
67 |
|
| 36 |
then |
68 |
# mimic source4/smbd/server.c and mask service before it fails |
| 37 |
for s in nmbd smbd samba-ad-dc; do |
69 |
# NB: server role = active directory domain controller is what we need to properly support |
| 38 |
if [ /dev/null = $(realpath /etc/systemd/system/$s.service) ] |
70 |
# NB: server services = smb is not compiled in |
| 39 |
then |
71 |
# NB: dcerpc endpoint servers = remote is for developpement |
| 40 |
rm -f /etc/systemd/system/$s.service |
72 |
# NB: dcerpc endpoint servers = mapiproxy is for OpenChange which is dead |
| 41 |
fi |
73 |
SERVER_ROLE=`samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1` |
| 42 |
done |
74 |
SERVER_SERVICES=`samba-tool testparm --parameter-name="server services" 2>/dev/null | tail -1` |
|
|
75 |
DCERPC_ENDPOINT_SERVERS=`samba-tool testparm --parameter-name="dcerpc endpoint servers" 2>/dev/null | tail -1` |
| 76 |
DISABLE_NETBIOS=`samba-tool testparm --parameter-name="disable netbios" 2>/dev/null | tail -1` |
| 77 |
|
| 78 |
if [ "$SERVER_ROLE" != "active directory domain controller" ] \ |
| 79 |
&& ( echo "$SERVER_SERVICES" | grep -qv '\(^\|, \)smb\(,\|$\)' ) \ |
| 80 |
&& ( echo "$DCERPC_ENDPOINT_SERVERS" | grep -qv '\(^\|, \)remote\(,\|$\)' ) \ |
| 81 |
&& ( echo "$DCERPC_ENDPOINT_SERVERS" | grep -qv '\(^\|, \)mapiproxy\(,\|$\)' ) \ |
| 82 |
; then |
| 83 |
mask_services "Samba is not being run as an AD Domain Controller" samba-ad-dc.service |
| 84 |
fi |
| 85 |
if [ "$SERVER_ROLE" = "active directory domain controller" ]; then |
| 86 |
mask_services "Samba is being run as an AD Domain Controller" smbd.service # Not in UCS: nmbd.service |
| 87 |
elif [ "$DISABLE_NETBIOS" = Yes ]; then |
| 88 |
mask_services "NetBIOS is disabled" nmbd.service |
| 43 |
fi |
89 |
fi |
| 44 |
|
90 |
|
| 45 |
# remove old spool directory (point it to /var/tmp if in use) |
91 |
# remove old spool directory (point it to /var/tmp if in use) |