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

Use YAML.safe_load_file instead of YAML.safe_load #939

Merged
merged 2 commits into from
Dec 18, 2023
Merged

Conversation

imobachgs
Copy link
Contributor

Problem

For some reason that I have not been able to find, I am facing a problem
when loading the products definition:

bundler: failed to load command: bin/agamactl (bin/agamactl)
/usr/lib64/ruby/3.2.0/psych/parser.rb:62:in `_native_parse': (<unknown>): control characters are not allowed at line 1 column 1 (Psych::SyntaxError)
	from /usr/lib64/ruby/3.2.0/psych/parser.rb:62:in `parse'
	from /usr/lib64/ruby/3.2.0/psych.rb:455:in `parse_stream'
	from /usr/lib64/ruby/3.2.0/psych.rb:399:in `parse'
	from /usr/lib64/ruby/3.2.0/psych.rb:323:in `safe_load'
	from /home/suse/agama/service/lib/agama/product_reader.rb:63:in `load_file'
	from /home/suse/agama/service/lib/agama/product_reader.rb:50:in `block in load_products'
	from /home/suse/agama/service/lib/agama/product_reader.rb:48:in `each'
	from /home/suse/agama/service/lib/agama/product_reader.rb:48:in `each_with_object'
	from /home/suse/agama/service/lib/agama/product_reader.rb:48:in `load_products'
	from /home/suse/agama/service/lib/agama/config.rb:102:in `products'
	from /home/suse/agama/service/lib/agama/config.rb:83:in `data'
	from /home/suse/agama/service/lib/agama/config.rb:139:in `merge'
	from /home/suse/agama/service/lib/agama/config_reader.rb:89:in `block in config'
	from /home/suse/agama/service/lib/agama/config_reader.rb:89:in `each'
	from /home/suse/agama/service/lib/agama/config_reader.rb:89:in `config'
	from /home/suse/agama/service/lib/agama/config.rb:43:in `load'
	from /home/suse/agama/service/lib/agama/dbus/service_runner.rb:70:in `config'
	from /home/suse/agama/service/lib/agama/dbus/service_runner.rb:82:in `build_service'
	from /home/suse/agama/service/lib/agama/dbus/service_runner.rb:50:in `run'
	from bin/agamactl:65:in `start_service'
	from bin/agamactl:107:in `<top (required)>'

It only happens when running Agama under a root session. Funny enough, it did not happen when using sudo.

Solution

Use YAML.safe_load_file (instead of File.read + YAML.safe_load) fixes the issue for me.

Testing

  • Tested manually

service/lib/agama/product_reader.rb Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Dec 18, 2023

Coverage Status

coverage: 74.743% (+0.02%) from 74.724%
when pulling 4506d86 on safe-load-file
into 8b04ffc on master.

@imobachgs imobachgs merged commit c14ce99 into master Dec 18, 2023
6 checks passed
@imobachgs imobachgs deleted the safe-load-file branch December 18, 2023 17:27
@imobachgs imobachgs mentioned this pull request Dec 21, 2023
imobachgs added a commit that referenced this pull request Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants