Compare commits
91 Commits
22d862cd12
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3473e35b38 | ||
|
|
af8a046f9d | ||
|
|
e4a5251a0b | ||
|
|
6892666807 | ||
|
|
3ee8490c0c | ||
|
|
5f3882f4e9 | ||
|
|
6ce3551704 | ||
|
|
dcb52b8708 | ||
|
|
f07488978c | ||
|
|
aea28fe38a | ||
|
|
cf9bfbb864 | ||
|
|
256317d959 | ||
|
|
c97700a1d3 | ||
|
|
698143d135 | ||
|
|
4e025b2e5e | ||
|
|
d93e6a7fbd | ||
|
|
01d654c76b | ||
|
|
faabab1f9f | ||
|
|
919ab99ad1 | ||
|
|
4b7d6a1bb9 | ||
|
|
07784e8e9c | ||
|
|
3bd41dd828 | ||
|
|
ed46e3aef9 | ||
|
|
7f4dd3b429 | ||
|
|
64ab3a4fab | ||
|
|
30db93ec8d | ||
|
|
347b9ee67f | ||
|
|
b0652ae5d5 | ||
|
|
c68d73faa6 | ||
|
|
a080dfaa56 | ||
|
|
0d466ce30a | ||
|
|
b5891740cf | ||
|
|
1f5cf85229 | ||
|
|
1b28bcfa99 | ||
|
|
52170c1092 | ||
|
|
f6b017391b | ||
|
|
1d4789de1b | ||
|
|
a5ce0d2f63 | ||
|
|
3562cd1301 | ||
|
|
99c3eed1bf | ||
|
|
ed5da6c063 | ||
|
|
19ded9333b | ||
|
|
847559631a | ||
|
|
1f74c940d8 | ||
|
|
24ccc1257d | ||
|
|
e6495fb949 | ||
|
|
e5aa3a8b90 | ||
|
|
56a76d3b43 | ||
|
|
0c14d040aa | ||
|
|
7ceddb8a82 | ||
|
|
cc96eb72c4 | ||
|
|
fe91b08d5d | ||
|
|
ae2e1c3062 | ||
|
|
f48f62dd91 | ||
|
|
fa999bd0c9 | ||
|
|
e4dc502dcb | ||
|
|
02566b661f | ||
|
|
c412f2ebbd | ||
|
|
b8b323e3c3 | ||
|
|
30fc1f7069 | ||
|
|
b42b0e2a58 | ||
|
|
4d01fbd118 | ||
|
|
a2d4025452 | ||
|
|
f0bb61b0d7 | ||
|
|
6db4fc17fa | ||
|
|
1601a80513 | ||
|
|
d1840da361 | ||
|
|
f263335ef9 | ||
|
|
bb6c34dce4 | ||
|
|
f0c1cfcd84 | ||
|
|
7e5b75b4cc | ||
|
|
4809bd7e30 | ||
|
|
0ca6a3baaf | ||
|
|
3d2e7913ad | ||
|
|
04c737d310 | ||
|
|
7dad85c13e | ||
|
|
00654ad161 | ||
|
|
7b3778ceb4 | ||
|
|
f08aa986a8 | ||
|
|
4e49ecec1a | ||
|
|
c53abba212 | ||
|
|
ff344fcf4c | ||
|
|
36d566939c | ||
|
|
09a3f9f551 | ||
|
|
7f66df5a6e | ||
|
|
d4b29aea5d | ||
|
|
c12c93b958 | ||
|
|
82202fd6fb | ||
|
|
534f70844a | ||
|
|
b40ec03e7d | ||
|
|
0ea11f7f5d |
@@ -23,6 +23,8 @@ set(MARS_DOSUTILS_PUBLIC_TOOLS
|
|||||||
map
|
map
|
||||||
mapdel
|
mapdel
|
||||||
logout
|
logout
|
||||||
|
slist
|
||||||
|
flag
|
||||||
capture
|
capture
|
||||||
endcap
|
endcap
|
||||||
)
|
)
|
||||||
@@ -34,12 +36,15 @@ if(MARS_NWE_BUILD_DOSUTILS)
|
|||||||
find_package(OpenWatcom REQUIRED)
|
find_package(OpenWatcom REQUIRED)
|
||||||
|
|
||||||
set(DOSUTILS_C_SOURCES
|
set(DOSUTILS_C_SOURCES
|
||||||
|
kern.c
|
||||||
net.c
|
net.c
|
||||||
tools.c
|
tools.c
|
||||||
netcall.c
|
netcall.c
|
||||||
ncpcall.c
|
ncpcall.c
|
||||||
login.c
|
login.c
|
||||||
map.c
|
map.c
|
||||||
|
slist.c
|
||||||
|
flag.c
|
||||||
nwcrypt.c
|
nwcrypt.c
|
||||||
nwdebug.c
|
nwdebug.c
|
||||||
nwtests.c
|
nwtests.c
|
||||||
@@ -115,3 +120,8 @@ install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
|||||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||||
RENAME map.exe)
|
RENAME map.exe)
|
||||||
|
|
||||||
|
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||||
|
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||||
|
RENAME slist.exe)
|
||||||
|
|
||||||
|
|||||||
486
flag.c
Normal file
486
flag.c
Normal file
@@ -0,0 +1,486 @@
|
|||||||
|
/* flag.c - Novell FLAG-like DOS utility, stage 1 */
|
||||||
|
|
||||||
|
#include "net.h"
|
||||||
|
#include <dos.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FLAG v4b: NCP 87 namespace DOS info.
|
||||||
|
*
|
||||||
|
* ncpfs reference:
|
||||||
|
* ncp_ns_modify_entry_dos_info():
|
||||||
|
* subfunction 7, namespace DOS, search attrs SA_ALL,
|
||||||
|
* ModifyInformationMask, struct ncp_dos_info, handle/path.
|
||||||
|
*
|
||||||
|
* We use dirstyle=0 (short directory handle) against the current DOS
|
||||||
|
* directory handle and a one-component DOS filename.
|
||||||
|
*/
|
||||||
|
#define FLAG_NW_NS_DOS 0x00
|
||||||
|
#define FLAG_SA_ALL 0x0006
|
||||||
|
#define FLAG_RIM_ATTRIBUTES 0x00000004UL
|
||||||
|
|
||||||
|
#define NWFA_RO 0x00000001UL
|
||||||
|
#define NWFA_H 0x00000002UL
|
||||||
|
#define NWFA_SY 0x00000004UL
|
||||||
|
#define NWFA_A 0x00000020UL
|
||||||
|
#define NWFA_S 0x00000080UL
|
||||||
|
#define NWFA_T 0x00001000UL
|
||||||
|
#define NWFA_RA 0x00004000UL
|
||||||
|
#define NWFA_WA 0x00008000UL
|
||||||
|
#define NWFA_P 0x00010000UL
|
||||||
|
#define NWFA_RI 0x00020000UL
|
||||||
|
#define NWFA_DI 0x00040000UL
|
||||||
|
#define NWFA_CI 0x00080000UL
|
||||||
|
|
||||||
|
static void flag_put_word_lh(uint8 *p, uint16 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_put_dword_lh(uint8 *p, uint32 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
p[2] = (uint8)((v >> 16) & 0xff);
|
||||||
|
p[3] = (uint8)((v >> 24) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32 flag_get_dword_lh(uint8 *p)
|
||||||
|
{
|
||||||
|
return((uint32)p[0] |
|
||||||
|
((uint32)p[1] << 8) |
|
||||||
|
((uint32)p[2] << 16) |
|
||||||
|
((uint32)p[3] << 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_get_current_drive(void)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x19; /* DOS get current default drive */
|
||||||
|
int86(0x21, ®s, ®s); /* AL = 0 for A:, 1 for B:, ... */
|
||||||
|
|
||||||
|
return((int)regs.h.al);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_current_dhandle(uint8 *dhandle)
|
||||||
|
{
|
||||||
|
uint8 connid = 0;
|
||||||
|
uint8 flags = 0;
|
||||||
|
int drive;
|
||||||
|
|
||||||
|
drive = flag_get_current_drive();
|
||||||
|
if (get_drive_info((uint8)drive, &connid, dhandle, &flags))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
if (!connid || (flags & 0x80))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_add_handle_path(uint8 *p, uint8 dhandle, char *name)
|
||||||
|
{
|
||||||
|
int nlen;
|
||||||
|
|
||||||
|
nlen = strlen(name);
|
||||||
|
if (nlen > 255) nlen = 255;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* handle/path:
|
||||||
|
* volume/handle byte
|
||||||
|
* dir base dword
|
||||||
|
* dirstyle byte (0 = short dir handle)
|
||||||
|
* path components: 1 component, length, bytes
|
||||||
|
*/
|
||||||
|
*p++ = dhandle;
|
||||||
|
flag_put_dword_lh(p, 0L); p += 4;
|
||||||
|
*p++ = 0; /* dirstyle = handle */
|
||||||
|
*p++ = 1; /* one path component */
|
||||||
|
*p++ = (uint8)nlen;
|
||||||
|
memcpy(p, name, nlen);
|
||||||
|
p += nlen;
|
||||||
|
|
||||||
|
return(1 + 4 + 1 + 1 + 1 + nlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_ncp87_obtain_attrs(char *name, uint32 *attrs)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[320];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[128];
|
||||||
|
} repl;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 *p;
|
||||||
|
int hlen;
|
||||||
|
|
||||||
|
if (flag_current_dhandle(&dhandle))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
p = req.data;
|
||||||
|
*p++ = 6; /* subfunction: obtain file/subdir info */
|
||||||
|
*p++ = FLAG_NW_NS_DOS; /* source namespace */
|
||||||
|
*p++ = FLAG_NW_NS_DOS; /* target namespace */
|
||||||
|
flag_put_word_lh(p, FLAG_SA_ALL); p += 2;
|
||||||
|
flag_put_dword_lh(p, FLAG_RIM_ATTRIBUTES); p += 4;
|
||||||
|
hlen = flag_add_handle_path(p, dhandle, name);
|
||||||
|
p += hlen;
|
||||||
|
|
||||||
|
req.len = (uint16)(p - req.data);
|
||||||
|
repl.len = sizeof(repl.data);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xF257, &req, &repl);
|
||||||
|
if (neterrno)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With RIM_ATTRIBUTES only, ncpfs expects NSI_Attributes first.
|
||||||
|
* First dword is the 32-bit Attributes field.
|
||||||
|
*/
|
||||||
|
if (attrs)
|
||||||
|
*attrs = flag_get_dword_lh(repl.data);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_ncp87_modify_attrs(char *name, uint32 attrs)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[384];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[8];
|
||||||
|
} repl;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 *p;
|
||||||
|
int hlen;
|
||||||
|
|
||||||
|
if (flag_current_dhandle(&dhandle))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
p = req.data;
|
||||||
|
*p++ = 7; /* subfunction: modify DOS info */
|
||||||
|
*p++ = FLAG_NW_NS_DOS;
|
||||||
|
*p++ = 0; /* reserved */
|
||||||
|
flag_put_word_lh(p, FLAG_SA_ALL); p += 2;
|
||||||
|
|
||||||
|
flag_put_dword_lh(p, FLAG_RIM_ATTRIBUTES); p += 4; /* modify mask */
|
||||||
|
flag_put_dword_lh(p, attrs); p += 4; /* Attributes */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remaining ncp_dos_info fields. Mask says only Attributes is valid,
|
||||||
|
* so these should be ignored, but ncpfs still sends the full structure.
|
||||||
|
*/
|
||||||
|
memset(p, 0, 34);
|
||||||
|
p += 34;
|
||||||
|
|
||||||
|
hlen = flag_add_handle_path(p, dhandle, name);
|
||||||
|
p += hlen;
|
||||||
|
|
||||||
|
req.len = (uint16)(p - req.data);
|
||||||
|
repl.len = sizeof(repl.data);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xF257, &req, &repl);
|
||||||
|
if (neterrno)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _A_NORMAL
|
||||||
|
#define _A_NORMAL 0x00
|
||||||
|
#endif
|
||||||
|
#ifndef _A_RDONLY
|
||||||
|
#define _A_RDONLY 0x01
|
||||||
|
#endif
|
||||||
|
#ifndef _A_HIDDEN
|
||||||
|
#define _A_HIDDEN 0x02
|
||||||
|
#endif
|
||||||
|
#ifndef _A_SYSTEM
|
||||||
|
#define _A_SYSTEM 0x04
|
||||||
|
#endif
|
||||||
|
#ifndef _A_SUBDIR
|
||||||
|
#define _A_SUBDIR 0x10
|
||||||
|
#endif
|
||||||
|
#ifndef _A_ARCH
|
||||||
|
#define _A_ARCH 0x20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int flag_same(char *a, char *b)
|
||||||
|
{
|
||||||
|
while (*a || *b) {
|
||||||
|
int ca = *a++;
|
||||||
|
int cb = *b++;
|
||||||
|
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||||
|
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||||
|
if (ca != cb) return(0);
|
||||||
|
}
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_help(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "USAGE: FLAG [path [ option | [+|-] attribute(s) ] [SUB]]\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "386 Attributes:\n");
|
||||||
|
fprintf(stdout, "--------------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "RO Read Only\n");
|
||||||
|
fprintf(stdout, "RW Read Write\n");
|
||||||
|
fprintf(stdout, "S Sharable\n");
|
||||||
|
fprintf(stdout, "H Hidden\n");
|
||||||
|
fprintf(stdout, "Sy System\n");
|
||||||
|
fprintf(stdout, "T Transactional\n");
|
||||||
|
fprintf(stdout, "P Purge\n");
|
||||||
|
fprintf(stdout, "A Archive Needed\n");
|
||||||
|
fprintf(stdout, "RA Read Audit\n");
|
||||||
|
fprintf(stdout, "WA Write Audit\n");
|
||||||
|
fprintf(stdout, "CI Copy Inhibit\n");
|
||||||
|
fprintf(stdout, "DI Delete Inhibit\n");
|
||||||
|
fprintf(stdout, "RI Rename Inhibit\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "All All\n");
|
||||||
|
fprintf(stdout, "N Normal\n");
|
||||||
|
fprintf(stdout, "SUB\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_attr_mask(char *s, unsigned *setbits, unsigned *clearbits)
|
||||||
|
{
|
||||||
|
int set = 1;
|
||||||
|
char *p = s;
|
||||||
|
|
||||||
|
if (*p == '+') {
|
||||||
|
set = 1;
|
||||||
|
p++;
|
||||||
|
} else if (*p == '-') {
|
||||||
|
set = 0;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*p) return(-1);
|
||||||
|
|
||||||
|
if (flag_same(p, "RO")) {
|
||||||
|
if (set) {
|
||||||
|
*setbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
} else {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
}
|
||||||
|
} else if (flag_same(p, "RW")) {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
} else if (flag_same(p, "S")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_S;
|
||||||
|
else *clearbits |= (unsigned)NWFA_S;
|
||||||
|
} else if (flag_same(p, "H")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_H;
|
||||||
|
else *clearbits |= (unsigned)NWFA_H;
|
||||||
|
} else if (flag_same(p, "SY") || flag_same(p, "SYS") || flag_same(p, "SYSTEM")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_SY;
|
||||||
|
else *clearbits |= (unsigned)NWFA_SY;
|
||||||
|
} else if (flag_same(p, "T")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_T;
|
||||||
|
else *clearbits |= (unsigned)NWFA_T;
|
||||||
|
} else if (flag_same(p, "P")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_P;
|
||||||
|
else *clearbits |= (unsigned)NWFA_P;
|
||||||
|
} else if (flag_same(p, "A")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_A;
|
||||||
|
else *clearbits |= (unsigned)NWFA_A;
|
||||||
|
} else if (flag_same(p, "RA")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_RA;
|
||||||
|
else *clearbits |= (unsigned)NWFA_RA;
|
||||||
|
} else if (flag_same(p, "WA")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_WA;
|
||||||
|
else *clearbits |= (unsigned)NWFA_WA;
|
||||||
|
} else if (flag_same(p, "CI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_CI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_CI;
|
||||||
|
} else if (flag_same(p, "DI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_DI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_DI;
|
||||||
|
} else if (flag_same(p, "RI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_RI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_RI;
|
||||||
|
} else if (flag_same(p, "N") || flag_same(p, "NORMAL")) {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_H | NWFA_SY | NWFA_A |
|
||||||
|
NWFA_S | NWFA_T | NWFA_P |
|
||||||
|
NWFA_RA | NWFA_WA | NWFA_CI | NWFA_DI | NWFA_RI);
|
||||||
|
} else if (flag_same(p, "ALL")) {
|
||||||
|
*setbits |= (unsigned)(NWFA_RO | NWFA_H | NWFA_SY | NWFA_A |
|
||||||
|
NWFA_S | NWFA_T | NWFA_P |
|
||||||
|
NWFA_RA | NWFA_WA | NWFA_CI | NWFA_DI | NWFA_RI);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Unknown attribute encountered in command line.\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_print_attrs(unsigned attr)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Novell order:
|
||||||
|
* RO/RW S A H Sy T P RA WA CI DI RI
|
||||||
|
*/
|
||||||
|
fprintf(stdout, "[ ");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RO) ? "RO" : "Rw");
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_S) ? 'S' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_A) ? 'A' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_H) ? 'H' : '-');
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_SY) ? "Sy" : "-");
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_T) ? 'T' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_P) ? 'P' : '-');
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RA) ? "Ra" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_WA) ? "Wa" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_CI) ? "CI" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_DI) ? "DI" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RI) ? "RI" : "--");
|
||||||
|
fprintf(stdout, "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_display_one(char *name, unsigned attr)
|
||||||
|
{
|
||||||
|
fprintf(stdout, " %-23s ", name);
|
||||||
|
flag_print_attrs(attr);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_has_wildcards(char *s)
|
||||||
|
{
|
||||||
|
while (*s) {
|
||||||
|
if (*s == '*' || *s == '?') return(1);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_list(char *pattern)
|
||||||
|
{
|
||||||
|
struct find_t ff;
|
||||||
|
unsigned findattr = _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
if (_dos_findfirst(pattern, findattr, &ff))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!(ff.attrib & _A_SUBDIR)) {
|
||||||
|
uint32 nwattrs;
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(ff.name, &nwattrs))
|
||||||
|
nwattrs = (uint32)ff.attrib;
|
||||||
|
|
||||||
|
flag_display_one(ff.name, (unsigned)nwattrs);
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
} while (!_dos_findnext(&ff));
|
||||||
|
|
||||||
|
return(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_apply(char *pattern, unsigned setbits, unsigned clearbits)
|
||||||
|
{
|
||||||
|
struct find_t ff;
|
||||||
|
unsigned findattr = _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH;
|
||||||
|
int shown = 0;
|
||||||
|
|
||||||
|
if (_dos_findfirst(pattern, findattr, &ff))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
uint32 attrs;
|
||||||
|
uint32 newattrs;
|
||||||
|
char fname[260];
|
||||||
|
|
||||||
|
if (ff.attrib & _A_SUBDIR) continue;
|
||||||
|
|
||||||
|
strmaxcpy(fname, ff.name, sizeof(fname) - 1);
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(fname, &attrs))
|
||||||
|
attrs = (uint32)ff.attrib;
|
||||||
|
|
||||||
|
newattrs = (attrs | (uint32)setbits) & ~((uint32)clearbits);
|
||||||
|
|
||||||
|
if (newattrs != attrs) {
|
||||||
|
if (flag_ncp87_modify_attrs(fname, newattrs)) {
|
||||||
|
unsigned dosattr = (unsigned)(newattrs & (_A_RDONLY|_A_HIDDEN|_A_SYSTEM|_A_ARCH));
|
||||||
|
if (_dos_setfileattr(fname, dosattr)) {
|
||||||
|
fprintf(stderr, "You don't have rights to change : %s\n", fname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(fname, &attrs))
|
||||||
|
attrs = newattrs;
|
||||||
|
|
||||||
|
flag_display_one(fname, (unsigned)attrs);
|
||||||
|
shown++;
|
||||||
|
|
||||||
|
} while (!_dos_findnext(&ff));
|
||||||
|
|
||||||
|
return(shown);
|
||||||
|
}
|
||||||
|
|
||||||
|
int func_flag(int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
char *path = "*.*";
|
||||||
|
int i;
|
||||||
|
unsigned setbits = 0;
|
||||||
|
unsigned clearbits = 0;
|
||||||
|
int have_change = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
(void)mode;
|
||||||
|
|
||||||
|
if (argc > 1 && (flag_same(argv[1], "/?") || flag_same(argv[1], "-?") ||
|
||||||
|
flag_same(argv[1], "?"))) {
|
||||||
|
flag_help();
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
path = argv[1];
|
||||||
|
if (flag_same(path, "SUB")) path = "*.*";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 2; i < argc; i++) {
|
||||||
|
if (flag_same(argv[i], "SUB")) continue;
|
||||||
|
|
||||||
|
rc = flag_attr_mask(argv[i], &setbits, &clearbits);
|
||||||
|
if (rc < 0) return(1);
|
||||||
|
if (rc > 0) continue;
|
||||||
|
have_change = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (have_change) {
|
||||||
|
rc = flag_apply(path, setbits, clearbits);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Files could not be found with pattern \"%s\"\n", path);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = flag_list(path);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Files could not be found with pattern \"%s\"\n", path);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
271
kern.c
Normal file
271
kern.c
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
/*
|
||||||
|
* kern.c - C-side experimental NetWare/DOS request wrappers
|
||||||
|
*
|
||||||
|
* kern_wasm.asm remains the production/reference implementation.
|
||||||
|
* These C functions are test wrappers so we can inspect register setup and
|
||||||
|
* slowly port proven pieces from ASM to C.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dos.h>
|
||||||
|
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__)
|
||||||
|
#define KERN_C_CALL _Cdecl
|
||||||
|
#else
|
||||||
|
#define KERN_C_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int in_ax;
|
||||||
|
unsigned int in_bx;
|
||||||
|
unsigned int in_cx;
|
||||||
|
unsigned int in_dx;
|
||||||
|
unsigned int in_si;
|
||||||
|
unsigned int in_di;
|
||||||
|
unsigned int in_ds;
|
||||||
|
unsigned int in_es;
|
||||||
|
|
||||||
|
unsigned int out_ax;
|
||||||
|
unsigned int out_bx;
|
||||||
|
unsigned int out_cx;
|
||||||
|
unsigned int out_dx;
|
||||||
|
unsigned int out_si;
|
||||||
|
unsigned int out_di;
|
||||||
|
unsigned int out_flags;
|
||||||
|
|
||||||
|
void far *req_ptr;
|
||||||
|
void far *repl_ptr;
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
} NET_CALL_C_DEBUG;
|
||||||
|
|
||||||
|
NET_CALL_C_DEBUG Net_Call_C_Last;
|
||||||
|
|
||||||
|
static void net_call_c_clear(void)
|
||||||
|
{
|
||||||
|
memset(&Net_Call_C_Last, 0, sizeof(Net_Call_C_Last));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void net_call_c_save_in(union REGS *r, struct SREGS *s,
|
||||||
|
void *req, void *repl)
|
||||||
|
{
|
||||||
|
Net_Call_C_Last.in_ax = r->x.ax;
|
||||||
|
Net_Call_C_Last.in_bx = r->x.bx;
|
||||||
|
Net_Call_C_Last.in_cx = r->x.cx;
|
||||||
|
Net_Call_C_Last.in_dx = r->x.dx;
|
||||||
|
Net_Call_C_Last.in_si = r->x.si;
|
||||||
|
Net_Call_C_Last.in_di = r->x.di;
|
||||||
|
Net_Call_C_Last.in_ds = s->ds;
|
||||||
|
Net_Call_C_Last.in_es = s->es;
|
||||||
|
Net_Call_C_Last.req_ptr = req;
|
||||||
|
Net_Call_C_Last.repl_ptr = repl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void net_call_c_save_out(union REGS *r, unsigned int returned_ax)
|
||||||
|
{
|
||||||
|
Net_Call_C_Last.out_ax = returned_ax;
|
||||||
|
Net_Call_C_Last.out_bx = r->x.bx;
|
||||||
|
Net_Call_C_Last.out_cx = r->x.cx;
|
||||||
|
Net_Call_C_Last.out_dx = r->x.dx;
|
||||||
|
Net_Call_C_Last.out_si = r->x.si;
|
||||||
|
Net_Call_C_Last.out_di = r->x.di;
|
||||||
|
Net_Call_C_Last.out_flags = r->x.cflag;
|
||||||
|
Net_Call_C_Last.rc = returned_ax & 0x00ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* C equivalent of kern_wasm.asm Net_Call:
|
||||||
|
* AX = func
|
||||||
|
* DS:SI = request
|
||||||
|
* ES:DI = reply
|
||||||
|
* int 21h
|
||||||
|
* return AL only, because kern_wasm.asm clears AH before return.
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_C(unsigned int ax, void *req, void *repl)
|
||||||
|
{
|
||||||
|
return Net_Call_CX(ax, 0, 0, 0, req, repl);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KERN_C_CALL Net_Call_CX(unsigned int ax, unsigned int bx,
|
||||||
|
unsigned int cx, unsigned int dx,
|
||||||
|
void *req, void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.x.ax = ax;
|
||||||
|
inregs.x.bx = bx;
|
||||||
|
inregs.x.cx = cx;
|
||||||
|
inregs.x.dx = dx;
|
||||||
|
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff; /* match ASM Net_Call return */
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)ret_ax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Experimental Novell Client/VLM AH=F2 wrapper derived from official FLAG.EXE
|
||||||
|
* disassembly:
|
||||||
|
* AH = F2h
|
||||||
|
* AL = NCP function, e.g. 57h for NCP 87
|
||||||
|
* CX = request length
|
||||||
|
* DX = reply buffer length
|
||||||
|
* DS:SI = request buffer
|
||||||
|
* ES:DI = reply buffer
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_F2_C(unsigned int function,
|
||||||
|
unsigned int req_len,
|
||||||
|
unsigned int repl_len,
|
||||||
|
void *req,
|
||||||
|
void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.h.ah = 0xF2;
|
||||||
|
inregs.h.al = (unsigned char)(function & 0xff);
|
||||||
|
inregs.x.cx = req_len;
|
||||||
|
inregs.x.dx = repl_len;
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell wrapper behavior:
|
||||||
|
* xor ah,ah
|
||||||
|
* or al,al
|
||||||
|
* if al != 0: ah=89h
|
||||||
|
* Return AL only for C caller, but keep 89xx in debug out_ax.
|
||||||
|
*/
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff;
|
||||||
|
if (ret_ax)
|
||||||
|
ret_ax |= 0x8900;
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)(ret_ax & 0x00ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fully generic INT 21h register test wrapper.
|
||||||
|
* Used for reproducing the NWCREQUEST/NWCSHELLREQ register calls seen in
|
||||||
|
* DeveloperNet 1997 clndos16.lib.
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_F2X_C(unsigned int ax,
|
||||||
|
unsigned int bx,
|
||||||
|
unsigned int cx,
|
||||||
|
unsigned int dx,
|
||||||
|
void *req,
|
||||||
|
void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.x.ax = ax;
|
||||||
|
inregs.x.bx = bx;
|
||||||
|
inregs.x.cx = cx;
|
||||||
|
inregs.x.dx = dx;
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff;
|
||||||
|
if (ret_ax)
|
||||||
|
ret_ax |= 0x8900;
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)(ret_ax & 0x00ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KERN_C_CALL Net_Call_C_Dump(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "NETCALLC in : AX=%04X BX=%04X CX=%04X DX=%04X DS:SI=%04X:%04X ES:DI=%04X:%04X\n",
|
||||||
|
Net_Call_C_Last.in_ax,
|
||||||
|
Net_Call_C_Last.in_bx,
|
||||||
|
Net_Call_C_Last.in_cx,
|
||||||
|
Net_Call_C_Last.in_dx,
|
||||||
|
Net_Call_C_Last.in_ds,
|
||||||
|
Net_Call_C_Last.in_si,
|
||||||
|
Net_Call_C_Last.in_es,
|
||||||
|
Net_Call_C_Last.in_di);
|
||||||
|
|
||||||
|
fprintf(stdout, "NETCALLC out: AX=%04X BX=%04X CX=%04X DX=%04X SI=%04X DI=%04X CF=%04X RC=%d\n",
|
||||||
|
Net_Call_C_Last.out_ax,
|
||||||
|
Net_Call_C_Last.out_bx,
|
||||||
|
Net_Call_C_Last.out_cx,
|
||||||
|
Net_Call_C_Last.out_dx,
|
||||||
|
Net_Call_C_Last.out_si,
|
||||||
|
Net_Call_C_Last.out_di,
|
||||||
|
Net_Call_C_Last.out_flags,
|
||||||
|
Net_Call_C_Last.rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int KERN_C_CALL Net_Call_C_GetDebug(unsigned int idx)
|
||||||
|
{
|
||||||
|
switch (idx) {
|
||||||
|
case 0: return Net_Call_C_Last.in_ax;
|
||||||
|
case 1: return Net_Call_C_Last.in_bx;
|
||||||
|
case 2: return Net_Call_C_Last.in_cx;
|
||||||
|
case 3: return Net_Call_C_Last.in_dx;
|
||||||
|
case 4: return Net_Call_C_Last.in_ds;
|
||||||
|
case 5: return Net_Call_C_Last.in_si;
|
||||||
|
case 6: return Net_Call_C_Last.in_es;
|
||||||
|
case 7: return Net_Call_C_Last.in_di;
|
||||||
|
case 8: return Net_Call_C_Last.out_ax;
|
||||||
|
case 9: return Net_Call_C_Last.out_bx;
|
||||||
|
case 10: return Net_Call_C_Last.out_cx;
|
||||||
|
case 11: return Net_Call_C_Last.out_dx;
|
||||||
|
case 12: return Net_Call_C_Last.out_si;
|
||||||
|
case 13: return Net_Call_C_Last.out_di;
|
||||||
|
case 14: return Net_Call_C_Last.out_flags;
|
||||||
|
case 15: return (unsigned int)Net_Call_C_Last.rc;
|
||||||
|
}
|
||||||
|
return 0xffff;
|
||||||
|
}
|
||||||
30
kern.h
30
kern.h
@@ -3,6 +3,8 @@
|
|||||||
#define KERN_CALL _Cdecl
|
#define KERN_CALL _Cdecl
|
||||||
#else
|
#else
|
||||||
#define KERN_CALL
|
#define KERN_CALL
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int KERN_CALL IPXinit(void);
|
extern int KERN_CALL IPXinit(void);
|
||||||
@@ -13,8 +15,34 @@ extern void asm_esr_routine(void);
|
|||||||
extern void esr_routine(ECB *ecb);
|
extern void esr_routine(ECB *ecb);
|
||||||
extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz);
|
extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz);
|
||||||
extern int KERN_CALL Net_Call(UI func, void *req, void *repl);
|
extern int KERN_CALL Net_Call(UI func, void *req, void *repl);
|
||||||
|
extern int KERN_CALL C32_LoadNios_Probe(UI axfunc, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_GetFunc_Probe(char *name, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_CallVersion_Nios_Probe(void *outbuf);
|
||||||
|
extern int KERN_CALL C32_MapLock_Probe(void *ptr, UI len, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_MapVar_Probe(UI specLen, UI flag, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_OpenRef_Probe(UI refLo, UI refHi, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_NCP87_Raw5_Probe(UI connLo, UI connHi,
|
||||||
|
void *hdr, UI hdrLen,
|
||||||
|
void *path, UI pathLen,
|
||||||
|
void *rep0, UI rep0Len,
|
||||||
|
void *rep1, UI rep1Len,
|
||||||
|
void *outbuf);
|
||||||
|
extern int KERN_CALL Net_Call_VLM_Raw(UI ax, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl,
|
||||||
|
UI p1, UI p2, UI p3);
|
||||||
|
extern int KERN_CALL Net_Call_C(UI func, void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_CX(UI func, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_F2_C(UI function, UI req_len, UI repl_len,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_F2X_C(UI ax, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern void KERN_CALL Net_Call_C_Dump(void);
|
||||||
|
extern UI KERN_CALL Net_Call_C_GetDebug(UI idx);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef KERN_CALL
|
#undef KERN_CALL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1244
kern_wasm.asm
1244
kern_wasm.asm
File diff suppressed because it is too large
Load Diff
734
login.c
734
login.c
@@ -6,6 +6,577 @@
|
|||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "nwcrypt.h"
|
#include "nwcrypt.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifndef BLACK
|
||||||
|
#define BLACK 0
|
||||||
|
#endif
|
||||||
|
#ifndef BLUE
|
||||||
|
#define BLUE 1
|
||||||
|
#endif
|
||||||
|
#ifndef LIGHTGRAY
|
||||||
|
#define LIGHTGRAY 7
|
||||||
|
#endif
|
||||||
|
#ifndef WHITE
|
||||||
|
#define WHITE 15
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static uint8 script_login_name[64];
|
||||||
|
static uint8 script_file_server[52];
|
||||||
|
|
||||||
|
static char **build_argv(char *buf, int bufsize, char *str);
|
||||||
|
extern int read_command_file(char *fstr);
|
||||||
|
extern int get_fs_name(int connid, char *name);
|
||||||
|
|
||||||
|
|
||||||
|
static uint8 login_video_attr = 0x07;
|
||||||
|
|
||||||
|
static void login_gotoxy(int x, int y)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x02;
|
||||||
|
regs.h.bh = 0x00;
|
||||||
|
regs.h.dh = (uint8)(y - 1);
|
||||||
|
regs.h.dl = (uint8)(x - 1);
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_cls_attr(uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x06;
|
||||||
|
regs.h.al = 0x00;
|
||||||
|
regs.h.bh = attr;
|
||||||
|
regs.h.ch = 0;
|
||||||
|
regs.h.cl = 0;
|
||||||
|
regs.h.dh = 24;
|
||||||
|
regs.h.dl = 79;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
login_gotoxy(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_write_attr(int x, int y, const char *s, uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
int col = x;
|
||||||
|
|
||||||
|
while (*s) {
|
||||||
|
login_gotoxy(col++, y);
|
||||||
|
regs.h.ah = 0x09;
|
||||||
|
regs.h.al = (uint8)*s++;
|
||||||
|
regs.h.bh = 0;
|
||||||
|
regs.h.bl = attr;
|
||||||
|
regs.x.cx = 1;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
login_gotoxy(col, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_fill_line(int y, uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
login_gotoxy(1, y);
|
||||||
|
regs.h.ah = 0x09;
|
||||||
|
regs.h.al = ' ';
|
||||||
|
regs.h.bh = 0;
|
||||||
|
regs.h.bl = attr;
|
||||||
|
regs.x.cx = 80;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_screen_normal(void)
|
||||||
|
{
|
||||||
|
login_video_attr = 0x07;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int login_help(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " LOGIN General Help Mars NWE\n");
|
||||||
|
fprintf(stdout, " ------------------------------------------------------------------------\n");
|
||||||
|
fprintf(stdout, " Purpose: To gain access to the network.\n");
|
||||||
|
fprintf(stdout, " Syntax: LOGIN [/VER] [[Server | Tree/][Username] [/options]\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " To: Use:\n");
|
||||||
|
fprintf(stdout, " Login without running login scripts /NS\n");
|
||||||
|
fprintf(stdout, " Clear the screen before executing /CLS\n");
|
||||||
|
fprintf(stdout, " Specify a script file /S filename\n");
|
||||||
|
fprintf(stdout, " Display version information /VER\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, " Examples:\n");
|
||||||
|
fprintf(stdout, " LOGIN SUPERVISOR\n");
|
||||||
|
fprintf(stdout, " LOGIN MARS/SUPERVISOR\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_banner(void)
|
||||||
|
{
|
||||||
|
login_cls_attr(0x07); /* normal black background */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NetWare-like header, but blue for Mars NWE:
|
||||||
|
* blue separator
|
||||||
|
* blue title line
|
||||||
|
* blue separator
|
||||||
|
* then normal black prompt area.
|
||||||
|
*/
|
||||||
|
login_fill_line(1, 0x1f); /* white on blue */
|
||||||
|
login_fill_line(2, 0x1f); /* white on blue */
|
||||||
|
login_write_attr(36, 2, "Mars NWE", 0x1f);
|
||||||
|
login_fill_line(3, 0x1f); /* white on blue */
|
||||||
|
|
||||||
|
login_screen_normal();
|
||||||
|
login_gotoxy(1, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *skip_spaces(char *p)
|
||||||
|
{
|
||||||
|
while (*p == 32 || *p == '\t') p++;
|
||||||
|
return(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void strip_quotes(char *s)
|
||||||
|
{
|
||||||
|
char *d = s;
|
||||||
|
char quote = 0;
|
||||||
|
|
||||||
|
while (*s) {
|
||||||
|
if (!quote && (*s == '"' || *s == '\'')) {
|
||||||
|
quote = *s++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (quote && *s == quote) {
|
||||||
|
quote = 0;
|
||||||
|
s++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*d++ = *s++;
|
||||||
|
}
|
||||||
|
*d = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void script_get_timevar(char *name, char *out, int outlen)
|
||||||
|
{
|
||||||
|
time_t now;
|
||||||
|
struct tm *tmv;
|
||||||
|
int hour;
|
||||||
|
static char *months[] = {
|
||||||
|
"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE",
|
||||||
|
"JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"
|
||||||
|
};
|
||||||
|
static char *days[] = {
|
||||||
|
"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
|
||||||
|
"THURSDAY", "FRIDAY", "SATURDAY"
|
||||||
|
};
|
||||||
|
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
tmv = localtime(&now);
|
||||||
|
if (!tmv) return;
|
||||||
|
|
||||||
|
upstr(name);
|
||||||
|
|
||||||
|
if (!strcmp(name, "GREETING_TIME")) {
|
||||||
|
if (tmv->tm_hour < 12) strcpy(out, "MORNING");
|
||||||
|
else if (tmv->tm_hour < 18) strcpy(out, "AFTERNOON");
|
||||||
|
else strcpy(out, "EVENING");
|
||||||
|
} else if (!strcmp(name, "MONTH_NAME")) {
|
||||||
|
strmaxcpy(out, months[tmv->tm_mon], outlen - 1);
|
||||||
|
} else if (!strcmp(name, "MONTH")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_mon + 1);
|
||||||
|
} else if (!strcmp(name, "DAY")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_mday);
|
||||||
|
} else if (!strcmp(name, "YEAR")) {
|
||||||
|
sprintf(out, "%04d", tmv->tm_year + 1900);
|
||||||
|
} else if (!strcmp(name, "DAY_OF_WEEK")) {
|
||||||
|
strmaxcpy(out, days[tmv->tm_wday], outlen - 1);
|
||||||
|
} else if (!strcmp(name, "HOUR")) {
|
||||||
|
hour = tmv->tm_hour % 12;
|
||||||
|
if (!hour) hour = 12;
|
||||||
|
sprintf(out, "%d", hour);
|
||||||
|
} else if (!strcmp(name, "MINUTE")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_min);
|
||||||
|
} else if (!strcmp(name, "SECOND")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_sec);
|
||||||
|
} else if (!strcmp(name, "AM_PM")) {
|
||||||
|
strcpy(out, tmv->tm_hour >= 12 ? "PM" : "AM");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_expand_var(char *name, char *out, int outlen)
|
||||||
|
{
|
||||||
|
upstr(name);
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
if (!strcmp(name, "LOGIN_NAME")) {
|
||||||
|
strmaxcpy(out, script_login_name, outlen - 1);
|
||||||
|
} else if (!strcmp(name, "FILE_SERVER")) {
|
||||||
|
strmaxcpy(out, script_file_server, outlen - 1);
|
||||||
|
} else if (!strcmp(name, "P_STATION") || !strcmp(name, "STATION")) {
|
||||||
|
strcpy(out, "000000000000");
|
||||||
|
} else {
|
||||||
|
script_get_timevar(name, out, outlen);
|
||||||
|
if (!*out) {
|
||||||
|
strcpy(out, "%");
|
||||||
|
strncat(out, name, outlen - strlen(out) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_put_expanded(char *s)
|
||||||
|
{
|
||||||
|
while (s && *s) {
|
||||||
|
if (*s == '%') {
|
||||||
|
char name[64];
|
||||||
|
char value[128];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
s++;
|
||||||
|
while ((*s == '_' ||
|
||||||
|
(*s >= 'A' && *s <= 'Z') ||
|
||||||
|
(*s >= 'a' && *s <= 'z') ||
|
||||||
|
(*s >= '0' && *s <= '9')) &&
|
||||||
|
i < (int)sizeof(name) - 1) {
|
||||||
|
name[i++] = *s++;
|
||||||
|
}
|
||||||
|
name[i] = '\0';
|
||||||
|
|
||||||
|
if (i) {
|
||||||
|
script_expand_var(name, value, sizeof(value));
|
||||||
|
fprintf(stdout, "%s", value);
|
||||||
|
} else {
|
||||||
|
fputc('%', stdout);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fputc(*s++, stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_write(char *p)
|
||||||
|
{
|
||||||
|
p = skip_spaces(p);
|
||||||
|
strip_quotes(p);
|
||||||
|
script_put_expanded(p);
|
||||||
|
fputc('\n', stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_join_args(char **argv, int argc)
|
||||||
|
{
|
||||||
|
if (argc > 2) {
|
||||||
|
char *p = argv[argc-1];
|
||||||
|
while (p-- > argv[1]) {
|
||||||
|
if (*p == '\0') *p = 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_call_line(char *line)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
char **argv;
|
||||||
|
int argc = 0;
|
||||||
|
char **pp;
|
||||||
|
|
||||||
|
buf = xmalloc(512);
|
||||||
|
argv = build_argv(buf, 512, line);
|
||||||
|
if (argv != NULL) {
|
||||||
|
pp = argv;
|
||||||
|
while (*pp) {
|
||||||
|
argc++;
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
if (argc > 0) {
|
||||||
|
upstr(argv[0]);
|
||||||
|
call_func_entry(argc, argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xfree(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int script_eval_if(char *line)
|
||||||
|
{
|
||||||
|
char tmp[512];
|
||||||
|
char *p;
|
||||||
|
char *q;
|
||||||
|
int neg = 0;
|
||||||
|
|
||||||
|
strmaxcpy(tmp, line, sizeof(tmp) - 1);
|
||||||
|
upstr(tmp);
|
||||||
|
|
||||||
|
if (strstr(tmp, "MEMBER OF") != NULL) {
|
||||||
|
if (strstr(tmp, "EVERYONE") != NULL) return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strstr(tmp, "LOGIN_NAME");
|
||||||
|
if (p != NULL) {
|
||||||
|
q = strstr(p, "<>");
|
||||||
|
if (q != NULL) neg = 1;
|
||||||
|
else q = strchr(p, '=');
|
||||||
|
|
||||||
|
if (q != NULL) {
|
||||||
|
char want[64];
|
||||||
|
char have[64];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
q += neg ? 2 : 1;
|
||||||
|
q = skip_spaces(q);
|
||||||
|
if (*q == '"' || *q == '\'') q++;
|
||||||
|
|
||||||
|
while (*q && *q != '"' && *q != '\'' && *q != 32 && *q != '\t' && i < 63)
|
||||||
|
want[i++] = *q++;
|
||||||
|
want[i] = '\0';
|
||||||
|
|
||||||
|
strmaxcpy(have, script_login_name, sizeof(have) - 1);
|
||||||
|
upstr(have);
|
||||||
|
|
||||||
|
if (neg) return(strcmp(have, want) != 0);
|
||||||
|
return(strcmp(have, want) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strstr(tmp, "DAY_OF_WEEK");
|
||||||
|
if (p != NULL) {
|
||||||
|
q = strchr(p, '=');
|
||||||
|
if (q != NULL) {
|
||||||
|
char want[64];
|
||||||
|
char have[64];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
q++;
|
||||||
|
q = skip_spaces(q);
|
||||||
|
if (*q == '"' || *q == '\'') q++;
|
||||||
|
|
||||||
|
while (*q && *q != '"' && *q != '\'' && *q != 32 && *q != '\t' && i < 63)
|
||||||
|
want[i++] = *q++;
|
||||||
|
want[i] = '\0';
|
||||||
|
|
||||||
|
strcpy(have, "DAY_OF_WEEK");
|
||||||
|
script_get_timevar(have, have, sizeof(have));
|
||||||
|
upstr(have);
|
||||||
|
|
||||||
|
return(strcmp(have, want) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int login_strnicmp(char *a, char *b, int n)
|
||||||
|
{
|
||||||
|
while (n-- > 0) {
|
||||||
|
int ca = *a++;
|
||||||
|
int cb = *b++;
|
||||||
|
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||||
|
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||||
|
if (ca != cb) return(ca - cb);
|
||||||
|
if (!ca) return(0);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int script_execute_line(char *line)
|
||||||
|
{
|
||||||
|
char work[512];
|
||||||
|
char cmd[32];
|
||||||
|
char *p;
|
||||||
|
char *arg;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
strmaxcpy(work, line, sizeof(work) - 1);
|
||||||
|
p = skip_spaces(work);
|
||||||
|
|
||||||
|
if (!*p || *p == ';') return(0);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (p[i] && p[i] != 32 && p[i] != '\t' && i < 31) {
|
||||||
|
cmd[i] = p[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
cmd[i] = '\0';
|
||||||
|
upstr(cmd);
|
||||||
|
|
||||||
|
arg = skip_spaces(p + i);
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "WRITE") || !strcmp(cmd, "ECHO")) {
|
||||||
|
script_write(arg);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "PAUSE")) {
|
||||||
|
fprintf(stdout, "Strike any key when ready . . .");
|
||||||
|
fflush(stdout);
|
||||||
|
getch();
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "CLS")) {
|
||||||
|
login_cls_attr(0x07);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "BREAK")) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "SET")) {
|
||||||
|
if (*arg) putglobenv(arg);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "DRIVE")) {
|
||||||
|
arg = skip_spaces(arg);
|
||||||
|
if ((*arg >= 'A' && *arg <= 'Z') || (*arg >= 'a' && *arg <= 'z')) {
|
||||||
|
if (*arg >= 'a') setdisk(*arg - 'a');
|
||||||
|
else setdisk(*arg - 'A');
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "MAP")) {
|
||||||
|
char up[512];
|
||||||
|
|
||||||
|
strmaxcpy(up, arg, sizeof(up) - 1);
|
||||||
|
upstr(up);
|
||||||
|
|
||||||
|
if (!strncmp(up, "DISPLAY", 7)) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(up, "ROOT ", 5)) {
|
||||||
|
char callbuf[512];
|
||||||
|
sprintf(callbuf, "MAP %s", skip_spaces(arg + 5));
|
||||||
|
script_call_line(callbuf);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(up, "INS ", 4) || !strncmp(up, "INSERT ", 7)) {
|
||||||
|
char callbuf[512];
|
||||||
|
char *a = arg;
|
||||||
|
if (!login_strnicmp(up, "INS ", 4)) a += 4;
|
||||||
|
else a += 7;
|
||||||
|
sprintf(callbuf, "PATHINS %s", skip_spaces(a));
|
||||||
|
script_call_line(callbuf);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(up, "DEL ", 4) || !strncmp(up, "DELETE ", 7)) {
|
||||||
|
char callbuf[512];
|
||||||
|
char *a = arg;
|
||||||
|
if (!login_strnicmp(up, "DEL ", 4)) a += 4;
|
||||||
|
else a += 7;
|
||||||
|
sprintf(callbuf, "PATHDEL %s", skip_spaces(a));
|
||||||
|
script_call_line(callbuf);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "ATTACH")) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "EXIT")) {
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
script_call_line(p);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int try_login_script_file(char *name)
|
||||||
|
{
|
||||||
|
return(read_command_file(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int run_login_script(void)
|
||||||
|
{
|
||||||
|
char profile[200];
|
||||||
|
char drive;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell LOGIN looks for the system login script using server based paths,
|
||||||
|
* for example \\SERVER\SYS\PUBLIC\NET$LOG.DAT. Try that first.
|
||||||
|
*/
|
||||||
|
if (*script_file_server) {
|
||||||
|
sprintf(profile, "\\\\%s\\SYS\\PUBLIC\\NET$LOG.DAT", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "\\\\%s\\SYS\\PUBLIC\\net$log.dat", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "\\\\%s\\SYS\\LOGIN\\LOGIN", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "\\\\%s\\SYS\\LOGIN\\NET$LOG.DAT", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Then try current directory and the executable path. LOGIN.EXE is often
|
||||||
|
* executed from PUBLIC, so this covers SYS:PUBLIC\NET$LOG.DAT without
|
||||||
|
* relying on an absolute drive path.
|
||||||
|
*/
|
||||||
|
if (try_login_script_file("NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("net$log.dat") != -2) return(0);
|
||||||
|
if (try_login_script_file("LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("login") != -2) return(0);
|
||||||
|
|
||||||
|
if (*prgpath) {
|
||||||
|
sprintf(profile, "%sNET$LOG.DAT", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%snet$log.dat", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%sLOGIN", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%slogin", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallbacks for requesters/runtimes that cannot open UNC from C fopen().
|
||||||
|
*/
|
||||||
|
if (try_login_script_file("\\PUBLIC\\NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\public\\net$log.dat") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\PUBLIC\\LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\public\\login") != -2) return(0);
|
||||||
|
|
||||||
|
if (try_login_script_file("\\LOGIN\\LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\login\\login") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\LOGIN\\NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\login\\net$log.dat") != -2) return(0);
|
||||||
|
|
||||||
|
for (drive = 'C'; drive <= 'Z'; drive++) {
|
||||||
|
sprintf(profile, "%c:\\PUBLIC\\NET$LOG.DAT", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\public\\net$log.dat", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\PUBLIC\\LOGIN", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\LOGIN\\LOGIN", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\LOGIN\\NET$LOG.DAT", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int do_change_object_passwd(char *name,
|
static int do_change_object_passwd(char *name,
|
||||||
uint16 objtyp,
|
uint16 objtyp,
|
||||||
@@ -14,31 +585,55 @@ static int do_change_object_passwd(char *name,
|
|||||||
|
|
||||||
{
|
{
|
||||||
uint8 key[8];
|
uint8 key[8];
|
||||||
if (0 && !ncp_17_17(key)) {
|
|
||||||
|
if (!ncp_17_17(key)) {
|
||||||
uint32 objid = ncp_17_35(name, objtyp);
|
uint32 objid = ncp_17_35(name, objtyp);
|
||||||
if (objid) {
|
if (objid) {
|
||||||
uint8 buff[128];
|
uint8 oldpwd[16]; /* old passwd as stored by server */
|
||||||
uint8 encrypted[8];
|
uint8 newpwd[16]; /* new passwd as stored by server */
|
||||||
uint8 newcryptpasswd[16];
|
uint8 cryptkey[8];
|
||||||
int passwdx=0;
|
|
||||||
uint8 tmpid[4];
|
uint8 tmpid[4];
|
||||||
|
uint8 passwdx;
|
||||||
|
int newlen;
|
||||||
|
|
||||||
|
memcpy(cryptkey, key, 8);
|
||||||
U32_TO_BE32(objid, tmpid);
|
U32_TO_BE32(objid, tmpid);
|
||||||
shuffle(tmpid, oldpassword, strlen(oldpassword), buff);
|
|
||||||
nw_encrypt(key, buff, encrypted);
|
|
||||||
|
|
||||||
shuffle(tmpid, newpassword, strlen(newpassword), buff);
|
shuffle(tmpid, oldpassword, strlen(oldpassword), oldpwd);
|
||||||
|
shuffle(tmpid, newpassword, strlen(newpassword), newpwd);
|
||||||
|
|
||||||
if (!ncp_17_4b(encrypted, name, objtyp, passwdx, newcryptpasswd)) {
|
nw_encrypt(cryptkey, oldpwd, cryptkey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same keyed change password transformation as ncpfs
|
||||||
|
* ncp_change_login_passwd(): encrypt both 8-byte halves of the
|
||||||
|
* stored new password using the stored old password as key material.
|
||||||
|
* newpassencrypt() intentionally mutates oldpwd; the passwd length
|
||||||
|
* byte must be calculated afterwards, just like ncpfs does it.
|
||||||
|
*/
|
||||||
|
newpassencrypt(oldpwd, newpwd);
|
||||||
|
newpassencrypt(oldpwd + 8, newpwd + 8);
|
||||||
|
|
||||||
|
newlen = strlen(newpassword);
|
||||||
|
if (newlen > 63) newlen = 63;
|
||||||
|
passwdx = (uint8)(((newlen ^ oldpwd[0] ^ oldpwd[1]) & 0x7f) | 0x40);
|
||||||
|
|
||||||
|
if (!ncp_17_4b(cryptkey, name, objtyp, passwdx, newpwd)) {
|
||||||
;;
|
;;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* now we use old unencrypted algorithmus */
|
|
||||||
if (!ncp_17_40(name, objtyp, oldpassword, newpassword)) {
|
|
||||||
;;
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallback for old servers/requesters where Get Encryption Key is not
|
||||||
|
* available. Keep the original unencrypted behavior as fallback only.
|
||||||
|
*/
|
||||||
|
if (!ncp_17_40(name, objtyp, oldpassword, newpassword)) {
|
||||||
|
;;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +678,10 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
|
|||||||
case 8 : if (len) {
|
case 8 : if (len) {
|
||||||
--len;
|
--len;
|
||||||
--s;
|
--s;
|
||||||
if (doecho) fprintf(stdout, "\010 \010");
|
if (doecho) {
|
||||||
|
fprintf(stdout, "\010 \010");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
} else beep();
|
} else beep();
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -94,7 +692,10 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
|
|||||||
len++;
|
len++;
|
||||||
break;
|
break;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
if (doecho) fprintf(stdout, "%c", (uint8)key);
|
if (doecho) {
|
||||||
|
fprintf(stdout, "%c", (uint8)key);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*s='\0';
|
*s='\0';
|
||||||
return(len);
|
return(len);
|
||||||
@@ -110,9 +711,7 @@ static void getstr(char *what, char *str, int rsize, int doecho)
|
|||||||
|
|
||||||
static int login_usage(void)
|
static int login_usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage:\t%s [-u] [user | user password]\n", funcname);
|
return(login_help());
|
||||||
fprintf(stderr, "\t-u : use unecrypted password\n" );
|
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int func_login(int argc, char *argv[], int mode)
|
int func_login(int argc, char *argv[], int mode)
|
||||||
@@ -122,10 +721,23 @@ int func_login(int argc, char *argv[], int mode)
|
|||||||
uint8 uname[200];
|
uint8 uname[200];
|
||||||
uint8 upasswd[200];
|
uint8 upasswd[200];
|
||||||
SEARCH_VECTOR save_drives;
|
SEARCH_VECTOR save_drives;
|
||||||
|
int interactive_login = 0;
|
||||||
|
int no_script = 0;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (argv[1][0] == '-') {
|
if (!strcmp(argv[1], "/?") || !strcmp(argv[1], "-?") || !strcmp(argv[1], "?"))
|
||||||
if (argv[1][1] == 'u') option |= 1;
|
return(login_help());
|
||||||
|
if (!strcmp(argv[1], "/VER") || !strcmp(argv[1], "-VER")) {
|
||||||
|
fprintf(stdout, "Mars NWE LOGIN 0.99\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if (argv[1][0] == '-' || argv[1][0] == '/') {
|
||||||
|
if (argv[1][1] == 'u' || argv[1][1] == 'U') option |= 1;
|
||||||
|
else if (!strcmp(argv[1], "/NS") || !strcmp(argv[1], "-NS")) no_script = 1;
|
||||||
|
else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) login_cls_attr(0x07);
|
||||||
else return(login_usage());
|
else return(login_usage());
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
@@ -138,13 +750,18 @@ int func_login(int argc, char *argv[], int mode)
|
|||||||
if (argc > 2) strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
|
if (argc > 2) strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
|
||||||
else upasswd[0]='\0';
|
else upasswd[0]='\0';
|
||||||
|
|
||||||
|
if (!uname[0]) {
|
||||||
|
interactive_login = 1;
|
||||||
|
login_banner();
|
||||||
|
}
|
||||||
|
|
||||||
while (result) {
|
while (result) {
|
||||||
if (!uname[0]) getstr("Login", uname, sizeof(uname)-1, 1);
|
if (!uname[0]) getstr("Enter your login name", uname, sizeof(uname)-1, 1);
|
||||||
if (uname[0]) {
|
if (uname[0]) {
|
||||||
upstr(uname);
|
upstr(uname);
|
||||||
upstr(upasswd);
|
upstr(upasswd);
|
||||||
if ((result = do_object_login(uname, 0x1, upasswd, option)) < 0 && !*upasswd) {
|
if ((result = do_object_login(uname, 0x1, upasswd, option)) < 0 && !*upasswd) {
|
||||||
getstr("Password", upasswd, sizeof(upasswd)-1, 0);
|
getstr("Enter your password", upasswd, sizeof(upasswd)-1, 0);
|
||||||
upstr(upasswd);
|
upstr(upasswd);
|
||||||
result = do_object_login(uname, 0x1, upasswd, option);
|
result = do_object_login(uname, 0x1, upasswd, option);
|
||||||
}
|
}
|
||||||
@@ -156,10 +773,18 @@ int func_login(int argc, char *argv[], int mode)
|
|||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
if (result > -1) {
|
if (result > -1) {
|
||||||
char profile[200];
|
strmaxcpy(script_login_name, uname, sizeof(script_login_name) - 1);
|
||||||
|
|
||||||
|
if (get_fs_name(1, script_file_server))
|
||||||
|
strcpy(script_file_server, "MARS");
|
||||||
|
|
||||||
|
if (interactive_login)
|
||||||
|
fprintf(stdout, "You are attached to server %s.\n", script_file_server);
|
||||||
|
|
||||||
remove_nwpathes();
|
remove_nwpathes();
|
||||||
sprintf(profile, "%slogin", prgpath);
|
|
||||||
read_command_file(profile);
|
if (!no_script)
|
||||||
|
run_login_script();
|
||||||
} else {
|
} else {
|
||||||
(void)set_search_drive_vektor(save_drives);
|
(void)set_search_drive_vektor(save_drives);
|
||||||
}
|
}
|
||||||
@@ -294,36 +919,53 @@ int read_command_file(char *fstr)
|
|||||||
{
|
{
|
||||||
FILE *f=fopen(fstr, "r");
|
FILE *f=fopen(fstr, "r");
|
||||||
int result=-1;
|
int result=-1;
|
||||||
|
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
char *linebuf= xmalloc(512);
|
char *linebuf = xmalloc(512);
|
||||||
char *buf = xmalloc(512);
|
char *buf = xmalloc(512);
|
||||||
|
int stack[16];
|
||||||
|
int level = 0;
|
||||||
|
int active = 1;
|
||||||
|
|
||||||
while (get_line(f, buf, 512, linebuf, 512) > -1) {
|
while (get_line(f, buf, 512, linebuf, 512) > -1) {
|
||||||
char **argv=build_argv(buf, 512, linebuf);
|
char tmp[512];
|
||||||
if (argv != NULL) {
|
char *p;
|
||||||
int argc=0;
|
|
||||||
char **pp=argv;
|
strmaxcpy(tmp, linebuf, sizeof(tmp) - 1);
|
||||||
while (*pp) {
|
p = skip_spaces(tmp);
|
||||||
argc++;
|
upstr(p);
|
||||||
pp++;
|
|
||||||
|
if (!strncmp(p, "IF ", 3)) {
|
||||||
|
if (level < 16) {
|
||||||
|
stack[level++] = active;
|
||||||
|
active = active && script_eval_if(linebuf);
|
||||||
}
|
}
|
||||||
upstr(argv[0]);
|
|
||||||
if (argc > 2 && !strcmp(argv[0], "ECHO")) {
|
|
||||||
char *p=argv[argc-1];
|
|
||||||
while (p-- > argv[1]) {
|
|
||||||
if (*p=='\0') *p=32;
|
|
||||||
}
|
|
||||||
argc=2;
|
|
||||||
}
|
|
||||||
call_func_entry(argc, argv);
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(p, "END") || !strncmp(p, "END ", 4)) {
|
||||||
|
if (level > 0) active = stack[--level];
|
||||||
|
result = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
result = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (script_execute_line(linebuf))
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
xfree(linebuf);
|
xfree(linebuf);
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
} else result=-2;
|
} else result=-2;
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,9 +1034,9 @@ int func_exec(int argc, char *argv[], int mode)
|
|||||||
xfree(buff);
|
xfree(buff);
|
||||||
if (nargv != NULL) {
|
if (nargv != NULL) {
|
||||||
if (!mode)
|
if (!mode)
|
||||||
spawnvp(P_WAIT, buf, nargv);
|
spawnvp(P_WAIT, buf, (const char *const *)nargv);
|
||||||
else
|
else
|
||||||
execvp(buf, nargv);
|
execvp(buf, (const char *const *)nargv);
|
||||||
}
|
}
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
355
map.c
355
map.c
@@ -28,9 +28,9 @@ static void show_map(uint8 *drvstr)
|
|||||||
if (flags & 0x80) { /* lokal DRIVE */
|
if (flags & 0x80) { /* lokal DRIVE */
|
||||||
path[0]= '\\';
|
path[0]= '\\';
|
||||||
if (j < 2){
|
if (j < 2){
|
||||||
strcpy(path, "DISK LW");
|
strcpy(path, "maps to a local disk.");
|
||||||
} else if (getcurdir(j+1, path+1)) {
|
} else if (getcurdir(j+1, path+1)) {
|
||||||
strcpy(path, "LW !OK");
|
strcpy(path, "maps to a local disk.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_dir_path(dhandle, path)) {
|
if (get_dir_path(dhandle, path)) {
|
||||||
@@ -41,7 +41,7 @@ static void show_map(uint8 *drvstr)
|
|||||||
strcat(servern, "\\");
|
strcat(servern, "\\");
|
||||||
} else servern[0]='\0';
|
} else servern[0]='\0';
|
||||||
}
|
}
|
||||||
printf("MAP %c: = %s%s\n", (char)j+'A', servern, path);
|
if (flags & 0x80) printf("Drive %c: %s\n", (char)j+'A', path); else printf("Drive %c: = %s%s\n", (char)j+'A', servern, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,9 +58,9 @@ static void do_map(int drive, NWPATH *nwp)
|
|||||||
if (flags & 0x80) { /* lokal DRIVE */
|
if (flags & 0x80) { /* lokal DRIVE */
|
||||||
path[0]= '\\';
|
path[0]= '\\';
|
||||||
if (drive < 2){
|
if (drive < 2){
|
||||||
strcpy(path, "DISK LW");
|
strcpy(path, "maps to a local disk.");
|
||||||
} else if (getcurdir(drive+1, path+1)) {
|
} else if (getcurdir(drive+1, path+1)) {
|
||||||
strcpy(path, "LW !OK");
|
strcpy(path, "maps to a local disk.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_dir_path(dhandle, path)) {
|
if (get_dir_path(dhandle, path)) {
|
||||||
@@ -80,19 +80,41 @@ static void do_map(int drive, NWPATH *nwp)
|
|||||||
static int do_map(int drive, NWPATH *nwp, int delete)
|
static int do_map(int drive, NWPATH *nwp, int delete)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
if (drive > -1 && drive < 32) {
|
if (drive > -1 && drive < 32) {
|
||||||
uint8 connid;
|
uint8 connid = 0;
|
||||||
uint8 dhandle;
|
uint8 dhandle = 0;
|
||||||
uint8 flags;
|
uint8 flags = 0;
|
||||||
if (!delete ||
|
|
||||||
(!get_drive_info(drive, &connid, &dhandle, &flags) && flags && connid)){
|
if (delete) {
|
||||||
uint8 nmdrive[3];
|
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||||
nmdrive[0] = drive+'A';
|
&& flags && !(flags & 0x80) && connid) {
|
||||||
nmdrive[1] = ':';
|
result = dealloc_dir_handle(dhandle);
|
||||||
nmdrive[2] = '\0';
|
}
|
||||||
result = redir_device_drive(delete ? -1 : 0x4, nmdrive, nwp->path);
|
} else {
|
||||||
|
/*
|
||||||
|
* The old mars-dosutils MAP used DOS redirector INT 21h AX=5F03h.
|
||||||
|
* NetWare Client32 returns AX=0001 for that call, while Novell MAP
|
||||||
|
* works. Use the NetWare shell/NCP "Allocate Permanent Directory
|
||||||
|
* Handle" path instead; this is what the surrounding code already
|
||||||
|
* provides via alloc_permanent_dir_handle().
|
||||||
|
*/
|
||||||
|
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||||
|
&& flags && !(flags & 0x80) && connid) {
|
||||||
|
(void)dealloc_dir_handle(dhandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'A', NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some requesters historically accepted lowercase drive letters in
|
||||||
|
* this call. Keep this only as compatibility fallback.
|
||||||
|
*/
|
||||||
|
if (result < 0)
|
||||||
|
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'a', NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,18 +188,133 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int parse_pathins_arg(uint8 *drvstr, NWPATH *nwp,
|
||||||
|
int argc, char *argv[], int mode);
|
||||||
|
static int set_search_native(uint8 *drvstr, NWPATH *nwp, int pathmode);
|
||||||
|
static int show_search(uint8 *drvstr);
|
||||||
|
|
||||||
|
static int map_same_arg(char *a, char *b)
|
||||||
|
{
|
||||||
|
while (*a || *b) {
|
||||||
|
int ca = *a++;
|
||||||
|
int cb = *b++;
|
||||||
|
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||||
|
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||||
|
if (ca != cb) return(0);
|
||||||
|
}
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_is_drive_arg(char *s)
|
||||||
|
{
|
||||||
|
if (!s || !s[0] || s[1] != ':' || s[2]) return(0);
|
||||||
|
if (s[0] >= 'A' && s[0] <= 'Z') return(1);
|
||||||
|
if (s[0] >= 'a' && s[0] <= 'z') return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_drive_index(char *s)
|
||||||
|
{
|
||||||
|
if (s[0] >= 'a' && s[0] <= 'z') return(s[0] - 'a');
|
||||||
|
return(s[0] - 'A');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void map_drive_name(char *dst, char *src)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
if (dst[0] >= 'a' && dst[0] <= 'z') dst[0] -= 32;
|
||||||
|
dst[1] = ':';
|
||||||
|
dst[2] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_handle_path_command(int argc, char *argv[], int pathmode)
|
||||||
|
{
|
||||||
|
uint8 drvstr[22];
|
||||||
|
NWPATH nwpath;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = parse_pathins_arg(drvstr, &nwpath, argc, argv, pathmode);
|
||||||
|
if (!rc) {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (*(nwpath.path) || pathmode == 1)
|
||||||
|
result = set_search_native(drvstr, &nwpath, pathmode);
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
else if (pathmode != 1)
|
||||||
|
show_search(drvstr);
|
||||||
|
else
|
||||||
|
fprintf(stdout, "The search mapping for drive S%d: was deleted\n",
|
||||||
|
(int)drvstr[1]);
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int func_map(int argc, char *argv[], int mode)
|
int func_map(int argc, char *argv[], int mode)
|
||||||
{
|
{
|
||||||
uint8 drvstr[22];
|
uint8 drvstr[22];
|
||||||
NWPATH nwpath;
|
NWPATH nwpath;
|
||||||
|
|
||||||
if (!ipx_init()) argc = 1;
|
if (!ipx_init()) argc = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell MAP accepts subcommands through MAP itself:
|
||||||
|
* MAP DEL H:
|
||||||
|
* MAP INS S1:=SYS:PUBLIC
|
||||||
|
* MAP DEL S1:
|
||||||
|
* The original mars-dosutils exposed those mainly as MAPDEL/PATHINS/PATHDEL,
|
||||||
|
* so handle the Novell syntax here and then reuse the existing primitives.
|
||||||
|
*/
|
||||||
|
if (argc > 1) {
|
||||||
|
if (map_same_arg(argv[1], "/?") || map_same_arg(argv[1], "-?") ||
|
||||||
|
map_same_arg(argv[1], "?")) {
|
||||||
|
fprintf(stderr, "Directory \"/?\" is not locatable.\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_same_arg(argv[1], "INS") || map_same_arg(argv[1], "INSERT")) {
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(map_handle_path_command(argc - 1, argv + 1, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_same_arg(argv[1], "DEL") || map_same_arg(argv[1], "DELETE")) {
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_is_drive_arg(argv[2])) {
|
||||||
|
char dname[3];
|
||||||
|
int drive = map_drive_index(argv[2]);
|
||||||
|
|
||||||
|
if (do_map(drive, &nwpath, 1) < 0) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
map_drive_name(dname, argv[2]);
|
||||||
|
fprintf(stdout, "The mapping for drive %s has been deleted.\n", dname);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(map_handle_path_command(argc - 1, argv + 1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||||
if (*(nwpath.path) || mode==1) {
|
if (*(nwpath.path) || mode==1) {
|
||||||
{
|
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||||
int rc = do_map(*drvstr - 'A', &nwpath, mode);
|
fprintf(stderr, "MAP Error\n");
|
||||||
if (rc < 0)
|
|
||||||
fprintf(stderr, "MAP Error rc=%d\n", rc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mode != 1)
|
if (mode != 1)
|
||||||
show_map(drvstr);
|
show_map(drvstr);
|
||||||
@@ -278,18 +415,192 @@ static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int path_is_drive_path(uint8 *path)
|
||||||
|
{
|
||||||
|
if (!path || !path[0] || path[1] != ':') return(0);
|
||||||
|
if (path[0] >= 'A' && path[0] <= 'Z') return(1);
|
||||||
|
if (path[0] >= 'a' && path[0] <= 'z') return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void upstr_local(uint8 *s)
|
||||||
|
{
|
||||||
|
while (*s) {
|
||||||
|
if (*s >= 'a' && *s <= 'z') *s -= 0x20;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_pathins_arg(uint8 *drvstr, NWPATH *nwp, int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
char joined[512];
|
||||||
|
char *p;
|
||||||
|
char *q;
|
||||||
|
int slot = 0;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
*drvstr = '\0';
|
||||||
|
memset(nwp, 0, sizeof(NWPATH));
|
||||||
|
nwp->path = nwp->buff;
|
||||||
|
*(nwp->buff) = '\0';
|
||||||
|
|
||||||
|
if (argc < 2) return(1);
|
||||||
|
|
||||||
|
joined[0] = '\0';
|
||||||
|
for (k = 1; k < argc; k++) {
|
||||||
|
if (k > 1) strcat(joined, " ");
|
||||||
|
strncat(joined, argv[k], sizeof(joined) - strlen(joined) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = joined;
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (*p != 'S' && *p != 's') return(-1);
|
||||||
|
p++;
|
||||||
|
|
||||||
|
while (*p >= '0' && *p <= '9') {
|
||||||
|
slot = slot * 10 + (*p - '0');
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot < 1 || slot > 16) return(-1);
|
||||||
|
if (*p != ':') return(-1);
|
||||||
|
p++;
|
||||||
|
|
||||||
|
drvstr[0] = 's';
|
||||||
|
drvstr[1] = (uint8)slot;
|
||||||
|
drvstr[2] = '\0';
|
||||||
|
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (mode == 1) {
|
||||||
|
/* PATHDEL S1: */
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p == '=') p++;
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (!*p) return(-1);
|
||||||
|
|
||||||
|
q = nwp->buff;
|
||||||
|
while (*p && (q - nwp->buff) < (int)sizeof(nwp->buff) - 1) {
|
||||||
|
*q++ = *p++;
|
||||||
|
}
|
||||||
|
*q = '\0';
|
||||||
|
|
||||||
|
upstr_local(nwp->buff);
|
||||||
|
nwp->path = nwp->buff;
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_search_native(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
||||||
|
{
|
||||||
|
int result=-1;
|
||||||
|
SEARCH_VECTOR drives;
|
||||||
|
SEARCH_VECTOR_ENTRY *p=drives;
|
||||||
|
int j=0;
|
||||||
|
int entry = (*drvstr=='s') ? *(drvstr+1) : 0;
|
||||||
|
|
||||||
|
get_search_drive_vektor(drives);
|
||||||
|
|
||||||
|
while (p->drivenummer != 0xff && j++ < 16) {
|
||||||
|
if (!entry && path_is_drive_path(nwp->path)
|
||||||
|
&& (p->drivenummer + 'A' == nwp->path[0])) entry=j;
|
||||||
|
|
||||||
|
if (path_is_drive_path(nwp->path)
|
||||||
|
&& p->drivenummer + 'A' == nwp->path[0]
|
||||||
|
&& !strcmp(nwp->path+2, p->dospath)) {
|
||||||
|
p->drivenummer=0xfe;
|
||||||
|
*(p->dospath) = '\0';
|
||||||
|
p->flags = 0;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry > 0) {
|
||||||
|
if (entry > 16) entry = 16;
|
||||||
|
|
||||||
|
if (pathmode == 2 && entry <= j && entry < 16) { /* insert modus */
|
||||||
|
int k=j+1-entry;
|
||||||
|
if (j < 16) {
|
||||||
|
p++;
|
||||||
|
k++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
while (k--) {
|
||||||
|
memcpy(p, p-1, sizeof(SEARCH_VECTOR_ENTRY));
|
||||||
|
--p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--entry < j)
|
||||||
|
p = drives+entry;
|
||||||
|
else
|
||||||
|
(p+1)->drivenummer = 0xff;
|
||||||
|
|
||||||
|
memset(p, 0, sizeof(SEARCH_VECTOR_ENTRY));
|
||||||
|
|
||||||
|
if (pathmode==1) {
|
||||||
|
p->drivenummer = 0xfe;
|
||||||
|
*(p->dospath) = '\0';
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
} else if (path_is_drive_path(nwp->path)) {
|
||||||
|
p->flags = 0;
|
||||||
|
p->drivenummer = (uint8)(nwp->path[0] - 'A');
|
||||||
|
if (nwp->path[0] >= 'a' && nwp->path[0] <= 'z')
|
||||||
|
p->drivenummer = (uint8)(nwp->path[0] - 'a');
|
||||||
|
strmaxcpy(p->dospath, nwp->path+2, sizeof(p->dospath)-1);
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Search path entries are not drive mappings. The original code stores
|
||||||
|
* the NetWare path text directly in dospath with drivenummer=0xfe.
|
||||||
|
* Client32 keeps/prints these entries correctly; allocating a permanent
|
||||||
|
* directory handle here made set_search_drive_vektor() return success,
|
||||||
|
* but the entry did not actually replace SEARCH1.
|
||||||
|
*/
|
||||||
|
p->flags = 0;
|
||||||
|
p->drivenummer = 0xfe;
|
||||||
|
strmaxcpy(p->dospath, nwp->path, sizeof(p->dospath)-1);
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int func_path(int argc, char *argv[], int mode)
|
int func_path(int argc, char *argv[], int mode)
|
||||||
{
|
{
|
||||||
uint8 drvstr[22];
|
uint8 drvstr[22];
|
||||||
NWPATH nwpath;
|
NWPATH nwpath;
|
||||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1, mode)) {
|
int rc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PATH/PATHINS/PATHDEL need their own parser. The old parse_argv()
|
||||||
|
* rejects common login-script syntax such as:
|
||||||
|
* PATHINS S1:=SYS:PUBLIC
|
||||||
|
* MAP INS S1:=SYS:PUBLIC
|
||||||
|
*/
|
||||||
|
if (argc < 2) {
|
||||||
|
show_search("");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = parse_pathins_arg(drvstr, &nwpath, argc, argv, mode);
|
||||||
|
if (!rc) {
|
||||||
int result=0;
|
int result=0;
|
||||||
if (*(nwpath.path) || mode==1)
|
if (*(nwpath.path) || mode==1)
|
||||||
result=set_search(drvstr, &nwpath, mode);
|
result=set_search_native(drvstr, &nwpath, mode);
|
||||||
if (mode != 1)
|
if (mode != 1)
|
||||||
show_search(drvstr);
|
show_search(drvstr);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
103
ncpcall.c
103
ncpcall.c
@@ -283,3 +283,106 @@ int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
|
|||||||
if (neterrno) return(-1);
|
if (neterrno) return(-1);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
||||||
|
BINDERY_OBJECT *target)
|
||||||
|
/* scan bindery object */
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 func;
|
||||||
|
uint8 last_id[4];
|
||||||
|
uint8 typ[2];
|
||||||
|
uint8 patlen;
|
||||||
|
uint8 pattern[48];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 object_id[4];
|
||||||
|
uint8 object_type[2];
|
||||||
|
uint8 object_name[48];
|
||||||
|
uint8 object_flags;
|
||||||
|
uint8 object_security;
|
||||||
|
uint8 object_has_prop;
|
||||||
|
} repl;
|
||||||
|
int patlen = (pattern) ? min(48, strlen(pattern)) : 1;
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
req.func = 0x37;
|
||||||
|
U32_TO_BE32(last_id, req.last_id);
|
||||||
|
U16_TO_BE16(objtyp, req.typ);
|
||||||
|
req.patlen = (uint8)patlen;
|
||||||
|
if (pattern) memcpy(req.pattern, pattern, patlen);
|
||||||
|
else req.pattern[0] = '*';
|
||||||
|
req.len = 8 + patlen;
|
||||||
|
|
||||||
|
repl.len = sizeof(repl) - sizeof(uint16);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xE300, &req, &repl);
|
||||||
|
if (neterrno) return(-1);
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
target->object_id = GET_BE32(repl.object_id);
|
||||||
|
target->object_type = GET_BE16(repl.object_type);
|
||||||
|
memcpy(target->object_name, repl.object_name, 48);
|
||||||
|
target->object_name[48] = '\0';
|
||||||
|
deb(target->object_name);
|
||||||
|
target->object_flags = repl.object_flags;
|
||||||
|
target->object_security = repl.object_security;
|
||||||
|
target->object_has_prop = repl.object_has_prop;
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
|
||||||
|
uint8 *propname, NW_PROPERTY *target)
|
||||||
|
/* read bindery property value */
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 func;
|
||||||
|
uint8 typ[2];
|
||||||
|
uint8 buff[1+48+1+1+16];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 value[128];
|
||||||
|
uint8 more_flag;
|
||||||
|
uint8 property_flag;
|
||||||
|
} repl;
|
||||||
|
uint8 *p = req.buff;
|
||||||
|
int objlen = min(48, strlen(objname));
|
||||||
|
int proplen = min(16, strlen(propname));
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
req.func = 0x3d;
|
||||||
|
U16_TO_BE16(objtyp, req.typ);
|
||||||
|
|
||||||
|
*p++ = (uint8)objlen;
|
||||||
|
memcpy(p, objname, objlen);
|
||||||
|
p += objlen;
|
||||||
|
|
||||||
|
*p++ = (uint8)segment;
|
||||||
|
|
||||||
|
*p++ = (uint8)proplen;
|
||||||
|
memcpy(p, propname, proplen);
|
||||||
|
|
||||||
|
req.len = 6 + objlen + proplen;
|
||||||
|
repl.len = sizeof(repl) - sizeof(uint16);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xE300, &req, &repl);
|
||||||
|
if (neterrno) return(-1);
|
||||||
|
|
||||||
|
if (target) {
|
||||||
|
memcpy(target->value, repl.value, 128);
|
||||||
|
target->more_flag = repl.more_flag;
|
||||||
|
target->property_flag = repl.property_flag;
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
3
net.c
3
net.c
@@ -34,9 +34,8 @@ static struct s_net_functions {
|
|||||||
{"PATHDEL","removes search path" , func_path , 1},
|
{"PATHDEL","removes search path" , func_path , 1},
|
||||||
{"PATHINS","insert search path" , func_path , 2},
|
{"PATHINS","insert search path" , func_path , 2},
|
||||||
{"LOGOUT", "logout from server", func_logout , 0},
|
{"LOGOUT", "logout from server", func_logout , 0},
|
||||||
#if 0
|
{"FLAG", "display or modify file attributes", func_flag , 0},
|
||||||
{"SLIST", "list servers", func_slist , 0},
|
{"SLIST", "list servers", func_slist , 0},
|
||||||
#endif
|
|
||||||
{"PASSWD", "change password", func_passwd , 0},
|
{"PASSWD", "change password", func_passwd , 0},
|
||||||
#if 1
|
#if 1
|
||||||
{"TESTS", "only testroutines!", func_tests , 0},
|
{"TESTS", "only testroutines!", func_tests , 0},
|
||||||
|
|||||||
27
net.h
27
net.h
@@ -58,7 +58,7 @@ typedef struct {
|
|||||||
uint16 fragment_count; /* Anzahl Fragment Buffers */
|
uint16 fragment_count; /* Anzahl Fragment Buffers */
|
||||||
uint8 *fragment_1;
|
uint8 *fragment_1;
|
||||||
uint16 fragment_1_size;
|
uint16 fragment_1_size;
|
||||||
/* K”nnen auch mehr sein */
|
/* K<EFBFBD>nnen auch mehr sein */
|
||||||
} ECB;
|
} ECB;
|
||||||
|
|
||||||
#include "kern.h"
|
#include "kern.h"
|
||||||
@@ -106,6 +106,24 @@ typedef struct {
|
|||||||
#define NWCLIENT 4
|
#define NWCLIENT 4
|
||||||
#define NWBIND 5
|
#define NWBIND 5
|
||||||
|
|
||||||
|
#define NCP_BINDERY_FSERVER 0x0004
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32 object_id;
|
||||||
|
uint16 object_type;
|
||||||
|
uint8 object_name[49];
|
||||||
|
uint8 object_flags;
|
||||||
|
uint8 object_security;
|
||||||
|
uint8 object_has_prop;
|
||||||
|
} BINDERY_OBJECT;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8 value[128];
|
||||||
|
uint8 more_flag;
|
||||||
|
uint8 property_flag;
|
||||||
|
} NW_PROPERTY;
|
||||||
|
|
||||||
|
|
||||||
/* net.c */
|
/* net.c */
|
||||||
extern char *funcname;
|
extern char *funcname;
|
||||||
extern char prgpath[];
|
extern char prgpath[];
|
||||||
@@ -234,5 +252,12 @@ extern int func_tests (int argc, char *argv[], int mode);
|
|||||||
/* capture.c */
|
/* capture.c */
|
||||||
extern int func_capture(int argc, char *argv[], int mode);
|
extern int func_capture(int argc, char *argv[], int mode);
|
||||||
|
|
||||||
|
/* flag.c */
|
||||||
|
extern int func_flag (int argc, char *argv[], int mode);
|
||||||
|
|
||||||
|
|
||||||
|
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
||||||
|
BINDERY_OBJECT *target);
|
||||||
|
extern int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
|
||||||
|
uint8 *propname, NW_PROPERTY *target);
|
||||||
|
|
||||||
|
|||||||
25
netcall.c
25
netcall.c
@@ -54,38 +54,24 @@ int redir_device_drive(int devicetyp, uint8 *devname, uint8 *remotename)
|
|||||||
{
|
{
|
||||||
REGS regs;
|
REGS regs;
|
||||||
SREGS sregs;
|
SREGS sregs;
|
||||||
|
int result;
|
||||||
uint8 buff1[16];
|
uint8 buff1[16];
|
||||||
uint8 buff2[128];
|
uint8 buff2[128];
|
||||||
uint8 *ldevname = buff1;
|
uint8 *ldevname = buff1;
|
||||||
uint8 *lremotename = buff2;
|
uint8 *lremotename = buff2;
|
||||||
|
strncpy(ldevname, devname, 16);
|
||||||
memset(®s, 0, sizeof(regs));
|
|
||||||
memset(&sregs, 0, sizeof(sregs));
|
|
||||||
memset(buff1, 0, sizeof(buff1));
|
|
||||||
memset(buff2, 0, sizeof(buff2));
|
|
||||||
|
|
||||||
strmaxcpy(ldevname, devname, sizeof(buff1) - 1);
|
|
||||||
|
|
||||||
regs.x.ax = (devicetyp == -1) ? 0x5f04 : 0x5f03;
|
regs.x.ax = (devicetyp == -1) ? 0x5f04 : 0x5f03;
|
||||||
regs.h.bl = (uint8)devicetyp;
|
regs.h.bl = (uint8)devicetyp;
|
||||||
regs.x.cx = 0x574e; /* user sign 'NW' */
|
regs.x.cx = 0x574e; /* user sign 'NW' */
|
||||||
sregs.ds = FP_SEG(ldevname);
|
sregs.ds = FP_SEG(ldevname);
|
||||||
regs.x.si = FP_OFF(ldevname);
|
regs.x.si = FP_OFF(ldevname);
|
||||||
|
|
||||||
if (devicetyp > -1) {
|
if (devicetyp > -1) {
|
||||||
strmaxcpy(lremotename, remotename, sizeof(buff2) - 1);
|
strncpy(lremotename, remotename, 128);
|
||||||
sregs.es = FP_SEG(lremotename);
|
sregs.es = FP_SEG(lremotename);
|
||||||
regs.x.di = FP_OFF(lremotename);
|
regs.x.di = FP_OFF(lremotename);
|
||||||
}
|
}
|
||||||
|
result = intdosx(®s, ®s, &sregs);
|
||||||
intdosx(®s, ®s, &sregs);
|
return(regs.x.cflag ? -result : 0);
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the actual DOS/redirector error code from AX when carry is set.
|
|
||||||
* The old code returned the intdosx() function result. With OpenWatcom
|
|
||||||
* this can hide which redirector error happened.
|
|
||||||
*/
|
|
||||||
return(regs.x.cflag ? -(int)regs.x.ax : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int list_redir(int index, int *devicetyp, uint8 *devname, uint8 *remotename)
|
int list_redir(int index, int *devicetyp, uint8 *devname, uint8 *remotename)
|
||||||
@@ -255,7 +241,6 @@ int alloc_dir_handle(int func,
|
|||||||
printf("alloc_dir_handle, path=%s, len=%d, disk=%c\n", path, pathlen, driveletter);
|
printf("alloc_dir_handle, path=%s, len=%d, disk=%c\n", path, pathlen, driveletter);
|
||||||
*/
|
*/
|
||||||
neterrno = Net_Call(0xE200, &req, &repl);
|
neterrno = Net_Call(0xE200, &req, &repl);
|
||||||
fprintf(stderr, "neterrno=%d\n", neterrno);
|
|
||||||
if (neterrno && neterrno != 0xff) return(-1);
|
if (neterrno && neterrno != 0xff) return(-1);
|
||||||
|
|
||||||
if (effrights) *effrights = repl.effrights;
|
if (effrights) *effrights = repl.effrights;
|
||||||
|
|||||||
113
nwcrypt.c
113
nwcrypt.c
@@ -118,6 +118,7 @@ static buf32 encryptkeys =
|
|||||||
0x6B,0x0F,0xD5,0x70,0xAE,0xFB,0xAD,0x11,
|
0x6B,0x0F,0xD5,0x70,0xAE,0xFB,0xAD,0x11,
|
||||||
0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0};
|
0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0};
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "nwcrypt.h"
|
#include "nwcrypt.h"
|
||||||
static void
|
static void
|
||||||
shuffle1(buf32 temp, unsigned char *target)
|
shuffle1(buf32 temp, unsigned char *target)
|
||||||
@@ -210,4 +211,116 @@ nw_encrypt(unsigned char *fra,unsigned char *buf,unsigned char *til)
|
|||||||
til[s] = k[s] ^ k[15 - s];
|
til[s] = k[s] ^ k[15 - s];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned char
|
||||||
|
newshuffle[256] =
|
||||||
|
{
|
||||||
|
0x0f, 0x08, 0x05, 0x07, 0x0c, 0x02, 0x0e, 0x09,
|
||||||
|
0x00, 0x01, 0x06, 0x0d, 0x03, 0x04, 0x0b, 0x0a,
|
||||||
|
0x02, 0x0c, 0x0e, 0x06, 0x0f, 0x00, 0x01, 0x08,
|
||||||
|
0x0d, 0x03, 0x0a, 0x04, 0x09, 0x0b, 0x05, 0x07,
|
||||||
|
|
||||||
|
0x05, 0x02, 0x09, 0x0f, 0x0c, 0x04, 0x0d, 0x00,
|
||||||
|
0x0e, 0x0a, 0x06, 0x08, 0x0b, 0x01, 0x03, 0x07,
|
||||||
|
0x0f, 0x0d, 0x02, 0x06, 0x07, 0x08, 0x05, 0x09,
|
||||||
|
0x00, 0x04, 0x0c, 0x03, 0x01, 0x0a, 0x0b, 0x0e,
|
||||||
|
|
||||||
|
0x05, 0x0e, 0x02, 0x0b, 0x0d, 0x0a, 0x07, 0x00,
|
||||||
|
0x08, 0x06, 0x04, 0x01, 0x0f, 0x0c, 0x03, 0x09,
|
||||||
|
0x08, 0x02, 0x0f, 0x0a, 0x05, 0x09, 0x06, 0x0c,
|
||||||
|
0x00, 0x0b, 0x01, 0x0d, 0x07, 0x03, 0x04, 0x0e,
|
||||||
|
|
||||||
|
0x0e, 0x08, 0x00, 0x09, 0x04, 0x0b, 0x02, 0x07,
|
||||||
|
0x0c, 0x03, 0x0a, 0x05, 0x0d, 0x01, 0x06, 0x0f,
|
||||||
|
0x01, 0x04, 0x08, 0x0a, 0x0d, 0x0b, 0x07, 0x0e,
|
||||||
|
0x05, 0x0f, 0x03, 0x09, 0x00, 0x02, 0x06, 0x0c,
|
||||||
|
|
||||||
|
0x05, 0x03, 0x0c, 0x08, 0x0b, 0x02, 0x0e, 0x0a,
|
||||||
|
0x04, 0x01, 0x0d, 0x00, 0x06, 0x07, 0x0f, 0x09,
|
||||||
|
0x06, 0x00, 0x0b, 0x0e, 0x0d, 0x04, 0x0c, 0x0f,
|
||||||
|
0x07, 0x02, 0x08, 0x0a, 0x01, 0x05, 0x03, 0x09,
|
||||||
|
|
||||||
|
0x0b, 0x05, 0x0a, 0x0e, 0x0f, 0x01, 0x0c, 0x00,
|
||||||
|
0x06, 0x04, 0x02, 0x09, 0x03, 0x0d, 0x07, 0x08,
|
||||||
|
0x07, 0x02, 0x0a, 0x00, 0x0e, 0x08, 0x0f, 0x04,
|
||||||
|
0x0c, 0x0b, 0x09, 0x01, 0x05, 0x0d, 0x03, 0x06,
|
||||||
|
|
||||||
|
0x07, 0x04, 0x0f, 0x09, 0x05, 0x01, 0x0c, 0x0b,
|
||||||
|
0x00, 0x03, 0x08, 0x0e, 0x02, 0x0a, 0x06, 0x0d,
|
||||||
|
0x09, 0x04, 0x08, 0x00, 0x0a, 0x03, 0x01, 0x0c,
|
||||||
|
0x05, 0x0f, 0x07, 0x02, 0x0b, 0x0e, 0x06, 0x0d,
|
||||||
|
|
||||||
|
0x09, 0x05, 0x04, 0x07, 0x0e, 0x08, 0x03, 0x01,
|
||||||
|
0x0d, 0x0b, 0x0c, 0x02, 0x00, 0x0f, 0x06, 0x0a,
|
||||||
|
0x09, 0x0a, 0x0b, 0x0d, 0x05, 0x03, 0x0f, 0x00,
|
||||||
|
0x01, 0x0c, 0x08, 0x07, 0x06, 0x04, 0x0e, 0x02,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char final_shuffle[16] = {
|
||||||
|
0x03, 0x0e, 0x0f, 0x02, 0x0d, 0x0c, 0x04, 0x05,
|
||||||
|
0x09, 0x06, 0x00, 0x01, 0x0b, 0x07, 0x0a, 0x08,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* verschluesseln des neuen Passworts fuer keyed change password
|
||||||
|
* Verwendung:
|
||||||
|
* - Shuffle (aus nwcrypt.c) altes passwort nach old (16 bytes)
|
||||||
|
* - shuffle neues passwort nach new (16 bytes)
|
||||||
|
* - nwpassencrypt (diese Funktion) zweimal aufrufen fuer je 8 bytes:
|
||||||
|
* nwpassencrypt(old+0, new+0, out+0)
|
||||||
|
* nwpassencrypt(old+8, new+8, out+8)
|
||||||
|
* - NCP-Buffer aufbauen:
|
||||||
|
* 2 byte Laenge im Hi-Lo-Format
|
||||||
|
* 1 byte Funktion (0x4b)
|
||||||
|
* 8 byte (nwcrypt Ergebnis analog login/verify password)
|
||||||
|
* 2 byte Objecttype
|
||||||
|
* 1 byte Objectname-Laenge
|
||||||
|
* n byte Objectname
|
||||||
|
* 1 byte (Laenge des eingegebenen neuen Passworts ^ old[0] ^ old[1])&0x7f|0x40
|
||||||
|
* 16 byte (Ergebnis dieser Funktion doppelt aufgerufen, s.o.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encrypt the new password for keyed change password
|
||||||
|
* For info on how to use this function, look at ncp_change_login_passwd
|
||||||
|
* in ncplib.c.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
newpassencrypt(unsigned char *old, unsigned char *npwd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
int di, ax;
|
||||||
|
unsigned char *p, *bx;
|
||||||
|
unsigned char cl, dl, ch;
|
||||||
|
unsigned char copy[8];
|
||||||
|
|
||||||
|
memcpy(copy, npwd, 8);
|
||||||
|
for (di = 0, ax = 0, p = old; di < 8; di++, ax += 0x20, p++)
|
||||||
|
{
|
||||||
|
cl = newshuffle[(((copy[di] ^ *p) >> 4) & 0x0f) + ax + 0x10] << 4;
|
||||||
|
dl = newshuffle[((copy[di] ^ *p) & 0xf) + ax];
|
||||||
|
copy[di] = cl | dl;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = old[7];
|
||||||
|
for (bx = old + 7; bx > old; bx--)
|
||||||
|
{
|
||||||
|
*bx = ((bx[-1] >> 4) & 0x0f) | ((*bx) << 4);
|
||||||
|
}
|
||||||
|
*old = ((ch >> 4) & 0x0f) | (*old) << 4;
|
||||||
|
|
||||||
|
memset(npwd, 0, 8);
|
||||||
|
|
||||||
|
for (di = 0; di < 16; di++)
|
||||||
|
{
|
||||||
|
if (final_shuffle[di] & 1)
|
||||||
|
ch = ((copy[final_shuffle[di] / 2] >> 4) & 0x0f);
|
||||||
|
else
|
||||||
|
ch = copy[final_shuffle[di] / 2] & 0x0f;
|
||||||
|
npwd[di / 2] |= ((di & 1) ? ch << 4 : ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ extern void shuffle(unsigned char *lon,
|
|||||||
|
|
||||||
extern void nw_encrypt(unsigned char *fra,
|
extern void nw_encrypt(unsigned char *fra,
|
||||||
unsigned char *buf,unsigned char *til);
|
unsigned char *buf,unsigned char *til);
|
||||||
|
|
||||||
|
extern void newpassencrypt(unsigned char *old, unsigned char *npwd);
|
||||||
|
|||||||
106
slist.c
106
slist.c
@@ -1,15 +1,111 @@
|
|||||||
/* map.c 12-Jan-96 */
|
/* slist.c - list known NetWare file servers, DOS mars-dosutils version */
|
||||||
|
|
||||||
/****************************************************************
|
|
||||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
|
||||||
****************************************************************/
|
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
|
#define NCP_BINDERY_FSERVER 0x0004
|
||||||
|
|
||||||
|
static int usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "Usage: SLIST [Server] [/Continue]\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int same_arg(char *a, char *b)
|
||||||
|
{
|
||||||
|
while (*a || *b) {
|
||||||
|
int ca = *a++;
|
||||||
|
int cb = *b++;
|
||||||
|
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||||
|
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||||
|
if (ca != cb) return(0);
|
||||||
|
}
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_help_arg(char *s)
|
||||||
|
{
|
||||||
|
if (!s) return(0);
|
||||||
|
return(same_arg(s, "/?") || same_arg(s, "-?") || same_arg(s, "?"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long node_to_number(uint8 *addr)
|
||||||
|
{
|
||||||
|
unsigned long n = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 4; i < 10; i++)
|
||||||
|
n = (n << 8) + addr[i];
|
||||||
|
|
||||||
|
return(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_net_node_status(uint8 *addr, int is_default)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "[%08lX][%12lu]%s",
|
||||||
|
(unsigned long)GET_BE32(addr),
|
||||||
|
node_to_number(addr),
|
||||||
|
is_default ? "Default" : "");
|
||||||
|
}
|
||||||
|
|
||||||
int func_slist(int argc, char *argv[], int mode)
|
int func_slist(int argc, char *argv[], int mode)
|
||||||
{
|
{
|
||||||
|
BINDERY_OBJECT obj;
|
||||||
|
uint32 last_id = MAX_U32;
|
||||||
|
uint8 pattern[50];
|
||||||
|
int found = 0;
|
||||||
|
int result;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
(void)mode;
|
||||||
|
|
||||||
|
strcpy(pattern, "*");
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (is_help_arg(argv[i])) return(usage());
|
||||||
|
|
||||||
|
if (argv[i][0] == '/' || argv[i][0] == '-') {
|
||||||
|
if (same_arg(argv[i], "/C") || same_arg(argv[i], "/CONTINUE") ||
|
||||||
|
same_arg(argv[i], "-C") || same_arg(argv[i], "-CONTINUE")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return(usage());
|
||||||
|
}
|
||||||
|
|
||||||
|
strmaxcpy(pattern, argv[i], sizeof(pattern) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
upstr(pattern);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell-like layout from the DOS client:
|
||||||
|
* Known NetWare File Servers Network Node Address Status
|
||||||
|
* ------------------------- -------- -------------------
|
||||||
|
*/
|
||||||
|
fprintf(stdout, "%-44sNetwork Node Address Status\n",
|
||||||
|
"Known NetWare File Servers");
|
||||||
|
fprintf(stdout, "%-44s------- ----------- ------\n",
|
||||||
|
"--------------------------");
|
||||||
|
|
||||||
|
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
|
||||||
|
pattern, &obj)) == 0) {
|
||||||
|
NW_PROPERTY prop;
|
||||||
|
|
||||||
|
found++;
|
||||||
|
last_id = obj.object_id;
|
||||||
|
|
||||||
|
fprintf(stdout, "%-44s", obj.object_name);
|
||||||
|
|
||||||
|
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
|
||||||
|
1, "NET_ADDRESS", &prop)) {
|
||||||
|
print_net_node_status(prop.value, found == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
if (last_id == MAX_U32) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "\nTotal of %d file servers found\n", found);
|
||||||
|
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user