win32-service 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c61135d653d2cd836f4b191664aade237c35ceb
4
- data.tar.gz: 1d5c27933e9a68469dcc40ca580307e521eebfe0
3
+ metadata.gz: d9da3b7cac48ec6cfe0304595e3b6c6cdf8a7480
4
+ data.tar.gz: e71218d14b39f03d49582806ae139306c4570883
5
5
  SHA512:
6
- metadata.gz: c23f2a150c83ab807c44d15b7fd52efdfcfef3018472470838ebf3895685f10475a427e78375ca75f9b01367816a7668b920ca1dd257d4515df90b3fe67e22cb
7
- data.tar.gz: 705f5de01cdf3e709350385763afe7b7aa3bdf63c81b0b914da6a1c84181435b116e38617cf6a96974b2c836bf40632b25bf4ebd7463aadc1528606e674671ec
6
+ metadata.gz: 7952a1dcd227fbcf118cbfdc1c3d9efcd681b82a4f3f10e331506e4cecae2456c3d181fe2c853d056c7c197f83b3d72d3506d0313234c6297127e5c0910fdda8
7
+ data.tar.gz: 293fc5528459592f6cb781b48959db7184a88da758197271fa3f2bc2ed74c717b79e558d87381820b66c2d5cf2e1cc418b88e1efb915421f0d3674e40446a3de
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.8.5 - 2-Jul-2014
2
+ * The service type for Service.new no longer defaults to being an interactive
3
+ process. This could cause process credential issues and wasn't very
4
+ useful in practice anyway. Thanks go to Pierre Ynard for the report.
5
+ * More tests skipped unless run with admin privileges.
6
+ * Use relative_require instead of doing things manually.
7
+ * Minor memory efficieny improvements.
8
+ * Skip errors on ERROR_RESOURCE_TYPE_NOT_FOUND when getting service config info.
9
+ Thanks go to Rob Reynolds for the patch.
10
+
1
11
  == 0.8.4 - 23-Jan-2014
2
12
  * Added support for the delayed start startup type. Thanks go to Jim Arnold
3
13
  for the patch.
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ namespace 'gem' do
24
24
  desc "Install the win32-service gem"
25
25
  task :install => [:create] do
26
26
  file = Dir['*.gem'].first
27
- sh "gem install #{file}"
27
+ sh "gem install -l #{file}"
28
28
  end
29
29
  end
30
30
 
@@ -1,7 +1,7 @@
1
- require File.join(File.dirname(__FILE__), 'windows', 'helper')
2
- require File.join(File.dirname(__FILE__), 'windows', 'constants')
3
- require File.join(File.dirname(__FILE__), 'windows', 'structs')
4
- require File.join(File.dirname(__FILE__), 'windows', 'functions')
1
+ require_relative 'windows/helper'
2
+ require_relative 'windows/constants'
3
+ require_relative 'windows/structs'
4
+ require_relative 'windows/functions'
5
5
 
6
6
  # The Win32 module serves as a namespace only.
7
7
  module Win32
@@ -17,7 +17,7 @@ module Win32
17
17
  extend Windows::Functions
18
18
 
19
19
  # The version of the win32-service library
20
- VERSION = '0.8.4'
20
+ VERSION = '0.8.5'
21
21
 
22
22
  # SCM security and access rights
23
23
 
@@ -81,7 +81,7 @@ module Win32
81
81
  FILE_SYSTEM_DRIVER = SERVICE_FILE_SYSTEM_DRIVER
82
82
 
83
83
  # Service that runs in its own process
84
- WIN32_OWN_PROCESS = SERVICE_WIN32_OWN_PROCESS
84
+ WIN32_OWN_PROCESS = SERVICE_WIN32_OWN_PROCESS
85
85
 
86
86
  # Service that shares a process with one or more other services.
87
87
  WIN32_SHARE_PROCESS = SERVICE_WIN32_SHARE_PROCESS
@@ -260,8 +260,7 @@ module Win32
260
260
  # * host => nil (optional)
261
261
  # * display_name => service_name
262
262
  # * desired_access => Service::ALL_ACCESS
263
- # * service_type => Service::WIN32_OWN_PROCESS |
264
- # Service::INTERACTIVE_PROCESS
263
+ # * service_type => Service::WIN32_OWN_PROCESS
265
264
  # * start_type => Service::DEMAND_START
