commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r161096 - in jakarta/commons/proper/daemon/trunk/src/native/nt/procrun: apps/apsvcmgr/apsvcmgr.c apps/prunmgr/prunmgr.c apps/prunsrv/prunsrv.c include/service.h src/service.c
Date Tue, 12 Apr 2005 19:23:41 GMT
Author: mturk
Date: Tue Apr 12 12:23:39 2005
New Revision: 161096

URL: http://svn.apache.org/viewcvs?view=rev&rev=161096
Log:
Finer grade access to the Service manager.

Modified:
    jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c
    jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c
    jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
    jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/include/service.h
    jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c

Modified: jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c?view=diff&r1=161095&r2=161096
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c Tue
Apr 12 12:23:39 2005
@@ -262,14 +262,15 @@
     switch (uMsg) {
         case WM_USER+1:
             hDlg = (HWND)lParam;
-            hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
+            hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
             if (!hSrv) {
                 EndDialog(hDlg, IDOK);
                 PostMessage(_gui_store->hMainWnd, WM_COMMAND,
                             MAKEWPARAM(IDMS_REFRESH, 0), 0);
                 return FALSE;
             }
-            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+                                GENERIC_READ | GENERIC_EXECUTE)) {
                 apxCloseHandle(hSrv);
                 EndDialog(hDlg, IDOK);
                 PostMessage(_gui_store->hMainWnd, WM_COMMAND,
@@ -303,10 +304,11 @@
     switch (uMsg) {
         case WM_USER+1:
             hDlg = (HWND)lParam;
-            hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
+            hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
             if (!hSrv)
                 return FALSE;
-            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+                                GENERIC_READ | GENERIC_EXECUTE)) {
                 apxCloseHandle(hSrv);
                 return FALSE;
             }
@@ -337,10 +339,11 @@
     switch (uMsg) {
         case WM_USER+1:
             hDlg = (HWND)lParam;
-            hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
+            hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
             if (!hSrv)
                 return FALSE;
-            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+                                GENERIC_READ | GENERIC_EXECUTE)) {
                 apxCloseHandle(hSrv);
                 return FALSE;
             }
@@ -374,10 +377,11 @@
     switch (uMsg) {
         case WM_USER+1:
             hDlg = (HWND)lParam;
-            hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE);
+            hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
             if (!hSrv)
                 return FALSE;
-            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+            if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+                                GENERIC_READ | GENERIC_EXECUTE)) {
                 apxCloseHandle(hSrv);
                 return FALSE;
             }
@@ -648,9 +652,9 @@
         return TRUE;
     CLR_BIT_FLAG(_propertyChanged, 1);
 
-    if (!(hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE)))
+    if (!(hSrv = apxCreateService(hPool, SC_MANAGER_CREATE_SERVICE, FALSE)))
         return FALSE;
-    if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+    if (!apxServiceOpen(hSrv, _currentEntry->szServiceName, SERVICE_ALL_ACCESS)) {
         apxCloseHandle(hSrv);
         return FALSE;
     }
@@ -685,9 +689,9 @@
         return TRUE;
     CLR_BIT_FLAG(_propertyChanged, 2);
 
-    if (!(hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE)))
+    if (!(hSrv = apxCreateService(hPool, SC_MANAGER_CREATE_SERVICE, FALSE)))
         return FALSE;
