Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

108.2. samba-4.24.7

SMB/CIFS file and print server and client tools

Version 4.24.7, release 3
Shelf servers — Daemons that serve other machines: remote shell, web, mail, XMPP, IRC, CalDAV/CardDAV, SMB and DLNA
Phase 41_system (System), 584 of 1047 in build order
Licence GPL-3.0-or-later AND LGPL-3.0-or-later
Homepage https://www.samba.org/
Build time 11.9 SBU
Installed size 92.2 MiB in 1610 files
Recipe ports/core/servers/samba/kpkgbuild

About

Samba implements SMB, the file- and printer-sharing protocol of Windows. In KDOS it is built as a file and print server, smbd, with the client tools and libraries: smbclient, libsmbclient, which gvfs, kodi and vlc use to open smb:// addresses, and ntlm_auth, which libsoup3 tries for NTLM sign-on. A Windows laptop, a phone or a network printer often speaks SMB and nothing else. The Active Directory domain controller, domain membership and winbind are not built.

The package carries a service script, 83_samba, that runs smbd under the supervisor only once some account can share, so a machine where nobody shares listens on nothing. At each start it works through these steps:

  1. It skips itself while /etc/samba/smb.conf is missing or empty.
  2. It creates /var/log/samba and /var/cache/samba. smbd never makes its log directory, and without it writes nothing but the supervisor’s log; testparm reports a missing cache directory as an error until smbd has first written there.
  3. It creates /var/lib/samba/usershares, owned by root with group sambashare and mode 1770. This is the usershare path that smb.conf names and that net usershare (Dolphin’s Share tab) writes into. A package cannot carry that mode, and without the directory every share fails, so it is made at every start whether or not smbd then runs.
  4. It starts smbd if any one of these holds, and otherwise prints [SKIP] samba: no account shares folders:
    • the sambashare group has a member in /etc/group;
    • the usershare directory holds a share: a regular file, not a symbolic link (smbd refuses one), whose name does not begin with : (net usershare writes each share through a :tmp file it then renames);
    • smb.conf has a section other than [global].

A group member is enough on its own because no share can be made while smbd is down: net usershare add turns every name in a share’s access list, Dolphin’s Everyone among them, into a security identifier (SID) by asking the local smbd (source3/utils/net_usershare.c), and fails when there is none to ask. An account that Dolphin’s Share tab has just added to the group starts the server without a reboot: at that account’s next login kded-kdos asks kdos-powerd to run this script’s start.

The script passes supervise --stop-grace 15, so on a stop smbd has fifteen seconds to end its per-client children and close their open files before the supervisor sends SIGKILL; the default is five. Other machines reach the server once the firewall’s smb name is opened (see Opening a service).

Sources

Dependencies

Depends on: python3, perl, pkgconf, gnutls, libtasn1, zlib, jansson, readline, popt, libarchive, icu, ncurses, e2fsprogs, util-linux, libtirpc, rpcsvc-proto, perl-parse-yapp, libxslt, docbook-xsl, docbook-xml, acl, avahi, liburing, libcap, libbsd, cups, libunwind-nongnu, talloc, tdb, tevent.

Required by (6): gvfs, kdenetwork-filesharing, kio-extras, kodi, libsoup3, vlc.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install samba'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/servers/samba.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/servers/samba
echo '45b7747a47452eff2b2159a44cc63eb43690d339fd1069088e023a015fed06c7  samba-4.24.7.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/samba
SRC=$SRC_ROOT/samba-4.24.7
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf samba-4.24.7.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/musl-netlink.patch"

export XSLTPROC="xsltproc --maxdepth 10000"

