summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a31b680)
- 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.
svn path=/trunk/; revision=63509
-add_executable(net ${SOURCE})
+add_executable(net ${SOURCE} net.rc)
set_module_type(net win32cui UNICODE)
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)
add_pch(net net.h SOURCE)
add_cd_file(TARGET net DESTINATION reactos/system32 FOR all)
PUSER_MODALS_INFO_1 Info1 = NULL;
PUSER_MODALS_INFO_3 Info3 = NULL;
NT_PRODUCT_TYPE ProductType;
PUSER_MODALS_INFO_1 Info1 = NULL;
PUSER_MODALS_INFO_3 Info3 = NULL;
NT_PRODUCT_TYPE ProductType;
+ LPWSTR p;
+ LPWSTR endptr;
DWORD ParamErr;
ULONG value;
INT i;
BOOL Modified = FALSE;
// BOOL Domain = FALSE;
NET_API_STATUS Status;
DWORD ParamErr;
ULONG value;
INT i;
BOOL Modified = FALSE;
// BOOL Domain = FALSE;
NET_API_STATUS Status;
- for (i = 3; i < argc; i++)
+ for (i = 2; i < argc; i++)
- if (wcsicmp(argv[i], L"help") == 0)
+ if (_wcsicmp(argv[i], L"help") == 0)
{
/* Print short syntax help */
{
/* 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);
- if (wcsicmp(argv[i], L"/help") == 0)
+ if (_wcsicmp(argv[i], L"/help") == 0)
- /* FIXME: Print long help text*/
+ /* Print full help text*/
+ PrintResourceString(IDS_ACCOUNTS_HELP);
- if (wcsicmp(argv[i], L"/domain") == 0)
+ if (_wcsicmp(argv[i], L"/domain") == 0)
if (Status != NERR_Success)
goto done;
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)
{
{
if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
{
- 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;
Info0->usrmod0_force_logoff = value * 60;
Modified = TRUE;
else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
{
p = &argv[i][10];
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;
}
Info0->usrmod0_min_passwd_len = value;
Modified = TRUE;
}
- 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;
Info0->usrmod0_max_passwd_age = value * 86400;
Modified = TRUE;
else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
{
p = &argv[i][10];
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;
Info0->usrmod0_min_passwd_age = value * 86400;
Modified = TRUE;
else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
{
p = &argv[i][10];
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;
Info0->usrmod0_password_hist_len = value;
Modified = TRUE;
else
printf("%lu\n", Info0->usrmod0_password_hist_len);
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);
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);
if (Info0 != NULL)
NetApiBufferFree(Info0);
if (Info0 != NULL)
NetApiBufferFree(Info0);
SC_HANDLE hService = NULL;
SERVICE_STATUS status;
INT nError = 0;
SC_HANDLE hService = NULL;
SERVICE_STATUS status;
INT nError = 0;
- puts("Usage: NET CONTINUE <Service Name>");
+ PrintResourceString(IDS_CONTINUE_SYNTAX);
+ 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);
if (hManager == NULL)
{
hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
if (hManager == NULL)
{
if (_wcsicmp(argv[2],L"ACCOUNTS")==0)
{
if (_wcsicmp(argv[2],L"ACCOUNTS")==0)
{
- puts("ACCOUNTS");
- puts("help text");
+ PrintResourceString(IDS_ACCOUNTS_HELP);
if (_wcsicmp(argv[2],L"CONTINUE")==0)
{
if (_wcsicmp(argv[2],L"CONTINUE")==0)
{
- puts("CONTINUE");
- puts("help text");
+ PrintResourceString(IDS_CONTINUE_HELP);
--- /dev/null
+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
+#define MAX_BUFFER_SIZE 4096
+
typedef struct _COMMAND
{
WCHAR *name;
typedef struct _COMMAND
{
WCHAR *name;
+
+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;
int wmain(int argc, WCHAR **argv)
{
PCOMMAND cmdptr;
#include <windef.h>
#include <winbase.h>
#include <windef.h>
#include <winbase.h>
#include <winsvc.h>
#include <stdio.h>
#include <stdlib.h>
#include <winsvc.h>
#include <stdio.h>
#include <stdlib.h>
#include <lm.h>
#include <ndk/rtlfuncs.h>
#include <lm.h>
#include <ndk/rtlfuncs.h>
+#include "resource.h"
+
+VOID
+PrintResourceString(
+ INT resID,
+ ...);
+
VOID help(VOID);
INT unimplemented(INT argc, WCHAR **argv);
VOID help(VOID);
INT unimplemented(INT argc, WCHAR **argv);
--- /dev/null
+#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
--- /dev/null
+#pragma once
+
+#define IDS_ACCOUNTS_SYNTAX 100
+#define IDS_ACCOUNTS_HELP 101
+#define IDS_CONTINUE_SYNTAX 102
+#define IDS_CONTINUE_HELP 103
\ No newline at end of file