Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't copy certain files after upgarde to salt-3002.7 #61008

Open
gotsmth opened this issue Oct 6, 2021 · 9 comments
Open

[BUG] Can't copy certain files after upgarde to salt-3002.7 #61008

gotsmth opened this issue Oct 6, 2021 · 9 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors Core relates to code central or existential to Salt Regression The issue is a bug that breaks functionality known to work in previous releases. severity-high 2nd top severity, seen by most users, causes major problems
Milestone

Comments

@gotsmth
Copy link

gotsmth commented Oct 6, 2021

Hey.

I have some problems with salt-cp after upgrade to latest 3002 version.
Some type of files are crashing python script, fe. - [master ~]0$ sudo salt-cp 'host' tree.bin /tmp :

[ERROR ] An un-handled exception was caught by salt's global exception handler:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Traceback (most recent call last):
File "/usr/bin/salt-cp", line 11, in
load_entry_point('salt==3002.7', 'console_scripts', 'salt-cp')()
File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 429, in salt_cp
client.run()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 53, in run
cp_.run()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 145, in run
ret = self.run_oldstyle()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 153, in run_oldstyle
arg = [self._load_files(), self.opts["dest"]]
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 128, in _load_files
files.update(self.file_dict(fn))
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 117, in file_dict
data = fp
.read()
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self.buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Traceback (most recent call last):
File "/usr/bin/salt-cp", line 11, in
load_entry_point('salt==3002.7', 'console_scripts', 'salt-cp')()
File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 429, in salt_cp
client.run()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 53, in run
cp
.run()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 145, in run
ret = self.run_oldstyle()
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 153, in run_oldstyle
arg = [self._load_files(), self.opts["dest"]]
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 128, in _load_files
files.update(self.file_dict(fn))
File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 117, in file_dict
data = fp
.read()
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)

All was ok before upgrade, current version:
Salt Version:
Salt: 3002.7

Dependency Versions:
cffi: Not Installed
cherrypy: 5.6.0
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
M2Crypto: 0.33.0
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: 1.3.12
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Aug 13 2020, 07:46:32)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 17.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4

System Versions:
dist: rhel 7.9 Maipo
locale: UTF-8
machine: x86_64
release: 3.10.0-1160.42.2.el7.x86_64
system: Linux
version: Red Hat Enterprise Linux Server 7.9 Maipo`

Any idea?
Latest RHEL7.9 OS without EPEL packages.

@gotsmth gotsmth added Bug broken, incorrect, or confusing behavior needs-triage labels Oct 6, 2021
@OrangeDog
Copy link
Contributor

OrangeDog commented Oct 6, 2021

I'm guessing that the file you're trying to copy is in UTF-16 and starts with the bytes FFEF?

Salt shouldn't be trying to decode any files that it's copying, if if it does it shouldn't be assuming they're all UTF-8.

I don't see any workaround, other than changing the file before copying, and then changing it back afterwards on all the minions.

What version did you upgrade from?

@OrangeDog OrangeDog added Regression The issue is a bug that breaks functionality known to work in previous releases. bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors Core relates to code central or existential to Salt severity-high 2nd top severity, seen by most users, causes major problems and removed needs-triage labels Oct 6, 2021
@OrangeDog OrangeDog added this to the Approved milestone Oct 6, 2021
@OrangeDog OrangeDog added the info-needed waiting for more info label Oct 6, 2021
@gotsmth
Copy link
Author

gotsmth commented Oct 6, 2021

master> cat tree.bin | hexdump -C | head
00000000  ff d8 ff e0 00 10 4a 46  49 46 00 01 02 01 00 48  |......JFIF.....H|
00000010  00 48 00 00 ff ed 02 0e  50 68 6f 74 6f 73 68 6f  |.H......Photosho|
00000020  70 20 33 2e 30 00 38 42  49 4d 04 04 00 00 00 00  |p 3.0.8BIM......|
00000030  00 49 1c 02 00 00 02 00  02 1c 02 78 00 1d 47 6f  |.I.........x..Go|
00000040  76 2e 20 47 65 6f 72 67  65 20 57 2e 20 42 75 73  |v. George W. Bus|
00000050  68 20 28 52 2d 54 65 78  61 73 29 1c 02 37 00 08  |h (R-Texas)..7..|
00000060  31 39 39 39 30 38 31 39  1c 02 19 00 05 54 65 78  |19990819.....Tex|
00000070  61 73 1c 02 19 00 04 42  75 73 68 00 38 42 49 4d  |as.....Bush.8BIM|
00000080  03 e9 00 00 00 00 00 78  00 03 00 00 00 48 00 48  |.......x.....H.H|
00000090  00 00 00 00 02 d8 02 28  ff e1 ff e2 02 f9 02 46  |.......(.......F|

@gotsmth
Copy link
Author

gotsmth commented Oct 6, 2021

Ah sorry - from 3002.6 up to 3002.7:

`master> sudo cat /var/log/yum.log | grep master
Mar 30 08:37:46 Updated: salt-master-3002.6-1.el7.noarch
Sep 08 08:00:14 Updated: salt-master-3002.7-1.el7.noarch
`

@gotsmth
Copy link
Author

gotsmth commented Oct 6, 2021

Another example, other file type -> .p12:

`master> sudo salt-cp 'host' keystore.p12 /tmp
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1: invalid start byte
Traceback (most recent call last):
  File "/usr/bin/salt-cp", line 11, in <module>
    load_entry_point('salt==3002.7', 'console_scripts', 'salt-cp')()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 429, in salt_cp
    client.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 53, in run
    cp_.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 145, in run
    ret = self.run_oldstyle()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 153, in run_oldstyle
    arg = [self._load_files(), self.opts["dest"]]
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 128, in _load_files
    files.update(self._file_dict(fn_))
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 117, in _file_dict
    data = fp_.read()
  File "/usr/lib64/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1: invalid start byte
