[PATCH cygutils 1/1] cygstart: add 'runas' as option to elevate privileges like UAC
Mark Geisert
mark@maxrnd.com
Fri Aug 8 08:51:21 GMT 2025
Hello Vadim,
Thank you for this useful patch.
A couple minor comments inlined below...
On 8/6/2025 7:07 AM, Vadim (vadcx) via Cygwin-apps wrote:
> From: "Vadim (vadcx)" <vad.git-0tzhX9vkJDo@public.gmane.org>
>
> Inspired by https://stackoverflow.com/q/4090301
>
> If other known actions have easy aliases, runas should have one too and hint at
> its existence.
> ---
> src/cygstart/cygstart.1 | 4 ++++
> src/cygstart/cygstart.c | 14 ++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/src/cygstart/cygstart.1 b/src/cygstart/cygstart.1
> index c641a4c..7701115 100644
> --- a/src/cygstart/cygstart.1
> +++ b/src/cygstart/cygstart.1
> @@ -56,6 +56,10 @@ Short for: \fB\-\-action\fP \fIfind\fP
> \fB\-p\fP, \fB\-\-print\fP
> Short for: \fB\-\-action\fP \fIprint\fP
>
> +.TP
> +\fB\-r\fP, \fB\-\-runas\fP
> +Short for: \fB\-\-action\fP \fIrunas\fP
> +
> .TP
> \fIDirectory options\fP
>
> diff --git a/src/cygstart/cygstart.c b/src/cygstart/cygstart.c
> index 7e5bf3a..d995d9b 100644
> --- a/src/cygstart/cygstart.c
> +++ b/src/cygstart/cygstart.c
> @@ -41,6 +41,7 @@
> #define ACTION_EDIT "edit"
> #define ACTION_FIND "find"
> #define ACTION_PRINT "print"
> +#define ACTION_RUNAS "runas"
>
> /* MSDN reference URL */
> #define MSDN_URL "http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx"
> @@ -150,6 +151,8 @@ main (int argc, const char **argv)
> "Short for: --action find", NULL},
> {"print", 'p', POPT_ARG_NONE, NULL, 'p',
> "Short for: --action print", NULL},
> + {"runas", 'r', POPT_ARG_NONE, NULL, 'r',
> + "Short for: --action runas", NULL},
I understand you're adding a new action selected by arg 'r'...
> {NULL, '\0', 0, NULL, 0, NULL, NULL}
> };
>
> @@ -223,7 +226,7 @@ main (int argc, const char **argv)
> "Display version information", NULL},
> {"license", '\0', POPT_ARG_NONE, NULL, 'l',
> "Display licensing information", NULL},
> - {"reference", '\0', POPT_ARG_NONE, NULL, 'r',
> + {"reference", '\0', POPT_ARG_NONE, NULL, 'W',
> "Open MSDN reference for ShellExecute", NULL},
... and changing existing action 'r' to 'W'. But the string "reference"
needs to be changed to something starting with 'W' then. Did you have a
word in mind when choosing 'W' as the new action?
Alternatively, is there a word+action that better indicates what that
command does? Granted, it's a pretty obscure and complicated thing to
reduce down to one word.
> {NULL, '\0', 0, NULL, 0, NULL, NULL}
> };
> @@ -294,7 +297,7 @@ main (int argc, const char **argv)
> if (workDir)
> free (workDir);
> return (0);
> - case 'r':
> + case 'W':
> cygStart (MSDN_URL, NULL, NULL, NULL, SW_NORMAL, startFlags);
> poptFreeContext (optCon);
> free (program_name);
> @@ -350,6 +353,13 @@ main (int argc, const char **argv)
> exit (1);
> }
> break;
> + case 'r':
> + if ((action = mbstowcs_dup (ACTION_RUNAS)) == NULL)
> + {
> + fprintf (stderr, "%s: memory allocation error\n", argv[0]);
> + exit (1);
> + }
> + break;
>
> /* Directory options */
> case 'd':
Otherwise, all looks good to me. Once we decide what minor change to
make (as above) I'll add the patch to cygutils' patch blob and build the
next version for release.
Thanks & Regards,
..mark
More information about the Cygwin-apps
mailing list