From 63d0aa10795c8396454d2dd097f752376ceda2cc Mon Sep 17 00:00:00 2001 From: Zogoo Date: Fri, 6 Sep 2019 11:30:39 +0900 Subject: [PATCH 1/2] Remove memory segment fault issue I hope GSS will doing clean up before this one called. --- lib/gssapi/lib_gssapi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gssapi/lib_gssapi.rb b/lib/gssapi/lib_gssapi.rb index 9ff67a5..2810d81 100644 --- a/lib/gssapi/lib_gssapi.rb +++ b/lib/gssapi/lib_gssapi.rb @@ -179,7 +179,7 @@ def self.release_ptr(name_ptr) class GssCtxIdT < GssPointer def self.release_ptr(context_ptr) min_stat = FFI::MemoryPointer.new :OM_uint32 - maj_stat = LibGSSAPI.gss_delete_sec_context(min_stat, context_ptr, LibGSSAPI::GSS_C_NO_BUFFER) + # maj_stat = LibGSSAPI.gss_delete_sec_context(min_stat, context_ptr, LibGSSAPI::GSS_C_NO_BUFFER) end def self.gss_c_no_context From 9a74303a324347683eb202be143027833a826305 Mon Sep 17 00:00:00 2001 From: Zogoo Date: Fri, 6 Sep 2019 11:31:26 +0900 Subject: [PATCH 2/2] Error without min stat --- lib/gssapi/exceptions.rb | 17 +++++++++++++++++ lib/gssapi/simple.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/gssapi/exceptions.rb b/lib/gssapi/exceptions.rb index d4a3528..d08d949 100644 --- a/lib/gssapi/exceptions.rb +++ b/lib/gssapi/exceptions.rb @@ -21,6 +21,23 @@ def initialize(maj_stat = nil, min_stat = nil) if(maj_stat.nil? && min_stat.nil?) @s = '(no error info)' + elsif (min_stat.nil?) + min = FFI::MemoryPointer.new :OM_uint32 + message_context = FFI::MemoryPointer.new :OM_uint32 + @s = '' + oid = GssOID.gss_c_no_oid + message_context.write_int 0 + begin + out_buff = ManagedGssBufferDesc.new + maj = gss_display_status(min, maj_stat, GSS_C_GSS_CODE, oid, message_context, out_buff.pointer) + if (maj != 0) + @s += "failed to retrieve GSSAPI display for status #{maj_stat}" + @s += " of major status #{maj_stat}\n" + @s += "(with major status #{maj}, minor status #{min.read_uint32}\n" + break + end + @s += out_buff.value.to_s + "\n" + end while message_context.read_int != 0 else min = FFI::MemoryPointer.new :OM_uint32 message_context = FFI::MemoryPointer.new :OM_uint32 diff --git a/lib/gssapi/simple.rb b/lib/gssapi/simple.rb index c37ebb6..ca8bf7f 100644 --- a/lib/gssapi/simple.rb +++ b/lib/gssapi/simple.rb @@ -261,7 +261,7 @@ def unwrap_message(msg, encrypted = true) # @param [String] keytab the path to the keytab def set_keytab(keytab) maj_stat = LibGSSAPI.krb5_gss_register_acceptor_identity(keytab) - raise GssApiError.new(maj_stat, min_stat), "krb5_gss_register_acceptor_identity did not return GSS_S_COMPLETE" if maj_stat != 0 + raise GssApiError.new(maj_stat), "krb5_gss_register_acceptor_identity did not return GSS_S_COMPLETE" if maj_stat != 0 true end