Traceback (most recent call last):
  File "/usr/bin/salt-cp", line 11, in <module>
    load_entry_point('salt==3002.7', 'console_scripts', 'salt-cp')()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 429, in salt_cp
    client.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 53, in run
    cp_.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 145, in run
    ret = self.run_oldstyle()
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 153, in run_oldstyle
    arg = [self._load_files(), self.opts["dest"]]
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 128, in _load_files
    files.update(self._file_dict(fn_))
  File "/usr/lib/python3.6/site-packages/salt/cli/cp.py", line 117, in _file_dict
    data = fp_.read()
  File "/usr/lib64/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 1: invalid start byte
master>
master> cat keystore.p12 | hexdump -C | head
00000000  30 82 1b d7 02 01 03 30  82 1b 93 06 09 2a 86 48  |0......0.....*.H|
00000010  86 f7 0d 01 07 01 a0 82  1b 84 04 82 1b 80 30 82  |..............0.|
00000020  1b 7c 30 82 06 0d 06 09  2a 86 48 86 f7 0d 01 07  |.|0.....*.H.....|
00000030  01 a0 82 05 fe 04 82 05  fa 30 82 05 f6 30 82 05  |.........0...0..|
00000040  f2 06 0b 2a 86 48 86 f7  0d 01 0c 0a 01 02 a0 82  |...*.H..........|
00000050  04 fe 30 82 04 fa 30 1c  06 0a 2a 86 48 86 f7 0d  |..0...0...*.H...|
00000060  01 0c 01 03 30 0e 04 08  08 5f 77 80 96 6f 8c 2d  |....0...._w..o.-|
00000070  02 02 07 d0 04 82 04 d8  8e cb ed e6 ea 1d 53 d2  |..............S.|
00000080  bc 26 ae 98 41 90 8d 13  a1 eb ca 44 15 3f 64 65  |.&..A......D.?de|
00000090  4e af c0 7e 21 b9 89 c2  4f 93 ab d9 7a 20 d2 16  |N..~!...O...z ..|
`

@OrangeDog
Copy link
Contributor

Oh right, they're not even text files.

3002.7 only had three changes in it.
Perhaps it's the CVE-2021-21996 one, and you need to clear some caches?

@OrangeDog OrangeDog removed the info-needed waiting for more info label Oct 6, 2021
@gotsmth
Copy link
Author

gotsmth commented Oct 6, 2021

I used clear_cache and sync_all on minions.
Hosts are after reboot - what do i need to clear more?
Some /var/cache/salt* on master host?

This is first time when i need to clear some cache after upgrade, no problems up to .7.

@OrangeDog
Copy link
Contributor

I'm afraid I don't know. I've looked at the .6 -> .7 diffs and don't see how it could have caused this.
Have you tried 3003.3 or 3004rc1 in case it's already fixed?

@gotsmth
Copy link
Author

gotsmth commented Oct 6, 2021

I can't do an upgrade at this moment.
We will find some workaround with other tools.

Okey, thanks.

@OrangeDog
Copy link
Contributor

This may be a duplicate of #53490, which says adding --chunked should make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior bytes-vs-strings py2 vs py3 bytes vs strings encode/decode errors Core relates to code central or existential to Salt Regression The issue is a bug that breaks functionality known to work in previous releases. severity-high 2nd top severity, seen by most users, causes major problems
Projects
None yet
Development

No branches or pull requests

3 participants