@@ -3782,6 +3782,75 @@ static void SysOsVersionMajor(EvalContext *ctx)
3782
3782
free (flavor );
3783
3783
}
3784
3784
3785
+ /*****************************************************************************/
3786
+
3787
+ static const char * OSReleaseGet (EvalContext * ctx , const char * field )
3788
+ {
3789
+ #ifndef __MINGW32__
3790
+ DataType type_out ;
3791
+ const JsonElement * os_rel = EvalContextVariableGetSpecial (
3792
+ ctx , SPECIAL_SCOPE_SYS , "os_release" , & type_out );
3793
+
3794
+ if (type_out != CF_DATA_TYPE_CONTAINER )
3795
+ {
3796
+ return NULL ;
3797
+ }
3798
+ const JsonElement * child = JsonObjectGet (os_rel , field );
3799
+ if (child == NULL )
3800
+ {
3801
+ return NULL ;
3802
+ }
3803
+ const char * result = JsonPrimitiveGetAsString (child );
3804
+ return result ;
3805
+
3806
+ #else
3807
+
3808
+ Log (LOG_LEVEL_ERR , "os-release is not defined on Windows" )
3809
+ return NULL ;
3810
+
3811
+ #endif
3812
+ }
3813
+
3814
+ static void SysOSVersionMinor (EvalContext * ctx )
3815
+ {
3816
+ const char * version_id = OSReleaseGet (ctx , "VERSION_ID" );
3817
+ const char * name = OSReleaseGet (ctx , "NAME" );
3818
+
3819
+ char * minor ;
3820
+ if (version_id != NULL )
3821
+ {
3822
+ Item * version_tuple = SplitString (version_id , '.' );
3823
+
3824
+ if (version_tuple != NULL )
3825
+ {
3826
+ if (name != NULL && (StringStartsWith (name , "solaris" ) || StringStartsWith (name , "sunos" )))
3827
+ {
3828
+ minor = version_tuple -> name ;
3829
+ }
3830
+ else if (version_tuple -> next != NULL )
3831
+ {
3832
+ minor = version_tuple -> next -> name ;
3833
+ }
3834
+ }
3835
+ free (version_tuple );
3836
+ }
3837
+
3838
+ if (NULL_OR_EMPTY (minor ))
3839
+ {
3840
+ EvalContextVariablePutSpecial (ctx , SPECIAL_SCOPE_SYS ,
3841
+ "os_version_minor" , "Unknown" ,
3842
+ CF_DATA_TYPE_STRING , "source=agent" );
3843
+ }
3844
+ else
3845
+ {
3846
+ EvalContextVariablePutSpecial (ctx , SPECIAL_SCOPE_SYS ,
3847
+ "os_version_minor" , minor ,
3848
+ CF_DATA_TYPE_STRING ,
3849
+ "source=agent,derived-from=os_release" );
3850
+ }
3851
+ }
3852
+
3853
+
3785
3854
/*****************************************************************************/
3786
3855
3787
3856
void DetectEnvironment (EvalContext * ctx )
@@ -3796,4 +3865,5 @@ void DetectEnvironment(EvalContext *ctx)
3796
3865
GetDefVars (ctx );
3797
3866
SysOSNameHuman (ctx );
3798
3867
SysOsVersionMajor (ctx );
3868
+ SysOSVersionMinor (ctx );
3799
3869
}
0 commit comments