#4030 sss_obfuscate fails to rewriting comments
Closed: Fixed 10 months ago by pbrezina. Opened a year ago by arielb.

at the time of rewriting the configuration file and there are byte strings that need to be encoded, it fails.

sss_obfuscate -d domain
Enter password:
Re-enter password:
Traceback (most recent call last):
File "/usr/sbin/sss_obfuscate", line 122, in <module>
ret = main()
File "/usr/sbin/sss_obfuscate", line 112, in main
sssdconfig.write()
File "/usr/lib/python2.7/site-packages/SSSDConfig/init.py", line 1527, in write
output = self.dump(self.opts).encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 906: ordinal not in range(128)
user@server->/etc/sssd>ls -ltrs
total 0
0 -rwx------. 1 root root 0 Jun 24 10:47 sssd.conf

sssd.conf

... está en enforcing


at the time of rewriting the configuration file and there are byte strings that need to be encoded, it fails.

Why do you need to use bytes ? Or is the issue with non utf-8 encondings ?
IMHO the simplest would be to attach problematic sssd.conf.

thanks for your comments, you're right, it's my mistake,
fails trying to rewrite this:

'# el selinux lo bloquea cuando está en enforcing'

with the word 'está'

I'm sorry I cannot reproduce it:

sh-5.0# wget https://pagure.io/SSSD/sssd/issue/raw/files/3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
--2019-06-24 21:30:50--  https://pagure.io/SSSD/sssd/issue/raw/files/3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
Resolving pagure.io (pagure.io)... 152.19.134.147, 2605:bc80:3010:600:dead:beef:cafe:fed8
Connecting to pagure.io (pagure.io)|152.19.134.147|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1116 (1.1K) [text/plain]
Saving to: ‘3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf’

3d31deed24c69b9479c 100%[===================>]   1.09K  --.-KB/s    in 0s      

2019-06-24 21:30:51 (45.9 MB/s) - ‘3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf’ saved [1116/1116]

sh-5.0# md5sum 3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
91b67a56acac4ee3d8f2aa2ba5f938eb  3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf

sh-5.0# echo -e "123" | sss_obfuscate -s -d default -f 3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf

sh-5.0# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"

well, I tried the same steps

root@server->/tmp>wget https://pagure.io/SSSD/sssd/issue/raw/files/3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
--2019-06-24 15:46:58-- https://pagure.io/SSSD/sssd/issue/raw/files/3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
Connecting to IP:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 1116 (1.1K) [text/plain]
Saving to: ‘3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf’

100%[==================================================================================>] 1,116 --.-K/s in 0s

2019-06-24 15:47:00 (25.3 MB/s) - ‘3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf’ saved [1116/1116]

root@server->/tmp>md5sum 3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
69ee06819a3a0df216ebe4d1fc80bab7 3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
root@server->/tmp>echo -e "123" | sss_obfuscate -s -d default -f 3d31deed24c69b9479ce96d79c9a8e70ec37b20c03b4f6e557b238f99a91f917-sssd.conf
Traceback (most recent call last):
File "/usr/sbin/sss_obfuscate", line 122, in <module>
ret = main()
File "/usr/sbin/sss_obfuscate", line 112, in main
sssdconfig.write()
File "/usr/lib/python2.7/site-packages/SSSDConfig/init.py", line 1527, in write
output = self.dump(self.opts).encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 748: ordinal not in range(128)
root@server->/tmp>locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Will this be helpful?

python
Python 2.7.5 (default, Sep 12 2018, 05:31:16)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import locale
loc = locale.getlocale()
print loc
(None, None)

Hi,

it looks like the issue is only present in python-2. My tests with python-3 are working without issues. Unfortunately your patch in https://github.com/SSSD/sssd/pull/836 breaks python-3, please see my comment there.

bye,
Sumit

Hi,
it looks like the issue is only present in python-2. My tests with python-3 are working without issues. Unfortunately your patch in https://github.com/SSSD/sssd/pull/836 breaks python-3, please see my comment there.
bye,
Sumit

Hi sbose.
Thanks for your comments.
Considering this link, I made the change in a general way, it applies to the complete file.

https://portingguide.readthedocs.io/en/latest/strings.html#file-i-o

  • master
    • c53311e - sss_obfuscate: do not fail if sssd.conf contains non-ascii characters

Metadata Update from @pbrezina:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

10 months ago

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/5000

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Login to comment on this ticket.

Metadata
Attachments 1
Attached a year ago View Comment