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 +4 -4
- data/CHANGES +10 -0
- data/Rakefile +1 -1
- data/lib/win32/service.rb +11 -13
- data/lib/win32/windows/constants.rb +1 -0
- data/test/test_win32_service.rb +11 -5
- data/test/test_win32_service_configure.rb +2 -2
- data/test/test_win32_service_create.rb +1 -1
- data/win32-service.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9da3b7cac48ec6cfe0304595e3b6c6cdf8a7480
|
4
|
+
data.tar.gz: e71218d14b39f03d49582806ae139306c4570883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/win32/service.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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.
|
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
|
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
|
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
|
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
|
1377
|
+
bytes_needed.clear
|
1380
1378
|
|
1381
1379
|
# Second attempt at QueryServiceConfig2 gets the actual info
|
1382
1380
|
begin
|
data/test/test_win32_service.rb
CHANGED
@@ -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.
|
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(
|
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
|
-
|
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
|
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
|
-
|
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
|
57
|
+
assert_equal('own process', @info1.service_type)
|
58
58
|
end
|
59
59
|
|
60
60
|
test "expected start type configuration information" do
|
data/win32-service.gemspec
CHANGED
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
|
+
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-
|
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.
|
115
|
+
rubygems_version: 2.2.2
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: An interface for MS Windows services
|