ruby-lsapi 5.7 → 5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lsapi.gemspec CHANGED
@@ -1,14 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{ruby-lsapi}
3
- s.version = "5.7"
4
- s.date = %q{2024-03-13}
3
+ s.version = "5.9"
4
+ s.date = %q{2026-10-26}
5
5
  s.description = "This is a ruby extension for fast communication with LiteSpeed Web Server."
6
6
  s.summary = %q{A ruby extension for fast communication with LiteSpeed Web Server.}
7
- s.has_rdoc = false
8
7
  s.authors = ["LiteSpeed Technologies Inc."]
9
8
  s.email = "info@litespeedtech.com"
10
9
  s.homepage = "http://www.litespeedtech.com/"
11
- s.rubyforge_project = "ruby-lsapi"
12
10
  s.files = ["lsapi.gemspec", "README", "examples", "examples/testlsapi.rb", "examples/lsapi_with_cgi.rb", "ext", "ext/lsapi", "ext/lsapi/extconf.rb", "ext/lsapi/lsapidef.h", "ext/lsapi/lsapilib.c", "ext/lsapi/lsapilib.h", "ext/lsapi/lsruby.c", "rails", "rails/dispatch.lsapi", "scripts", "scripts/lsruby_runner.rb", "setup.rb"]
13
11
  s.extra_rdoc_files = ["README"]
14
12
  s.extensions << "ext/lsapi/extconf.rb"
data/rails/dispatch.lsapi CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
+ if Process.euid == 0
4
+ warn 'ruby-lsapi: refusing to run as root'
5
+ exit 1
6
+ end
7
+
3
8
  if GC.respond_to?(:copy_on_write_friendly=)
4
9
  GC.copy_on_write_friendly = true
5
10
  end
@@ -11,6 +16,29 @@ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_
11
16
  require "dispatcher"
12
17
  require "lsapi"
13
18
 
14
- while LSAPI.accept != nil
15
- Dispatcher.dispatch
19
+ def dispatch_lsapi_request
20
+ Dispatcher.dispatch
21
+ rescue LSAPI::ConnectionError
22
+ # the client went away; drop the rest of this response
23
+ end
24
+
25
+ if LSAPI.respond_to?("accept_new_connection")
26
+ while LSAPI.accept_new_connection != nil
27
+ begin
28
+ fork do
29
+ LSAPI.postfork_child
30
+ while LSAPI.accept != nil
31
+ dispatch_lsapi_request
32
+ end
33
+ end
34
+ LSAPI.postfork_parent
35
+ rescue SystemCallError => e
36
+ LSAPI.postfork_failed
37
+ warn "ruby-lsapi: fork failed: #{e.message}"
38
+ end
39
+ end
40
+ else
41
+ while LSAPI.accept != nil
42
+ dispatch_lsapi_request
43
+ end
16
44
  end
@@ -1,5 +1,10 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
+ if Process.euid == 0
4
+ warn 'ruby-lsapi: refusing to run as root'
5
+ exit 1
6
+ end
7
+
3
8
  require 'lsapi'
4
9
 
5
10
  class CodeCache
@@ -26,7 +31,7 @@ class CodeCache
26
31
  def compile(filename)
27
32
  open(filename) do |f|
28
33
  s = f.read
29
- s.untaint
34
+ s.untaint if s.respond_to?(:untaint)
30
35
  binding = eval_string_wrap("binding")
31
36
  return eval(format("Proc.new {\n%s\n}", s), binding, filename, 0)
32
37
  end
@@ -39,12 +44,9 @@ $count = 0;
39
44
  $cache = CodeCache.new
40
45
 
41
46
 
42
- while true
43
- $req = LSAPI.accept
44
- break if $req == nil
45
-
47
+ def process_lsapi_request
46
48
  filename = ENV['SCRIPT_FILENAME']
47
- filename.untaint
49
+ filename.untaint if filename.respond_to?(:untaint)
48
50
 
49
51
  filename =~ %r{^(\/.*?)\/*([^\/]+)$}
50
52
  path = $1
@@ -52,13 +54,35 @@ while true
52
54
  #load( filename, true )
53
55
  code = $cache[filename]
54
56
  code.call
55
-
57
+ rescue LSAPI::ConnectionError
58
+ # the client went away; drop the rest of this response
59
+ end
60
+
61
+ if LSAPI.respond_to?("accept_new_connection")
62
+ while LSAPI.accept_new_connection != nil
63
+ begin
64
+ fork do
65
+ LSAPI.postfork_child
66
+ while ($req = LSAPI.accept) != nil
67
+ process_lsapi_request
68
+ end
69
+ end
70
+ LSAPI.postfork_parent
71
+ rescue SystemCallError => e
72
+ LSAPI.postfork_failed
73
+ warn "ruby-lsapi: fork failed: #{e.message}"
74
+ end
75
+ end
76
+ else
77
+ while ($req = LSAPI.accept) != nil
78
+ process_lsapi_request
79
+ end
56
80
  end
57
81
 
58
82
  class CodeEntry
59
- public :path, :name, :mtime, :opcode
83
+ attr_reader :path, :name, :mtime, :opcode
60
84
 
61
- def initizlize( filename, mtime, opcode )
85
+ def initialize( filename, mtime, opcode )
62
86
  filename =~ %r{^(\/.*?)\/*([^\/]+)$}
63
87
  @path = $1
64
88
  @name = $2
@@ -68,4 +92,3 @@ class CodeEntry
68
92
 
69
93
  end
70
94
 
71
-
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsapi
3
3
  version: !ruby/object:Gem::Version
4
- version: '5.7'
4
+ version: '5.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - LiteSpeed Technologies Inc.
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
10
+ date: 2026-10-26 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: This is a ruby extension for fast communication with LiteSpeed Web Server.
14
13
  email: info@litespeedtech.com
@@ -33,7 +32,6 @@ files:
33
32
  homepage: http://www.litespeedtech.com/
34
33
  licenses: []
35
34
  metadata: {}
36
- post_install_message:
37
35
  rdoc_options: []
38
36
  require_paths:
39
37
  - lib
@@ -48,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
46
  - !ruby/object:Gem::Version
49
47
  version: '0'
50
48
  requirements: []
51
- rubygems_version: 3.3.5
52
- signing_key:
49
+ rubygems_version: 3.6.7
53
50
  specification_version: 4
54
51
  summary: A ruby extension for fast communication with LiteSpeed Web Server.
55
52
  test_files: []