{"record":{"id":"9611027d4c73b363","repo":"AdguardTeam/AdGuardHome","slug":"os-mkdirall-s-w","errorCode":null,"errorMessage":"os.MkdirAll: %s: %w","messagePattern":"os\\.MkdirAll: (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/controlinstall.go","lineNumber":333,"sourceCode":"\tresolvedConfPath = \"/etc/systemd/resolved.conf.d/adguardhome.conf\"\n\tresolvedConfData = `[Resolve]\nDNS=127.0.0.1\nDNSStubListener=no\n`\n)\nconst resolvConfPath = \"/etc/resolv.conf\"\n\n// disableDNSStubListener deactivates DNSStubListerner and returns an error, if\n// any.  cmdCons must not be nil.\nfunc disableDNSStubListener(\n\tctx context.Context,\n\tl *slog.Logger,\n\tcmdCons executil.CommandConstructor,\n) (err error) {\n\tdir := filepath.Dir(resolvedConfPath)\n\terr = os.MkdirAll(dir, 0o755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"os.MkdirAll: %s: %w\", dir, err)\n\t}\n\n\terr = os.WriteFile(resolvedConfPath, []byte(resolvedConfData), 0o644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"os.WriteFile: %s: %w\", resolvedConfPath, err)\n\t}\n\n\t_ = os.Rename(resolvConfPath, resolvConfPath+\".backup\")\n\terr = os.Symlink(\"/run/systemd/resolve/resolv.conf\", resolvConfPath)\n\tif err != nil {\n\t\t_ = os.Remove(resolvedConfPath) // remove the file we've just created\n\t\treturn fmt.Errorf(\"os.Symlink: %s: %w\", resolvConfPath, err)\n\t}\n\n\tconst systemctlCmd = \"systemctl\"\n\n\tsystemctlArgs := []string{\"reload-or-restart\", \"systemd-resolved\"}\n","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/controlinstall.go#L315-L351","documentation":"Disabling the systemd-resolved DNS stub listener required creating the parent directory of resolvedConfPath (e.g. /etc/systemd/resolved.conf.d) and os.MkdirAll failed. Typical causes are missing privileges or a read-only filesystem.","triggerScenarios":"Initial setup (validateDNS/disableDNSStubListener) on a Linux host using systemd-resolved when the process can't create the directory with mode 0755.","commonSituations":"Running AdGuard Home as a non-root user without sudo; immutable/read-only /etc; misconfigured containers; SELinux denying writes.","solutions":["Run setup with sufficient privileges (root or sudo) so /etc/systemd/resolved.conf.d can be created","If systemd-resolved isn't in use, skip/disable the stub-listener step in setup","In containers/immutable hosts, configure the host's resolved manually or run with port 53 already free","Check the wrapped error for EACCES vs EROFS to confirm the cause"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight: check we can create the resolved conf dir\nif err := os.MkdirAll(filepath.Dir(resolvedConfPath), 0o755); err != nil {\n    return fmt.Errorf(\"need privileges to disable DNS stub: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// Skip stub-disable step when not applicable\nif isMkdirErr(err) { skipStepWithWarning(\"run setup as root to disable systemd-resolved stub\") }","preventionTips":["Run installer/setup with root privileges on systemd hosts","Pre-free port 53 manually if running unprivileged","On immutable OSes, configure resolved out-of-band"],"tags":["install","systemd","resolved","permissions","filesystem"],"backgroundTag":"permission-denied-mkdir","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}