saltext-winshell 1.0.1__py2.py3-none-any.whl

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.
@@ -0,0 +1,30 @@
1
+ # pylint: disable=missing-module-docstring
2
+ import pathlib
3
+
4
+ PACKAGE_ROOT = pathlib.Path(__file__).resolve().parent
5
+ try:
6
+ from .version import __version__
7
+ except ImportError: # pragma: no cover
8
+ __version__ = "0.0.0.not-installed"
9
+ try:
10
+ from importlib.metadata import PackageNotFoundError
11
+ from importlib.metadata import version
12
+
13
+ try:
14
+ __version__ = version(__name__)
15
+ except PackageNotFoundError:
16
+ # package is not installed
17
+ pass
18
+ except ImportError:
19
+ try:
20
+ from pkg_resources import DistributionNotFound
21
+ from pkg_resources import get_distribution
22
+
23
+ try:
24
+ __version__ = get_distribution(__name__).version
25
+ except DistributionNotFound:
26
+ # package is not installed
27
+ pass
28
+ except ImportError:
29
+ # pkg resources isn't even available?!
30
+ pass
@@ -0,0 +1,361 @@
1
+ """
2
+ Core functions to impliment the salt windows shell
3
+ """
4
+
5
+ # Copyright 2021 VMware, Inc.
6
+ # SPDX-License-Identifier: Apache-2.0
7
+
8
+ import logging
9
+ import ntpath
10
+ import os
11
+ import time
12
+
13
+ import paramiko
14
+ import salt.exceptions
15
+ import scp
16
+ from salt.client.ssh.shell import Shell as LinuxShell
17
+
18
+ from saltext.winshell.env_version import ENV_VERSION
19
+
20
+ log = logging.getLogger(__name__)
21
+
22
+ # Windows Powershell Shim - actually, this is python
23
+ SSH_PS_SHIM = "\n".join([s.strip() for s in r'''
24
+ import base64
25
+
26
+ exec(base64.b64decode("""{SSH_PY_CODE}"""))
27
+ '''.split("\n")])
28
+
29
+
30
+ def set_winvars(self, ssh_python_env=None): # pylint: disable=unused-argument
31
+ """
32
+ Set the Win Vars
33
+ """
34
+ self.thin_dir = "c:/saltremote/thin"
35
+ self.python_dir = "c:/saltremote/bin"
36
+ pyver = "Py3"
37
+ self.python_env_map = {
38
+ "AMD64": f"Salt-Env-{ENV_VERSION}-AMD64-{pyver}.zip",
39
+ "x86": f"Salt-Env-{ENV_VERSION}-x86-{pyver}.zip",
40
+ }
41
+ self.python_saltwinshell = "/extra/salt/saltwinshell"
42
+
43
+
44
+ def gen_shim(py_code_enc):
45
+ """
46
+ Generate a PowerShell shim
47
+ """
48
+ return SSH_PS_SHIM.format(SSH_PY_CODE=py_code_enc)
49
+
50
+
51
+ def get_target_shim_file(self, target_shim_file):
52
+ """
53
+ Get the target shim file
54
+ """
55
+ return ntpath.normpath(ntpath.sep.join((self.python_dir, target_shim_file)))
56
+
57
+
58
+ def call_python(self, target_shim_file):
59
+ """
60
+ Call python stuff
61
+ """
62
+ python_exe = ntpath.normpath(ntpath.sep.join((self.python_dir, "python.exe")))
63
+ return self.shell.exec_cmd(f"{python_exe} {ntpath.normpath(target_shim_file)}")
64
+
65
+
66
+ def deploy_python(self):
67
+ """
68
+ Deploy the Windows python environment
69
+ """
70
+ if not self.python_env:
71
+ log.debug("No Python Environment found. Determining which env to use")
72
+ self.python_env = os.path.join(self.python_saltwinshell, self.python_env_map[self.arch])
73
+ if not os.path.isfile(self.python_env):
74
+ if os.path.isfile(
75
+ os.path.join(self.python_saltwinshell, self.python_env_map[self.arch])
76
+ ):
77
+ self.python_env = os.path.join(
78
+ self.python_saltwinshell, self.python_env_map[self.arch]
79
+ )
80
+ if not os.path.isfile(self.python_env):
81
+ raise salt.exceptions.SaltConfigurationError(
82
+ f"Python env: {self.python_env} doesn't exist."
83
+ )
84
+ self.shell.send(
85
+ self.python_env,
86
+ os.path.join(self.python_dir, "bin.zip"),
87
+ makedirs=True,
88
+ )
89
+
90
+ zip_path = os.path.join(self.python_dir, "bin.zip")
91
+ # Extract via .NET System.IO.Compression first (much faster than
92
+ # Expand-Archive); PS 5.1/.NET Framework has no overwrite flag on
93
+ # ZipFile.ExtractToDirectory, so extract entry-by-entry with
94
+ # ZipFileExtensions.ExtractToFile($entry, $target, $true). On any error
95
+ # fall back to Expand-Archive -Force
96
+ extract_cmd = (
97
+ f"powershell \"$ErrorActionPreference='Stop'; "
98
+ f"try {{ "
99
+ f"Add-Type -AssemblyName System.IO.Compression.FileSystem; "
100
+ f"$zip = [System.IO.Compression.ZipFile]::OpenRead('{zip_path}'); "
101
+ f"foreach ($entry in $zip.Entries) {{ "
102
+ f"if ($entry.Name -eq '') {{ continue }}; "
103
+ f"$target = Join-Path '{self.python_dir}' $entry.FullName; "
104
+ f"$dir = Split-Path $target -Parent; "
105
+ f"if (-not (Test-Path $dir)) {{ New-Item -ItemType Directory -Path $dir -Force | Out-Null }}; "
106
+ f"[System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $target, $true) }}; "
107
+ f"$zip.Dispose(); "
108
+ f"Write-Output 'DOTNET' "
109
+ f"}} catch {{ "
110
+ f"Write-Output ('DOTNET FAILED: ' + $_.Exception.Message); "
111
+ f"Expand-Archive -Path '{zip_path}' -DestinationPath '{self.python_dir}' -Force; "
112
+ f"Write-Output 'EXPAND-ARCHIVE' }}"
113
+ )
114
+ start = time.time()
115
+ stdout, stderr, retcode = self.shell.exec_cmd(extract_cmd)
116
+ elapsed = time.time() - start
117
+ if "DOTNET FAILED" not in stdout and "DOTNET" in stdout:
118
+ method = "System.IO.Compression"
119
+ elif "EXPAND-ARCHIVE" in stdout:
120
+ method = "Expand-Archive fallback"
121
+ log.debug("dotnet extraction failed: %s", stdout.strip())
122
+ else:
123
+ method = "unknown"
124
+ log.error("extraction failed: stdout=%s stderr=%s retcode=%s", stdout, stderr, retcode)
125
+ log.debug(
126
+ "extracted %s via %s in %.2f seconds (retcode %s)", zip_path, method, elapsed, retcode
127
+ )
128
+ log.trace("shim_cmd %s - %s - %s", extract_cmd, stdout, retcode)
129
+ return True
130
+
131
+
132
+ class Shell(LinuxShell):
133
+ send_retries = 3
134
+ retry_delay = 5
135
+
136
+ def __init__(self, *args, **kwargs):
137
+ super().__init__(*args, **kwargs)
138
+ self._conn = None
139
+
140
+ def get_connection(self):
141
+ """
142
+ Return a cached Connection, creating it if necessary.
143
+ Returns None if the connection cannot be established.
144
+ """
145
+ conn = self._conn
146
+ if conn is not None and conn.connected:
147
+ return conn
148
+ if conn is not None:
149
+ conn.close()
150
+ self._conn = None
151
+ conn = Connection(self.host, self.user, self.priv)
152
+ if conn.connect():
153
+ self._conn = conn
154
+ return conn
155
+ return None
156
+
157
+ def drop_connection(self):
158
+ """
159
+ Close and forget the cached connection
160
+ """
161
+ conn = self._conn
162
+ if conn is not None:
163
+ conn.close()
164
+ self._conn = None
165
+
166
+ def send(self, local, remote, makedirs=False):
167
+ """
168
+ Send a file to the remote system using scp, retrying on failure.
169
+
170
+ Raises SaltException once all retries are exhausted - a failed
171
+ scp leaves a truncated file on the target which the shim will
172
+ happily unpack, so a failed send must never look like success.
173
+ """
174
+ last_err = "no attempt made"
175
+ for attempt in range(1, self.send_retries + 1):
176
+ conn = self.get_connection()
177
+ if conn is None:
178
+ last_err = f"Unable to connect to {self.host}"
179
+ log.error(
180
+ "send attempt %s/%s to %s failed: %s",
181
+ attempt,
182
+ self.send_retries,
183
+ self.host,
184
+ last_err,
185
+ )
186
+ time.sleep(self.retry_delay)
187
+ continue
188
+
189
+ if makedirs:
190
+ log.debug(
191
+ "Making directory %s on %s", ntpath.dirname(ntpath.normpath(remote)), self.host
192
+ )
193
+ ret = conn.cmd_exec(f"mkdir {ntpath.dirname(ntpath.normpath(remote))}")
194
+ log.trace("%s - %s - %s", ret[0], ret[1], ret[2])
195
+
196
+ log.debug(
197
+ "Copying %s to %s on minion (attempt %s/%s)",
198
+ local,
199
+ remote,
200
+ attempt,
201
+ self.send_retries,
202
+ )
203
+ ret = conn.send(local, remote)
204
+
205
+ if ret and ret[2] == 0:
206
+ log.trace("COPY %s - %s - %s", ret[0], ret[1], ret[2])
207
+ return ret[0], ret[1], ret[2]
208
+
209
+ last_err = str(ret[1]) if ret else "no result from scp"
210
+ log.error(
211
+ "send attempt %s/%s failed for %s -> %s on %s: %s",
212
+ attempt,
213
+ self.send_retries,
214
+ local,
215
+ remote,
216
+ self.host,
217
+ last_err,
218
+ )
219
+ # a failed scp can leave a truncated file on the target - drop
220
+ # the cached connection so the retry starts clean
221
+ self.drop_connection()
222
+ time.sleep(self.retry_delay)
223
+
224
+ raise salt.exceptions.SaltException(
225
+ f"Failed to send {local} to {remote} on {self.host} after {self.send_retries} attempts: {last_err}"
226
+ )
227
+
228
+ def exec_cmd(self, cmd):
229
+ """
230
+ Execute a remote command
231
+ """
232
+ logmsg = f"Executing command: {cmd}"
233
+ if 'decode("base64")' in logmsg or "base64.b64decode(" in logmsg:
234
+ log.debug("Executed SHIM command. Command logged to TRACE")
235
+ log.trace(logmsg)
236
+ else:
237
+ log.debug(logmsg)
238
+
239
+ conn = self.get_connection()
240
+ if conn is None:
241
+ return "", f"Unable to connect to {self.host}", 1
242
+ ret, err, code = conn.cmd_exec(cmd)
243
+ log.trace("COMMAND: cmd:%s - ret:%s - err:%s - code:%s", cmd, ret, err, code)
244
+ return ret, err, code
245
+
246
+
247
+ class Connection:
248
+ def __init__(self, host, user, key="/etc/salt/pki/master/ssh/salt-ssh.id_ed25519"):
249
+ self.host = host
250
+ self.user = user
251
+ self.key = key
252
+ self.conn = paramiko.client.SSHClient()
253
+ self.conn.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # nosec B507
254
+ self.connected = False
255
+ if not self.key or not os.path.isfile(self.key):
256
+ raise salt.exceptions.SaltConfigurationError(
257
+ f"ssh config error: {self.key} doesn't exist."
258
+ )
259
+ if not os.access(self.key, os.R_OK):
260
+ raise salt.exceptions.SaltConfigurationError(f"cannot access: {self.key}")
261
+
262
+ def connect(self, host=None, user=None):
263
+ if host:
264
+ self.host = host
265
+ if user:
266
+ self.user = user
267
+ try:
268
+ self.conn.connect(self.host, username=self.user, key_filename=self.key)
269
+ self.connected = True
270
+ except Exception as err: # pylint: disable=broad-exception-caught
271
+ log.error("Unable to connect to %s as %s: %s", self.host, self.user, err)
272
+ self.connected = False
273
+
274
+ return self.connected
275
+
276
+ def connect_scp(self):
277
+ scp_client = None
278
+ if not self.connected:
279
+ self.connect()
280
+
281
+ if self.connected:
282
+ scp_client = scp.SCPClient(self.conn.get_transport())
283
+
284
+ return scp_client
285
+
286
+ def close(self):
287
+ """
288
+ Close the ssh connection
289
+ """
290
+ try:
291
+ self.conn.close()
292
+ except Exception: # pylint: disable=broad-exception-caught
293
+ pass
294
+ self.connected = False
295
+
296
+ def send(self, local, remote):
297
+ remote_path = remote.replace("c:", "").replace("\\", "/")
298
+ err = None
299
+ stdout = None
300
+ code = None
301
+
302
+ try:
303
+ scp_c = self.connect_scp()
304
+ if scp_c:
305
+ scp_c.put(local, remote_path)
306
+ scp_c.close()
307
+ code = 0
308
+ else:
309
+ stdout = "Failed to open SCP"
310
+ err = "SCP connection failed"
311
+ code = 1
312
+ except Exception as e: # pylint: disable=broad-exception-caught
313
+ stdout = f"Failed to upload file {remote_path}"
314
+ err = e
315
+ code = 1
316
+
317
+ return stdout, err, code
318
+
319
+ def cmd_exec(self, cmd):
320
+ ret = None
321
+ err = None
322
+ code = None
323
+
324
+ if not self.connected:
325
+ self.connect()
326
+
327
+ if self.connected:
328
+ try:
329
+ _, stdout, stderr = self.conn.exec_command(cmd)
330
+ ret = stdout.read().decode()
331
+ err = stderr.read().decode()
332
+ code = 0
333
+ # The shim signals the master by printing a bare command
334
+ # ('deploy' or 'ext_mods') as the first line of stdout.
335
+ # Match that exactly - a substring match anywhere in the
336
+ # output would trigger spurious redeploys whenever a
337
+ # command result happens to contain those words.
338
+ first_line = ret.split("\n", 1)[0].strip()
339
+ if first_line == "deploy":
340
+ code = 11
341
+ elif first_line == "ext_mods":
342
+ code = 13
343
+ elif "exists but is not a directory" in err:
344
+ code = 73
345
+ if err and "WARNING" not in err:
346
+ code = 1
347
+ except Exception as exc: # pylint: disable=broad-exception-caught
348
+ log.error("Command execution failed on %s: %s", self.host, exc)
349
+ # the connection is likely dead - force a reconnect on the
350
+ # next call
351
+ self.connected = False
352
+ ret = ""
353
+ err = f"Command execution failed: {exc}"
354
+ code = 1
355
+
356
+ else:
357
+ ret = ""
358
+ err = f"Unable to connect to {self.host}"
359
+ code = 1
360
+
361
+ return ret, err, code
@@ -0,0 +1,8 @@
1
+ # Version of the deployed Salt-Env zip files.
2
+ #
3
+ # This is NOT the package release version - it is the version suffix used
4
+ # to locate the Salt-Env archives on the salt master, e.g.:
5
+ # Salt-Env-3008-AMD64-Py3.zip
6
+ # The zips are expected under /extra/salt/saltwinshell on the master
7
+ # (they are intentionally not carried in this repository).
8
+ ENV_VERSION = "3008"
File without changes
@@ -0,0 +1,38 @@
1
+ """
2
+ Salt execution module for the agentless Windows shell.
3
+
4
+ These functions run on the salt master alongside the salt-ssh client.
5
+ """
6
+
7
+ import logging
8
+
9
+ import saltext.winshell.core
10
+ from saltext.winshell import __version__
11
+
12
+ log = logging.getLogger(__name__)
13
+
14
+ __virtualname__ = "winshell"
15
+
16
+
17
+ def __virtual__():
18
+ # The core library needs paramiko/scp; surface a useful message when
19
+ # they are missing instead of failing later at ssh time
20
+ try:
21
+ import paramiko # pylint: disable=import-outside-toplevel,unused-import
22
+ import scp # pylint: disable=import-outside-toplevel,unused-import
23
+ except ImportError as exc:
24
+ return False, f"The winshell execution module cannot be loaded: {exc}"
25
+ return __virtualname__
26
+
27
+
28
+ def version():
29
+ """
30
+ Return the winshell package and deployed Salt-Env versions
31
+
32
+ CLI Example:
33
+
34
+ .. code-block:: bash
35
+
36
+ salt '*' winshell.version
37
+ """
38
+ return {"package": __version__, "env": saltext.winshell.core.ENV_VERSION}
File without changes
@@ -0,0 +1,16 @@
1
+ """
2
+ Salt state module for the agentless Windows shell.
3
+
4
+ No states are implemented yet - the winshell execution module and the
5
+ salt-ssh shell integration are the supported interfaces.
6
+ """
7
+
8
+ import logging
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+ __virtualname__ = "winshell"
13
+
14
+
15
+ def __virtual__():
16
+ return False, "The winshell state module does not provide any states yet"
@@ -0,0 +1 @@
1
+ __version__ = "1.0.1"
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: saltext-winshell
3
+ Version: 1.0.1
4
+ Summary: Salt Extension for interacting with windows via salt-ssh
5
+ Author-email: Norbert <jaegerbomber@gmail.com>
6
+ License: Apache Software License
7
+ Project-URL: Homepage, https://github.com/salt-extensions/saltext-winshell
8
+ Project-URL: Documentation, https://salt-extensions.github.io/saltext-winshell/
9
+ Project-URL: Source, https://github.com/salt-extensions/saltext-winshell
10
+ Project-URL: Tracker, https://github.com/salt-extensions/saltext-winshell/issues
11
+ Keywords: salt-extension
12
+ Platform: any
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Development Status :: 4 - Beta
22
+ Classifier: Intended Audience :: Developers
23
+ Classifier: License :: OSI Approved :: Apache Software License
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ Requires-Dist: salt>=3006
29
+ Requires-Dist: paramiko
30
+ Requires-Dist: scp
31
+ Provides-Extra: changelog
32
+ Requires-Dist: towncrier==25.8.0; extra == "changelog"
33
+ Provides-Extra: dev
34
+ Requires-Dist: nox[uv]!=2025.05.01,>=2024.3; extra == "dev"
35
+ Requires-Dist: pre-commit>=2.21.0; extra == "dev"
36
+ Provides-Extra: dev-extra
37
+ Requires-Dist: black==26.5.1; extra == "dev-extra"
38
+ Requires-Dist: isort==8.0.1; extra == "dev-extra"
39
+ Requires-Dist: coverage==7.14.3; extra == "dev-extra"
40
+ Provides-Extra: docs
41
+ Requires-Dist: sphinx; extra == "docs"
42
+ Requires-Dist: sphinx-prompt; extra == "docs"
43
+ Requires-Dist: sphinxcontrib-spelling; extra == "docs"
44
+ Requires-Dist: sphinx-copybutton; extra == "docs"
45
+ Requires-Dist: towncrier==25.8.0; extra == "docs"
46
+ Requires-Dist: sphinxcontrib-towncrier; extra == "docs"
47
+ Requires-Dist: myst_parser; extra == "docs"
48
+ Requires-Dist: furo; extra == "docs"
49
+ Requires-Dist: sphinx-inline-tabs; extra == "docs"
50
+ Provides-Extra: docsauto
51
+ Requires-Dist: sphinx-autobuild; extra == "docsauto"
52
+ Provides-Extra: lint
53
+ Requires-Dist: pylint==4.0.4; extra == "lint"
54
+ Provides-Extra: tests
55
+ Requires-Dist: pytest>=7.2.0; extra == "tests"
56
+ Requires-Dist: pytest-salt-factories>=1.0.0; extra == "tests"
57
+ Requires-Dist: pytest-instafail; extra == "tests"
58
+ Dynamic: license-file
59
+
60
+ # Salt Extension for Winshell
61
+
62
+ Salt Extension for interacting with windows via salt-ssh
63
+
64
+ This is a conversion of the [saltwinshell][saltwinshell] agentless Windows
65
+ module into a salt extension. When a salt-ssh roster entry carries
66
+ `winrm: True`, Salt (3006/3008) imports the `saltwinshell` module by name;
67
+ this package ships a `saltwinshell` compatibility module that re-exports the
68
+ implementation from the `winshell` package, so existing masters keep working
69
+ unpatched.
70
+
71
+ The implementation itself is now plain Python (the original package built its
72
+ core with Cython). The Salt-Env python environment zips
73
+ (`Salt-Env-<version>-AMD64/x86-Py3.zip`) are not carried in this repository -
74
+ they are expected under `/extra/salt/saltwinshell` on the salt master.
75
+
76
+
77
+ ## Security
78
+
79
+ If you discover a security vulnerability, please refer
80
+ to [Salt's security guide][security].
81
+
82
+ ## User Documentation
83
+
84
+ For setup and usage instructions, please refer to the
85
+ [User Documentation][docs].
86
+
87
+ ## Contributing
88
+
89
+ The winshell project welcomes contributions from anyone!
90
+
91
+ The [Salt Extensions guide][salt-extensions-guide] provides comprehensive instructions on all aspects
92
+ of Salt extension development, including [writing tests][writing-tests], [running tests][running-tests],
93
+ [writing documentation][writing-docs] and [rendering the docs][rendering-docs].
94
+
95
+ ### Quickstart
96
+
97
+ To get started contributing, first clone this repository (or your fork):
98
+
99
+ ```bash
100
+ # Clone the repo
101
+ git clone --origin upstream git@github.com:salt-extensions/saltext-winshell.git
102
+
103
+ # Change to the repo dir
104
+ cd winshell
105
+ ```
106
+
107
+ #### Automatic
108
+ If you have installed [direnv][direnv], copying the included `.envrc.example` to `.envrc` and
109
+ allowing it to run ensures a proper development environment is present and the virtual environment is active.
110
+
111
+ Without `direnv`, you can still run the automation explicitly:
112
+
113
+ ```bash
114
+ make dev # or python3 tools/initialize.py
115
+ source .venv/bin/activate
116
+ ```
117
+
118
+ #### Manual
119
+ Please follow the [first steps][first-steps], skipping the repository initialization and first commit.
120
+
121
+ ### Pull request
122
+
123
+ Always make changes in a feature branch:
124
+
125
+ ```bash
126
+ git switch -c my-feature-branch
127
+ ```
128
+
129
+ Please ensure you include a [news fragment](https://salt-extensions.github.io/salt-extension-copier/topics/documenting/changelog.html#procedure)
130
+ describing your changes. This is a requirement for all user-facing changes (bug fixes, new features),
131
+ with the exception of documentation changes.
132
+
133
+ To [submit a Pull Request][submitting-pr], you'll need a fork of this repository in
134
+ your own GitHub account. If you followed the instructions above,
135
+ set your fork as the `origin` remote now:
136
+
137
+ ```bash
138
+ git remote add origin git@github.com:<your_fork>.git
139
+ ```
140
+
141
+ Ensure you followed the [first steps][first-steps] and commit your changes, fixing any
142
+ failing `pre-commit` hooks. Then push the feature branch to your fork and submit a PR.
143
+
144
+ ### Ways to contribute
145
+
146
+ Contributions come in many forms, and they’re all valuable! Here are some ways you can help
147
+ without writing code:
148
+
149
+ * **Documentation**: Especially examples showing how to use this project
150
+ to solve specific problems.
151
+ * **Triaging issues**: Help manage [issues][issues] and participate in [discussions][discussions].
152
+ * **Reviewing [Pull Requests][PRs]**: We especially appreciate reviews using [Conventional Comments][comments].
153
+
154
+ You can also contribute by:
155
+
156
+ * Writing blog posts
157
+ * Sharing your experiences using Salt + Winshell
158
+ on social media
159
+ * Giving talks at conferences
160
+ * Publishing videos
161
+ * Engaging in IRC, Discord or email groups
162
+
163
+ Any of these things are super valuable to our community, and we sincerely
164
+ appreciate every contribution!
165
+
166
+ [security]: https://github.com/saltstack/salt/blob/master/SECURITY.md
167
+ [salt-extensions-guide]: https://salt-extensions.github.io/salt-extension-copier/
168
+ [writing-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/writing.html
169
+ [running-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/running.html
170
+ [writing-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/writing.html
171
+ [rendering-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/building.html
172
+ [first-steps]: https://salt-extensions.github.io/salt-extension-copier/topics/creation.html#initialize-the-python-virtual-environment
173
+ [submitting-pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork
174
+ [direnv]: https://direnv.net
175
+ [issues]: https://github.com/salt-extensions/saltext-winshell/issues
176
+ [PRs]: https://github.com/salt-extensions/saltext-winshell/pulls
177
+ [discussions]: https://github.com/salt-extensions/saltext-winshell/discussions
178
+ [comments]: https://conventionalcomments.org/
179
+ [docs]: https://salt-extensions.github.io/saltext-winshell/
@@ -0,0 +1,16 @@
1
+ saltext/winshell/__init__.py,sha256=-Y5ing-717L5fQKDKZBFRauFt8qV-C-K6BL8O7lCPzE,938
2
+ saltext/winshell/core.py,sha256=-Lx15N8z0KdyIWgxZchiGSGdUluAXu3u6jedbNpxkPY,12348
3
+ saltext/winshell/env_version.py,sha256=9Xexab-xw_ELayPCumAJcGK8D_kjE4YCxfDNK8-jeZc,365
4
+ saltext/winshell/version.py,sha256=d4QHYmS_30j0hPN8NmNPnQ_Z0TphDRbu4MtQj9cT9e8,22
5
+ saltext/winshell/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ saltext/winshell/modules/winshell_mod.py,sha256=iirv8GJLqctvABJb6-Olg0Yp4Hetz65lIKP-uBdTcEU,996
7
+ saltext/winshell/states/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ saltext/winshell/states/winshell_mod.py,sha256=qaGzv4nTRrlpqoqm_jTGgDViVebVb04XriKwea2SKD8,367
9
+ saltext_winshell-1.0.1.dist-info/licenses/LICENSE,sha256=N3BrLCS5BoktqKUWDHjH9I1lhX1kEirCPOQQ3VlR4RE,11337
10
+ saltext_winshell-1.0.1.dist-info/licenses/NOTICE,sha256=wFoWcna9ydt7bcx9p9157TbgedI4HcRHCHh8HI7Z2F8,452
11
+ saltwinshell/__init__.py,sha256=CqtgCjlaikBB61pXn70csptsyyyn3EyySUlnmtuTx3I,1154
12
+ saltext_winshell-1.0.1.dist-info/METADATA,sha256=zwnAKs_4wvPLQELuYZbO_Hxook6Jd_rbkXivLj7cz9k,7353
13
+ saltext_winshell-1.0.1.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
14
+ saltext_winshell-1.0.1.dist-info/entry_points.txt,sha256=Hu_cSG2FjLbp7zHQ1wJ_y3JuOIqjnuZydxhkibkFWbQ,50
15
+ saltext_winshell-1.0.1.dist-info/top_level.txt,sha256=ayn69Y65o0zP2AroV4AkHDFF0OL4wb3xeFCJUzjbFDw,21
16
+ saltext_winshell-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1,2 @@
1
+ [salt.loader]
2
+ saltext.winshell = saltext.winshell
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Norbert
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ Salt Extension Modules for Winshell
2
+ Copyright 2026 Norbert
3
+
4
+ This product is licensed to you under the Apache 2.0 license (the "License").
5
+ You may not use this product except in compliance with the Apache 2.0 License.
6
+
7
+ This product may include a number of subcomponents with separate copyright
8
+ notices and license terms. Your use of these subcomponents is subject to the
9
+ terms and conditions of the subcomponent's license, as noted in the LICENSE
10
+ file.
@@ -0,0 +1,2 @@
1
+ saltext
2
+ saltwinshell
@@ -0,0 +1,38 @@
1
+ """
2
+ Compatibility shim for Salt's agentless Windows support.
3
+
4
+ Salt (3006/3008) imports this module by its original name whenever a
5
+ roster entry carries ``winrm: True``::
6
+
7
+ salt/client/ssh/shell.py: import saltwinshell
8
+ salt/client/ssh/__init__.py: import saltwinshell
9
+
10
+ The implementation now lives in the :mod:`winshell` package; this shim
11
+ re-exports the interface Salt calls so existing masters keep working
12
+ without patching Salt.
13
+ """
14
+
15
+ # Copyright 2021 VMware, Inc.
16
+ # SPDX-License-Identifier: Apache-2.0
17
+
18
+ from saltext.winshell.core import SSH_PS_SHIM # noqa: F401
19
+ from saltext.winshell.core import Connection
20
+ from saltext.winshell.core import Shell
21
+ from saltext.winshell.core import call_python
22
+ from saltext.winshell.core import deploy_python
23
+ from saltext.winshell.core import gen_shim
24
+ from saltext.winshell.core import get_target_shim_file
25
+ from saltext.winshell.core import set_winvars
26
+ from saltext.winshell.env_version import ENV_VERSION # noqa: F401
27
+
28
+ __all__ = [
29
+ "SSH_PS_SHIM",
30
+ "Shell",
31
+ "Connection",
32
+ "call_python",
33
+ "deploy_python",
34
+ "gen_shim",
35
+ "get_target_shim_file",
36
+ "set_winvars",
37
+ "ENV_VERSION",
38
+ ]