n8n-nodes-smbclient 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +8 -0
- package/.gitattributes +5 -0
- package/.github/workflows/one-shot-npm-publish.yml +78 -36
- package/Readme.md +52 -0
- package/dist/nodes/Smb2/SmbClientWrapper.js +52 -29
- package/dist/nodes/Smb2/SmbClientWrapper.js.map +1 -1
- package/dist/package.json +1 -1
- package/docker/Dockerfile +44 -0
- package/docker/entrypoint.sh +31 -0
- package/docker-compose.yml +74 -0
- package/nodes/Smb2/SmbClientWrapper.ts +88 -32
- package/package.json +1 -1
package/.dockerignore
ADDED
package/.gitattributes
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Shell scripts must keep LF endings, otherwise the CRLF shebang breaks
|
|
2
|
+
# `exec` inside Linux/Docker ("No such file or directory"). This matters on
|
|
3
|
+
# Windows checkouts where core.autocrlf would otherwise rewrite them.
|
|
4
|
+
*.sh text eol=lf
|
|
5
|
+
docker/entrypoint.sh text eol=lf
|
|
@@ -1,36 +1,78 @@
|
|
|
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
|
-
|
|
1
|
+
# Manually-triggered release: bump the version, commit/tag it, then publish to npm.
|
|
2
|
+
#
|
|
3
|
+
# Trigger it from the Actions tab ("Run workflow") and supply `version`:
|
|
4
|
+
# - an explicit semver, e.g. "1.2.0"
|
|
5
|
+
# - or a bump keyword: "patch" | "minor" | "major"
|
|
6
|
+
#
|
|
7
|
+
# The workflow writes that version into package.json, commits it back to the
|
|
8
|
+
# branch and creates a matching `vX.Y.Z` tag, then publishes — so you never have
|
|
9
|
+
# to edit package.json by hand for a release.
|
|
10
|
+
#
|
|
11
|
+
# Requires the NPM_TOKEN secret (an npm automation token with publish rights).
|
|
12
|
+
|
|
13
|
+
name: Version Bump and Publish
|
|
14
|
+
|
|
15
|
+
on:
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
inputs:
|
|
18
|
+
version:
|
|
19
|
+
description: 'Version to release (explicit semver like 1.2.0, or patch/minor/major)'
|
|
20
|
+
required: true
|
|
21
|
+
type: string
|
|
22
|
+
|
|
23
|
+
# Needed so the workflow can push the version-bump commit and tag back.
|
|
24
|
+
permissions:
|
|
25
|
+
contents: write
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
publish-npm:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v6
|
|
32
|
+
with:
|
|
33
|
+
# Use a token that can push the bump commit/tag back to the repo.
|
|
34
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
|
|
36
|
+
- uses: pnpm/action-setup@v6
|
|
37
|
+
with:
|
|
38
|
+
version: latest
|
|
39
|
+
|
|
40
|
+
- uses: actions/setup-node@v6
|
|
41
|
+
with:
|
|
42
|
+
node-version: 24
|
|
43
|
+
registry-url: https://registry.npmjs.org/
|
|
44
|
+
|
|
45
|
+
- run: pnpm install --frozen-lockfile
|
|
46
|
+
|
|
47
|
+
# Write the requested version into package.json (no tag/commit yet — we do
|
|
48
|
+
# that ourselves below so the message and tag are under our control).
|
|
49
|
+
- name: Set version
|
|
50
|
+
id: bump
|
|
51
|
+
run: |
|
|
52
|
+
# `pnpm version` prints a human message ("Releasing pkg: x → y"), not
|
|
53
|
+
# the bare version, so read the result back from package.json instead.
|
|
54
|
+
pnpm version "${{ inputs.version }}" --no-git-tag-version
|
|
55
|
+
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
56
|
+
echo "version=v${NEW_VERSION}" >> "$GITHUB_OUTPUT"
|
|
57
|
+
echo "Releasing v${NEW_VERSION}"
|
|
58
|
+
|
|
59
|
+
# Commit the bump and tag it, then push both back to the triggering branch.
|
|
60
|
+
# NOTE: this pushes directly to the branch the workflow ran on. If that
|
|
61
|
+
# branch is protected (required reviews/checks), the default GITHUB_TOKEN
|
|
62
|
+
# push will be rejected — run releases from an unprotected branch or swap
|
|
63
|
+
# in a PAT/deploy key with bypass rights.
|
|
64
|
+
- name: Commit and tag
|
|
65
|
+
run: |
|
|
66
|
+
git config user.name 'github-actions[bot]'
|
|
67
|
+
git config user.email 'github-actions[bot]@users.noreply.github.com'
|
|
68
|
+
TAG="${{ steps.bump.outputs.version }}"
|
|
69
|
+
git commit -am "chore(release): ${TAG}"
|
|
70
|
+
git tag -a "${TAG}" -m "${TAG}"
|
|
71
|
+
git push origin HEAD
|
|
72
|
+
git push origin "${TAG}"
|
|
73
|
+
|
|
74
|
+
# `prepublishOnly` (build + strict lint) runs automatically here.
|
|
75
|
+
- name: Publish to npm
|
|
76
|
+
run: pnpm publish --no-git-checks
|
|
77
|
+
env:
|
|
78
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/Readme.md
CHANGED
|
@@ -94,6 +94,58 @@ The node provides detailed error messages for common SMB issues:
|
|
|
94
94
|
- Quota issues
|
|
95
95
|
- File sharing violations
|
|
96
96
|
|
|
97
|
+
## Local testing with Docker Compose
|
|
98
|
+
|
|
99
|
+
A ready-to-use stack is provided to test the node from the n8n UI against a
|
|
100
|
+
throwaway Samba server. It spins up two services:
|
|
101
|
+
|
|
102
|
+
- **n8n** — built from `docker/Dockerfile` with the `samba-client` CLI baked in
|
|
103
|
+
(the node shells out to it) and this package auto-installed into
|
|
104
|
+
`~/.n8n/nodes` on startup.
|
|
105
|
+
- **smb** — a disposable Samba server (`dperson/samba`) exposing a writable
|
|
106
|
+
share `n8nshare` for the user `n8n` / `n8npass`.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# 1. Build the node (the container loads the compiled dist/, not the .ts)
|
|
110
|
+
npm run build
|
|
111
|
+
|
|
112
|
+
# 2. Start the stack
|
|
113
|
+
docker compose up --build
|
|
114
|
+
|
|
115
|
+
# 3. Open http://localhost:5678
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
In n8n, create an **Smbclient (SMB2) API** credential with:
|
|
119
|
+
|
|
120
|
+
| Field | Value |
|
|
121
|
+
| ---------- | ---------- |
|
|
122
|
+
| Server | `smb` |
|
|
123
|
+
| Share Name | `n8nshare` |
|
|
124
|
+
| User Name | `n8n` |
|
|
125
|
+
| Password | `n8npass` |
|
|
126
|
+
| Domain | _(empty)_ |
|
|
127
|
+
| Port | `445` |
|
|
128
|
+
|
|
129
|
+
Then add the **SMB2 using smbclient** node and try the operations (List, Upload,
|
|
130
|
+
Download, …) against the share.
|
|
131
|
+
|
|
132
|
+
After changing the node code, rebuild and reinstall it into the running n8n:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm run build
|
|
136
|
+
REINSTALL_SMB_NODE=true docker compose up -d --force-recreate n8n
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The n8n version is configurable (defaults to the latest stable 2.x):
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
N8N_VERSION=2.23.3 docker compose up --build
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> n8n 2.x ships as a hardened Alpine image without a package manager, so the
|
|
146
|
+
> Dockerfile installs `samba-client` in a matching Alpine stage and copies the
|
|
147
|
+
> binary and its libraries into the final image.
|
|
148
|
+
|
|
97
149
|
## Running local (Development)
|
|
98
150
|
|
|
99
151
|
> Required podman and n8nio image setup
|
|
@@ -4,11 +4,12 @@ exports.SmbClientWrapper = void 0;
|
|
|
4
4
|
exports.getReadableError = getReadableError;
|
|
5
5
|
exports.connectToSmbServer = connectToSmbServer;
|
|
6
6
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
|
-
const node_util_1 = require("node:util");
|
|
8
7
|
const node_child_process_1 = require("node:child_process");
|
|
9
8
|
const util_1 = require("util");
|
|
10
9
|
const debug = (0, util_1.debuglog)('n8n-nodes-smbclient');
|
|
11
|
-
const SMB_FAILURE_RE = /NT_STATUS_(?!OK\b)[A-Z0-9_]+/;
|
|
10
|
+
const SMB_FAILURE_RE = /NT_STATUS_(?!OK\b|NO_MORE_FILES\b|NO_MORE_ENTRIES\b)[A-Z0-9_]+/;
|
|
11
|
+
const BENIGN_WARNING_RE = /^.*NT_STATUS_\w+\s+getting shadow copy data.*$/gim;
|
|
12
|
+
const stripBenignWarnings = (s) => s.replace(BENIGN_WARNING_RE, '');
|
|
12
13
|
const SMB_ERROR_HINTS = [
|
|
13
14
|
[/EACCES/i, 'Access Denied - Check your permissions for this file/folder'],
|
|
14
15
|
[/ENOENT/i, 'File/Path Not Found'],
|
|
@@ -28,7 +29,6 @@ function getReadableError(error) {
|
|
|
28
29
|
}
|
|
29
30
|
return msg;
|
|
30
31
|
}
|
|
31
|
-
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
32
32
|
const redactCmd = (s) => {
|
|
33
33
|
if (!s)
|
|
34
34
|
return s;
|
|
@@ -75,43 +75,66 @@ class SmbClientWrapper {
|
|
|
75
75
|
]);
|
|
76
76
|
throw new n8n_workflow_1.NodeOperationError(this.node, `smbclient failed. cmd="${safeCmd}" stderr="${safeErr}"`);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
var _a, _b;
|
|
78
|
+
runOne(cmd) {
|
|
80
79
|
const args = [...this.buildBaseArgs(), '-c', cmd];
|
|
81
80
|
const { username, password, domain } = this.auth;
|
|
82
81
|
const rawCmd = [this.smbclientPath, ...args].join(' ');
|
|
83
82
|
const safeCmd = maskSecrets(redactCmd(rawCmd), [username, password, domain]);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const child = (0, node_child_process_1.spawn)(this.smbclientPath, args, { windowsHide: true });
|
|
85
|
+
const outChunks = [];
|
|
86
|
+
const errChunks = [];
|
|
87
|
+
let spawnError;
|
|
88
|
+
child.stdout.on('data', (c) => outChunks.push(c));
|
|
89
|
+
child.stderr.on('data', (c) => errChunks.push(c));
|
|
90
|
+
child.on('error', (e) => {
|
|
91
|
+
spawnError = e;
|
|
92
|
+
});
|
|
93
|
+
child.on('close', (code, signal) => {
|
|
94
|
+
const stdout = Buffer.concat(outChunks).toString('utf8');
|
|
95
|
+
const stderr = Buffer.concat(errChunks).toString('utf8');
|
|
96
|
+
const couldNotRun = !!spawnError || signal != null;
|
|
97
|
+
const diagnostics = stripBenignWarnings(`${stdout}\n${stderr}`);
|
|
98
|
+
try {
|
|
99
|
+
if (couldNotRun || SMB_FAILURE_RE.test(diagnostics)) {
|
|
100
|
+
this.fail(safeCmd, stripBenignWarnings(stderr).trim() ||
|
|
101
|
+
stdout.trim() ||
|
|
102
|
+
(spawnError === null || spawnError === void 0 ? void 0 : spawnError.message) ||
|
|
103
|
+
`smbclient exited (code=${code}, signal=${signal})`);
|
|
104
|
+
}
|
|
105
|
+
resolve(stdout);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
reject(err);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
98
112
|
}
|
|
99
113
|
async stat(remotePath) {
|
|
100
|
-
var _a, _b, _c, _d, _e;
|
|
114
|
+
var _a, _b, _c, _d, _e, _f;
|
|
101
115
|
const out = await this.runOne(`allinfo "${remotePath}"`);
|
|
102
116
|
const info = new Map();
|
|
103
117
|
for (const line of out.split('\n')) {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
118
|
+
const idx = line.indexOf(':');
|
|
119
|
+
if (idx === -1)
|
|
120
|
+
continue;
|
|
121
|
+
const key = line.slice(0, idx).trim().toUpperCase();
|
|
122
|
+
const value = line.slice(idx + 1).trim();
|
|
123
|
+
if (key)
|
|
124
|
+
info.set(key, value);
|
|
107
125
|
}
|
|
108
|
-
const attrs = ((_a = info.get('ATTRIBUTES')) !== null && _a !== void 0 ? _a : '')
|
|
126
|
+
const attrs = ((_a = info.get('ATTRIBUTES')) !== null && _a !== void 0 ? _a : '')
|
|
127
|
+
.split('(')[0]
|
|
128
|
+
.trim()
|
|
129
|
+
.split('')
|
|
130
|
+
.filter((c) => /[A-Za-z]/.test(c));
|
|
131
|
+
const sizeMatch = ((_b = info.get('STREAM')) !== null && _b !== void 0 ? _b : '').match(/(\d+)\s*bytes/i);
|
|
109
132
|
return {
|
|
110
|
-
size:
|
|
111
|
-
createTime: (
|
|
112
|
-
accessTime: (
|
|
113
|
-
writeTime: (
|
|
114
|
-
changeTime: (
|
|
133
|
+
size: sizeMatch ? Number(sizeMatch[1]) : undefined,
|
|
134
|
+
createTime: (_c = info.get('CREATE_TIME')) !== null && _c !== void 0 ? _c : undefined,
|
|
135
|
+
accessTime: (_d = info.get('ACCESS_TIME')) !== null && _d !== void 0 ? _d : undefined,
|
|
136
|
+
writeTime: (_e = info.get('WRITE_TIME')) !== null && _e !== void 0 ? _e : undefined,
|
|
137
|
+
changeTime: (_f = info.get('CHANGE_TIME')) !== null && _f !== void 0 ? _f : undefined,
|
|
115
138
|
attributes: attrs,
|
|
116
139
|
isDirectory: attrs.includes('D'),
|
|
117
140
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmbClientWrapper.js","sourceRoot":"","sources":["../../../nodes/Smb2/SmbClientWrapper.ts"],"names":[],"m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AAEM,KAAK,UAAU,kBAAkB;;IAGvC,IAAI,CAAC;QACJ,MAAM,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAA+B,CAAC;QAEzF,KAAK,CACJ,mCAAmC,EACnC,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC,KAAK,EACjB,MAAA,WAAW,CAAC,MAAM,mCAAI,EAAE,EACxB,WAAW,CAAC,QAAQ,CACpB,CAAC;QACF,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,EAAE,WAAW,CAAW,CAAC;QACvF,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAGhF,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEtB,OAAO,EAAE,MAAM,EAAE,CAAC;IACnB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACrB,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAClC,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE;YAC7C,OAAO,EAAE,oCAAoC,aAAa,EAAE;SAC5D,CAAC,CAAC;IACJ,CAAC;AACF,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-smbclient",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Transfer files via Samba (SMB2) and smbclient package with n8n, some of the base work are based on https://github.com/drudge/n8n-nodes-smb work.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# n8n image preloaded with the samba-client CLI that n8n-nodes-smbclient
|
|
2
|
+
# shells out to. The community node itself is installed at startup by
|
|
3
|
+
# entrypoint.sh from the source mounted at /opt/code-temp.
|
|
4
|
+
#
|
|
5
|
+
# n8n 2.x ships as a Docker Hardened Image (Alpine, no package manager), so we
|
|
6
|
+
# can't `apk add` directly. Instead we install samba-client in a matching plain
|
|
7
|
+
# Alpine and copy the resulting files (smbclient + its dependency libraries)
|
|
8
|
+
# into the final image.
|
|
9
|
+
|
|
10
|
+
# Declared before the first FROM so it can be used in the stage-2 FROM line.
|
|
11
|
+
ARG N8N_VERSION=2.25.6
|
|
12
|
+
|
|
13
|
+
# ---- Stage 1: collect smbclient + its dependency files ----
|
|
14
|
+
FROM alpine:3.23 AS smb
|
|
15
|
+
RUN set -eux; \
|
|
16
|
+
apk add --no-cache samba-client 2>&1 | tee /tmp/apk.log; \
|
|
17
|
+
smbclient --version; \
|
|
18
|
+
mkdir -p /export; \
|
|
19
|
+
# Copy every file owned by samba-client and the packages it pulled in.
|
|
20
|
+
# Base Alpine packages (musl, etc.) are already in the hardened image, so
|
|
21
|
+
# they never appear in the "Installing" lines and aren't copied/clobbered.
|
|
22
|
+
for p in $(grep -oE 'Installing [^ ]+' /tmp/apk.log | awk '{print $2}'); do \
|
|
23
|
+
apk info -L "$p" | grep -E '^(usr/|lib/|etc/)' | while read -r f; do \
|
|
24
|
+
[ -e "/$f" ] || continue; \
|
|
25
|
+
mkdir -p "/export/$(dirname "$f")"; \
|
|
26
|
+
cp -a "/$f" "/export/$f"; \
|
|
27
|
+
done; \
|
|
28
|
+
done
|
|
29
|
+
|
|
30
|
+
# ---- Stage 2: n8n + smbclient ----
|
|
31
|
+
FROM n8nio/n8n:${N8N_VERSION}
|
|
32
|
+
|
|
33
|
+
USER root
|
|
34
|
+
|
|
35
|
+
COPY --from=smb /export/ /
|
|
36
|
+
# Fail the build early if smbclient can't run (missing lib, etc.).
|
|
37
|
+
RUN smbclient --version
|
|
38
|
+
|
|
39
|
+
COPY docker/entrypoint.sh /usr/local/bin/smbclient-node-entrypoint.sh
|
|
40
|
+
RUN chmod +x /usr/local/bin/smbclient-node-entrypoint.sh
|
|
41
|
+
|
|
42
|
+
USER node
|
|
43
|
+
|
|
44
|
+
ENTRYPOINT ["tini", "--", "/usr/local/bin/smbclient-node-entrypoint.sh"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Installs the locally-built n8n-nodes-smbclient package (mounted at
|
|
3
|
+
# /opt/code-temp) into n8n's user nodes directory, then starts n8n.
|
|
4
|
+
#
|
|
5
|
+
# The host must run `npm run build` (or `pnpm build`) first so that
|
|
6
|
+
# /opt/code-temp/dist exists — n8n loads the compiled files, not the .ts.
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
SOURCE_DIR="/opt/code-temp"
|
|
10
|
+
NODES_DIR="/home/node/.n8n/nodes"
|
|
11
|
+
PKG_NAME="n8n-nodes-smbclient"
|
|
12
|
+
|
|
13
|
+
if [ ! -d "$SOURCE_DIR/dist" ]; then
|
|
14
|
+
echo "WARNING: $SOURCE_DIR/dist not found."
|
|
15
|
+
echo " Run 'npm run build' on the host, then restart this container."
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
mkdir -p "$NODES_DIR"
|
|
19
|
+
cd "$NODES_DIR"
|
|
20
|
+
|
|
21
|
+
[ -f package.json ] || echo '{"name":"installed-nodes","private":true}' >package.json
|
|
22
|
+
|
|
23
|
+
if [ ! -d "node_modules/$PKG_NAME" ] || [ "${REINSTALL_SMB_NODE:-false}" = "true" ]; then
|
|
24
|
+
echo "Installing $PKG_NAME from $SOURCE_DIR ..."
|
|
25
|
+
npm install "$SOURCE_DIR" --no-audit --no-fund --loglevel error
|
|
26
|
+
else
|
|
27
|
+
echo "$PKG_NAME already installed (set REINSTALL_SMB_NODE=true to refresh after a rebuild)."
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Hand off to n8n's own entrypoint.
|
|
31
|
+
exec /docker-entrypoint.sh "$@"
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: n8n-nodes-smbclient-dev
|
|
2
|
+
|
|
3
|
+
# Local stack to test the SMB2 node end-to-end from the n8n UI:
|
|
4
|
+
# - n8n: built with the samba-client CLI + this node auto-installed
|
|
5
|
+
# - smb: a throwaway Samba server with a ready-to-use share
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# 1. npm run build # produce dist/ on the host
|
|
9
|
+
# 2. docker compose up --build
|
|
10
|
+
# 3. open http://localhost:5678 and create an "Smbclient (SMB2) API" credential:
|
|
11
|
+
# Server: smb
|
|
12
|
+
# Share Name: n8nshare
|
|
13
|
+
# User Name: n8n
|
|
14
|
+
# Password: n8npass
|
|
15
|
+
# Domain: (leave empty)
|
|
16
|
+
# Port: 445
|
|
17
|
+
#
|
|
18
|
+
# After editing the node code: `npm run build`, then
|
|
19
|
+
# REINSTALL_SMB_NODE=true docker compose up -d --force-recreate n8n
|
|
20
|
+
#
|
|
21
|
+
# Connecting to the share from your host (the `smb` service publishes 1445:445):
|
|
22
|
+
# - smbclient supports an explicit port, so from WSL / Git-Bash / Linux:
|
|
23
|
+
# smbclient //localhost/n8nshare -p 1445 -U 'n8n%n8npass'
|
|
24
|
+
# - Windows Explorer / `net use` cannot use a custom port (UNC has no port
|
|
25
|
+
# syntax) and Windows already binds 445 for its own file sharing, so you
|
|
26
|
+
# cannot simply republish this service as "445:445". To map a drive letter
|
|
27
|
+
# you must first free 445 (stop the "Server"/LanmanServer service), change
|
|
28
|
+
# the published port below to "445:445", then:
|
|
29
|
+
# net use Z: \\localhost\n8nshare /user:n8n n8npass
|
|
30
|
+
# Re-enable LanmanServer afterwards.
|
|
31
|
+
|
|
32
|
+
services:
|
|
33
|
+
n8n:
|
|
34
|
+
build:
|
|
35
|
+
context: .
|
|
36
|
+
dockerfile: docker/Dockerfile
|
|
37
|
+
args:
|
|
38
|
+
N8N_VERSION: ${N8N_VERSION:-2.23.3}
|
|
39
|
+
container_name: n8n-smbclient
|
|
40
|
+
restart: unless-stopped
|
|
41
|
+
ports:
|
|
42
|
+
- "5678:5678"
|
|
43
|
+
environment:
|
|
44
|
+
- N8N_SECURE_COOKIE=false
|
|
45
|
+
- N8N_RUNNERS_ENABLED=true
|
|
46
|
+
- GENERIC_TIMEZONE=${TZ:-UTC}
|
|
47
|
+
- TZ=${TZ:-UTC}
|
|
48
|
+
# set to true to reinstall the node from /opt/code-temp on next start
|
|
49
|
+
- REINSTALL_SMB_NODE=${REINSTALL_SMB_NODE:-false}
|
|
50
|
+
volumes:
|
|
51
|
+
- n8n_data:/home/node/.n8n
|
|
52
|
+
# the built package, installed into ~/.n8n/nodes by the entrypoint
|
|
53
|
+
- ./:/opt/code-temp:ro
|
|
54
|
+
depends_on:
|
|
55
|
+
- smb
|
|
56
|
+
|
|
57
|
+
smb:
|
|
58
|
+
image: dperson/samba
|
|
59
|
+
container_name: n8n-smbclient-samba
|
|
60
|
+
restart: unless-stopped
|
|
61
|
+
# -u "user;password"
|
|
62
|
+
# -s "name;path;browseable;readonly;guest;users;admins"
|
|
63
|
+
command: >-
|
|
64
|
+
-p
|
|
65
|
+
-u "n8n;n8npass"
|
|
66
|
+
-s "n8nshare;/share;yes;no;no;n8n;n8n"
|
|
67
|
+
ports:
|
|
68
|
+
- "1445:445" # host:container — only needed to inspect the share from the host
|
|
69
|
+
volumes:
|
|
70
|
+
- smb_data:/share
|
|
71
|
+
|
|
72
|
+
volumes:
|
|
73
|
+
n8n_data:
|
|
74
|
+
smb_data:
|
|
@@ -5,18 +5,29 @@ import {
|
|
|
5
5
|
NodeApiError,
|
|
6
6
|
NodeOperationError,
|
|
7
7
|
} from 'n8n-workflow';
|
|
8
|
-
import {
|
|
9
|
-
import { execFile } from 'node:child_process';
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
10
9
|
import { Smb2Credentials, SmbListEntry, SmbStat } from './interfaces';
|
|
11
10
|
import { debuglog } from 'util';
|
|
12
11
|
|
|
13
12
|
const debug = debuglog('n8n-nodes-smbclient');
|
|
14
13
|
|
|
15
|
-
// smbclient
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
14
|
+
// smbclient's exit code is unreliable — it can exit non-zero even when the
|
|
15
|
+
// requested command actually succeeded (notably `del`/`rename` against some
|
|
16
|
+
// Windows servers, which complete the operation but still return a failure
|
|
17
|
+
// status). The reliable signal is whether its output contains a genuine
|
|
18
|
+
// NT_STATUS_* error code. We therefore key success/failure off this pattern
|
|
19
|
+
// rather than the exit code. Excluded: NT_STATUS_OK (success) and the benign
|
|
20
|
+
// end-of-listing markers emitted during normal `ls`/`del` wildcard expansion.
|
|
21
|
+
const SMB_FAILURE_RE = /NT_STATUS_(?!OK\b|NO_MORE_FILES\b|NO_MORE_ENTRIES\b)[A-Z0-9_]+/;
|
|
22
|
+
|
|
23
|
+
// smbclient also prints NT_STATUS_* lines to stderr that carry a status code but
|
|
24
|
+
// do NOT mean the requested operation failed. The main offender is the VFS
|
|
25
|
+
// "shadow copy" probe that many Samba builds run on `allinfo`, e.g.:
|
|
26
|
+
// NT_STATUS_INVALID_DEVICE_REQUEST getting shadow copy data for \file.txt
|
|
27
|
+
// These benign lines must be stripped before failure detection, otherwise a
|
|
28
|
+
// perfectly good `stat` would be reported as an error.
|
|
29
|
+
const BENIGN_WARNING_RE = /^.*NT_STATUS_\w+\s+getting shadow copy data.*$/gim;
|
|
30
|
+
const stripBenignWarnings = (s: string): string => s.replace(BENIGN_WARNING_RE, '');
|
|
20
31
|
|
|
21
32
|
const SMB_ERROR_HINTS: Array<[RegExp, string]> = [
|
|
22
33
|
[/EACCES/i, 'Access Denied - Check your permissions for this file/folder'],
|
|
@@ -39,7 +50,6 @@ export function getReadableError(error: any): string {
|
|
|
39
50
|
return msg;
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
const execFileAsync = promisify(execFile);
|
|
43
53
|
const redactCmd = (s: string): string => {
|
|
44
54
|
if (!s) return s;
|
|
45
55
|
s = s.replace(/-U\s+\S+/g, '-U ***');
|
|
@@ -92,7 +102,7 @@ export class SmbClientWrapper {
|
|
|
92
102
|
throw new NodeOperationError(this.node, `smbclient failed. cmd="${safeCmd}" stderr="${safeErr}"`);
|
|
93
103
|
}
|
|
94
104
|
|
|
95
|
-
private
|
|
105
|
+
private runOne(cmd: string): Promise<string> {
|
|
96
106
|
const args = [...this.buildBaseArgs(), '-c', cmd];
|
|
97
107
|
|
|
98
108
|
const { username, password, domain } = this.auth;
|
|
@@ -100,37 +110,83 @@ export class SmbClientWrapper {
|
|
|
100
110
|
const rawCmd = [this.smbclientPath, ...args].join(' ');
|
|
101
111
|
const safeCmd = maskSecrets(redactCmd(rawCmd), [username, password, domain]);
|
|
102
112
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
// We stream stdout/stderr through `spawn` rather than buffering with
|
|
114
|
+
// `execFile`'s fixed `maxBuffer`: large directory listings (e.g. 160k+
|
|
115
|
+
// files) easily exceed any sane cap and would otherwise fail with
|
|
116
|
+
// ERR_CHILD_PROCESS_STDIO_MAXBUFFER. Output is bounded only by heap.
|
|
117
|
+
return new Promise<string>((resolve, reject) => {
|
|
118
|
+
const child = spawn(this.smbclientPath, args, { windowsHide: true });
|
|
119
|
+
|
|
120
|
+
const outChunks: Buffer[] = [];
|
|
121
|
+
const errChunks: Buffer[] = [];
|
|
122
|
+
let spawnError: Error | undefined;
|
|
123
|
+
|
|
124
|
+
child.stdout.on('data', (c: Buffer) => outChunks.push(c));
|
|
125
|
+
child.stderr.on('data', (c: Buffer) => errChunks.push(c));
|
|
126
|
+
child.on('error', (e: Error) => {
|
|
127
|
+
spawnError = e;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
child.on('close', (code: number | null, signal: string | null) => {
|
|
131
|
+
const stdout = Buffer.concat(outChunks).toString('utf8');
|
|
132
|
+
const stderr = Buffer.concat(errChunks).toString('utf8');
|
|
133
|
+
|
|
134
|
+
// smbclient's exit code is unreliable (it can exit non-zero on
|
|
135
|
+
// success), so we do NOT key failure off `code`. We only fail when
|
|
136
|
+
// the process could not run at all (spawn error or it was killed by a
|
|
137
|
+
// signal) or when its output contains a real NT_STATUS_* error.
|
|
138
|
+
const couldNotRun = !!spawnError || signal != null;
|
|
139
|
+
const diagnostics = stripBenignWarnings(`${stdout}\n${stderr}`);
|
|
140
|
+
try {
|
|
141
|
+
if (couldNotRun || SMB_FAILURE_RE.test(diagnostics)) {
|
|
142
|
+
this.fail(
|
|
143
|
+
safeCmd,
|
|
144
|
+
stripBenignWarnings(stderr).trim() ||
|
|
145
|
+
stdout.trim() ||
|
|
146
|
+
spawnError?.message ||
|
|
147
|
+
`smbclient exited (code=${code}, signal=${signal})`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
resolve(stdout);
|
|
151
|
+
} catch (err) {
|
|
152
|
+
reject(err);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
122
156
|
}
|
|
123
157
|
|
|
124
158
|
async stat(remotePath: string): Promise<SmbStat> {
|
|
125
159
|
const out = await this.runOne(`allinfo "${remotePath}"`);
|
|
160
|
+
|
|
161
|
+
// `allinfo` output is colon-delimited "key: value" (NOT pipe-delimited —
|
|
162
|
+
// the `-g` flag has no effect on it), e.g.:
|
|
163
|
+
// altname: SOMEFI~1.PDF
|
|
164
|
+
// create_time: Thu Sep 4 14:39:03 2025 CEST
|
|
165
|
+
// attributes: A (20)
|
|
166
|
+
// stream: [::$DATA], 2058 bytes
|
|
167
|
+
// Time values contain colons, so we split on the FIRST colon only.
|
|
126
168
|
const info = new Map<string, string>();
|
|
127
169
|
for (const line of out.split('\n')) {
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
170
|
+
const idx = line.indexOf(':');
|
|
171
|
+
if (idx === -1) continue;
|
|
172
|
+
const key = line.slice(0, idx).trim().toUpperCase();
|
|
173
|
+
const value = line.slice(idx + 1).trim();
|
|
174
|
+
if (key) info.set(key, value);
|
|
130
175
|
}
|
|
131
|
-
|
|
176
|
+
|
|
177
|
+
// "A (20)" -> letter flags only ("A"); drop the trailing "(hex)" annotation.
|
|
178
|
+
const attrs = (info.get('ATTRIBUTES') ?? '')
|
|
179
|
+
.split('(')[0]
|
|
180
|
+
.trim()
|
|
181
|
+
.split('')
|
|
182
|
+
.filter((c) => /[A-Za-z]/.test(c));
|
|
183
|
+
|
|
184
|
+
// There is no `size` key — the byte count lives in the stream line, e.g.
|
|
185
|
+
// "[::$DATA], 2058 bytes" (absent for directories).
|
|
186
|
+
const sizeMatch = (info.get('STREAM') ?? '').match(/(\d+)\s*bytes/i);
|
|
187
|
+
|
|
132
188
|
return {
|
|
133
|
-
size:
|
|
189
|
+
size: sizeMatch ? Number(sizeMatch[1]) : undefined,
|
|
134
190
|
createTime: info.get('CREATE_TIME') ?? undefined,
|
|
135
191
|
accessTime: info.get('ACCESS_TIME') ?? undefined,
|
|
136
192
|
writeTime: info.get('WRITE_TIME') ?? undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-smbclient",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Transfer files via Samba (SMB2) and smbclient package with n8n, some of the base work are based on https://github.com/drudge/n8n-nodes-smb work.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|