./configure \
	--prefix=/usr \
	--enable-fhs \
	--sysconfdir=/etc \
	--libdir=/usr/lib \
	--localstatedir=/var \
	--with-piddir=/run/samba \
	--with-lockdir=/var/lib/samba/lock \
	--with-privatedir=/var/lib/samba/private \
	--with-logfilebase=/var/log/samba \
	--bundled-libraries='!talloc,!tdb,!tevent,ALL' \
	--without-ad-dc \
	--without-ads \
	--without-ldap \
	--without-pam \
	--without-systemd \
	--without-winbind \
	--with-acl-support \
	--without-quotas \
	--without-ldb-lmdb \
	--with-libunwind \
	--without-lttng \
	--without-fam \
	--without-dmapi \
	--without-winexe \
	--without-kernel-keyring \
	--with-regedit \
	--with-shared-modules='vfs_io_uring,!vfs_snapper' \
	--disable-spotlight \
	--disable-glusterfs \
	--disable-cephfs \
	--enable-cups \
	--disable-iprint \
	--enable-avahi \
	--disable-rpath \
	--disable-rpath-install \
	--nopyc --nopyo
grep -q 'define HAVE_CUPS 1' bin/default/include/config.h || {
	echo 'samba: libcups not found, printer shares would be missing' >&2
	exit 1
}
grep -q 'define HAVE_LINUX_RTNETLINK_H 1' bin/default/include/config.h
make
make DESTDIR=$PKG install
rm -rf "$PKG/run" "$PKG/var/run"
install -d -m 755 "$PKG/var/lib/samba/lock"
PKG_CONFIG_PATH="$PKG/usr/lib/pkgconfig" pkg-config --exists ndr_standard samba-util smbclient

install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/83_samba.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper

NAME="samba"
DAEMON="/usr/sbin/smbd"
USERSHARES="/var/lib/samba/usershares"

has_member() {
    grep -Eq '^sambashare:[^:]*:[^:]*:[^:[:space:]]' /etc/group
}

has_shares() {
    for f in "$USERSHARES"/*; do
        case "${f##*/}" in :*) continue ;; esac
        [ -f "$f" ] && [ ! -L "$f" ] && return 0
    done
    grep -Eiv '^[[:space:]]*\[global\]' /etc/samba/smb.conf |
        grep -Eq '^[[:space:]]*\['
}

case "$1" in
    start)
        [ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
        if [ ! -s /etc/samba/smb.conf ]; then
            echo "[SKIP] $NAME: no /etc/samba/smb.conf"
            exit 0
        fi
        install -d -m 755 /var/log/samba /var/cache/samba
        install -d -m 1770 -o root -g sambashare "$USERSHARES"
        if ! has_member && ! has_shares; then
            echo "[SKIP] $NAME: no account shares folders"
            exit 0
        fi
        echo "[KDOS] Starting $NAME..."
        supervise --stop-grace 15 "$NAME" "$DAEMON" --foreground --no-process-group
        ;;
    stop)   stop_service "$NAME" ;;
    status) check_status "$NAME" ;;
    *)      echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/83_samba.sh"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/samba, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf samba-4.24.7-3.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/samba, and runs the triggers its paths call for.

Contents

Installed programs: cifsdd, dbwrap_tool, eventlogadm, gentest, ldbadd, ldbdel, ldbedit, ldbmodify, ldbrename, ldbsearch, locktest, masktest, mdsearch, mvxattr, ndrdump, net, nmbd, nmblookup, ntlm_auth, oLschema2ldif, pdbedit, profiles, regdiff, regpatch, regshell, regtree, rpcclient, samba-gpupdate, samba-log-parser, samba-regedit, sharesec, smbcacls, smbclient, smbcontrol, smbcquotas, smbd, smbget, smbpasswd, smbspool, smbstatus, smbtar, smbtorture, smbtree, testparm, wbinfo, wspsearch.

Installed libraries: libdcerpc-binding.so, libdcerpc-server-core.so, libndr-krb5pac.so, libndr-nbt.so, libndr-standard.so, libndr.so, libnetapi.so, libnss_winbind.so, libnss_wins.so, libsamba-errors.so, libsamba-passdb.so, libsamba-util.so, libsmbclient.so, libsmbconf.so, libwbclient.so.

Installed directories: /etc/samba, /usr/include/samba-4.0, /usr/lib/python3.14/site-packages/samba, /usr/lib/samba, /usr/libexec/samba, /usr/share/licenses/samba, /var/cache/samba, /var/lib/samba, /var/log/samba.

