Skip to content

Commit 34a70df

Browse files
committed
CreateService() requires admin rights
Calling Win32::Daemon::CreateService() without sufficient privileges was resulting in uninformative "The operation completed successfully" error. Lack of meaningful error message was caused by not calling GetLastError() after OpenSCManager() failure. Resolves RT#73715, RT#86501 and RT#86882.
1 parent b499db8 commit 34a70df

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Revision history for Perl extension {{$dist->name}}
1010
- Move Daemon.pm to its proper spot in the lib/Win32 directory
1111
- Take Cygwin out of the supported OSes as there are many compilation errors
1212
at the moment. Please submit a PR if you are capable of fixing this!
13+
- Document that CreateService() requires admin rights and don't hide
14+
"permission denied" error (RT #73715, RT #86501 and RT #86882)
1315

1416
20131206 2013-12-06
1517
- Fix required perl version 5.6 -> 5.006

Daemon.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@
144144
gdwLastError = GetLastError(); \
145145
} \
146146
CloseServiceHandle( hSc ); \
147+
} \
148+
else \
149+
{ \
150+
gdwLastError = GetLastError(); \
147151
}
148152

149153

lib/Win32/Daemon.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ This function creates a new service in the system configuration. The
264264
return is TRUE if the service was created, and FALSE otherwise. If an error
265265
occurred, call GetLastError to retrieve the actual error code.
266266
267+
B<NOTE:> This function will fail if the script is not running with administrator
268+
privileges.
269+
267270
The hash describes the service to be created. The keys are:
268271
269272
=over 4

0 commit comments

Comments
 (0)