-    if (!apxServiceOpen(hSrv, _currentEntry->szServiceName)) {
+    if (!apxServiceOpen(hSrv, _currentEntry->szServiceName, SERVICE_ALL_ACCESS)) {
         apxCloseHandle(hSrv);
         return FALSE;
     }
@@ -1364,8 +1368,9 @@
                         if (apxYesNoMessage(apxLoadResource(IDS_DELSERVICEC, 0),
                                             szT, TRUE)) {
                             APXHANDLE hSrv;
-                            if ((hSrv = apxCreateService(hPool, GENERIC_ALL, FALSE))) {
-                                if (apxServiceOpen(hSrv, _currentEntry->szServiceName))
{
+                            if ((hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE)))
{
+                                if (apxServiceOpen(hSrv, _currentEntry->szServiceName,
+                                                   SERVICE_ALL_ACCESS)) {
                                     apxServiceDelete(hSrv);
                                     RefreshServices(1);
                                 }

Modified: jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c?view=diff&r1=161095&r2=161096
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunmgr/prunmgr.c Tue Apr
12 12:23:39 2005
@@ -1580,18 +1580,20 @@
         quiet = TRUE;
     else if (lpCmdline->dwCmdIndex >= 2)
         bEnableTry = TRUE;
-    hService = apxCreateService(hPool, GENERIC_ALL, FALSE);
+    hService = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
     if (IS_INVALID_HANDLE(hService)) {
         if (!quiet)
             apxDisplayError(TRUE, NULL, 0, "Unable to open the Service Manager");
         goto cleanup;
     }
     /* Open the main service handle */
-    if (!apxServiceOpen(hService, lpCmdline->szApplication)) {
+    if (!apxServiceOpen(hService, lpCmdline->szApplication,
+                        GENERIC_READ | GENERIC_EXECUTE)) {
         LPWSTR w = lpCmdline->szApplication + lstrlenW(lpCmdline->szApplication) -
1;
         if (*w == L'w')
             *w = L'\0';
-        if (!apxServiceOpen(hService, lpCmdline->szApplication)) {
+        if (!apxServiceOpen(hService, lpCmdline->szApplication,
+                            GENERIC_READ | GENERIC_EXECUTE)) {
             if (!quiet)
                 apxDisplayError(TRUE, NULL, 0, "Unable to open the service '%S'",
                                 lpCmdline->szApplication);

Modified: jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c?view=diff&r1=161095&r2=161096
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/apps/prunsrv/prunsrv.c Tue Apr
12 12:23:39 2005
@@ -493,7 +493,7 @@
     WCHAR szImage[SIZ_HUGLEN];
     
     apxLogWrite(APXLOG_MARK_DEBUG "Installing service...");
-    hService = apxCreateService(gPool, GENERIC_ALL, FALSE);
+    hService = apxCreateService(gPool, SC_MANAGER_CREATE_SERVICE, FALSE);
     if (IS_INVALID_HANDLE(hService)) {
         apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
         return FALSE;
@@ -558,13 +558,13 @@
     BOOL  rv = FALSE;
 
     apxLogWrite(APXLOG_MARK_INFO "Deleting service...");
-    hService = apxCreateService(gPool, GENERIC_ALL, FALSE);
+    hService = apxCreateService(gPool, SC_MANAGER_CONNECT, FALSE);
     if (IS_INVALID_HANDLE(hService)) {
         apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
         return FALSE;
     }
     /* Delete service will stop the service if running */
-    if (apxServiceOpen(hService, lpCmdline->szApplication)) {
+    if (apxServiceOpen(hService, lpCmdline->szApplication, SERVICE_ALL_ACCESS)) {
         WCHAR szWndManagerClass[SIZ_RESLEN];
         HANDLE hWndManager = NULL;
         lstrcpyW(szWndManagerClass, lpCmdline->szApplication);
@@ -604,7 +604,8 @@
 
     SetLastError(ERROR_SUCCESS);
     /* Open the service */
-    if (apxServiceOpen(hService, lpCmdline->szApplication)) {
+    if (apxServiceOpen(hService, lpCmdline->szApplication,
+                       GENERIC_READ | GENERIC_EXECUTE)) {
         rv = apxServiceControl(hService,
                                SERVICE_CONTROL_STOP,
                                0,
@@ -633,14 +634,14 @@
 
     apxLogWrite(APXLOG_MARK_INFO "Updating service...");
 
-    hService = apxCreateService(gPool, GENERIC_ALL, FALSE);
+    hService = apxCreateService(gPool, SC_MANAGER_CREATE_SERVICE, FALSE);
     if (IS_INVALID_HANDLE(hService)) {
         apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
         return FALSE;
     }
     SetLastError(0);
     /* Open the service */
-    if (apxServiceOpen(hService, lpCmdline->szApplication)) {
+    if (apxServiceOpen(hService, lpCmdline->szApplication, SERVICE_ALL_ACCESS)) {
         apxServiceSetNames(hService,
                            NULL,                /* Never update the ImagePath */
                            SO_DISPLAYNAME,

Modified: jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/include/service.h
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/include/service.h?view=diff&r1=161095&r2=161096
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/include/service.h (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/include/service.h Tue Apr 12
12:23:39 2005
@@ -33,7 +33,7 @@
 APXHANDLE   apxCreateService(APXHANDLE hPool, DWORD dwOptions,
                              BOOL bManagerMode);
 
-BOOL        apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName);
+BOOL        apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName, DWORD dwOptions);
 
 
 BOOL        apxServiceSetNames(APXHANDLE hService, LPCWSTR szImagePath,

Modified: jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c?view=diff&r1=161095&r2=161096
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/nt/procrun/src/service.c Tue Apr 12 12:23:39
2005
@@ -28,8 +28,6 @@
                          u,p,d)
 
 typedef struct APXSERVICE {
-    /* Service access options */
-    DWORD           dwOptions;
     /* Are we a service manager or we are the service itself */
     BOOL            bManagerMode;
     /* Handle to the current service */
@@ -90,7 +88,6 @@
     }
     hService->dwType = APXHANDLE_TYPE_SERVICE;
     lpService = APXHANDLE_DATA(hService);
-    lpService->dwOptions    = dwOptions;
     lpService->hManager     = hManager;
     lpService->bManagerMode = bManagerMode;
 
@@ -98,7 +95,7 @@
 }
 
 BOOL
-apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName)
+apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName, DWORD dwOptions)
 {
     LPAPXSERVICE lpService;
     DWORD dwNeeded;
@@ -122,7 +119,7 @@
     /* Open the service */
     lpService->hService = OpenServiceW(lpService->hManager,
                                        szServiceName,
-                                       lpService->dwOptions);
+                                       dwOptions);
 
     if (IS_INVALID_HANDLE(lpService->hService)) {
         apxLogWrite(APXLOG_MARK_SYSERR);
@@ -405,7 +402,7 @@
     lpService->hService = CreateServiceW(lpService->hManager,
                                          szServiceName,
                                          szDisplayName,
-                                         lpService->dwOptions,
+                                         SERVICE_ALL_ACCESS,
                                          dwServiceType,
                                          dwStartType,
                                          SERVICE_ERROR_NORMAL,



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message