~javier-lopez/ubuntu/vivid/ruby1.9.1/fix-1426828

« back to all changes in this revision

Viewing changes to ext/socket/lib/socket.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-11-25 09:59:41 UTC
  • mfrom: (21.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20131125095941-aou3ymnwm79em09y
Tags: 1.9.3.448-1ubuntu1
* Merge from Debian. Remaining changes:
  - debian/control: Add ca-certificates to libruby1.9.1 depends so that
    rubygems can perform certificate verification
  - debian/rules: Don't install SSL certificates from upstream sources
  - debian/patches/20120927-rubygems_disable_upstream_certs.patch: Use
    /etc/ssl/certs/ca-certificates.crt for the trusted CA certificates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
716
716
  #   }
717
717
  #
718
718
  def self.unix_server_socket(path)
719
 
    begin
720
 
      st = File.lstat(path)
721
 
    rescue Errno::ENOENT
722
 
    end
723
 
    if st && st.socket? && st.owned?
724
 
      File.unlink path
 
719
    if !unix_socket_abstract_name?(path)
 
720
      begin
 
721
        st = File.lstat(path)
 
722
      rescue Errno::ENOENT
 
723
      end
 
724
      if st && st.socket? && st.owned?
 
725
        File.unlink path
 
726
      end
725
727
    end
726
728
    s = Addrinfo.unix(path).listen
727
729
    if block_given?
729
731
        yield s
730
732
      ensure
731
733
        s.close if !s.closed?
732
 
        File.unlink path
 
734
        if !unix_socket_abstract_name?(path)
 
735
          File.unlink path
 
736
        end
733
737
      end
734
738
    else
735
739
      s
736
740
    end
737
741
  end
738
742
 
 
743
  class << self
 
744
    private
 
745
 
 
746
    def unix_socket_abstract_name?(path)
 
747
      /linux/ =~ RUBY_PLATFORM && /\A(\0|\z)/ =~ path
 
748
    end
 
749
  end
 
750
 
739
751
  # creates a UNIX socket server on _path_.
740
752
  # It calls the block for each socket accepted.
741
753
  #