8000 ENT-8118: Added os_version_minor sys variable by victormlg · Pull Request #5777 · cfengine/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ENT-8118: Added os_version_minor sys variable 8000 #5777

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

victormlg
Copy link
Contributor
@victormlg victormlg 8000 commented Apr 23, 2025

No description provided.

Copy link

Marking this PR as stale due to inactivity; it will be closed in 7 days.

@github-actions github-actions bot added the stale Pull requests with no recent activity label May 26, 2025
Copy link
Contributor
@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀 Would be nice if you could add an acceptance test. You can use os_version_major.cf as inspiration.

@github-actions github-actions bot removed the stale Pull requests with no recent activity label May 27, 2025
@victormlg victormlg force-pushed the os_version_minor branch 2 times, most recently from b01c5ad to 77e6a40 Compare June 10, 2025 14:40
@victormlg victormlg requested a review from larsewi June 10, 2025 15:06
@larsewi larsewi requested a review from jakub-nt June 11, 2025 07:16
Copy link
Contributor
@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will have to derive os_version_minor from somewhere else on Windows. We don't want it to be "Unknown" on supported platforms.

@victormlg
Copy link
Contributor Author

@cf-bottom jenkins, please

@cf-bottom
Copy link

@larsewi
Copy link
Contributor
larsewi commented Jun 24, 2025

Build for Windows (no tests)
Build Status
Packages here

@olehermanse olehermanse requested a review from larsewi June 24, 2025 13:50
@victormlg
Copy link
Contributor Author

I tested sys.os_version_minor on a win-2019-dev-v8 ami and got the following:

image

It looks like it is working. It's difficult to make sense of a "os version minor" on this type of machine. Here is the version of the OS that I got by running winver

image

@victormlg victormlg requested a review from olehermanse June 24, 2025 14:29
@olehermanse
Copy link
Member

That's okay, I guess. From your screenshot I would kind of expect the minor version to be 1809.

Copy link
Contributor
@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @victormlg 🚀 Only some smaller comments. Not sure what to do about Windows. Maybe $(sys.os_version_minor) -> Unknown is okey?

@olehermanse olehermanse requested a review from larsewi June 26, 2025 17:01
Copy link
Contributor
@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀 The fixes to the C code should be amended to the first commit though

@larsewi
Copy link
Contributor
larsewi commented Jun 27, 2025

@cf-bottom Jenkins with exotics please :)

@cf-bottom
Copy link

Copy link
Member
@olehermanse olehermanse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash both commits into 1 commit (or amend the first commit with the C code changes so the second commit is only the test).

@victormlg victormlg force-pushed the os_version_minor branch 2 times, most recently from 3a2708b to a2b616f Compare June 30, 2025 09:43
@victormlg victormlg requested review from olehermanse and larsewi June 30, 2025 10:38
Copy link
Contributor
@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acceptance test failed on redhat 7

FAIL (UNEXPECTED FAILURE) ./01_vars/01_basic/os_version_minor.cf

See log below

