1
0
mirror of https://github.com/deadw00d/AROS.git synced 2025-12-06 13:11:35 +00:00

# add AROS debug # add the local __assert implementation, matching its expected prototype. # determine the used database files on server startup, from the SYS/userdb and SYS/groupdb env variables.

This commit is contained in:
Kalamatee
2025-10-06 13:14:30 +01:00
committed by deadwood
parent 5eebe3ad2c
commit bfc524197f
10 changed files with 136 additions and 23 deletions

View File

@ -0,0 +1,28 @@
#include <proto/intuition.h>
#include <clib/alib_protos.h>
#if defined(LC_LIBDEFS_FILE)
#include LC_LIBDEFS_FILE
#endif
void __assert(CONST char *expr, CONST char *file, unsigned int line)
{
struct EasyStruct libraryES;
struct {
const char *assertion;
ULONG lno;
const char *fnam;
} arArgs = {
.assertion = expr,
.lno = line,
.fnam = file
};
libraryES.es_StructSize = sizeof(libraryES);
libraryES.es_Flags = 0;
libraryES.es_Title = (STRPTR)MOD_NAME_STRING;
libraryES.es_TextFormat =
"Assertion \"%s\" failed at line %lu in file %s.";
libraryES.es_GadgetFormat = "Continue";
EasyRequestArgs(NULL, &libraryES, NULL, (RAWARG)&arArgs);
}

View File

@ -12,11 +12,13 @@ static inline void __inline_InMsg(struct IntuitionBase *IntuitionBase, CONST_STR
{
AROS_SLOWSTACKFORMAT_PRE(__arg1);
struct EasyStruct libraryES;
libraryES.es_StructSize = sizeof(libraryES);
libraryES.es_Flags = 0;
libraryES.es_Title = (STRPTR)MOD_NAME_STRING;
libraryES.es_TextFormat = (STRPTR)__arg1;
libraryES.es_GadgetFormat = "Continue";
EasyRequestArgs(NULL, &libraryES, NULL, AROS_SLOWSTACKFORMAT_ARG(__arg1));
AROS_SLOWSTACKFORMAT_POST(__arg1);
}

View File

@ -74,6 +74,8 @@ struct NetInfoDevice {
struct MsgPort nid_NotifyPort[1]; /* Port for notify messages */
struct List nid_Instances[1];
struct NetInfoMap *nid_Maps[NETINFO_UNITS];
char *nid_dbuser;
char *nid_dbgroup;
};
#define nid_Task nid_Port->mp_SigTask

View File

@ -11,8 +11,13 @@
#include <proto/dos.h>
#include "entries.h"
#include <string.h>
#if defined(DEBUG)
#include <assert.h>
#include "assert.h"
#endif
static struct NetInfoPointer *FindPointer(struct List *list, struct Ent*to);
void GetByNameCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInfoMap *nim);

View File

