[PATCH 0/2] MR10113: services: Allow ".\LocalSystem" account name for an interactive service.
From: Andrew Nguyen <arethusa26@gmail.com> --- dlls/advapi32/tests/service.c | 45 +++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index f0882e33aff..100864d8c94 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -200,9 +200,21 @@ static void test_create_delete_svc(void) static const CHAR pathname [] = "we_dont_care.exe"; static const CHAR empty [] = ""; static const CHAR password [] = "secret"; + static const struct + { + const CHAR *account; + BOOL todo; + } localsystem_account_tests[] = + { + {"LocalSystem"}, + {"localsystem"}, + {".\\LocalSystem", TRUE}, + {".\\localsystem", TRUE}, + }; char buffer[200]; DWORD size; BOOL ret; + UINT i; /* Get the username and turn it into an account to be used in some tests */ GetUserNameA(username, &user_size); @@ -325,8 +337,37 @@ static void test_create_delete_svc(void) svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, account, password); ok(!svc_handle1, "Expected failure\n"); - ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INVALID_SERVICE_ACCOUNT, - "Expected ERROR_INVALID_PARAMETER or ERROR_INVALID_SERVICE_ACCOUNT, got %ld\n", GetLastError()); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + + SetLastError(0xdeadbeef); + svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL, SERVICE_WIN32_SHARE_PROCESS | SERVICE_INTERACTIVE_PROCESS, + SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, account, password); + ok(!svc_handle1, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); + + /* A valid LocalSystem account name is accepted for an interactive service. */ + for (i = 0; i < ARRAY_SIZE(localsystem_account_tests); i++) + { + winetest_push_context("%u:%s", i, localsystem_account_tests[i].account); + + do + { + SetLastError(0xdeadbeef); + svc_handle1 = CreateServiceA(scm_handle, servicename, NULL, GENERIC_ALL, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, + SERVICE_DISABLED, 0, pathname, NULL, NULL, NULL, localsystem_account_tests[i].account, NULL); + } while (!svc_handle1 && GetLastError() == ERROR_SERVICE_MARKED_FOR_DELETE); + todo_wine_if(localsystem_account_tests[i].todo) + ok(!!svc_handle1, "Failed to create service, error %lu\n", GetLastError()); + + if (svc_handle1) + { + ret = DeleteService(svc_handle1); + ok(ret, "Failed to delete service, error %lu\n", GetLastError()); + CloseServiceHandle(svc_handle1); + } + + winetest_pop_context(); + } /* Illegal (start-type is not a mask and should only be one of the possibilities) * Remark : 'OR'-ing them could result in a valid possibility (but doesn't make sense as -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10113
From: Andrew Nguyen <arethusa26@gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59426 --- dlls/advapi32/tests/service.c | 4 ++-- programs/services/services.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index 100864d8c94..8eccfe27f0b 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -208,8 +208,8 @@ static void test_create_delete_svc(void) { {"LocalSystem"}, {"localsystem"}, - {".\\LocalSystem", TRUE}, - {".\\localsystem", TRUE}, + {".\\LocalSystem"}, + {".\\localsystem"}, }; char buffer[200]; DWORD size; diff --git a/programs/services/services.c b/programs/services/services.c index dff3cd60040..0830a75016b 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -520,9 +520,12 @@ BOOL validate_service_config(struct service_entry *entry) case SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS: case SERVICE_WIN32_SHARE_PROCESS | SERVICE_INTERACTIVE_PROCESS: /* These can be only run as LocalSystem */ - if (entry->config.lpServiceStartName && wcsicmp(entry->config.lpServiceStartName, L"LocalSystem") != 0) + if (entry->config.lpServiceStartName && + wcsicmp(entry->config.lpServiceStartName, L"LocalSystem") != 0 && + wcsicmp(entry->config.lpServiceStartName, L".\\LocalSystem") != 0) { - WINE_ERR("Service %s is interactive but has a start name\n", wine_dbgstr_w(entry->name)); + WINE_ERR("Service %s is interactive but has the disallowed account name %s\n", + wine_dbgstr_w(entry->name), wine_dbgstr_w(entry->config.lpServiceStartName)); return FALSE; } break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10113
participants (2)
-
Andrew Nguyen -
Andrew Nguyen (@arethusa)