266
265
  # * error_control => Service::ERROR_NORMAL
267
266
  # * binary_path_name => nil
@@ -306,8 +305,7 @@ module Win32
306
305
  opts = {
307
306
  'display_name' => nil,
308
307
  'desired_access' => SERVICE_ALL_ACCESS,
309
- 'service_type' => SERVICE_WIN32_OWN_PROCESS |
310
- SERVICE_INTERACTIVE_PROCESS,
308
+ 'service_type' => SERVICE_WIN32_OWN_PROCESS,
311
309
  'start_type' => SERVICE_DEMAND_START,
312
310
  'error_control' => SERVICE_ERROR_NORMAL,
313
311
  'binary_path_name' => nil,
@@ -1334,7 +1332,7 @@ module Win32
1334
1332
  FFI.raise_windows_error('QueryServiceConfig', error)
1335
1333
  end
1336
1334
 
1337
- bytes_needed = FFI::MemoryPointer.new(:ulong)
1335
+ bytes_needed.clear
1338
1336
 
1339
1337
  # Second attempt at QueryServiceConfig gets the actual info
1340
1338
  begin
@@ -1369,14 +1367,14 @@ module Win32
1369
1367
  #
1370
1368
  if !bool && err_num == ERROR_INSUFFICIENT_BUFFER
1371
1369
  config2_buf = FFI::MemoryPointer.new(:char, bytes_needed.read_ulong)
1372
- elsif err_num == ERROR_FILE_NOT_FOUND
1370
+ elsif [ERROR_FILE_NOT_FOUND, ERROR_RESOURCE_TYPE_NOT_FOUND].include?(err_num)
1373
1371
  return err_num
1374
1372
  else
1375
1373
  CloseServiceHandle(handle)
1376
1374
  FFI.raise_windows_error('QueryServiceConfig2', err_num)
1377
1375
  end
1378
1376
 
1379
- bytes_needed = FFI::MemoryPointer.new(:ulong)
1377
+ bytes_needed.clear
1380
1378
 
1381
1379
  # Second attempt at QueryServiceConfig2 gets the actual info
1382
1380
  begin
@@ -136,6 +136,7 @@ module Windows
136
136
  ERROR_INSUFFICIENT_BUFFER = 122
137
137
  ERROR_MORE_DATA = 234
138
138
  ERROR_FILE_NOT_FOUND = 2
139
+ ERROR_RESOURCE_TYPE_NOT_FOUND = 1813
139
140
  WAIT_FAILED = 0xFFFFFFFF
140
141
  end
141
142
  end
@@ -12,6 +12,7 @@ class TC_Win32_Service < Test::Unit::TestCase
12
12
  def self.startup
13
13
  @@host = Socket.gethostname
14
14
  @@service_name = 'stisvc'
15
+ @@elevated = Win32::Security.elevated_security?
15
16
  end
16
17
 
17
18
  def setup
@@ -19,7 +20,6 @@ class TC_Win32_Service < Test::Unit::TestCase
19
20
  @service_name = 'stisvc'
20
21
  @service_stat = nil
21
22
  @services = []
22
- @elevated = Win32::Security.elevated_security?
23
23
 
24
24
  @singleton_methods = Win32::Service.methods.map{ |m| m.to_s }
25
25
  @instance_methods = Win32::Service.instance_methods.map{ |m| m.to_s }
@@ -52,7 +52,7 @@ class TC_Win32_Service < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  test "version number is expected value" do
55
- assert_equal('0.8.4', Win32::Service::VERSION)
55
+ assert_equal('0.8.5', Win32::Service::VERSION)
56
56
  end
57
57
 
58
58
  test "services basic functionality" do
@@ -99,6 +99,7 @@ class TC_Win32_Service < Test::Unit::TestCase
99
99
  end
100
100
 
101
101
  test "delete method raises an error if a bogus service name is provided" do
102
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
102
103
  assert_raise(SystemCallError){ Win32::Service.delete('bogus') }
103
104
  end
104
105
 
@@ -119,7 +120,7 @@ class TC_Win32_Service < Test::Unit::TestCase
119
120
  end
120
121
 
121
122
  test "pause and resume work as expected" do
122
- omit_unless(@elevated, "Skipped unless run with admin privileges")
123
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
123
124
  start_service(@service_name)
124
125
 
125
126
  assert_nothing_raised{ Win32::Service.pause(@service_name) }
@@ -130,6 +131,7 @@ class TC_Win32_Service < Test::Unit::TestCase
130
131
  end
131
132
 
132
133
  test "pausing an already paused service is harmless" do
134
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
133
135
  start_service(@service_name)
134
136
 
135
137
  assert_nothing_raised{ Win32::Service.pause(@service_name) }
@@ -178,6 +180,7 @@ class TC_Win32_Service < Test::Unit::TestCase
178
180
  end
179
181
 
180
182
  test "stop and start methods work as expected" do
183
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
181
184
  start_service(@service_name)
182
185
 
183
186
  assert_nothing_raised{ Win32::Service.stop(@service_name) }
@@ -188,6 +191,7 @@ class TC_Win32_Service < Test::Unit::TestCase
188
191
  end
189
192
 
190
193
  test "attempting to stop a stopped service raises an error" do
194
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
191
195
  start_service(@service_name)
192
196
 
193
197
  assert_nothing_raised{ Win32::Service.stop(@service_name) }
@@ -218,7 +222,8 @@ class TC_Win32_Service < Test::Unit::TestCase
218
222
  end
219
223
 
220
224
  test "attempting to start a running service raises an error" do
221
- start_service(@service_name)
225
+ omit_unless(@@elevated, "Skipped unless run with admin privileges")
226
+ start_service(@service_name)
222
227
  assert_raise(SystemCallError){ Win32::Service.start(@service_name) }
223
228
  end
224
229
 
@@ -413,7 +418,6 @@ class TC_Win32_Service < Test::Unit::TestCase
413
418
  @service_name = nil
414
419
  @service_stat = nil
415
420
  @services = nil
416
- @elevated = nil
417
421
  end
418
422
 
419
423
  def self.shutdown
@@ -427,5 +431,7 @@ class TC_Win32_Service < Test::Unit::TestCase
427
431
  unless ['running', 'start pending'].include?(status)
428
432
  Win32::Service.start(@@service_name)
429
433
  end
434
+
435
+ @@elevated = nil
430
436
  end
431
437
  end
@@ -47,7 +47,7 @@ class TC_Win32_Service_Configure < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  test "configuring the service type works as expected" do
50
- assert_equal('own process, interactive', config_info.service_type)
50
+ assert_equal('own process', config_info.service_type)
51
51
  service_configure(:service_type => Win32::Service::WIN32_SHARE_PROCESS)
52
52
  assert_equal('share process', config_info.service_type)
53
53
  end
@@ -65,7 +65,7 @@ class TC_Win32_Service_Configure < Test::Unit::TestCase
65
65
  end
66
66
 
67
67
  test "service start can be delayed" do
68
- service_configure(:start_type => Win32::Service::AUTO_START, :delayed_start => true)
68
+ service_configure(:start_type => Win32::Service::AUTO_START, :delayed_start => true)
69
69
  assert_true(full_info.delayed_start)
70
70
  end
71
71
 
@@ -54,7 +54,7 @@ class TC_Win32_Service_Create < Test::Unit::TestCase
54
54
  end
55
55
 
56
56
  test "expected service type configuration information" do
57
- assert_equal('own process, interactive', @info1.service_type)
57
+ assert_equal('own process', @info1.service_type)
58
58
  end
59
59
 
60
60
  test "expected start type configuration information" do
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-service'
5
- spec.version = '0.8.4'
5
+ spec.version = '0.8.5'
6
6
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -71,6 +71,9 @@ extra_rdoc_files:
71
71
  - doc/daemon.txt
72
72
  files:
73
73
  - CHANGES
74
+ - MANIFEST
75
+ - README
76
+ - Rakefile
74
77
  - doc/daemon.txt
75
78
  - doc/service.txt
76
79
  - examples/demo_daemon.rb
@@ -82,9 +85,6 @@ files:
82
85
  - lib/win32/windows/functions.rb
83
86
  - lib/win32/windows/helper.rb
84
87
  - lib/win32/windows/structs.rb
85
- - MANIFEST
86
- - Rakefile
87
- - README
88
88
  - test/test_win32_daemon.rb
89
89
  - test/test_win32_service.rb
90
90
  - test/test_win32_service_configure.rb
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.0.3
115
+ rubygems_version: 2.2.2
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: An interface for MS Windows services