https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4109072bc835f3c66d694c...
commit 4109072bc835f3c66d694c428b38a03ef7d4349c Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Sat Feb 26 18:57:57 2022 +0100 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Sat Feb 26 18:57:57 2022 +0100
[RUNAS] Support the /netonly option and improve the help text --- base/applications/runas/lang/de-DE.rc | 14 +++++++++----- base/applications/runas/lang/en-US.rc | 14 +++++++++----- base/applications/runas/resource.h | 6 +++++- base/applications/runas/runas.c | 24 ++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/base/applications/runas/lang/de-DE.rc b/base/applications/runas/lang/de-DE.rc index 7bba0d9ea01..01b3d2cdd59 100644 --- a/base/applications/runas/lang/de-DE.rc +++ b/base/applications/runas/lang/de-DE.rc @@ -13,11 +13,15 @@ BEGIN IDS_USAGE09 " /profile Legt fest, dass das Benutzerprofil geladen werden soll.\n" IDS_USAGE10 " Dies ist die Standardeinstellung.\n" IDS_USAGE11 " /env Verwendet die aktuelle Umgebung statt der des Benutzers.\n" - IDS_USAGE12 " /netonly Noch nicht implementiert.\n" - IDS_USAGE13 " /savecred Noch nicht implementiert.\n" - IDS_USAGE14 " /smartcard Noch nicht implementiert.\n" - IDS_USAGE15 " /user <Benutzername> muss in der Form Benutzer@Domäne oder\n Domäne\Benutzer angegeben werden\n" - IDS_USAGE16 " Programm Befehlszeile einer ausführbaren Datei. Siehe unten\n aufgeführte Beispiele.\n\n" + IDS_USAGE12 " /netonly Falls Anmeldeinformationen nur für den Remotezugriff\n" + IDS_USAGE13 " gültig sind.\n" + IDS_USAGE14 " /savecred Noch nicht implementiert.\n" + IDS_USAGE15 " /smartcard Noch nicht implementiert.\n" + IDS_USAGE16 " /user <Benutzername> muss in der Form Benutzer@Domäne oder\n Domäne\Benutzer angegeben werden\n" + IDS_USAGE17 " Programm Befehlszeile einer ausführbaren Datei. Siehe unten\n aufgeführte Beispiele.\n\n" + IDS_USAGE18 "Beispiel:\n" + IDS_USAGE19 "> runas /noprofile /user:mymachine\administrator cmd\n\n" + IDS_USAGE20 "HINWEIS: /profile is nicht kompatibel mit /netonly.\n"
IDS_START "Es wird versucht, %s als Benutzer ""%s\%s"" zu starten...\n" IDS_RUN_ERROR "RUNAS-FEHLER: %s kann nicht ausgeführt werden\n" diff --git a/base/applications/runas/lang/en-US.rc b/base/applications/runas/lang/en-US.rc index b06713718cc..c2ca553ea2e 100644 --- a/base/applications/runas/lang/en-US.rc +++ b/base/applications/runas/lang/en-US.rc @@ -13,11 +13,15 @@ BEGIN IDS_USAGE09 " /profile specifies that the user's profile should be loaded.\n" IDS_USAGE10 " This is the default.\n" IDS_USAGE11 " /env to use current environment instead of user's.\n" - IDS_USAGE12 " /netonly Not implemented yet.\n" - IDS_USAGE13 " /savecred Not implemented yet.\n" - IDS_USAGE14 " /smartcard Not implemented yet.\n" - IDS_USAGE15 " /user <UserName> should be in form USER@DOMAIN or DOMAIN\USER\n" - IDS_USAGE16 " program command line for EXE. See below for examples\n\n" + IDS_USAGE12 " /netonly use if the credentials specified are for remote\n" + IDS_USAGE13 " access only.\n" + IDS_USAGE14 " /savecred Not implemented yet.\n" + IDS_USAGE15 " /smartcard Not implemented yet.\n" + IDS_USAGE16 " /user <UserName> should be in form USER@DOMAIN or DOMAIN\USER\n" + IDS_USAGE17 " program command line for EXE. See below for examples\n\n" + IDS_USAGE18 "Example:\n" + IDS_USAGE19 "> runas /noprofile /user:mymachine\administrator cmd\n\n" + IDS_USAGE20 "NOTE: /profile is not compatible with /netonly.\n"
IDS_START "Attempting to start %s as user ""%s\%s""...\n" IDS_RUN_ERROR "RUNAS ERROR: Unable to run %s\n" diff --git a/base/applications/runas/resource.h b/base/applications/runas/resource.h index e0f920557ba..2248cf31188 100644 --- a/base/applications/runas/resource.h +++ b/base/applications/runas/resource.h @@ -14,7 +14,11 @@ #define IDS_USAGE14 7013 #define IDS_USAGE15 7014 #define IDS_USAGE16 7015 -#define IDS_USAGE_MAX IDS_USAGE16 +#define IDS_USAGE17 7016 +#define IDS_USAGE18 7017 +#define IDS_USAGE19 7018 +#define IDS_USAGE20 7019 +#define IDS_USAGE_MAX IDS_USAGE20
#define IDS_START 7100 #define IDS_RUN_ERROR 7101 diff --git a/base/applications/runas/runas.c b/base/applications/runas/runas.c index 9f78e909f93..f0d7689dd5a 100644 --- a/base/applications/runas/runas.c +++ b/base/applications/runas/runas.c @@ -80,7 +80,7 @@ wmain( LPCWSTR pszArg; int i, result = 0; BOOL bProfile = FALSE, bNoProfile = FALSE; - BOOL bEnv = FALSE; + BOOL bEnv = FALSE, bNetOnly = FALSE; PWSTR pszUserName = NULL; PWSTR pszDomain = NULL; PWSTR pszCommandLine = NULL; @@ -122,6 +122,10 @@ wmain( { bProfile = TRUE; } + else if (wcsicmp(pszArg, L"netonly") == 0) + { + bNetOnly = TRUE; + } else if (wcsicmp(pszArg, L"noprofile") == 0) { bNoProfile = TRUE; @@ -224,7 +228,17 @@ wmain( } }
- if (bProfile && bNoProfile) + /* Check for incompatible options */ + if ((bProfile && bNoProfile) || + (bProfile && bNetOnly)) + { + Usage(); + result = -1; + goto done; + } + + /* Check for existing command line and user name */ + if (pszCommandLine == NULL || pszUserName == NULL) { Usage(); result = -1; @@ -237,6 +251,12 @@ wmain( if (bNoProfile) dwLogonFlags &= ~LOGON_WITH_PROFILE;
+ if (bNetOnly) + { + dwLogonFlags |= LOGON_NETCREDENTIALS_ONLY; + dwLogonFlags &= ~LOGON_WITH_PROFILE; + } + DPRINT("User: %S\n", pszUserName); DPRINT("Domain: %S\n", pszDomain); DPRINT("CommandLine: %S\n", pszCommandLine);