@ -60,12 +60,6 @@ struct GroupEnt {
*/
#define MAXLINELENGTH 1024
/*
* Datastruct NetInfoDevice * paths
*/
#define _PATH_PASSWD "AmiTCP:db/passwd"
#define _PATH_GROUP "AmiTCP:db/group"
/*
* As this far there are no quick commands
* we bother to lock only niu_ReqLock

View File

@ -7,12 +7,18 @@
* Helsinki University of Technology, Finland.
*/
#include <aros/debug.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "entries.h"
#include <assert.h>
#include <string.h>
#if defined(DEBUG)
#include <assert.h>
#include "assert.h"
#endif
static void *CopyEntToGroup(struct NetInfoReq *req, struct Ent *e);
static struct Ent *CopyGroupToEnt(struct NetInfoDevice *nid, struct NetInfoReq *req);
@ -38,14 +44,18 @@ const static struct MapMethods group_methods[1] = {
*/
struct NetInfoMap *InitGroupMap(struct NetInfoDevice *nid)
{
struct NetInfoMap *nim = AllocVec(sizeof(*nim), MEMF_CLEAR|MEMF_PUBLIC);
struct NetInfoMap *nim = NULL;
D(bug("[NetInfo] %s()\n", __func__));
if (nid->nid_dbgroup) {
nim = AllocVec(sizeof(*nim), MEMF_CLEAR|MEMF_PUBLIC);
if (nim) {
nim->nim_Methods = group_methods;
nim->nim_Name = "group";
nim->nim_Filename = _PATH_GROUP;
nim->nim_Filename = nid->nid_dbgroup;
}
}
return nim;
}
@ -64,6 +74,8 @@ static void *CopyEntToGroup(struct NetInfoReq *req, struct Ent *e)
UBYTE **mfrom;
D(bug("[NetInfo] %s()\n", __func__));
req->io_Actual = actual;
if (size < actual) {
@ -100,6 +112,8 @@ static struct Ent *CopyGroupToEnt(struct NetInfoDevice *nid, struct NetInfoReq *
short nmem = 1;
ULONG txtlen = 0;
D(bug("[NetInfo] %s()\n", __func__));
/*
* These cause EFAULT
*/
@ -203,6 +217,8 @@ static struct Ent *ParseGroup(struct NetInfoDevice *nid, register UBYTE *p)
struct GroupEnt *ge;
D(bug("[NetInfo] %s()\n", __func__));
np = p;
name = strsep((char **)&np, "|\n");
@ -274,6 +290,8 @@ static int PrintGroup(struct NetInfoDevice *nid, BPTR file, struct Ent *e)
UBYTE **member = ge->ge_group->gr_mem;
UBYTE *fmt = "%s";
D(bug("[NetInfo] %s()\n", __func__));
VFPrintf(file, "%s|%s|%ld|", (RAWARG)ge->ge_group);
while (*member) {
FPrintf(file, fmt, *member++);
@ -297,6 +315,8 @@ static void GetGroups(struct NetInfoDevice *nid, struct NetInfoReq *req, struct
register int i;
BYTE retval = 0;
D(bug("[NetInfo] %s()\n", __func__));
#if __WORDSIZE == 32
uname = (STRPTR)req->io_Offset;
#else

View File

@ -2,6 +2,7 @@
include $(SRCDIR)/config/aros.cfg
FILES := \
assert \
netinfo \
server \
entries \

View File

@ -109,6 +109,8 @@
****************************************************************************
*/
#include <aros/debug.h>
#include <proto/exec.h>
#include <proto/dos.h>
@ -124,6 +126,8 @@
*/
static int NetInfo__DevInit(LIBBASETYPEPTR LIBBASE)
{
D(bug("[NetInfo] %s()\n", __func__));
LIBBASE->nid_Task = NULL;
InitSemaphore(LIBBASE->nid_Lock);
return TRUE;
@ -137,6 +141,8 @@ static int NetInfo__DevOpen(LIBBASETYPEPTR LIBBASE,
{
int retval = FALSE;
D(bug("[NetInfo] %s()\n", __func__));
/* Enforce single threading so we can Wait() */
ObtainSemaphore(LIBBASE->nid_Lock);
if (unit >= NETINFO_UNITS)
@ -202,6 +208,8 @@ static int NetInfo__DevClose(LIBBASETYPEPTR LIBBASE,
{
int retval = FALSE;
D(bug("[NetInfo] %s()\n", __func__));
ObtainSemaphore(LIBBASE->nid_Lock);
{
ExpungeUnit(LIBBASE, req->io_Unit);
@ -217,6 +225,8 @@ static int NetInfo__DevClose(LIBBASETYPEPTR LIBBASE,
*/
static int NetInfo__DevExpunge(LIBBASETYPEPTR LIBBASE)
{
D(bug("[NetInfo] %s()\n", __func__));
if (AttemptSemaphore(LIBBASE->nid_Lock)) {
if (LIBBASE->nid_Task) {
if (LIBBASE->nid_Death && LIBBASE->nid_Death->mn_Node.ln_Type == NT_MESSAGE)
@ -244,6 +254,8 @@ AROS_LH1(void, BeginIO,
{
AROS_LIBFUNC_INIT
D(bug("[NetInfo] %s()\n", __func__));
req->io_Message.mn_Node.ln_Type = NT_MESSAGE;
if (req->io_Command >= NI_END) {
@ -278,6 +290,8 @@ AROS_LH1(LONG, AbortIO,
ULONG result = 0L;
struct NetInfoMap *nim;
D(bug("[NetInfo] %s()\n", __func__));
if (ni->io_Unit == NULL)
return NIERR_NULL_POINTER;

View File

@ -7,13 +7,17 @@
* Helsinki University of Technology, Finland.
*/
#include <aros/debug.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "entries.h"
#include <string.h>
#if defined(DEBUG)
#include <assert.h>
#include "assert.h"
#endif
static void *CopyEntToPasswd(struct NetInfoReq *req, struct Ent *e);
@ -39,12 +43,16 @@ const static struct MapMethods passwd_methods[1] = {
*/
struct NetInfoMap *InitPasswdMap(struct NetInfoDevice *nid)
{
struct NetInfoMap *nim = AllocVec(sizeof(*nim), MEMF_CLEAR|MEMF_PUBLIC);
D(bug("[NetInfo] %s()\n", __func__));
struct NetInfoMap *nim = NULL;
if (nid->nid_dbuser) {
nim = AllocVec(sizeof(*nim), MEMF_CLEAR|MEMF_PUBLIC);
if (nim) {
nim->nim_Methods = passwd_methods;
nim->nim_Name = "passwd";
nim->nim_Filename = _PATH_PASSWD;
nim->nim_Filename = nid->nid_dbuser;
}
}
return nim;
@ -55,6 +63,8 @@ struct NetInfoMap *InitPasswdMap(struct NetInfoDevice *nid)
*/
static void *CopyEntToPasswd(struct NetInfoReq *req, struct Ent *e)
{
D(bug("[NetInfo] %s()\n", __func__));
struct PasswdEnt *pe = (struct PasswdEnt *)e;
struct NetInfoPasswd *pw = req->io_Data;
UBYTE *to = (UBYTE *)(pw + 1);
@ -95,6 +105,8 @@ static struct Ent *CopyPasswdToEnt(struct NetInfoDevice *nid, struct NetInfoReq
UBYTE *to;
ULONG txtlen;
D(bug("[NetInfo] %s()\n", __func__));
/*
* These cause EFAULT
*/
@ -238,6 +250,8 @@ static struct Ent *ParsePasswd(struct NetInfoDevice *nid, register UBYTE *p)
LONG uid, gid;
struct PasswdEnt *pe;
D(bug("[NetInfo] %s()\n", __func__));
for (i = 0;
i < PASSWDFIELDS && (field[i++] = strsep((char **)&np, "|\n")) && np && *np;)
;
@ -284,6 +298,8 @@ static int PrintPasswd(struct NetInfoDevice *nid, BPTR file, struct Ent *e)
{
struct PasswdEnt *pe = (struct PasswdEnt *)e;
D(bug("[NetInfo] %s()\n", __func__));
if (VFPrintf(file, "%s|%s|%ld|%ld|%s|%s|%s\n", (RAWARG)pe->pe_passwd) == -1)
return NIERR_ACCESS;
else
@ -295,6 +311,8 @@ static int PrintPasswd(struct NetInfoDevice *nid, BPTR file, struct Ent *e)
*/
static void GetMembers(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInfoMap *nim)
{
D(bug("[NetInfo] %s()\n", __func__));
req->io_Error = NIERR_NOTFOUND;
TermIO(req);
}

View File

@ -7,7 +7,10 @@
* Helsinki University of Technology, Finland.
*/
#include <aros/debug.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include "base.h"
#include "assert.h"
@ -18,19 +21,29 @@ static void NetInfoPoll(struct NetInfoDevice *nid);
* Task Startup routine
* This is called from DOS, so it has got no devbase
*/
#if !defined(__AROS__)
#undef SysBase
#define SysBase (*(APTR *)4)
#endif
SAVEDS ASM LONG NetInfoStartup(void)
{
struct NetInfoDevice *dev;
struct Message *ok_message = (struct Message *)
((struct Process*)FindTask(NULL))->pr_ExitData;
D(bug("[NetInfo:Server] %s()\n", __func__));
if (ok_message) {
char buf[128];
LONG len;
dev = (struct NetInfoDevice *) ok_message->mn_Node.ln_Name;
len = GetVar("SYS/userdb", buf, sizeof(buf), GVF_GLOBAL_ONLY);
if (len > 0) {
} else
dev->nid_dbuser = "SYS:System/Network/AROSTCP/db/passwd";
len = GetVar("SYS/groupdb", buf, sizeof(buf), GVF_GLOBAL_ONLY);
if (len > 0) {
} else
dev->nid_dbgroup = "SYS:System/Network/AROSTCP/db/group";
if (dev) {
NetInfoTask(dev, ok_message);
} else {
@ -44,6 +57,8 @@ SAVEDS ASM LONG NetInfoStartup(void)
void TermIO(struct NetInfoReq *req)
{
D(bug("[NetInfo:Server] %s()\n", __func__));
if ((req->io_Flags & IOF_QUICK) == 0)
ReplyMsg((struct Message *)req);
}
@ -60,6 +75,8 @@ void NetInfoTask(struct NetInfoDevice *nid, struct Message *ok_message)
BYTE ps = AllocSignal(-1);
struct Message *death;
D(bug("[NetInfo:Server] %s()\n", __func__));
/* Create main message port */
if (ps != -1) {
@ -115,6 +132,8 @@ static void NetInfoPoll(struct NetInfoDevice *nid)
{
ULONG mask = 1L << nid->nid_Port->mp_SigBit;
D(bug("[NetInfo:Server] %s()\n", __func__));
while (mask) {
struct NetInfoReq *req;
struct NotifyMessage *notify;
@ -175,6 +194,8 @@ struct Unit *CreateNewUnit(struct NetInfoDevice *nid, short unit)
struct NetInfoMap *nim = nid->nid_Maps[unit];
struct NetInfoPointer *nip = AllocVec(sizeof(*nip), MEMF_CLEAR);
D(bug("[NetInfo:Server] %s()\n", __func__));
if (nip) {
nim->nim_OpenCnt++;
nip->nip_Name = nim->nim_Name;
@ -197,6 +218,8 @@ void ExpungeUnit(struct NetInfoDevice *nid, struct Unit *u)
struct NetInfoPointer *nip = (struct NetInfoPointer *)u;
struct NetInfoMap *nim = CheckUnit(nid, u);
D(bug("[NetInfo:Server] %s()\n", __func__));
if (nim == NULL) {
/* We should do an Alert */
InMsg("CloseDevice(): illegal unit pointer %lx", u);
@ -214,6 +237,8 @@ void PerformIO(struct NetInfoDevice *nid, struct NetInfoReq *req)
{
struct NetInfoMap *nim = CheckUnit(nid, req->io_Unit);
D(bug("[NetInfo:Server] %s()\n", __func__));
if (nim) {
DoNIMethod(req->io_Command, req, nim);
} else {
@ -226,6 +251,8 @@ ULONG AbortReq(struct NetInfoDevice *nid, struct List *l, struct NetInfoReq *req
{
struct Node *n;
D(bug("[NetInfo:Server] %s()\n", __func__));
for (n = l->lh_Head; n->ln_Succ; n = n->ln_Succ) {
if (n == (struct Node *)req) {
Remove((struct Node *)req);
@ -240,6 +267,8 @@ ULONG AbortReq(struct NetInfoDevice *nid, struct List *l, struct NetInfoReq *req
void UnknownCommand(struct NetInfoDevice *nid, struct NetInfoReq * req, struct NetInfoMap *nim)
{
D(bug("[NetInfo:Server] %s()\n", __func__));
req->io_Error = IOERR_NOCMD;
TermIO(req);
}