- From c6d6e4f2c3313bfc323273776e0e2d7bd001ce43 Mon Sep 17 00:00:00 2001
- From: Aurelien Couderc <aurelien.couderc2002@gmail.com>
- Date: Fri, 20 Jun 2025 12:03:09 +0200
- Subject: [PATCH 1/2] daemon,tests: Invalid HANDLE should have the value
- INVALID_HANDLE_VALUE, not NULL
- Invalid HANDLE should have the value INVALID_HANDLE_VALUE, not NULL.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/util.c | 7 ++++---
- tests/winsg/winsg.c | 2 +-
- 2 files changed, 5 insertions(+), 4 deletions(-)
- diff --git a/daemon/util.c b/daemon/util.c
- index 765fb27..3a56b7c 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -435,7 +435,7 @@ subcmd_popen_context *subcmd_popen(const char *command)
- if (!pinfo)
- return NULL;
- - pinfo->hReadPipe = pinfo->hWritePipe = NULL;
- + pinfo->hReadPipe = pinfo->hWritePipe = INVALID_HANDLE_VALUE;
- #ifdef NOT_WORKING_YET
- /*
- @@ -507,13 +507,14 @@ subcmd_popen_context *subcmd_popen(const char *command)
- }
- (void)CloseHandle(pinfo->hWritePipe);
- + pinfo->hWritePipe = INVALID_HANDLE_VALUE;
- return pinfo;
- fail:
- if (pinfo) {
- - if (pinfo->hReadPipe)
- + if (pinfo->hReadPipe != INVALID_HANDLE_VALUE)
- (void)CloseHandle(pinfo->hReadPipe);
- - if (pinfo->hWritePipe)
- + if (pinfo->hWritePipe != INVALID_HANDLE_VALUE)
- (void)CloseHandle(pinfo->hWritePipe);
- free(pinfo);
- diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
- index bfc0b49..1ac43f6 100644
- --- a/tests/winsg/winsg.c
- +++ b/tests/winsg/winsg.c
- @@ -545,7 +545,7 @@ int wmain(int ac, wchar_t *av[])
- (int)subcmdret));
- done:
- - if (tok == INVALID_HANDLE_VALUE) {
- + if (tok != INVALID_HANDLE_VALUE) {
- (void)CloseHandle(tok);
- }
- --
- 2.45.1
- From 883e3bf0e8e1b7b62554991ec337e29e8b37246c Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Fri, 20 Jun 2025 12:48:25 +0200
- Subject: [PATCH 2/2] tests: winsg.exe should have a /P option for powershell
- winsg.exe should have a /P option for powershell.
- Reported-by: Aurelien Couderc <aurelien.couderc2002@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/winsg/winsg.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
- 1 file changed, 40 insertions(+), 5 deletions(-)
- diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
- index 1ac43f6..21ff821 100644
- --- a/tests/winsg/winsg.c
- +++ b/tests/winsg/winsg.c
- @@ -59,6 +59,8 @@
- #define CYGWIN_BASH_PATH L"C:\\cygwin\\bin\\bash.exe"
- #endif /* _WIN64 */
- #define WIN32_CMDEXE_PATH L"C:\\Windows\\system32\\cmd.exe"
- +#define WIN32_POWERSHELLEXE_PATH \
- + L"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
- /*
- * DECLARE_SID_BUFFER - declare a buffer for a SID value
- @@ -284,6 +286,7 @@ int usage(void)
- (void)fwprintf(stderr,
- L"Usage: winsg [-] -g group [-c command]\n"
- L"Usage: winsg [-] /g group [/C command]\n"
- + L"Usage: winsg [-] /g group [/P command]\n"
- L"Usage: winsg -L\n"
- L"Usage: winsg /? | -h | --help\n"
- L"Execute command as different primary group ID\n"
- @@ -292,17 +295,23 @@ int usage(void)
- L"\t1. Run new cmd.exe with primary group 'abc1':\n"
- L"\t\twinsg /g abc1 /C\n"
- L"\n"
- - L"\t2. Run new Cygwin shell (bash) with primary group 'abc2':\n"
- + L"\t2. Run new powershell.exe with primary group 'abc1':\n"
- + L"\t\twinsg /p abc1 /P\n"
- + L"\n"
- + L"\t3. Run new Cygwin shell (bash) with primary group 'abc2':\n"
- L"\t\twinsg -g abc2 -c\n"
- L"\n"
- - L"\t3. Start /bin/id from cmd.exe with primary group 'abc3':\n"
- + L"\t4. Start /bin/id from cmd.exe with primary group 'abc3':\n"
- L"\t\twinsg /g abc3 /C 'C:\\cygwin64\\bin\\id.exe -a'\n"
- L"\n"
- - L"\t4. Start /bin/id from Cygwin shell (bash) with primary "
- + L"\t5. Start /bin/id from powershell.exe with primary group 'abc3':\n"
- + L"\t\twinsg /g abc3 /P 'C:\\cygwin64\\bin\\id.exe -a'\n"
- + L"\n"
- + L"\t6. Start /bin/id from Cygwin shell (bash) with primary "
- L"group 'abc4':\n"
- L"\t\twinsg -g abc4 -c '/bin/id.exe -a'\n"
- L"\n"
- - L"\t5. List currently available groups which can be passed to "
- + L"\t7. List currently available groups which can be passed to "
- L"winsg -g ...\n"
- L"\t\twinsg -L\n"
- L"\n"
- @@ -317,7 +326,8 @@ enum shelltype {
- SHELLTYPE_NOT_SET = 0,
- SHELLTYPE_NONE,
- SHELLTYPE_CMD,
- - SHELLTYPE_SYSTEM
- + SHELLTYPE_SYSTEM,
- + SHELLTYPE_POWERSHELL
- };
- int wmain(int ac, wchar_t *av[])
- @@ -375,6 +385,20 @@ int wmain(int ac, wchar_t *av[])
- cmd_arg_index = i+1;
- break;
- }
- + else if (!wcscmp(av[i], L"/P")) {
- + /* /P can take zero or one argument */
- + if ((ac-i) > 2) {
- + (void)fwprintf(stderr,
- + L"%ls: Too many arguments for /P.\n", av[0]);
- + retval = 1;
- + goto done;
- + }
- +
- + cmd_runasgroup = true;
- + st = SHELLTYPE_POWERSHELL;
- + cmd_arg_index = i+1;
- + break;
- + }
- else if ((!wcscmp(av[i], L"-g")) ||
- (!wcscmp(av[i], L"/g"))) {
- newgrpname = av[i+1];
- @@ -532,6 +556,17 @@ int wmain(int ac, wchar_t *av[])
- WIN32_CMDEXE_PATH, WIN32_CMDEXE_PATH, NULL);
- }
- break;
- + case SHELLTYPE_POWERSHELL:
- + if (av[cmd_arg_index] != NULL) {
- + subcmdret = _wspawnl(_P_WAIT,
- + WIN32_POWERSHELLEXE_PATH, WIN32_POWERSHELLEXE_PATH,
- + L"-Command", av[cmd_arg_index], NULL);
- + }
- + else {
- + subcmdret = _wspawnl(_P_WAIT,
- + WIN32_POWERSHELLEXE_PATH, WIN32_POWERSHELLEXE_PATH, NULL);
- + }
- + break;
- case SHELLTYPE_NONE:
- subcmdret = _wspawnl(_P_WAIT,
- WIN32_CMDEXE_PATH, WIN32_CMDEXE_PATH, NULL);
- --
- 2.45.1
msnfs41client: Patches for winsg powershell support+misc, 2025-06-20
Posted by Anonymous on Fri 20th Jun 2025 15:31
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.