Short descriptions

cifsdd convert and copy a file over SMB
dbwrap_tool low level TDB/CTDB manipulation tool using the dbwrap interface
eventlogadm push records into the Samba event log store
gentest Run random generic SMB operations against two SMB servers and show the differences in behavior
ldbadd Command-line utility for adding records to an LDB
ldbdel Command-line program for deleting LDB records
ldbedit Edit LDB databases using your preferred editor
ldbmodify Modify records in a LDB database
ldbrename Edit LDB databases using your favorite editor
ldbsearch Search for records in a LDB database
locktest Find differences in locking between two SMB servers
masktest Find differences in wildcard matching between Sambas implementation and that of a remote server.
mdsearch Run Spotlight searches against an SMB server
mvxattr Recursively rename extended attributes
ndrdump DCE/RPC Packet Parser and Dumper
net Tool for administration of Samba and remote CIFS servers.
nmbd NetBIOS name server to provide NetBIOS over IP naming services to clients
nmblookup NetBIOS over TCP/IP client used to lookup NetBIOS names
ntlm_auth tool to allow external access to Winbinds NTLM authentication function
oLschema2ldif Converts LDAP schemas to LDB-compatible LDIF
pdbedit manage the SAM database (Database of Samba Users)
profiles A utility to report and change SIDs in registry files
regdiff Diff program for Windows registry files
regpatch Applies registry patches to registry files
regshell Windows registry file browser using readline
regtree Text-mode registry viewer
rpcclient tool for executing client side MS-RPC functions
samba-gpupdate apply group policy
samba-log-parser Samba (winbind) trace parser. options: -h, --help show this help message and exit --traceid ID specify the traceid of the trace records --pid PID specify the pid of winbind client --breakdown breakdown the traces into per traceid files --merge-by-timestamp merge logs by timestamp --flow show the request/sub-request flow traces --flow-compact show the request/sub-request flow traces without dcerpc details
samba-regedit ncurses based tool to manage the Samba registry
sharesec Set or get share ACLs
smbcacls Set or get ACLs on an NT file or directory names
smbclient ftp-like client to access SMB/CIFS resources on servers
smbcontrol send messages to smbd, nmbd or winbindd processes
smbcquotas Set or get QUOTAs of NTFS 5 shares
smbd server to provide SMB/CIFS services to clients
smbget wget-like utility for download files over SMB
smbpasswd change a users SMB password
smbspool send a print file to an SMB printer
smbstatus report on current Samba connections
smbtar shell script for backing up SMB/CIFS shares directly to UNIX tape drives
smbtorture Run a series of tests against a SMB server
smbtree A text based smb network browser
testparm check an smb.conf configuration file for internal correctness
wbinfo Query information from winbind daemon
wspsearch Run Windows Search Protocol searches against a SMB server
ndr.pc Network Data Representation Core Library
ndr_krb5pac.pc NDR marshallers for the KRB5 PAC formats
ndr_nbt.pc NDR marshallers for nbt formats
ndr_standard.pc NDR marshallers for the standard set of DCE/RPC interfaces
netapi.pc A library to control CIFS servers
samba-util.pc Samba utility functions
smbclient.pc A SMB library interface
wbclient.pc Winbind client

Notes

After configure, build.sh greps bin/default/include/config.h for HAVE_CUPS and for HAVE_LINUX_RTNETLINK_H, and stops when either is missing. The second is the proof that the patch took effect.

rm -rf "$PKG/run" "$PKG/var/run" drops the runtime directories the install creates; /run is a fresh tmpfs at every boot. The lock directory is installed with an explicit install -d -m 755, so its mode does not depend on the installer’s umask. The pkg-config --exists line fails the build unless the ndr_standard, samba-util and smbclient pkg-config files were installed, the ones the client library’s consumers build against.

Samba’s build system, waf, is Python run at build time, which is why python3 is in the depends of a C program, and it builds inside the source tree.