R: Version number extracted from class: centos_7_9
R: Defined classes: centos
R: Defined classes: feature_tls_1_0
R: Defined classes: GMT_Min31
R: Defined classes: ipv4_192_168
R: Defined classes: feature_copyfrom_restrict_keys
R: Defined classes: Lcycle_0
R: Defined classes: GMT_Yr2025
R: Defined classes: feature_def
R: Defined classes: Hr08_Q3
R: Defined classes: cfengine_3_27
R: Defined classes: feature_yaml
R: Defined classes: ipv4_192_168_121
R: Defined classes: June
R: Defined classes: error_mode
R: Defined classes: x86_64
R: Defined classes: warning_mode
R: Defined classes: net_iface_lo
R: Defined classes: GMT_Lcycle_0
R: Defined classes: ipv4_127_0
R: Defined classes: cfengine_3
R: Defined classes: GMT_Morning
R: Defined classes: feature_def_json_preparse
R: Defined classes: GMT_Friday
R: Defined classes: feature_host_specific_data_load
R: Defined classes: feature_host
R: Defined classes: GMT_Hr08
R: Defined classes: linux
R: Defined classes: 1_cpusocket
R: Defined classes: centos_7_x64_j2
R: Defined classes: GMT_Min30_35
R: Defined classes: redhat
R: Defined classes: DEBUG
R: Defined classes: systemd
R: Defined classes: GMT_June
R: Defined classes: compiled_on_linux_gnu
R: Defined classes: feature_host_specific_data
R: Defined classes: feature
R: Defined classes: cfengine
R: Defined classes: mac_52_54_00_0c_ef_5c
R: Defined classes: cfengine_3_27_0a_f77177768
R: Defined classes: 64_bit
R: Defined classes: linux_3_10_0_1127_el7_x86_64
R: Defined classes: notice_mode
R: Defined classes: feature_curl
R: Defined classes: feature_tls_1_3
R: Defined classes: linux_x86_64_3_10_0_1127_el7_x86_64__1_SMP_Tue_Mar_31_23_36_51_UTC_2020
R: Defined classes: feature_tls_1
R: Defined classes: agent
R: Defined classes: GMT_Day27
R: Defined classes: ipv4_192_168_121_34
R: Defined classes: 127_0_0_1
R: Defined classes: Friday
R: Defined classes: any
R: Defined classes: feature_copyfrom
R: Defined classes: feature_copyfrom_restrict
R: Defined classes: ipv4_gw_192_168_121_1
R: Defined classes: centos_7_9
R: Defined classes: centos_7
R: Defined classes: linux_x86_64_3_10_0_1127_el7_x86_64
R: Defined classes: ipv4_127_0_0_1
R: Defined classes: cfengine_3_27_0a
R: Defined classes: GMT_Hr8
R: Defined classes: net_iface_eth0
R: Defined classes: ipv4_192
R: Defined classes: feature_xml
R: Defined classes: 1_cpu
R: Defined classes: Day27
R: Defined classes: inform_mode
R: Defined classes: 192_168_121_34
R: Defined classes: linux_x86_64
R: Defined classes: Min30_35
R: Defined classes: ipv4_127_0_0
R: Defined classes: feature_def_json
R: Defined classes: feature_tls_1_1
R: Defined classes: feature_host_specific
R: Defined classes: Hr8
R: Defined classes: GMT_Q3
R: Defined classes: feature_pam
R: Defined classes: Morning
R: Defined classes: feature_tls
R: Defined classes: AUTO
R: Defined classes: community_edition
R: Defined classes: ipv4_127
R: Defined classes: Min31
R: Defined classes: Yr2025
R: Defined classes: Q3
R: Defined classes: GMT_Hr08_Q3
R: Defined classes: feature_tls_1_2
R: Defined classes: Hr08
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf Expected: 9
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf Found: Unknown
R: /home/jenkins/workspace/testing-pr/label/PACKAGES_x86_64_linux_redhat_7/cfengine-3.27.0a.f77177768/tests/acceptance/./01_vars/01_basic/os_version_minor.cf FAIL

@victormlg
Copy link
Contributor Author

@cf-bottom Jenkins with exotics please :)

@cf-bottom
Copy link

@victormlg
Copy link
Contributor Author

@cf-bottom Jenkins with exotics please :)

@cf-bottom
Copy link

if (major != -1 && minor != -2)
{
char version_id[CF_MAXVARSIZE];
strcat(version_id, strmajor);

Check failure

Code scanning / CodeQL

Unbounded write Critical

This 'call to strcat' with input from
string read by fgets
may overflow the destination.
char version_id[CF_MAXVARSIZE];
strcat(version_id, strmajor);
strcat(version_id, ".");
strcat(version_id, strminor);

Check failure

Code scanning / CodeQL

Unbounded write Critical

This 'call to strcat' with input from
string read by fgets
may overflow the destination.
victormlg added 2 commits July 7, 2025 14:57
Ticket: ENT-8118
Changelog: Title
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0