Author: ekohl
Date: Sat May 31 08:32:54 2014
New Revision: 63509
URL:
http://svn.reactos.org/svn/reactos?rev=63509&view=rev
Log:
[NET]
- Fix an off-by-one bug in the ACCOUNTS command.
- Improve input validation for the ACCOUNTS command.
- Add the /help option to the CONTINUE command.
- Add version resource and start to move texts into resources.
Added:
trunk/reactos/base/applications/network/net/lang/ (with props)
trunk/reactos/base/applications/network/net/lang/en-US.rc (with props)
trunk/reactos/base/applications/network/net/net.rc (with props)
trunk/reactos/base/applications/network/net/resource.h (with props)
Modified:
trunk/reactos/base/applications/network/net/CMakeLists.txt
trunk/reactos/base/applications/network/net/cmdAccounts.c
trunk/reactos/base/applications/network/net/cmdContinue.c
trunk/reactos/base/applications/network/net/help.c
trunk/reactos/base/applications/network/net/main.c
trunk/reactos/base/applications/network/net/net.h
Modified: trunk/reactos/base/applications/network/net/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/CMakeLists.txt [iso-8859-1] Sat May 31
08:32:54 2014
@@ -12,8 +12,8 @@
help.c
net.h)
-add_executable(net ${SOURCE})
+add_executable(net ${SOURCE} net.rc)
set_module_type(net win32cui UNICODE)
-add_importlibs(net advapi32 netapi32 msvcrt kernel32 ntdll)
+add_importlibs(net advapi32 netapi32 msvcrt kernel32 user32 ntdll)
add_pch(net net.h SOURCE)
add_cd_file(TARGET net DESTINATION reactos/system32 FOR all)
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 May 31
08:32:54 2014
@@ -18,33 +18,34 @@
PUSER_MODALS_INFO_1 Info1 = NULL;
PUSER_MODALS_INFO_3 Info3 = NULL;
NT_PRODUCT_TYPE ProductType;
- LPWSTR p, perr;
+ LPWSTR p;
+ LPWSTR endptr;
DWORD ParamErr;
ULONG value;
INT i;
BOOL Modified = FALSE;
// BOOL Domain = FALSE;
NET_API_STATUS Status;
-
- for (i = 3; i < argc; i++)
- {
- if (wcsicmp(argv[i], L"help") == 0)
+ INT result = 0;
+
+ for (i = 2; i < argc; i++)
+ {
+ if (_wcsicmp(argv[i], L"help") == 0)
{
/* Print short syntax help */
- puts("NET ACCOUNTS [/FORCELOGOFF:{Minutes|NO}]
[/MINPWLEN:Length]");
- puts(" [/MAXPWAGE:{Days|UNLIMITED}]
[/MINPWAGE:Days]");
- puts(" [/UNIQUEPW:Count] [/DOMAIN]");
+ PrintResourceString(IDS_ACCOUNTS_SYNTAX);
return 0;
}
- if (wcsicmp(argv[i], L"/help") == 0)
- {
- /* FIXME: Print long help text*/
+ if (_wcsicmp(argv[i], L"/help") == 0)
+ {
+ /* Print full help text*/
+ PrintResourceString(IDS_ACCOUNTS_HELP);
return 0;
}
/*
- if (wcsicmp(argv[i], L"/domain") == 0)
+ if (_wcsicmp(argv[i], L"/domain") == 0)
{
Domain = TRUE;
}
@@ -55,7 +56,7 @@
if (Status != NERR_Success)
goto done;
- for (i = 3; i < argc; i++)
+ for (i = 2; i < argc; i++)
{
if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
{
@@ -67,7 +68,13 @@
}
else
{
- value = wcstoul(p, &perr, 10);
+ value = wcstoul(p, &endptr, 10);
+ if (*endptr != 0)
+ {
+ printf("You entered an invalid value for the /FORCELOGOFF
option.\n");
+ result = 1;
+ goto done;
+ }
Info0->usrmod0_force_logoff = value * 60;
Modified = TRUE;
@@ -76,7 +83,14 @@
else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
{
p = &argv[i][10];
- value = wcstoul(p, &perr, 10);
+ value = wcstoul(p, &endptr, 10);
+ if (*endptr != 0)
+ {
+ printf("You entered an invalid value for the /MINPWLEN
option.\n");
+ result = 1;
+ goto done;
+ }
+
Info0->usrmod0_min_passwd_len = value;
Modified = TRUE;
}
@@ -91,7 +105,13 @@
}
else
{
- value = wcstoul(p, &perr, 10);
+ value = wcstoul(p, &endptr, 10);
+ if (*endptr != 0)
+ {
+ printf("You entered an invalid value for the /MAXPWAGE
option.\n");
+ result = 1;
+ goto done;
+ }
Info0->usrmod0_max_passwd_age = value * 86400;
Modified = TRUE;
@@ -100,7 +120,13 @@
else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
{
p = &argv[i][10];
- value = wcstoul(p, &perr, 10);
+ value = wcstoul(p, &endptr, 10);
+ if (*endptr != 0)
+ {
+ printf("You entered an invalid value for the /MINPWAGE
option.\n");
+ result = 1;
+ goto done;
+ }
Info0->usrmod0_min_passwd_age = value * 86400;
Modified = TRUE;
@@ -108,7 +134,13 @@
else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
{
p = &argv[i][10];
- value = wcstoul(p, &perr, 10);
+ value = wcstoul(p, &endptr, 10);
+ if (*endptr != 0)
+ {
+ printf("You entered an invalid value for the /UNIQUEPW
option.\n");
+ result = 1;
+ goto done;
+ }
Info0->usrmod0_password_hist_len = value;
Modified = TRUE;
@@ -149,7 +181,12 @@
else
printf("%lu\n", Info0->usrmod0_password_hist_len);
- printf("Lockout threshold: %lu\n",
Info3->usrmod3_lockout_threshold);
+ printf("Lockout threshold: ");
+ if (Info3->usrmod3_lockout_threshold == 0)
+ printf("Never\n");
+ else
+ printf("%lu\n", Info3->usrmod3_lockout_threshold);
+
printf("Lockout duration (in minutes): %lu\n",
Info3->usrmod3_lockout_duration / 60);
printf("Lockout observation window (in minutes): %lu\n",
Info3->usrmod3_lockout_observation_window / 60);
@@ -186,7 +223,7 @@
if (Info0 != NULL)
NetApiBufferFree(Info0);
- return 0;
+ return result;
}
/* EOF */
Modified: trunk/reactos/base/applications/network/net/cmdContinue.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/cmdContinue.c [iso-8859-1] Sat May 31
08:32:54 2014
@@ -15,11 +15,21 @@
SC_HANDLE hService = NULL;
SERVICE_STATUS status;
INT nError = 0;
+ INT i;
if (argc != 3)
{
- puts("Usage: NET CONTINUE <Service Name>");
+ PrintResourceString(IDS_CONTINUE_SYNTAX);
return 1;
+ }
+
+ for (i = 2; i < argc; i++)
+ {
+ if (_wcsicmp(argv[i], L"/help") == 0)
+ {
+ PrintResourceString(IDS_CONTINUE_HELP);
+ return 1;
+ }
}
hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ENUMERATE_SERVICE);
Modified: trunk/reactos/base/applications/network/net/help.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/help.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/net/help.c [iso-8859-1] Sat May 31 08:32:54
2014
@@ -18,8 +18,7 @@
if (_wcsicmp(argv[2],L"ACCOUNTS")==0)
{
- puts("ACCOUNTS");
- puts("help text");
+ PrintResourceString(IDS_ACCOUNTS_HELP);
return 0;
}
@@ -39,8 +38,7 @@
if (_wcsicmp(argv[2],L"CONTINUE")==0)
{
- puts("CONTINUE");
- puts("help text");
+ PrintResourceString(IDS_CONTINUE_HELP);
return 0;
}
Propchange: trunk/reactos/base/applications/network/net/lang/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat May 31 08:32:54 2014
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/reactos/base/applications/network/net/lang/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/base/applications/network/net/lang/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/base/applications/network/net/lang/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: 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 (added)
+++ trunk/reactos/base/applications/network/net/lang/en-US.rc [iso-8859-1] Sat May 31
08:32:54 2014
@@ -0,0 +1,11 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+STRINGTABLE
+BEGIN
+ IDS_ACCOUNTS_SYNTAX "Usage:\nNET ACCOUNTS [/FORCELOGOFF:{Minutes|NO}]
[/MINPWLEN:Length]\n\
+ [/MAXPWAGE:{Days|UNLIMITED}] [/MINPWAGE:Days]\n\
+ [/UNIQUEPW:Count] [/DOMAIN]\n"
+ IDS_ACCOUNTS_HELP "ACCOUNTS\nhelp text"
+ IDS_CONTINUE_SYNTAX "Usage:\nNET CONTINUE <Service Name>"
+ IDS_CONTINUE_HELP "CONTINUE\nhelp text"
+END
Propchange: trunk/reactos/base/applications/network/net/lang/en-US.rc
------------------------------------------------------------------------------
svn:eol-style = native
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 May 31 08:32:54
2014
@@ -8,6 +8,8 @@
*/
#include "net.h"
+
+#define MAX_BUFFER_SIZE 4096
typedef struct _COMMAND
{
@@ -43,6 +45,22 @@
{NULL, NULL}
};
+
+VOID
+PrintResourceString(
+ INT resID,
+ ...)
+{
+ WCHAR szMsgBuf[MAX_BUFFER_SIZE];
+ va_list arg_ptr;
+
+ va_start(arg_ptr, resID);
+ LoadStringW(GetModuleHandle(NULL), resID, szMsgBuf, MAX_BUFFER_SIZE);
+ vwprintf(szMsgBuf, arg_ptr);
+ va_end(arg_ptr);
+}
+
+
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 May 31 08:32:54
2014
@@ -13,12 +13,20 @@
#include <windef.h>
#include <winbase.h>
+#include <winuser.h>
#include <winsvc.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <lm.h>
#include <ndk/rtlfuncs.h>
+
+#include "resource.h"
+
+VOID
+PrintResourceString(
+ INT resID,
+ ...);
VOID help(VOID);
INT unimplemented(INT argc, WCHAR **argv);
Added: trunk/reactos/base/applications/network/net/net.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/net/net.rc (added)
+++ trunk/reactos/base/applications/network/net/net.rc [iso-8859-1] Sat May 31 08:32:54
2014
@@ -0,0 +1,17 @@
+#include <windef.h>
+
+#include "resource.h"
+
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Net Command"
+#define REACTOS_STR_INTERNAL_NAME "net"
+#define REACTOS_STR_ORIGINAL_FILENAME "net.exe"
+#include <reactos/version.rc>
+
+/* UTF-8 */
+#pragma code_page(65001)
+
+#ifdef LANGUAGE_EN_US
+ #include "lang/en-US.rc"
+#endif
Propchange: trunk/reactos/base/applications/network/net/net.rc
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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 (added)
+++ trunk/reactos/base/applications/network/net/resource.h [iso-8859-1] Sat May 31
08:32:54 2014
@@ -0,0 +1,6 @@
+#pragma once
+
+#define IDS_ACCOUNTS_SYNTAX 100
+#define IDS_ACCOUNTS_HELP 101
+#define IDS_CONTINUE_SYNTAX 102
+#define IDS_CONTINUE_HELP 103
Propchange: trunk/reactos/base/applications/network/net/resource.h
------------------------------------------------------------------------------
svn:eol-style = native