Hello community, here is the log from the commit of package openwsman for openSUSE:Factory checked in at 2015-10-26 12:48:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/openwsman (Old) and /work/SRC/openSUSE:Factory/.openwsman.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "openwsman" Changes: -------- --- /work/SRC/openSUSE:Factory/openwsman/openwsman.changes 2015-08-29 20:05:02.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.openwsman.new/openwsman.changes 2015-10-26 12:48:53.000000000 +0100 @@ -1,0 +2,20 @@ +Wed Oct 7 14:49:51 UTC 2015 - [email protected] + +- Update to 2.6.2 + - Features + - Install winrs.rb (Windows Remote Shell) to /usr/bin + - New package: winrs + - Bugfixes + - Make iniparser thread-safe (Emil Bartczak) + - Fix excessive RPM rebuilds (Olaf Hering) + - Fix selector extraction from URI query (Markus Kolb) + - Fix RPM building on older distributions + - Fix RPM building on Fedora 22 + +------------------------------------------------------------------- +Mon Oct 5 14:22:50 UTC 2015 - [email protected] + +- Fix build for older distributions. + Add struct-epr.diff + +------------------------------------------------------------------- Old: ---- openwsman-2.6.1.tar.bz2 New: ---- openwsman-2.6.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ openwsman.spec ++++++ --- /var/tmp/diff_new_pack.op4QlI/_old 2015-10-26 12:48:54.000000000 +0100 +++ /var/tmp/diff_new_pack.op4QlI/_new 2015-10-26 12:48:54.000000000 +0100 @@ -43,7 +43,7 @@ %if 0%{?fedora} == 16 || (0%{?centos_version}>=500 && 0%{?centos_version}<700) || (0%{?rhel_version}>=500 && 0%{?rhel_version}<700) BuildRequires: java-1.6.0-openjdk-devel %else -%if 0%{?fedora} >= 17 || 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700 +%if (0%{?fedora} >= 17 && 0%{?fedora} < 22) || 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700 BuildRequires: java-1.7.0-openjdk-devel %else BuildRequires: java-devel @@ -122,7 +122,7 @@ %endif Requires(pre): sed coreutils grep /bin/hostname -Version: 2.6.1 +Version: 2.6.2 Release: 0 # Mandriva: # Release %%mkrel 1 @@ -309,6 +309,16 @@ %endif +%package -n winrs +Summary: Windows Remote Shell +Group: System/Management +Requires: openwsman-ruby = %{version} + +%description -n winrs +This is a command line tool for the Windows Remote Shell protocol. You +can use it to send shell commands to a remote Windows hosts. + + %prep %setup -q %if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel} @@ -330,8 +340,12 @@ %endif cd build +# SLE 10 Java doesn't like EXPLICIT_TARGET any more, disable cmake \ -DCMAKE_INSTALL_PREFIX=/usr \ +%if 0%{?suse_version} == 1010 + -DBUILD_JAVA=FALSE \ +%endif -DCMAKE_VERBOSE_MAKEFILE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS_RELEASE:STRING="$RPM_OPT_FLAGS -fno-strict-aliasing" \ @@ -374,6 +388,9 @@ install -D -m 644 %{S:3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/openwsman %endif +# rename winrs.rb -> winrs +mv $RPM_BUILD_ROOT%{_bindir}/winrs.rb $RPM_BUILD_ROOT%{_bindir}/winrs + %post -n libwsman3 -p /sbin/ldconfig %postun -n libwsman3 @@ -496,6 +513,7 @@ %{_sbindir}/rc%{name} %else %attr(0755,root,root) %{_sysconfdir}/init.d/openwsmand +%{_sbindir}/rc%{name}d %endif %dir %{_libdir}/openwsman %dir %{_libdir}/openwsman/authenticators @@ -522,4 +540,8 @@ %dir %{_includedir}/openwsman/cpp %{_includedir}/openwsman/cpp/*.h +%files -n winrs +%defattr(-,root,root) +%{_bindir}/winrs + %changelog ++++++ openwsman-2.6.1.tar.bz2 -> openwsman-2.6.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/CMakeLists.txt new/openwsman-2.6.2/CMakeLists.txt --- old/openwsman-2.6.1/CMakeLists.txt 2015-08-26 13:33:11.000000000 +0200 +++ new/openwsman-2.6.2/CMakeLists.txt 2015-10-06 11:06:58.000000000 +0200 @@ -29,10 +29,6 @@ MESSAGE(STATUS "Package Version ${PACKAGE_VERSION}") SET(OPENWSMAN_PLUGIN_API_VERSION \"${OPENWSMAN_PLUGIN_API_MAJOR}.${OPENWSMAN_PLUGIN_API_MINOR}\") MESSAGE(STATUS "Plugin API Version ${OPENWSMAN_PLUGIN_API_VERSION}") -# build timestamp -EXECUTE_PROCESS(COMMAND "/bin/date" "+%Y%m%d%H%M" OUTPUT_VARIABLE BUILD_DATE) -STRING(REPLACE "\n" "" PACKAGE_BUILDTS "${BUILD_DATE}") - MESSAGE(STATUS "Package build timestamp ${PACKAGE_BUILDTS}") # Package architecture IF ( NOT DEFINED PACKAGE_ARCHITECTURE ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/ChangeLog new/openwsman-2.6.2/ChangeLog --- old/openwsman-2.6.1/ChangeLog 2015-08-27 13:16:50.000000000 +0200 +++ new/openwsman-2.6.2/ChangeLog 2015-10-14 14:53:14.000000000 +0200 @@ -1,3 +1,14 @@ +2.6.2 +- Features + - Install winrs.rb (Windows Remote Shell) to /usr/bin + - New package: winrs +- Bugfixes + - Make iniparser thread-safe (Emil Bartczak) + - Fix excessive RPM rebuilds (Olaf Hering) + - Fix selector extraction from URI query (Markus Kolb) + - Fix RPM building on older distributions + - Fix RPM building on Fedora 22 + 2.6.1 - Features - Add curlopt_nosignal option to openwsman_client.conf to prevent diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/VERSION.cmake new/openwsman-2.6.2/VERSION.cmake --- old/openwsman-2.6.1/VERSION.cmake 2015-08-27 13:16:50.000000000 +0200 +++ new/openwsman-2.6.2/VERSION.cmake 2015-10-14 14:45:51.000000000 +0200 @@ -44,10 +44,10 @@ # set COMPATMINOR to MINOR. (binary incompatible change) # -# Package version 2.6.1 +# Package version 2.6.2 SET(OPENWSMAN_MAJOR "2") SET(OPENWSMAN_MINOR "6") -SET(OPENWSMAN_PATCH "1") +SET(OPENWSMAN_PATCH "2") # Plugin API 2.2 SET(OPENWSMAN_PLUGIN_API_MAJOR "2") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/bindings/ruby/tests/winrs.rb new/openwsman-2.6.2/bindings/ruby/tests/winrs.rb --- old/openwsman-2.6.1/bindings/ruby/tests/winrs.rb 2015-08-26 10:12:49.000000000 +0200 +++ new/openwsman-2.6.2/bindings/ruby/tests/winrs.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,298 +0,0 @@ -# winrs.rb -# -# Windows Remote Shell -# -# See http://msdn.microsoft.com/en-us/library/cc251731.aspx (Remote Shell Examples) -# for details on the SOAP protocol -# - -require 'rexml/document' -require 'openwsman' -require 'getoptlong' - -def usage msg=nil - if msg - STDERR.puts "Error: #{msg}" - STDERR.puts - end - STDERR.puts "Usage:" - STDERR.puts - STDERR.puts "winrs [-U|--url <host-url>] [<cmd>]" - STDERR.puts "winrs [-s|--scheme http|https] [-h|--host <host>] [-u|--user <user>] [-p|--password <password>] [-P|--port port] [<cmd>]" - STDERR.puts - STDERR.puts "If <cmd> is given as a command line argument, winrs exists after executing <cmd>." - STDERR.puts "Else winrs runs interactively, accepting and executing command until Ctrl-D is pressed." - exit 1 -end - -def handle_fault client, result - unless result - if client.last_error != 0 - STDERR.puts "Client connection to #{client.scheme}://#{client.user}:#{client.password}@#{client.host}:#{client.port}/#{client.path} failed with #{client.last_error}, Fault: #{client.fault_string}" - exit 1 - end - if client.response_code != 200 - STDERR.puts "Client requested result #{client.response_code}, Fault: #{client.fault_string}" - exit 1 - end - STDERR.puts "Client action failed for unknown reason" - exit 1 - end - if result.fault? - fault = Openwsman::Fault.new result - STDERR.puts "Fault code #{fault.code}, subcode #{fault.subcode}" - STDERR.puts "\treason #{fault.reason}" - STDERR.puts "\tdetail #{fault.detail}" - exit 1 - end -end - - # - # Argument parsing - # - - opts = GetoptLong.new( - [ "-U", "--url", GetoptLong::REQUIRED_ARGUMENT ], - [ "-h", "--host", GetoptLong::REQUIRED_ARGUMENT ], - [ "-u", "--user", GetoptLong::REQUIRED_ARGUMENT ], - [ "-p", "--password", GetoptLong::REQUIRED_ARGUMENT ], - [ "-P", "--port", GetoptLong::REQUIRED_ARGUMENT ], - [ "-s", "--scheme", GetoptLong::REQUIRED_ARGUMENT ], - [ "-?", "--help", GetoptLong::NO_ARGUMENT ] - ) - - options = { } - url = nil - opts.each do |opt,arg| - case opt - when "-?" - usage - exit 0 - when "-U" - usage "-U|--url invalid, --host|--user|--password|--port already given" unless options.empty? - url = arg - when "-h" - usage "-h|--host invalid, --url already given" unless url.nil? - options[:host] = arg - when "-u" - usage "-u|--user invalid, --url already given" unless url.nil? - options[:user] = arg - when "-p" - usage "-p|--password invalid, --url already given" unless url.nil? - options[:password] = arg - when "-P" - usage "-P|--port invalid, --url already given" unless url.nil? - options[:port] = arg.to_i - when "-s" - usage "-s|--scheme invalid, --url already given" unless url.nil? - options[:scheme] = arg - end - end - - options = { :port => 5985, :scheme => "http" }.merge(options) - - commands = ARGV.empty? ? nil : ARGV - - - client = if url - Openwsman::Client.new url - elsif options.empty? - usage - else - Openwsman::Client.new(options[:host], options[:port], "wsman", options[:scheme], options[:user], options[:password]) - end - - # - # Client connection - # - - client.transport.timeout = 120 - client.transport.auth_method = Openwsman::BASIC_AUTH_STR - # https - # client.transport.verify_peer = 0 - # client.transport.verify_host = 0 - - options = Openwsman::ClientOptions.new -# options.set_dump_request -# Openwsman::debug = -1 - options.timeout = 60 * 1000 # 60 seconds - uri = "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd" - - # - # Start shell - # - - service = "Themes" - options.add_selector( "Name", service ) - - options.add_option "WINRS_NOPROFILE","FALSE" - options.add_option "WINRS_CODEPAGE", 437 - - # instance values - instance = { "InputStreams" => "stdin", "OutputStreams" => "stdout stderr" } - - namespace = "http://schemas.microsoft.com/wbem/wsman/1/windows/shell" - data = Openwsman::XmlDoc.new("Shell", namespace) - root = data.root - instance.each do |key,value| - root.add namespace, key, value - end - - s = data.to_xml - result = client.create( options, uri, s, s.size, "utf-8" ) - # returns something like - # <s:Body> - # <x:ResourceCreated> - # <a:Address>http://10.120.5.37:5985/wsman</a:Address> - # <a:ReferenceParameters> - # <w:ResourceURI>http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI> - # <w:SelectorSet> - # <w:Selector Name="ShellId">3D5D8879-98EA-49B7-9A33-6842EC0D35D0</w:Selector> - # </w:SelectorSet> - # </a:ReferenceParameters> - # </x:ResourceCreated> - # </s:Body> - handle_fault client, result - - shell_id = result.find(nil, "Selector") - raise "No shell id returned" unless shell_id -# puts "Shell ID: #{shell_id}" - command_id = nil - - # - # Run command(s) - # - - loop do - if commands - break if commands.empty? - cmd = commands.shift - else - print "WinRS> " - STDOUT.flush - cmd = gets - break if cmd.nil? - cmd.chomp! - next if cmd.empty? - end - - # issue command - options.options = { "WINRS_CONSOLEMODE_STDIN" => "TRUE", "WINRS_SKIP_CMD_SHELL" => "FALSE" } - options.selectors = { "ShellId" => shell_id } - data = Openwsman::XmlDoc.new("CommandLine", namespace) - root = data.root - root.add namespace, "Command", cmd - result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command", data) - handle_fault client, result - - command_id = result.find(namespace, "CommandId") - raise "No command id returned" unless command_id - command_id = command_id.text -# puts "Command ID: #{command_id}" - - # - # Request stdout/stderr - # - - options.options = { } - # keep ShellId selector - data = Openwsman::XmlDoc.new("Receive", namespace) - root = data.root - node = root.add namespace, "DesiredStream", "stdout stderr" - node.attr_add nil, "CommandId", command_id - result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive", data) - handle_fault client, result - - # - # Receive response - # - - response = result.find(namespace, "ReceiveResponse") - unless response - STDERR.puts "***Err: No ReceiveResponse in: #{result.to_xml}" - next - end - response.each do |node| - cmd_id = node.attr "CommandId" - if cmd_id.nil? - STDERR.puts "***Err: No CommandId in ReceiveResponse node: #{node.to_xml}" - next - end - if cmd_id.value != command_id - STDERR.puts "***Err: Wrong CommandId in ReceiveResponse node. Expected #{command_id}, found #{cmd_id.value}" - next - end -# puts "Node: #{node.to_xml}" - case node.name - when "Stream" - stream_name = node.attr "Name" - unless stream_name - STDERR.puts "***Err: Stream node has no Name attribute: #{node.to_xml}" - next - end - stream_name = stream_name.value - str = node.text.unpack('m')[0] - case stream_name - when "stdout" - puts str - when "stderr" - STDERR.puts str - else - STDERR.puts "***Err: Unknown stream name: #{stream_name}" - end - when "CommandState" - state = node.attr "State" - unless state - STDERR.puts "***Err: CommandState node has no State attribute: #{node.to_xml}" - next - end - case state.value - when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done" - exit_code = node.get "ExitCode" - if exit_code - puts "Exit code: #{exit_code.text}" - else - STDERR.puts "***Err: No exit code for 'done' command: #{node.to_xml}" - end - when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running" - # unclear how to handle this - when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Pending" - # no-op - # WinRM 1.1 sends this with ExitCode:0 - else - STDERR.puts "***Err: Unknown command state: #{state.value}" - end - else - STDERR.puts "***Err: Unknown receive response: #{node.to_xml}" - end - end # response.each - - # - # terminate shell command - # - # not strictly needed for WinRM 2.0, but WinRM 1.1 requires this - # - data = Openwsman::XmlDoc.new("Signal", namespace) - root = data.root - root.attr_add nil, "CommandId", command_id - root.add namespace, "Code", "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/terminate" - result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal", data) - handle_fault client, result - - response = result.find(namespace, "SignalResponse") - unless response - STDERR.puts "***Err: No SignalResponse in: #{result.to_xml}" - end - end - - # - # delete shell resource - # - - if shell_id - options.options = { } - options.selectors = { "ShellId" => shell_id } - - result = client.invoke( options, uri, "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete", nil) - handle_fault client, result - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/configure.ac new/openwsman-2.6.2/configure.ac --- old/openwsman-2.6.1/configure.ac 2015-08-27 15:41:42.000000000 +0200 +++ new/openwsman-2.6.2/configure.ac 2015-10-06 11:06:58.000000000 +0200 @@ -476,12 +476,6 @@ ["$OPENWSMAN_PLUGIN_API_VERSION"], [Plugin API version]) - -PACKAGE_BUILDTS=`"/bin/date" "+%Y%m%d%H%M"` - -AC_DEFINE_UNQUOTED(PACKAGE_BUILDTS, ["$PACKAGE_BUILDTS"], [Build timestamp]) - - AC_CHECK_LIB([cmpisfcc], [cmciConnect], [have_sfcc="yes"],[have_sfcc="no"]) AM_CONDITIONAL(BUILD_LIBCIM, test "$have_sfcc" = "yes" ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/examples/CMakeLists.txt new/openwsman-2.6.2/examples/CMakeLists.txt --- old/openwsman-2.6.1/examples/CMakeLists.txt 2014-07-25 17:08:56.000000000 +0200 +++ new/openwsman-2.6.2/examples/CMakeLists.txt 2015-10-14 14:45:51.000000000 +0200 @@ -4,10 +4,18 @@ include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) +# serialize + SET( serialize_SOURCES serialize.c ) ADD_EXECUTABLE( serialize ${serialize_SOURCES} ) SET( TEST_LIBS wsman wsman_client ${LIBXML2_LIBRARIES} ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) TARGET_LINK_LIBRARIES( serialize ${TEST_LIBS} ) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test.xml ${CMAKE_CURRENT_BINARY_DIR}/test.xml COPYONLY ) \ No newline at end of file +# test.xml + +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test.xml ${CMAKE_CURRENT_BINARY_DIR}/test.xml COPYONLY ) + +# winrs.rb + +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/winrs.rb DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/examples/winrs.rb new/openwsman-2.6.2/examples/winrs.rb --- old/openwsman-2.6.1/examples/winrs.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/openwsman-2.6.2/examples/winrs.rb 2015-10-14 14:45:51.000000000 +0200 @@ -0,0 +1,300 @@ +# winrs.rb +# +# Windows Remote Shell +# +# See http://msdn.microsoft.com/en-us/library/cc251731.aspx (Remote Shell Examples) +# for details on the SOAP protocol +# + +require 'rexml/document' +require 'openwsman' +require 'getoptlong' + +def usage msg=nil + if msg + STDERR.puts "Error: #{msg}" + STDERR.puts + end + STDERR.puts "Usage:" + STDERR.puts + STDERR.puts "winrs [-U|--url <host-url>] [<cmd>]" + STDERR.puts "winrs [-s|--scheme http|https] [-h|--host <host>] [-u|--user <user>] [-p|--password <password>] [-P|--port port] [<cmd>]" + STDERR.puts + STDERR.puts "If <cmd> is given as a command line argument, winrs exists after executing <cmd>." + STDERR.puts "Else winrs runs interactively, accepting and executing command until Ctrl-D is pressed." + exit 1 +end + +def handle_fault client, result + unless result + if client.last_error != 0 + STDERR.puts "Client connection to #{client.scheme}://#{client.user}:#{client.password}@#{client.host}:#{client.port}/#{client.path} failed with #{client.last_error} HTTP #{client.response_code}, Fault: #{client.fault_string}" + exit 1 + end + if client.response_code != 200 + STDERR.puts "Client requested result #{client.response_code}, Fault: #{client.fault_string}" + exit 1 + end + STDERR.puts "Client action failed for unknown reason" + exit 1 + end + if result.fault? + fault = Openwsman::Fault.new result + STDERR.puts "Fault code #{fault.code}, subcode #{fault.subcode}" + STDERR.puts "\treason #{fault.reason}" + STDERR.puts "\tdetail #{fault.detail}" + exit 1 + end +end + + # + # Argument parsing + # + + opts = GetoptLong.new( + [ "-U", "--url", GetoptLong::REQUIRED_ARGUMENT ], + [ "-h", "--host", GetoptLong::REQUIRED_ARGUMENT ], + [ "-u", "--user", GetoptLong::REQUIRED_ARGUMENT ], + [ "-p", "--password", GetoptLong::REQUIRED_ARGUMENT ], + [ "-P", "--port", GetoptLong::REQUIRED_ARGUMENT ], + [ "-s", "--scheme", GetoptLong::REQUIRED_ARGUMENT ], + [ "-?", "--help", GetoptLong::NO_ARGUMENT ], + [ "-d", "--debug", GetoptLong::NO_ARGUMENT ] + ) + + options = { } + url = nil + opts.each do |opt,arg| + case opt + when "-?" + usage + exit 0 + when "-U" + usage "-U|--url invalid, --host|--user|--password|--port already given" unless options.empty? + url = arg + when "-h" + usage "-h|--host invalid, --url already given" unless url.nil? + options[:host] = arg + when "-u" + usage "-u|--user invalid, --url already given" unless url.nil? + options[:user] = arg + when "-p" + usage "-p|--password invalid, --url already given" unless url.nil? + options[:password] = arg + when "-P" + usage "-P|--port invalid, --url already given" unless url.nil? + options[:port] = arg.to_i + when "-s" + usage "-s|--scheme invalid, --url already given" unless url.nil? + options[:scheme] = arg + when "-d" + Openwsman::debug = 99 + end + end + + options = { :port => 5985, :scheme => "http" }.merge(options) + + commands = ARGV.empty? ? nil : ARGV + + + client = if url + Openwsman::Client.new url + elsif options.empty? + usage + else + Openwsman::Client.new(options[:host], options[:port], "wsman", options[:scheme], options[:user], options[:password]) + end + + # + # Client connection + # + + client.transport.timeout = 120 + client.transport.auth_method = Openwsman::BASIC_AUTH_STR + # https + # client.transport.verify_peer = 0 + # client.transport.verify_host = 0 + + options = Openwsman::ClientOptions.new + options.set_dump_request if Openwsman::debug == 99 + options.timeout = 60 * 1000 # 60 seconds + uri = "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd" + + # + # Start shell + # + + service = "Themes" + options.add_selector( "Name", service ) + + options.add_option "WINRS_NOPROFILE","FALSE" + options.add_option "WINRS_CODEPAGE", 437 + + # instance values + instance = { "InputStreams" => "stdin", "OutputStreams" => "stdout stderr" } + + namespace = "http://schemas.microsoft.com/wbem/wsman/1/windows/shell" + data = Openwsman::XmlDoc.new("Shell", namespace) + root = data.root + instance.each do |key,value| + root.add namespace, key, value + end + + s = data.to_xml + result = client.create( options, uri, s, s.size, "utf-8" ) + # returns something like + # <s:Body> + # <x:ResourceCreated> + # <a:Address>http://10.120.5.37:5985/wsman</a:Address> + # <a:ReferenceParameters> + # <w:ResourceURI>http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI> + # <w:SelectorSet> + # <w:Selector Name="ShellId">3D5D8879-98EA-49B7-9A33-6842EC0D35D0</w:Selector> + # </w:SelectorSet> + # </a:ReferenceParameters> + # </x:ResourceCreated> + # </s:Body> + handle_fault client, result + + shell_id = result.find(nil, "Selector") + raise "No shell id returned" unless shell_id +# puts "Shell ID: #{shell_id}" + command_id = nil + + # + # Run command(s) + # + + loop do + if commands + break if commands.empty? + cmd = commands.shift + else + print "WinRS> " + STDOUT.flush + cmd = gets + break if cmd.nil? + cmd.chomp! + next if cmd.empty? + end + + # issue command + options.options = { "WINRS_CONSOLEMODE_STDIN" => "TRUE", "WINRS_SKIP_CMD_SHELL" => "FALSE" } + options.selectors = { "ShellId" => shell_id } + data = Openwsman::XmlDoc.new("CommandLine", namespace) + root = data.root + root.add namespace, "Command", cmd + result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command", data) + handle_fault client, result + + command_id = result.find(namespace, "CommandId") + raise "No command id returned" unless command_id + command_id = command_id.text +# puts "Command ID: #{command_id}" + + # + # Request stdout/stderr + # + + options.options = { } + # keep ShellId selector + data = Openwsman::XmlDoc.new("Receive", namespace) + root = data.root + node = root.add namespace, "DesiredStream", "stdout stderr" + node.attr_add nil, "CommandId", command_id + result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive", data) + handle_fault client, result + + # + # Receive response + # + + response = result.find(namespace, "ReceiveResponse") + unless response + STDERR.puts "***Err: No ReceiveResponse in: #{result.to_xml}" + next + end + response.each do |node| + cmd_id = node.attr "CommandId" + if cmd_id.nil? + STDERR.puts "***Err: No CommandId in ReceiveResponse node: #{node.to_xml}" + next + end + if cmd_id.value != command_id + STDERR.puts "***Err: Wrong CommandId in ReceiveResponse node. Expected #{command_id}, found #{cmd_id.value}" + next + end +# puts "Node: #{node.to_xml}" + case node.name + when "Stream" + stream_name = node.attr "Name" + unless stream_name + STDERR.puts "***Err: Stream node has no Name attribute: #{node.to_xml}" + next + end + stream_name = stream_name.value + str = node.text.unpack('m')[0] + case stream_name + when "stdout" + puts str + when "stderr" + STDERR.puts str + else + STDERR.puts "***Err: Unknown stream name: #{stream_name}" + end + when "CommandState" + state = node.attr "State" + unless state + STDERR.puts "***Err: CommandState node has no State attribute: #{node.to_xml}" + next + end + case state.value + when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done" + exit_code = node.get "ExitCode" + if exit_code + STDERR.puts "Exit code: #{exit_code.text}" + else + STDERR.puts "***Err: No exit code for 'done' command: #{node.to_xml}" + end + when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running" + # unclear how to handle this + when "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Pending" + # no-op + # WinRM 1.1 sends this with ExitCode:0 + else + STDERR.puts "***Err: Unknown command state: #{state.value}" + end + else + STDERR.puts "***Err: Unknown receive response: #{node.to_xml}" + end + end # response.each + + # + # terminate shell command + # + # not strictly needed for WinRM 2.0, but WinRM 1.1 requires this + # + data = Openwsman::XmlDoc.new("Signal", namespace) + root = data.root + root.attr_add nil, "CommandId", command_id + root.add namespace, "Code", "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/terminate" + result = client.invoke( options, uri, "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal", data) + handle_fault client, result + + response = result.find(namespace, "SignalResponse") + unless response + STDERR.puts "***Err: No SignalResponse in: #{result.to_xml}" + end + end + + # + # delete shell resource + # + + if shell_id + options.options = { } + options.selectors = { "ShellId" => shell_id } + + result = client.invoke( options, uri, "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete", nil) + handle_fault client, result + end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/include/wsman-key-value.h new/openwsman-2.6.2/include/wsman-key-value.h --- old/openwsman-2.6.1/include/wsman-key-value.h 2015-08-26 13:33:11.000000000 +0200 +++ new/openwsman-2.6.2/include/wsman-key-value.h 2015-10-06 11:06:59.000000000 +0200 @@ -41,7 +41,7 @@ extern "C" { #endif /* __cplusplus */ -typedef struct epr_struct epr_t; +struct epr_struct; /* key/value pair * to represent either a value or an epr_t @@ -51,12 +51,12 @@ int type; /* 0: char*, else epr_t* */ union { char *text; - epr_t *epr; + struct epr_struct *epr; } v; } key_value_t; /* if kv is non-NULL, it's pre-allocated (part of array) */ -key_value_t *key_value_create(const char *key, const char *text, const epr_t *epr, key_value_t *prealloc); +key_value_t *key_value_create(const char *key, const char *text, const struct epr_struct *epr, key_value_t *prealloc); void key_value_copy(const key_value_t *from, key_value_t *to); /* if part_of_array is non-zero, only release key/value, not element itself */ void key_value_destroy(key_value_t *, int part_of_array); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/package/openwsman.spec new/openwsman-2.6.2/package/openwsman.spec --- old/openwsman-2.6.1/package/openwsman.spec 2015-06-05 11:44:53.000000000 +0200 +++ new/openwsman-2.6.2/package/openwsman.spec 2015-10-05 16:33:05.000000000 +0200 @@ -331,6 +331,9 @@ cd build cmake \ -DCMAKE_INSTALL_PREFIX=/usr \ +%if 0%{?suse_version} == 1010 # SLE 10 Java doesn't like EXPLICIT_TARGET any more, disable + -DBUILD_JAVA=FALSE \ +%endif -DCMAKE_VERBOSE_MAKEFILE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS_RELEASE:STRING="$RPM_OPT_FLAGS -fno-strict-aliasing" \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/package/openwsman.spec.in new/openwsman-2.6.2/package/openwsman.spec.in --- old/openwsman-2.6.1/package/openwsman.spec.in 2015-08-27 15:44:28.000000000 +0200 +++ new/openwsman-2.6.2/package/openwsman.spec.in 2015-10-14 14:49:41.000000000 +0200 @@ -43,7 +43,7 @@ %if 0%{?fedora} == 16 || (0%{?centos_version}>=500 && 0%{?centos_version}<700) || (0%{?rhel_version}>=500 && 0%{?rhel_version}<700) BuildRequires: java-1.6.0-openjdk-devel %else -%if 0%{?fedora} >= 17 || 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700 +%if (0%{?fedora} >= 17 && 0%{?fedora} < 22) || 0%{?centos_version} >= 700 || 0%{?rhel_version} >= 700 BuildRequires: java-1.7.0-openjdk-devel %else BuildRequires: java-devel @@ -309,6 +309,16 @@ %endif +%package -n winrs +Summary: Windows Remote Shell +Group: System/Management +Requires: openwsman-ruby = %{version} + +%description -n winrs +This is a command line tool for the Windows Remote Shell protocol. You +can use it to send shell commands to a remote Windows hosts. + + %prep %setup -q %if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel} @@ -330,8 +340,12 @@ %endif cd build +# SLE 10 Java doesn't like EXPLICIT_TARGET any more, disable cmake \ -DCMAKE_INSTALL_PREFIX=/usr \ +%if 0%{?suse_version} == 1010 + -DBUILD_JAVA=FALSE \ +%endif -DCMAKE_VERBOSE_MAKEFILE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS_RELEASE:STRING="$RPM_OPT_FLAGS -fno-strict-aliasing" \ @@ -374,6 +388,9 @@ install -D -m 644 %{S:3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/openwsman %endif +# rename winrs.rb -> winrs +mv $RPM_BUILD_ROOT%{_bindir}/winrs.rb $RPM_BUILD_ROOT%{_bindir}/winrs + %post -n libwsman3 -p /sbin/ldconfig %postun -n libwsman3 @@ -496,6 +513,7 @@ %{_sbindir}/rc%{name} %else %attr(0755,root,root) %{_sysconfdir}/init.d/openwsmand +%{_sbindir}/rc%{name}d %endif %dir %{_libdir}/openwsman %dir %{_libdir}/openwsman/authenticators @@ -522,4 +540,8 @@ %dir %{_includedir}/openwsman/cpp %{_includedir}/openwsman/cpp/*.h +%files -n winrs +%defattr(-,root,root) +%{_bindir}/winrs + %changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/src/lib/u/iniparser.c new/openwsman-2.6.2/src/lib/u/iniparser.c --- old/openwsman-2.6.1/src/lib/u/iniparser.c 2015-08-27 12:03:58.000000000 +0200 +++ new/openwsman-2.6.2/src/lib/u/iniparser.c 2015-10-14 14:45:16.000000000 +0200 @@ -49,21 +49,19 @@ /** @brief Convert a string to lowercase. @param s String to convert. - @return ptr to statically allocated string. + @param l Pointer to destination string. + @return ptr to the destination string. - This function returns a pointer to a statically allocated string - containing a lowercased version of the input string. Do not free - or modify the returned string! Since the returned string is statically - allocated, it will be modified at each function call (not re-entrant). + This function returns a pointer to string containing + a lowercased version of the input string. */ /*--------------------------------------------------------------------------*/ -static char * strlwc(char * s) +static char * strlwc(char * s, char * l) { - static char l[ASCIILINESZ+1]; int i ; - if (s==NULL) return NULL ; + if ((s==NULL) || (l==NULL)) return NULL ; memset(l, 0, ASCIILINESZ+1); i=0 ; while (s[i] && i<ASCIILINESZ) { @@ -104,23 +102,20 @@ /** @brief Remove blanks at the end of a string. @param s String to parse. - @return ptr to statically allocated string. + @param l Pointer to destination string. + @return ptr to the destination string. - This function returns a pointer to a statically allocated string, + This function returns a pointer to an array which contains string, which is identical to the input string, except that all blank characters at the end of the string have been removed. - Do not free or modify the returned string! Since the returned string - is statically allocated, it will be modified at each function call - (not re-entrant). */ /*--------------------------------------------------------------------------*/ -static char * strcrop(char * s) +static char * strcrop(char * s, char * l) { - static char l[ASCIILINESZ+1]; char * last ; - if (s==NULL) return NULL ; + if ((s==NULL) || (l==NULL)) return NULL ; memset(l, 0, ASCIILINESZ+1); strcpy(l, s); last = l + strlen(l); @@ -704,16 +699,11 @@ /*--------------------------------------------------------------------------*/ char * iniparser_getstring(dictionary * d, char * key, char * def) { - char * lc_key ; - char * sval ; + char lc_key[ASCIILINESZ+1]; if (d==NULL || key==NULL) return def ; - - lc_key = strdup(strlwc(key)); - sval = dictionary_get(d, lc_key, def); - free(lc_key); - return sval ; + return dictionary_get(d, strlwc(key, lc_key), def); } @@ -858,7 +848,9 @@ int iniparser_setstr(dictionary * ini, char * entry, char * val) { - return dictionary_set(ini, strlwc(entry), val); + char lc_key[ASCIILINESZ+1]; + + return dictionary_set(ini, strlwc(entry, lc_key), val); } /*-------------------------------------------------------------------------*/ @@ -873,7 +865,9 @@ /*--------------------------------------------------------------------------*/ void iniparser_unset(dictionary * ini, char * entry) { - dictionary_unset(ini, strlwc(entry)); + char lc_key[ASCIILINESZ+1]; + + dictionary_unset(ini, strlwc(entry, lc_key)); } @@ -924,9 +918,11 @@ if (*where==';' || *where=='#' || *where==0) continue ; /* Comment lines */ else { + char lc_key[ASCIILINESZ+1]; + if (sscanf(where, "[%[^]]", sec)==1) { /* Valid section name */ - strcpy(sec, strlwc(sec)); + strcpy(sec, strlwc(sec, lc_key)); if (iniparser_add_entry(d, sec, NULL, NULL) != 0) { dictionary_del(d); fclose(ini); @@ -935,7 +931,9 @@ } else if (sscanf (where, "%[^=] = \"%[^\"]\"", key, val) == 2 || sscanf (where, "%[^=] = '%[^\']'", key, val) == 2 || sscanf (where, "%[^=] = %[^;#]", key, val) == 2) { - strcpy(key, strlwc(strcrop(key))); + char crop_key[ASCIILINESZ+1]; + + strcpy(key, strlwc(strcrop(key, crop_key), lc_key)); /* * sscanf cannot handle "" or '' as empty value, * this is done here @@ -943,7 +941,7 @@ if (!strcmp(val, "\"\"") || !strcmp(val, "''")) { val[0] = (char)0; } else { - strcpy(val, strcrop(val)); + strcpy(val, strcrop(val, crop_key)); } if (iniparser_add_entry(d, sec, key, val) != 0) { dictionary_del(d); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/src/lib/wsman-client.c new/openwsman-2.6.2/src/lib/wsman-client.c --- old/openwsman-2.6.1/src/lib/wsman-client.c 2015-08-27 12:03:58.000000000 +0200 +++ new/openwsman-2.6.2/src/lib/wsman-client.c 2015-10-06 11:06:58.000000000 +0200 @@ -558,7 +558,10 @@ list_destroy_nodes(options->selectors); list_destroy(options->selectors); } - _wsmc_add_uri_to_list(&(options->selectors), resource_uri); + u_uri_t *uri = u_malloc(sizeof(u_uri_t)); + u_uri_parse(resource_uri, &uri); + wsmc_add_selectors_from_str(options, uri->query); + u_uri_free(uri); } /* Err: should be wsmc_set_selectors_from_uri() */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/src/lib/wsman-curl-client-transport.c new/openwsman-2.6.2/src/lib/wsman-curl-client-transport.c --- old/openwsman-2.6.1/src/lib/wsman-curl-client-transport.c 2015-08-27 12:03:58.000000000 +0200 +++ new/openwsman-2.6.2/src/lib/wsman-curl-client-transport.c 2015-10-14 14:45:51.000000000 +0200 @@ -626,6 +626,7 @@ */ r = 67; #endif + cl->fault_string = u_strdup(curl_easy_strerror(r)); curl_err("user/password wrong or empty."); break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/src/server/wsmand-daemon.c new/openwsman-2.6.2/src/server/wsmand-daemon.c --- old/openwsman-2.6.1/src/server/wsmand-daemon.c 2015-08-26 13:33:12.000000000 +0200 +++ new/openwsman-2.6.2/src/server/wsmand-daemon.c 2015-10-06 11:06:58.000000000 +0200 @@ -146,7 +146,7 @@ retval = 0; } if (version) { - fprintf(stdout, PACKAGE_NAME " " PACKAGE_VERSION " (" PACKAGE_BUILDTS ")\n\n"); + fprintf(stdout, PACKAGE_NAME " " PACKAGE_VERSION "\n\n"); exit(0); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/openwsman-2.6.1/wsman_config.h.cmake new/openwsman-2.6.2/wsman_config.h.cmake --- old/openwsman-2.6.1/wsman_config.h.cmake 2015-08-26 10:12:50.000000000 +0200 +++ new/openwsman-2.6.2/wsman_config.h.cmake 2015-10-06 11:06:58.000000000 +0200 @@ -360,9 +360,6 @@ /* Define to the API version of the server plugin interface. */ #define OPENWSMAN_PLUGIN_API_VERSION @OPENWSMAN_PLUGIN_API_VERSION@ -/* Define to the built timestamp of this package. */ -#define PACKAGE_BUILDTS "@PACKAGE_BUILDTS@" - /* The size of `int', as computed by sizeof. */ #define SIZEOF_INT @SIZEOF_INT@
