Author: ekohl
Date: Sat Nov 8 14:35:27 2014
New Revision: 65323
URL:
http://svn.reactos.org/svn/reactos?rev=65323&view=rev
Log:
[NET]
- Convert error messages to resource strings.
- ACCOUNTS: Add some padding to display strings.
- USER: Support interactive password input.
Modified:
trunk/reactos/base/applications/network/net/cmdAccounts.c
trunk/reactos/base/applications/network/net/cmdLocalGroup.c
trunk/reactos/base/applications/network/net/cmdUser.c
trunk/reactos/base/applications/network/net/lang/en-US.rc
trunk/reactos/base/applications/network/net/lang/ro-RO.rc
trunk/reactos/base/applications/network/net/lang/ru-RU.rc
trunk/reactos/base/applications/network/net/main.c
trunk/reactos/base/applications/network/net/net.h
trunk/reactos/base/applications/network/net/resource.h
Modified: trunk/reactos/base/applications/network/net/cmdAccounts.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdAccounts.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdAccounts.c [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -48,7 +48,7 @@
if (_wcsicmp(argv[i], L"/domain") == 0)
{
- PrintToConsole(L"The /DOMAIN option is not supported yet!\n");
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
#if 0
Domain = TRUE;
#endif
@@ -74,7 +74,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the
/FORCELOGOFF option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/FORCELOGOFF");
result = 1;
goto done;
}
@@ -89,7 +89,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the /MINPWLEN
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/MINPWLEN");
result = 1;
goto done;
}
@@ -111,7 +111,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the /MAXPWAGE
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/MAXPWLEN");
result = 1;
goto done;
}
@@ -126,7 +126,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the /MINPWAGE
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/MINPWAGE");
result = 1;
goto done;
}
@@ -140,7 +140,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the /UNIQUEPW
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/UNIQUEPW");
result = 1;
goto done;
}
@@ -168,32 +168,32 @@
RtlGetNtProductType(&ProductType);
- PrintToConsole(L"Force logoff after: ");
+ PrintToConsole(L"Force logoff after:
");
if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
PrintToConsole(L"Never\n");
else
PrintToConsole(L"%lu seconds\n", Info0->usrmod0_force_logoff);
- PrintToConsole(L"Minimum password age (in days): %lu\n",
Info0->usrmod0_min_passwd_age / 86400);
- PrintToConsole(L"Maximum password age (in days): %lu\n",
Info0->usrmod0_max_passwd_age / 86400);
- PrintToConsole(L"Minimum password length: %lu\n",
Info0->usrmod0_min_passwd_len);
-
- PrintToConsole(L"Password history length: ");
+ PrintToConsole(L"Minimum password age (in days):
%lu\n", Info0->usrmod0_min_passwd_age / 86400);
+ PrintToConsole(L"Maximum password age (in days):
%lu\n", Info0->usrmod0_max_passwd_age / 86400);
+ PrintToConsole(L"Minimum password length:
%lu\n", Info0->usrmod0_min_passwd_len);
+
+ PrintToConsole(L"Password history length:
");
if (Info0->usrmod0_password_hist_len == 0)
PrintToConsole(L"None\n");
else
PrintToConsole(L"%lu\n", Info0->usrmod0_password_hist_len);
- PrintToConsole(L"Lockout threshold: ");
+ PrintToConsole(L"Lockout threshold:
");
if (Info3->usrmod3_lockout_threshold == 0)
PrintToConsole(L"Never\n");
else
PrintToConsole(L"%lu\n", Info3->usrmod3_lockout_threshold);
- PrintToConsole(L"Lockout duration (in minutes): %lu\n",
Info3->usrmod3_lockout_duration / 60);
- PrintToConsole(L"Lockout observation window (in minutes): %lu\n",
Info3->usrmod3_lockout_observation_window / 60);
-
- PrintToConsole(L"Computer role: ");
+ PrintToConsole(L"Lockout duration (in minutes):
%lu\n", Info3->usrmod3_lockout_duration / 60);
+ PrintToConsole(L"Lockout observation window (in minutes):
%lu\n", Info3->usrmod3_lockout_observation_window / 60);
+
+ PrintToConsole(L"Computer role:
");
if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
{
Modified: trunk/reactos/base/applications/network/net/cmdLocalGroup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdLocalGroup.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdLocalGroup.c [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -248,7 +248,7 @@
}
else if (_wcsicmp(argv[i], L"/domain") == 0)
{
- printf("The /DOMAIN option is not supported yet!\n");
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
#if 0
bDomain = TRUE;
#endif
Modified: trunk/reactos/base/applications/network/net/cmdUser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdUser.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdUser.c [iso-8859-1] Sat Nov 8 14:35:27
2014
@@ -267,6 +267,47 @@
}
+static
+VOID
+ReadPassword(
+ LPWSTR *lpPassword,
+ LPBOOL lpAllocated)
+{
+ WCHAR szPassword1[PWLEN + 1];
+ WCHAR szPassword2[PWLEN + 1];
+ LPWSTR ptr;
+
+ *lpAllocated = FALSE;
+
+ printf("Enter the password for user xxx: ");
+ ReadFromConsole(szPassword1, PWLEN + 1, FALSE);
+ printf("\n");
+
+ printf("Enter the password again: ");
+ ReadFromConsole(szPassword2, PWLEN + 1, FALSE);
+ printf("\n");
+
+ if (wcslen(szPassword1) == wcslen(szPassword2) &&
+ wcscmp(szPassword1, szPassword2) == 0)
+ {
+ ptr = HeapAlloc(GetProcessHeap(),
+ 0,
+ (wcslen(szPassword1) + 1) * sizeof(WCHAR));
+ if (ptr != NULL)
+ {
+ wcscpy(ptr, szPassword1);
+ *lpPassword = ptr;
+ *lpAllocated = TRUE;
+ }
+ }
+ else
+ {
+ printf("The passwords do not match!");
+ *lpPassword = NULL;
+ }
+}
+
+
INT
cmdUser(
INT argc,
@@ -286,6 +327,7 @@
LPWSTR p;
LPWSTR endptr;
DWORD value;
+ BOOL bPasswordAllocated = FALSE;
NET_API_STATUS Status;
if (argc == 2)
@@ -305,14 +347,14 @@
if (argv[i][0] != L'/')
{
lpUserName = argv[i];
- printf("User: %S\n", lpUserName);
+// printf("User: %S\n", lpUserName);
i++;
}
if (argv[i][0] != L'/')
{
lpPassword = argv[i];
- printf("Password: %S\n", lpPassword);
+// printf("Password: %S\n", lpPassword);
i++;
}
@@ -333,7 +375,7 @@
}
else if (_wcsicmp(argv[j], L"/domain") == 0)
{
- printf("The /DOMAIN option is not supported yet!\n");
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/DOMAIN");
#if 0
bDomain = TRUE;
#endif
@@ -344,6 +386,13 @@
{
result = 1;
goto done;
+ }
+
+ /* Interactive password input */
+ if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
+ {
+ ReadPassword(&lpPassword,
+ &bPasswordAllocated);
}
if (!bAdd && !bDelete)
@@ -387,7 +436,7 @@
}
else
{
- PrintToConsole(L"You entered an invalid value for the /ACTIVE
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/ACTIVE");
result = 1;
goto done;
}
@@ -402,7 +451,7 @@
value = wcstoul(p, &endptr, 10);
if (*endptr != 0)
{
- PrintToConsole(L"You entered an invalid value for the /COUNTRYCODE
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/COUNTRYCODE");
result = 1;
goto done;
}
@@ -413,6 +462,16 @@
}
else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
{
+ p = &argv[i][9];
+ if (_wcsicmp(p, L"never") == 0)
+ {
+ pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
+ }
+ else
+ {
+ /* FIXME: Parse the date */
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED,
L"/EXPIRES");
+ }
}
else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
{
@@ -435,7 +494,7 @@
}
else
{
- PrintToConsole(L"You entered an invalid value for the /PASSWORDCHG
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/PASSWORDCHG");
result = 1;
goto done;
}
@@ -453,7 +512,7 @@
}
else
{
- PrintToConsole(L"You entered an invalid value for the /PASSWORDREQ
option.\n");
+ PrintResourceString(IDS_ERROR_INVALID_OPTION_VALUE,
L"/PASSWORDREQ");
result = 1;
goto done;
}
@@ -468,6 +527,8 @@
}
else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
{
+ /* FIXME */
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED, L"/TIMES");
}
else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
{
@@ -475,6 +536,8 @@
}
else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
{
+ /* FIXME */
+ PrintResourceString(IDS_ERROR_OPTION_NOT_SUPPORTED,
L"/WORKSTATIONS");
}
}
@@ -506,6 +569,9 @@
}
done:
+ if (bPasswordAllocated == TRUE && lpPassword != NULL)
+ HeapFree(GetProcessHeap(), 0, lpPassword);
+
if (!bAdd && !bDelete && pUserInfo != NULL)
NetApiBufferFree(pUserInfo);
Modified: trunk/reactos/base/applications/network/net/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/lang/en-US.rc [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -34,7 +34,7 @@
IDS_SESSION_HELP "SESSION\n..."
IDS_SHARE_SYNTAX "Usage:\nNET SHARE ..."
IDS_SHARE_HELP "SHARE\n..."
- IDS_START_SYNTAX "Usage:\nNET START ..."
+ IDS_START_SYNTAX "Usage:\nNET START <Service name>"
IDS_START_HELP "START\n..."
IDS_STATISTICS_SYNTAX "Usage:\nNET STATISTICS ..."
IDS_STATISTICS_HELP "STATISTICS\n..."
@@ -64,4 +64,7 @@
IDS_NET_SYNTAX "Usage:\nNET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE |
GROUP | HELP |\n\
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
+
+ IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
+ IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s
option.\n"
END
Modified: trunk/reactos/base/applications/network/net/lang/ro-RO.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/lang/ro-RO.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/lang/ro-RO.rc [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -70,4 +70,7 @@
IDS_NET_SYNTAX "Utilizare:\nNET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE
| GROUP | HELP |\n\
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
+
+ IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
+ IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s
option.\n"
END
Modified: trunk/reactos/base/applications/network/net/lang/ru-RU.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/lang/ru-RU.rc [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/lang/ru-RU.rc [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -66,4 +66,7 @@
IDS_NET_SYNTAX "ÐÑполÑзование:\nNET [ ACCOUNTS | COMPUTER | CONFIG
| CONTINUE | FILE | GROUP | HELP |\n\
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |\n\
SHARE | START | STATISTICS | STOP | TIME | USE | NET USER | VIEW ]\n"
+
+ IDS_ERROR_OPTION_NOT_SUPPORTED "The %s option is not supported yet.\n"
+ IDS_ERROR_INVALID_OPTION_VALUE "You entered an invalid value for the %s
option.\n"
END
Modified: trunk/reactos/base/applications/network/net/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/main.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/main.c [iso-8859-1] Sat Nov 8 14:35:27
2014
@@ -118,6 +118,43 @@
}
+VOID
+ReadFromConsole(
+ LPWSTR lpInput,
+ DWORD dwLength,
+ BOOL bEcho)
+{
+ DWORD dwOldMode;
+ DWORD dwRead = 0;
+ HANDLE hFile;
+ LPWSTR p;
+ PCHAR pBuf;
+
+ pBuf = HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
+ ZeroMemory(lpInput, dwLength * sizeof(WCHAR));
+ hFile = GetStdHandle(STD_INPUT_HANDLE);
+ GetConsoleMode(hFile, &dwOldMode);
+
+ SetConsoleMode(hFile, ENABLE_LINE_INPUT | (bEcho ? ENABLE_ECHO_INPUT : 0));
+
+ ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
+
+ MultiByteToWideChar(CP_OEMCP, 0, pBuf, dwRead, lpInput, dwLength - 1);
+ HeapFree(GetProcessHeap(), 0, pBuf);
+
+ for (p = lpInput; *p; p++)
+ {
+ if (*p == L'\x0d')
+ {
+ *p = L'\0';
+ break;
+ }
+ }
+
+ SetConsoleMode(hFile, dwOldMode);
+}
+
+
int wmain(int argc, WCHAR **argv)
{
PCOMMAND cmdptr;
Modified: trunk/reactos/base/applications/network/net/net.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/net.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/net.h [iso-8859-1] Sat Nov 8 14:35:27
2014
@@ -39,6 +39,12 @@
WriteToConsole(
LPWSTR lpString);
+VOID
+ReadFromConsole(
+ LPWSTR lpInput,
+ DWORD dwLength,
+ BOOL bEcho);
+
VOID help(VOID);
INT unimplemented(INT argc, WCHAR **argv);
Modified: trunk/reactos/base/applications/network/net/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/resource.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/resource.h [iso-8859-1] Sat Nov 8
14:35:27 2014
@@ -44,3 +44,6 @@
#define IDS_VIEW_HELP 141
#define IDS_HELP_SYNTAX 142
#define IDS_NET_SYNTAX 143
+
+#define IDS_ERROR_OPTION_NOT_SUPPORTED 500
+#define IDS_ERROR_INVALID_OPTION_VALUE 501