NIS on Ubuntu
NIS on Ubuntu
Overview
Setting up a NIS (네트워크 정보 서비스) master on Ubuntu (22.04 / 24.04). This page documents a known bug in the stock NIS tools on Ubuntu and the verified, non-invasive workaround: building the NIS maps with Python.
Summary
- What: how to set up a working single-node NIS master on Ubuntu, given that the stock tools (`ypinit`, `makedbm`) are broken there.
- Why: on Ubuntu the NIS C tools **segfault** (a 리졸버/NSS 라이브러리 버그) and the `ypserv-source` package (the 메이크 기반 맵 소스) **does not exist**, so the standard setup fails.
- When: deploying NIS (`ypserv`) on Ubuntu 22.04 / 24.04.
Purpose
- Goal: give operators a verified way to build a working NIS master on Ubuntu without modifying 시스템 네트워크 이름 체계.
- Scope: single-node NIS master (`ypserv` + `ypbind`) on Ubuntu.
- Non-goals: NIS replication, NIS+, client-only setup.
Investigation info
- Investigated: 2026-11-24
- Source: HPCMATE `nismaster` module debugging on an Ubuntu 24.04 (noble) host
- Next review: on the next Ubuntu release (25.04)
The Problem
On Ubuntu, the standard NIS master setup fails in two independent ways:
- `E: Unable to locate package ypserv-source` — the `ypserv-source` package (Debian-only) does not exist on Ubuntu, so the 메이크 기반 맵 빌드 (`make -C /var/yp`) fails.
- `ypinit` / `makedbm` / `yppasswd` **segfault** — even with a full `PATH` and a static `/etc/resolv.conf`. `strace` 추적이 보여 `openat(/etc/resolv.conf)` → a query → `SIGSEGV (SEGV_MAPERR, NULL)`.
Root Cause
The segfault is a known 라이브러리 버그 (Launchpad #1204530 and kin): the NIS C tools load `libresolv` and, when they resolve a name, the 라이브러리 touches **uninitialized data** and the process crashes. This is not fixable by editing `/etc/hosts`, `/etc/resolv.conf`, or the `PATH` — so the only robust fix is to **not run the C tools**.
Two smaller issues also bite on Ubuntu:
- `systemctl enable nis` fails — the `nis` package provides no `nis.service` unit; the real daemons are `ypserv` + `ypbind`.
- A shell redirect `printf ... > /etc/yp.conf` run through `sudo` fails with `Permission denied` (the `>` runs in the unprivileged shell). Use `| tee /etc/yp.conf` instead.
The Solution — build the maps with Python (GDBM)
The `makedbm` output format is **GDBM** (per the `makedbm(8)` manpage: "GDBM is used as database"). Python's `dbm.gnu` writes the same GDBM format, so `ypserv` reads it fine. Each line of `/etc/<map>` becomes one record: **key = first colon field** (username / groupname), **data = the full line** (exactly what `ypcat` prints).
The writer is sent as base64 (avoids every quoting/escaping issue over the SSH channel) and run as root:
import base64
script = (
'import dbm.gnu as dbm, os\n'
'DOMAIN = "{domain}"; d = "/var/yp/" + DOMAIN\n'
'os.makedirs(d, exist_ok=True)\n'
'for f in os.listdir(d): os.remove(os.path.join(d, f))\n'
'for m in ("passwd", "group", "shadow"):\n'
' src = "/etc/" + m\n'
' if not os.path.exists(src): continue\n'
' db = dbm.open(d + "/" + m, "n"); n = 0\n'
' for line in open(src):\n'
' line = line.rstrip("\n")\n'
' if not line or line.startswith("#"): continue\n'
' db[line.split(":", 1)[0]] = line; n += 1\n'
' db.close(); print("built " + m + " (" + str(n) + ")")\n'
).format(domain=DOMAIN)
enc = base64.b64encode(script.encode()).decode()
run_remote("echo " + enc + " | base64 -d | sudo python3 2>&1 || true")
Full Ubuntu recipe (verified on 24.04 / noble)
- Install: `apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y ypserv nis python3` (no `ypserv-source`).
- Pre-seed `nis` debconf (master role + domain) before install so it stays non-interactive.
- `/etc/default/nis`: `NISDOMAIN=<domain>`, `NISSERVER=master`, `NISCLIENT=false` (via `| tee`).
- `/etc/hosts`: ensure `<master_ip> <master_name>` is present.
- `/etc/yp.conf`: explicit `domain <domain>` + `ypserver <master_ip>` (via `| tee`, NOT `>`). The explicit `domain` line matters — otherwise the yp tools fall back to 커널 도메인.
- Build the maps with the Python GDBM writer above.
- nsswitch: add `nis` to the `passwd` / `group` / `shadow` lines (idempotent, local-first).
- `systemctl enable rpcbind ypserv ypbind && systemctl start rpcbind ypserv ypbind`.
- Verify: `ypwhich` returns the master IP and `ypcat passwd` lists users.
Verification
| Command | Expected (success) | Failure means |
|---|---|---|
| `sudo ypwhich` | returns the master IP | `Domain not bound` = maps missing |
| head` | lists real users | empty = maps not built |
Pitfalls
- Do not try to "fix" the segfault via `/etc/hosts` / `/etc/resolv.conf` / the `PATH` — it is a `libresolv`/라이브러리 버그; none of that helps. Bypass the C tools.
- `dbm.gnu.open(path, "n")` creates a single-file GDBM db (no `.dir` / `.pag`); the magic is confirmed readable by `ypserv`.
- Key = first colon field; data = the whole line (not the remainder after the colon).
- Rebuilding is idempotent: clear the directory, then rewrite.
- The map build is non-invasive — it only writes files under `/var/yp/<domain>/`; it does not touch 네트워크 이름 체계나 리졸버.
References
- Launchpad #1204530 — yppasswd results in a segmentation fault: https://bugs.launchpad.net/ubuntu/+source/nis
- `makedbm(8)` manpage — "GDBM is used as database": https://manpages.ubuntu.com/manpages/jammy/man8/makedbm.8.html
- `ypserv(8)` manpage: https://manpages.ubuntu.com/manpages/jammy/man8/ypserv.8.html
- HPCMATE `setup/modules/nismaster.py` — the Factory Mode `nismaster` service that uses this pattern