This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
commit 1ab887dc5eeb57c2c1f71453b9fac55d07486494 Author: Mark Thomas <[email protected]> AuthorDate: Thu May 23 21:53:47 2019 +0100 Add LocalService and NetworkService to procrun GUI for log on config --- src/changes/changes.xml | 4 + src/native/windows/apps/prunmgr/prunmgr.c | 149 ++++++++++++++++++++--------- src/native/windows/apps/prunmgr/prunmgr.h | 20 ++-- src/native/windows/apps/prunmgr/prunmgr.rc | 22 +++-- src/site/xdoc/procrun.xml | 4 + 5 files changed, 137 insertions(+), 62 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 456926a..1b6cd5a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -96,6 +96,10 @@ Procrun. Ensure that environment variables set via prunsrv are visible to native libraries that depend on the Universal CRT. </action> + <action type="add" dev="markt"> + Procrun. Add 'NT Authority\LocalService' and + 'NT Authority\NetworkService' as options to the Log On user interface. + </action> </release> <release version="1.1.0" date="2017-11-15" description="Feature and bug fix release"> <action issue="DAEMON-368" type="add" dev="ggregory"> diff --git a/src/native/windows/apps/prunmgr/prunmgr.c b/src/native/windows/apps/prunmgr/prunmgr.c index 8f92f95..4f317bd 100644 --- a/src/native/windows/apps/prunmgr/prunmgr.c +++ b/src/native/windows/apps/prunmgr/prunmgr.c @@ -41,6 +41,9 @@ LPAPXGUISTORE _gui_store = NULL; #define STAT_STOPPED TEXT("Stopped") #define STAT_DISABLED TEXT("Disabled") #define STAT_NONE TEXT("") + +#define STAT_SERVICE L"NT AUTHORITY\\LocalService" +#define STAT_NET_SERVICE L"NT AUTHORITY\\NetworkService" #define STAT_SYSTEM L"LocalSystem" #define LOGL_ERROR L"Error" @@ -48,7 +51,6 @@ LPAPXGUISTORE _gui_store = NULL; #define LOGL_INFO L"Info" #define LOGL_WARN L"Warn" - #define START_AUTO L"Automatic" #define START_MANUAL L"Manual" #define START_DISABLED L"Disabled" @@ -340,7 +342,28 @@ BOOL __generalLogonSave(HWND hDlg) GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, SIZ_RESMAX); GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, SIZ_RESMAX); - if (lstrlenW(szU) && lstrcmpiW(szU, STAT_SYSTEM)) { + if (lstrlenW(szU) == 0 || lstrcmpiW(szU, STAT_SERVICE) == 0) { + apxServiceSetNames(hService, NULL, NULL, NULL, STAT_SERVICE, L""); + lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, STAT_SERVICE); + } + else if (lstrcmpiW(szU, STAT_NET_SERVICE) == 0) { + apxServiceSetNames(hService, NULL, NULL, NULL, STAT_NET_SERVICE, L""); + lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, STAT_NET_SERVICE); + } + else if (lstrcmpiW(szU, STAT_SYSTEM) == 0) { + apxServiceSetNames(hService, NULL, NULL, NULL, STAT_SYSTEM, L""); + lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, STAT_SYSTEM); + if (IsDlgButtonChecked(hDlg, IDC_PPSLID) == BST_CHECKED) { + apxServiceSetOptions(hService, + _currentEntry->stServiceStatus.dwServiceType | SERVICE_INTERACTIVE_PROCESS, + SERVICE_NO_CHANGE, SERVICE_NO_CHANGE); + } + else { + apxServiceSetOptions(hService, + _currentEntry->stServiceStatus.dwServiceType & ~SERVICE_INTERACTIVE_PROCESS, + SERVICE_NO_CHANGE, SERVICE_NO_CHANGE); + } + } else { if (szP[0] != L' ' && szC[0] != L' ' && !lstrcmpW(szP, szC)) { apxServiceSetNames(hService, NULL, NULL, NULL, szU, szP); lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, szU); @@ -352,18 +375,7 @@ BOOL __generalLogonSave(HWND hDlg) return FALSE; } } - else { - apxServiceSetNames(hService, NULL, NULL, NULL, STAT_SYSTEM, L""); - lstrlcpyW(_currentEntry->szObjectName, SIZ_RESLEN, STAT_SYSTEM); - if (IsDlgButtonChecked(hDlg, IDC_PPSLID) == BST_CHECKED) - apxServiceSetOptions(hService, - _currentEntry->stServiceStatus.dwServiceType | SERVICE_INTERACTIVE_PROCESS, - SERVICE_NO_CHANGE, SERVICE_NO_CHANGE); - else - apxServiceSetOptions(hService, - _currentEntry->stServiceStatus.dwServiceType & ~SERVICE_INTERACTIVE_PROCESS, - SERVICE_NO_CHANGE, SERVICE_NO_CHANGE); - } + if (!(TST_BIT_FLAG(_propertyChanged, 1))) PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0); return TRUE; @@ -709,7 +721,9 @@ LRESULT CALLBACK __logonProperty(HWND hDlg, switch (uMessage) { case WM_INITDIALOG: { - BOOL bAccount = FALSE; + BOOL bNamedAccount = FALSE; + BOOL bLocalServiceAccount = FALSE; + startPage = 1; if (!bpropCentered) apxCenterWindow(GetParent(hDlg), NULL); @@ -718,33 +732,86 @@ LRESULT CALLBACK __logonProperty(HWND hDlg, SendMessage(GetDlgItem(hDlg, IDC_PPSLUSER), EM_LIMITTEXT, 63, 0); SendMessage(GetDlgItem(hDlg, IDC_PPSLPASS), EM_LIMITTEXT, 63, 0); SendMessage(GetDlgItem(hDlg, IDC_PPSLCPASS), EM_LIMITTEXT, 63, 0); - /* Check if we use LocalSystem or user defined account */ - if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) { - bAccount = TRUE; + + // LocalService + if (lstrcmpiW(_currentEntry->szObjectName, STAT_SERVICE) == 0) { + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, IDC_PPSLLSRV); + } + // NetworkService + else if (lstrcmpiW(_currentEntry->szObjectName, STAT_NET_SERVICE) == 0) { + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, IDC_PPSLNSRV); + } + // LocalSystem + else if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM) == 0) { + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, IDC_PPSLLSYS); + bLocalServiceAccount = TRUE; + if (_currentEntry->lpConfig->dwServiceType & SERVICE_INTERACTIVE_PROCESS) { + CheckDlgButton(hDlg, IDC_PPSLID, BST_CHECKED); + } + } + else { + bNamedAccount = TRUE; CheckRadioButton(hDlg, IDC_PPSLLSYS, IDC_PPSLUA, IDC_PPSLUA); SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName); SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD); SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD); } - else { - CheckRadioButton(hDlg, IDC_PPSLLSYS, IDC_PPSLUA, IDC_PPSLLSYS); - if (_currentEntry->lpConfig->dwServiceType & - SERVICE_INTERACTIVE_PROCESS) - CheckDlgButton(hDlg, IDC_PPSLID, BST_CHECKED); - } - EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), !bAccount); - EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), bAccount); - EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), bAccount); - EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), bAccount); - EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), bAccount); - EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), bAccount); - EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), bAccount); + + EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), !bLocalServiceAccount); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), bNamedAccount); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), bNamedAccount); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), bNamedAccount); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), bNamedAccount); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), bNamedAccount); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), bNamedAccount); } break; case WM_COMMAND: switch (LOWORD(wParam)) { + case IDC_PPSLLSRV: + SetDlgItemTextW(hDlg, IDC_PPSLUSER, STAT_SERVICE); + SetDlgItemTextW(hDlg, IDC_PPSLPASS, L""); + SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L""); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE); + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, (INT)wParam); + if (lstrcmpiW(_currentEntry->szObjectName, STAT_SERVICE)) { + PropSheet_Changed(GetParent(hDlg), hDlg); + SET_BIT_FLAG(_propertyChanged, 2); + } + else { + PropSheet_UnChanged(GetParent(hDlg), hDlg); + CLR_BIT_FLAG(_propertyChanged, 2); + } + break; + case IDC_PPSLNSRV: + SetDlgItemTextW(hDlg, IDC_PPSLUSER, STAT_NET_SERVICE); + SetDlgItemTextW(hDlg, IDC_PPSLPASS, L""); + SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L""); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE); + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, (INT)wParam); + if (lstrcmpiW(_currentEntry->szObjectName, STAT_NET_SERVICE)) { + PropSheet_Changed(GetParent(hDlg), hDlg); + SET_BIT_FLAG(_propertyChanged, 2); + } + else { + PropSheet_UnChanged(GetParent(hDlg), hDlg); + CLR_BIT_FLAG(_propertyChanged, 2); + } + break; case IDC_PPSLLSYS: - SetDlgItemTextW(hDlg, IDC_PPSLUSER, L""); + SetDlgItemTextW(hDlg, IDC_PPSLUSER, STAT_SYSTEM); SetDlgItemTextW(hDlg, IDC_PPSLPASS, L""); SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L""); EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE); @@ -754,7 +821,7 @@ LRESULT CALLBACK __logonProperty(HWND hDlg, EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE); EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE); - CheckRadioButton(hDlg, IDC_PPSLLSYS, IDC_PPSLUA, (INT)wParam); + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, (INT)wParam); if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) { PropSheet_Changed(GetParent(hDlg), hDlg); SET_BIT_FLAG(_propertyChanged, 2); @@ -763,7 +830,7 @@ LRESULT CALLBACK __logonProperty(HWND hDlg, PropSheet_UnChanged(GetParent(hDlg), hDlg); CLR_BIT_FLAG(_propertyChanged, 2); } - break; + break; case IDC_PPSLUA: SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName); SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD); @@ -775,16 +842,10 @@ LRESULT CALLBACK __logonProperty(HWND hDlg, EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), TRUE); EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), TRUE); - CheckRadioButton(hDlg, IDC_PPSLLSYS, IDC_PPSLUA, (INT)wParam); - if (lstrcmpW(_currentEntry->szObjectName, STAT_SYSTEM)) { - PropSheet_Changed(GetParent(hDlg), hDlg); - SET_BIT_FLAG(_propertyChanged, 2); - } - else { - PropSheet_UnChanged(GetParent(hDlg), hDlg); - CLR_BIT_FLAG(_propertyChanged, 2); - } - break; + CheckRadioButton(hDlg, IDC_PPSLLSRV, IDC_PPSLUA, (INT)wParam); + PropSheet_UnChanged(GetParent(hDlg), hDlg); + CLR_BIT_FLAG(_propertyChanged, 2); + break; case IDC_PPSLID: PropSheet_Changed(GetParent(hDlg), hDlg); SET_BIT_FLAG(_propertyChanged, 2); diff --git a/src/native/windows/apps/prunmgr/prunmgr.h b/src/native/windows/apps/prunmgr/prunmgr.h index 206074c..6d9b273 100644 --- a/src/native/windows/apps/prunmgr/prunmgr.h +++ b/src/native/windows/apps/prunmgr/prunmgr.h @@ -58,15 +58,17 @@ #define IDC_PPSGRESTART 2610 #define IDD_PROPPAGE_LOGON 2620 -#define IDC_PPSLLSYS 2621 -#define IDC_PPSLID 2622 -#define IDC_PPSLUA 2623 -#define IDC_PPSLUSER 2624 -#define IDC_PPSLBROWSE 2625 -#define IDC_PPSLPASS 2626 -#define IDC_PPSLCPASS 2627 -#define IDL_PPSLPASS 2628 -#define IDL_PPSLCPASS 2629 +#define IDC_PPSLLSRV 2621 +#define IDC_PPSLNSRV 2622 +#define IDC_PPSLLSYS 2623 +#define IDC_PPSLID 2624 +#define IDC_PPSLUA 2625 +#define IDC_PPSLUSER 2626 +#define IDC_PPSLBROWSE 2627 +#define IDC_PPSLPASS 2628 +#define IDC_PPSLCPASS 2629 +#define IDL_PPSLPASS 2630 +#define IDL_PPSLCPASS 2631 #define IDD_PROPPAGE_LOGGING 2640 #define IDC_PPLGLEVEL 2641 diff --git a/src/native/windows/apps/prunmgr/prunmgr.rc b/src/native/windows/apps/prunmgr/prunmgr.rc index 1b1e1e2..dcfeea0 100644 --- a/src/native/windows/apps/prunmgr/prunmgr.rc +++ b/src/native/windows/apps/prunmgr/prunmgr.rc @@ -108,18 +108,22 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN LTEXT "Log on as:",IDC_STATIC,10,8,51,8 - CONTROL "&Local System account",IDC_PPSLLSYS,"Button", + CONTROL "&Local Service account",IDC_PPSLLSRV,"Button", BS_AUTORADIOBUTTON,10,23,85,10 + CONTROL "&Network Service account",IDC_PPSLNSRV,"Button", + BS_AUTORADIOBUTTON,10,45,95,10 + CONTROL "Local &System account",IDC_PPSLLSYS,"Button", + BS_AUTORADIOBUTTON,10,67,85,10 CONTROL "Allo&w service to interact with desktop",IDC_PPSLID, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,37,135,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,81,135,10 CONTROL "&This account:",IDC_PPSLUA,"Button",BS_AUTORADIOBUTTON, - 10,59,61,10 - EDITTEXT IDC_PPSLUSER,86,58,114,12,ES_AUTOHSCROLL - PUSHBUTTON "&Browse...",IDC_PPSLBROWSE,205,57,50,14 - LTEXT "&Password:",IDL_PPSLPASS,21,76,36,8 - EDITTEXT IDC_PPSLPASS,86,75,114,12,ES_PASSWORD | ES_AUTOHSCROLL - LTEXT "&Confirm Password:",IDL_PPSLCPASS,20,93,63,8 - EDITTEXT IDC_PPSLCPASS,86,92,114,12,ES_PASSWORD | ES_AUTOHSCROLL + 10,103,61,10 + EDITTEXT IDC_PPSLUSER,86,102,114,12,ES_AUTOHSCROLL + PUSHBUTTON "&Browse...",IDC_PPSLBROWSE,205,101,50,14 + LTEXT "&Password:",IDL_PPSLPASS,21,120,36,8 + EDITTEXT IDC_PPSLPASS,86,119,114,12,ES_PASSWORD | ES_AUTOHSCROLL + LTEXT "&Confirm Password:",IDL_PPSLCPASS,20,137,63,8 + EDITTEXT IDC_PPSLCPASS,86,136,114,12,ES_PASSWORD | ES_AUTOHSCROLL END IDD_PROPPAGE_LOGGING DIALOGEX 0, 0, 260, 243 diff --git a/src/site/xdoc/procrun.xml b/src/site/xdoc/procrun.xml index 715965e..5838b24 100644 --- a/src/site/xdoc/procrun.xml +++ b/src/site/xdoc/procrun.xml @@ -354,6 +354,10 @@ will add the new value(s) to any existing value(s). Use an account name in the form <i>DomainName\UserName</i>. The service process will be logged on as this user. if the account belongs to the built-in domain, you can specify <i>.\UserName</i> + Note that the Service Control Manager does not accept localised forms of + the standard names so to use them you need to specify + <i>NT Authority\LocalService</i>, <i>NT Authority\NetworkService</i> or + <i>LocalSystem</i> as appropriate. </td> </tr> <tr>
