Hello community, here is the log from the commit of package cmpi-bindings for openSUSE:Factory checked in at 2013-10-19 11:10:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cmpi-bindings (Old) and /work/SRC/openSUSE:Factory/.cmpi-bindings.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "cmpi-bindings" Changes: -------- --- /work/SRC/openSUSE:Factory/cmpi-bindings/cmpi-bindings.changes 2013-09-26 14:43:14.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.cmpi-bindings.new/cmpi-bindings.changes 2013-10-19 11:14:35.000000000 +0200 @@ -1,0 +2,13 @@ +Wed Oct 9 11:56:48 UTC 2013 - kkaempf@suse.com + +- Update to 0.9.7 + Catch and log Ruby exceptions caused by invoke method type + conversions. + +------------------------------------------------------------------- +Wed Oct 9 08:17:54 UTC 2013 - kkaempf@suse.com + +- Update to 0.9.6 + Return correct status for failed method invocation in Ruby. + +------------------------------------------------------------------ Old: ---- cmpi-bindings-0.9.5.tar.bz2 New: ---- cmpi-bindings-0.9.7.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cmpi-bindings.spec ++++++ --- /var/tmp/diff_new_pack.gmyfrr/_old 2013-10-19 11:14:37.000000000 +0200 +++ /var/tmp/diff_new_pack.gmyfrr/_new 2013-10-19 11:14:37.000000000 +0200 @@ -20,7 +20,7 @@ Url: http://github.com/kkaempf/cmpi-bindings Name: cmpi-bindings -Version: 0.9.5 +Version: 0.9.7 Release: 0 Summary: Adapter to write and run CMPI-type CIM providers License: BSD-3-Clause and CPL-1.0 ++++++ cmpi-bindings-0.9.5.tar.bz2 -> cmpi-bindings-0.9.7.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/README new/cmpi-bindings-0.9.7/README --- old/cmpi-bindings-0.9.5/README 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/README 2013-09-26 09:08:40.000000000 +0200 @@ -58,9 +58,9 @@ ------------ cmake 2.4 or later CMPI header files, e.g. from sblim-cmpi-devel - python interface requires: python-devel, pywbem-0.7.0 - perl interface requires: ? - ruby interface requires: ruby-1.8 ruby-devel-1.8 + Python interface requires: python-devel, pywbem-0.7.0 + Perl interface requires: perl + Ruby interface requires: ruby ruby-devel (1.8, 1.9, or 2.0) Build ----- @@ -81,7 +81,7 @@ For each language, there is a test/<language> directory. Within that directory, there should be test providers, scripts that use the test providers, and scripts to register the mofs and providers with - cimoms. + CIMOMs. Testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/VERSION.cmake new/cmpi-bindings-0.9.7/VERSION.cmake --- old/cmpi-bindings-0.9.5/VERSION.cmake 2013-04-11 17:13:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/VERSION.cmake 2013-10-09 13:56:42.000000000 +0200 @@ -1,3 +1,3 @@ SET(VERSION_MAJOR "0") SET(VERSION_MINOR "9") -SET(VERSION_PATCH "5") +SET(VERSION_PATCH "7") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/package/cmpi-bindings.changes new/cmpi-bindings-0.9.7/package/cmpi-bindings.changes --- old/cmpi-bindings-0.9.5/package/cmpi-bindings.changes 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/package/cmpi-bindings.changes 2013-10-09 13:57:55.000000000 +0200 @@ -1,4 +1,22 @@ ------------------------------------------------------------------- +Wed Oct 9 11:56:48 UTC 2013 - kkaempf@suse.com + +- Update to 0.9.7 + Catch and log Ruby exceptions caused by invoke method type + conversions. + +------------------------------------------------------------------- +Wed Oct 9 08:17:54 UTC 2013 - kkaempf@suse.com + +- Update to 0.9.6 + Return correct status for failed method invocation in Ruby. + +------------------------------------------------------------------ +Thu Sep 26 07:18:08 UTC 2013 - kkaempf@suse.com + +- Drop explicit ruby(abi) requires (bnc#842433) + +------------------------------------------------------------------- Thu Apr 11 13:52:08 UTC 2013 - kkaempf@suse.com - Update to 0.9.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/package/cmpi-bindings.spec.in new/cmpi-bindings-0.9.7/package/cmpi-bindings.spec.in --- old/cmpi-bindings-0.9.5/package/cmpi-bindings.spec.in 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/package/cmpi-bindings.spec.in 2013-10-09 11:39:26.000000000 +0200 @@ -124,16 +124,6 @@ Group: Development/Languages/Ruby # for the debug package. we dont use debug_package_requires here as it would enforce to install both packages. Provides: %{name} = %{version}-%{release} -%if 0%{?fedora} + 0%{?rhel_version} + 0%{?centos_version} > 0 -Requires: ruby(abi) = 1.8 -%endif -%if 0%{?suse_version} > 1110 -%if 0%{?suse_version} > 1210 -Requires: ruby(abi) = 1.9.1 -%else -Requires: ruby(abi) = 1.8 -%endif -%endif %if 0%{?ruby_sitelib} == 0 %{!?ruby_sitelib: %global ruby_sitelib %(ruby -r rbconfig -e 'vd = RbConfig::CONFIG["vendorlibdir"]; print(vd ? vd : RbConfig::CONFIG["sitelibdir"])')} %{!?ruby_sitearch: %global ruby_sitearch %(ruby -r rbconfig -e 'vad = RbConfig::CONFIG["vendorarchdir"]; print(vad ? vad : RbConfig::CONFIG["sitearchdir"])')} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/src/cmpi_provider.c new/cmpi-bindings-0.9.7/src/cmpi_provider.c --- old/cmpi-bindings-0.9.5/src/cmpi_provider.c 2013-04-11 16:36:02.000000000 +0200 +++ new/cmpi-bindings-0.9.7/src/cmpi_provider.c 2013-10-09 13:12:13.000000000 +0200 @@ -874,27 +874,6 @@ } -#if defined(SWIGRUBY) -/* - * Check type of VALUE - * - * return 0 if ok - * return -1 if bad type, set status accordingly - * - */ - -static int -check_ruby_type( VALUE value, int type, const char *message, CMPIStatus *status, ProviderMIHandle* hdl ) -{ - if (TYPE(value) != type) { - status->rc = CMPI_RC_ERR_TYPE_MISMATCH; - status->msg = CMNewString(hdl->broker, message, NULL); - return -1; - } - return 0; -} -#endif - /* * invokeMethod */ @@ -919,93 +898,8 @@ _ctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0); _objName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0); - /* Ruby style method invocation */ #if defined(SWIGRUBY) - - /* de-camelize method name, might need 2time length */ - char *methodname = alloca(strlen(method) * 2 + 1); - decamelize(method, methodname); - - /* access method arguments information via <decamelized>_args */ - int argsnamesize = strlen(methodname) + 5 + 1; - char *argsname = alloca(argsnamesize); /* "<name>_args" */ - snprintf(argsname, argsnamesize, "%s_args", methodname); - - /* get the args array, gives names of input and output arguments */ - VALUE args = rb_funcall(((ProviderMIHandle*)self->hdl)->implementation, rb_intern(argsname), 0); - if (check_ruby_type(args, T_ARRAY, "invoke: <method>_args must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0) - return status; - - VALUE argsin = rb_ary_entry(args, 0); /* array of input arg names */ - if (check_ruby_type(argsin, T_ARRAY, "invoke: Input arguments must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0) - return status; - - int number_of_arguments = RARRAY_LEN(argsin) / 2; - _SBLIM_TRACE(1,("%s -> %d input args", argsname, number_of_arguments)); - /* 3 args will be added by TargetCall, 2 args are added here, others are input args to function */ - VALUE *input = alloca((3 + 2 + number_of_arguments) * sizeof(VALUE)); - input[3] = _ctx; - input[4] = _objName; - /* loop over input arg names and types and get CMPIData via CMGetArg() */ - int i; - for (i = 0; i < number_of_arguments; ++i) { - const char *argname; - CMPIData data; - argname = target_charptr(rb_ary_entry(argsin, i*2)); - data = CMGetArg(in, argname, &status); - if (status.rc != CMPI_RC_OK) { - if ((data.state & CMPI_nullValue) - ||(data.state & CMPI_notFound)) { - input[5+i] = Target_Null; - continue; - } - _SBLIM_TRACE(1,("Failed (rc %d) to get input arg %d:%s for %s", status.rc, i>>1, argname, method)); - return status; - } - input[5+i] = data_value(&data); - } - - /* actual provider call, passes output args and return value via 'result' */ - VALUE result = TargetCall((ProviderMIHandle*)self->hdl, &status, methodname, -(2+number_of_arguments), input); - - /* argsout is array of [<return_type>, <output_arg_name>, <output_arg_type>, ... */ - VALUE argsout = rb_ary_entry(args, 1); - CMPIValue value; - CMPIType expected_type; - CMPIType actual_type; - if (check_ruby_type(argsout, T_ARRAY, "invoke: Output arguments must be Array", &status, (ProviderMIHandle*)self->hdl) < 0) - return status; - number_of_arguments = (RARRAY_LEN(argsout) - 1); - - if (number_of_arguments > 0) { - /* if output args are defined, result must be an array - * result[0] is the return value - * result[1..n] are the output args in argsout order - */ - if (check_ruby_type(result, T_ARRAY, "invoke: function with output arguments must return Array", &status, (ProviderMIHandle*)self->hdl) < 0) - return status; - - /* loop over output arg names and types and set CMPIData via CMSetArg() */ - for (i = 0; i < number_of_arguments; i += 2) { - const char *argname; - argname = target_charptr(rb_ary_entry(argsout, i+1)); - expected_type = FIX2ULONG(rb_ary_entry(argsout, i+2)); - actual_type = target_to_value(rb_ary_entry(result, (i >> 1) + 1), &value, expected_type); - status = CMAddArg(out, argname, &value, actual_type); - if (status.rc != CMPI_RC_OK) { - _SBLIM_TRACE(1,("Failed (rc %d) to set output arg %d:%s for %s; expected type %x, actual type %x", status.rc, i>>1, argname, method, expected_type, actual_type)); - return status; - } - } - /* result[0] is the return value */ - result = rb_ary_entry(result, 0); - - } - expected_type = FIX2ULONG(rb_ary_entry(argsout, 0)); - actual_type = target_to_value(result, &value, expected_type); - CMReturnData(rslt, &value, actual_type); - CMReturnDone(rslt); - + TargetInvoke((ProviderMIHandle*)self->hdl, _ctx, rslt, _objName, method, in, out, &status); #else Target_Type _rslt; Target_Type _in; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/src/target_ruby.c new/cmpi-bindings-0.9.7/src/target_ruby.c --- old/cmpi-bindings-0.9.5/src/target_ruby.c 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/src/target_ruby.c 2013-10-09 13:30:04.000000000 +0200 @@ -515,3 +515,188 @@ return; } + +/* + * Check type of VALUE + * - used by invokeMethod - + * + * return 0 if ok + * return -1 if bad type, set status accordingly + * + */ + +static int +check_ruby_type( VALUE value, int type, const char *message, CMPIStatus *status, ProviderMIHandle* hdl ) +{ + if (TYPE(value) != type) { + status->rc = CMPI_RC_ERR_TYPE_MISMATCH; + status->msg = CMNewString(hdl->broker, message, NULL); + return -1; + } + return 0; +} + + +/* + * protected_target_to_value + * call target_to_value via rb_protect in order to catch exceptions + * + */ + +static VALUE +call_ttv(VALUE args) +{ + VALUE *values = (VALUE *)args; + return target_to_value((Target_Type)values[0], (CMPIValue *)values[1], (CMPIType)values[2]); +} + +static VALUE +protected_target_to_value(ProviderMIHandle *hdl, Target_Type data, CMPIValue *value, CMPIType type, CMPIStatus *status) +{ + int error = 0; + VALUE args[3]; + VALUE result; + args[0] = (VALUE)data; + args[1] = (VALUE)value; + args[2] = (VALUE)type; + result = rb_protect(call_ttv, (VALUE)args, &error); + + if (error) { + CMPIString *trace = get_exc_trace(hdl->broker); + char *trace_s; + char* str; + if (trace) { + trace_s = CMGetCharPtr(trace); + } + else { + trace_s = "Unknown reason"; + } + str = fmtstr("Ruby: %s", trace_s); + if (trace) + trace->ft->release(trace); + _SBLIM_TRACE(1,("%s", str)); + status->rc = CMPI_RC_ERR_FAILED; + status->msg = hdl->broker->eft->newString(hdl->broker, str, NULL); + free(str); + } + else { + status->rc = CMPI_RC_OK; + } + return result; +} + +/* + * TargetInvoke + * Ruby style method invocation + */ +static void +TargetInvoke( + ProviderMIHandle* hdl, + Target_Type _ctx, + const CMPIResult* rslt, + Target_Type _objName, + const char* method, + const CMPIArgs* in, + CMPIArgs* out, + CMPIStatus *status) +{ + /* de-camelize method name, might need 2time length */ + char *methodname = alloca(strlen(method) * 2 + 1); + decamelize(method, methodname); + + /* access method arguments information via <decamelized>_args */ + int argsnamesize = strlen(methodname) + 5 + 1; + char *argsname = alloca(argsnamesize); /* "<name>_args" */ + snprintf(argsname, argsnamesize, "%s_args", methodname); + + /* get the args array, gives names of input and output arguments */ + VALUE args = rb_funcall(hdl->implementation, rb_intern(argsname), 0); + if (check_ruby_type(args, T_ARRAY, "invoke: <method>_args must be Array", status, hdl ) < 0) { + return; + } + + VALUE argsin = rb_ary_entry(args, 0); /* array of input arg names */ + if (check_ruby_type(argsin, T_ARRAY, "invoke: Input arguments of <method>_args must be Array", status, hdl ) < 0) { + return; + } + + int number_of_arguments = RARRAY_LEN(argsin) / 2; + _SBLIM_TRACE(1,("%s -> %d input args", argsname, number_of_arguments)); + /* 3 args will be added by TargetCall, 2 args are added here, others are input args to function */ + VALUE *input = alloca((3 + 2 + number_of_arguments) * sizeof(VALUE)); + input[3] = _ctx; + input[4] = _objName; + /* loop over input arg names and types and get CMPIData via CMGetArg() */ + int i; + for (i = 0; i < number_of_arguments; ++i) { + const char *argname; + CMPIData data; + argname = target_charptr(rb_ary_entry(argsin, i*2)); + data = CMGetArg(in, argname, status); + if (status->rc != CMPI_RC_OK) { + if ((data.state & CMPI_nullValue) + ||(data.state & CMPI_notFound)) { + input[5+i] = Target_Null; + continue; + } + _SBLIM_TRACE(1,("Failed (rc %d) to get input arg %d:%s for %s", status->rc, i>>1, argname, method)); + return; + } + input[5+i] = data_value(&data); + } + + /* actual provider call, passes output args and return value via 'result' */ + VALUE result = TargetCall(hdl, status, methodname, -(2+number_of_arguments), input); + + /* check CMPIStatus */ + if (status->rc != CMPI_RC_OK) { + return; + } + + /* argsout (from <method>_args) is array of [<return_type>, <output_arg_name>, <output_arg_type>, ... */ + VALUE argsout = rb_ary_entry(args, 1); + CMPIValue value; + CMPIType expected_type; + CMPIType actual_type; + if (check_ruby_type(argsout, T_ARRAY, "invoke: Output arguments of <method>_args must be Array", status, hdl) < 0) { + return; + } + number_of_arguments = (RARRAY_LEN(argsout) - 1); + + if (number_of_arguments > 0) { + /* if output args are defined, result must be an array + * result[0] is the return value + * result[1..n] are the output args in argsout order + */ + if (check_ruby_type(result, T_ARRAY, "invoke: function with output arguments must return Array", status, hdl) < 0) { + return; + } + /* loop over output arg names and types and set CMPIData via CMSetArg() */ + for (i = 0; i < number_of_arguments; i += 2) { + const char *argname; + argname = target_charptr(rb_ary_entry(argsout, i+1)); + expected_type = FIX2ULONG(rb_ary_entry(argsout, i+2)); + actual_type = protected_target_to_value(hdl, rb_ary_entry(result, (i >> 1) + 1), &value, expected_type, status); + if (status->rc != CMPI_RC_OK) { + _SBLIM_TRACE(0,("Failed (rc %d) type conversion for output arg %d:%s in call to %s; expected type %x, actual type %x", status->rc, i>>1, argname, method, expected_type, actual_type)); + return; + } + *status = CMAddArg(out, argname, &value, actual_type); + if (status->rc != CMPI_RC_OK) { + _SBLIM_TRACE(1,("Failed (rc %d) to set output arg %d:%s for %s; expected type %x, actual type %x", status->rc, i>>1, argname, method, expected_type, actual_type)); + return; + } + } + /* result[0] is the return value */ + result = rb_ary_entry(result, 0); + + } + expected_type = FIX2ULONG(rb_ary_entry(argsout, 0)); + actual_type = protected_target_to_value(hdl, result, &value, expected_type, status); + if (status->rc != CMPI_RC_OK) { + _SBLIM_TRACE(0,("Failed (rc %d) type conversion for return value of %s; expected type %x, actual type %x", status->rc, method, expected_type, actual_type)); + return; + } + CMReturnData(rslt, &value, actual_type); + CMReturnDone(rslt); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/swig/cmpi.i new/cmpi-bindings-0.9.7/swig/cmpi.i --- old/cmpi-bindings-0.9.5/swig/cmpi.i 2013-04-11 17:12:49.000000000 +0200 +++ new/cmpi-bindings-0.9.7/swig/cmpi.i 2013-04-18 15:23:52.000000000 +0200 @@ -905,6 +905,19 @@ * helper for CMPISelectExp wrapper */ +static void +release_select_filter_exp(select_filter_exp *sfe) +{ + CMRelease((CMPISelectExp *)sfe->exp); + if (sfe->filter) { + int i = 0; + while (sfe->filter[i]) + free(sfe->filter[i++]); + free(sfe->filter); + } + free(sfe); +} + static select_filter_exp * create_select_filter_exp(const CMPIBroker* broker, const char *query, const char *language, char **keys) { @@ -934,12 +947,7 @@ for (; i < count; i++) { CMPIData data = CMGetArrayElementAt(projection, i-kcount, &st); if (st.rc != CMPI_RC_OK) { - while(i) { - free(sfe->filter[--i]); - } - free(sfe->filter); - CMRelease((CMPISelectExp *)sfe->exp); - free(sfe); + release_select_filter_exp(sfe); sfe = NULL; RAISE_IF(st); break; @@ -948,7 +956,9 @@ CMRelease(data.value.string); } } - CMRelease(projection); + if (projection) { + CMRelease(projection); + } } #if !defined(SWIGRUBY) fail: @@ -956,19 +966,6 @@ return sfe; } -static void -release_select_filter_exp(select_filter_exp *sfe) -{ - CMRelease((CMPISelectExp *)sfe->exp); - if (sfe->filter) { - int i = 0; - while (sfe->filter[i]) - free(sfe->filter[i++]); - free(sfe->filter); - } - free(sfe); -} - %} %exceptionclass CMPIException; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cmpi-bindings-0.9.5/swig/ruby/CMakeLists.txt new/cmpi-bindings-0.9.7/swig/ruby/CMakeLists.txt --- old/cmpi-bindings-0.9.5/swig/ruby/CMakeLists.txt 2013-04-11 16:06:06.000000000 +0200 +++ new/cmpi-bindings-0.9.7/swig/ruby/CMakeLists.txt 2013-09-26 09:10:23.000000000 +0200 @@ -29,7 +29,7 @@ ADD_CUSTOM_COMMAND ( OUTPUT ${SWIG_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for ruby..." + COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for Ruby..." COMMAND ${SWIG_EXECUTABLE} -ruby -o ${SWIG_OUTPUT} -outdir ${CMAKE_CURRENT_BINARY_DIR} -DHAVE_CMPI_BROKER=1 -I/usr/include ${SWIG_INPUT} COMMAND ${CMAKE_COMMAND} -E echo "Done." WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org