mirror of
https://github.com/deadw00d/AROS.git
synced 2025-12-06 13:11:35 +00:00
pack necessary structures to ensure correct alignment of elements.
This commit is contained in:
@ -102,26 +102,24 @@ void GetByNameCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetI
|
|||||||
const UBYTE *name = (const UBYTE *)
|
const UBYTE *name = (const UBYTE *)
|
||||||
((struct NetInfoEnt*)req->io_Data)->nie_name;
|
((struct NetInfoEnt*)req->io_Data)->nie_name;
|
||||||
struct Ent *e;
|
struct Ent *e;
|
||||||
LONG retval = NIERR_NOTFOUND;
|
|
||||||
|
|
||||||
D(bug("[NetInfo] %s()\n", __func__));
|
D(bug("[NetInfo] %s()\n", __func__));
|
||||||
|
|
||||||
|
req->io_Error = NIERR_NOTFOUND;
|
||||||
|
|
||||||
e = InternalSetEnts(nid, nim);
|
e = InternalSetEnts(nid, nim);
|
||||||
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
|
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
|
||||||
|
|
||||||
while (e = GetNextEnt(e)) {
|
while (e = GetNextEnt(e)) {
|
||||||
if (strcmp(e->e_name, name) == 0) {
|
if (strcmp(e->e_name, name) == 0) {
|
||||||
if (Method(copy_out, nim)(req, e)) {
|
if (Method(copy_out, nim)(req, e)) {
|
||||||
retval = 0;
|
req->io_Error = 0;
|
||||||
} else {
|
} else {
|
||||||
retval = NIERR_TOOSMALL;
|
req->io_Error = NIERR_TOOSMALL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req->io_Error = retval;
|
|
||||||
|
|
||||||
InternalEndEnts(nid, nim);
|
InternalEndEnts(nid, nim);
|
||||||
TermIO(req);
|
TermIO(req);
|
||||||
}
|
}
|
||||||
@ -133,26 +131,27 @@ void GetByIDCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInf
|
|||||||
{
|
{
|
||||||
struct Ent *e;
|
struct Ent *e;
|
||||||
LONG id = ((struct NetInfoEnt*)req->io_Data)->nie_id;
|
LONG id = ((struct NetInfoEnt*)req->io_Data)->nie_id;
|
||||||
BYTE retval = NIERR_NOTFOUND;
|
|
||||||
|
|
||||||
D(bug("[NetInfo] %s()\n", __func__));
|
D(bug("[NetInfo] %s()\n", __func__));
|
||||||
|
D(bug("[NetInfo] %s: ID %ld\n", __func__, id));
|
||||||
|
|
||||||
|
req->io_Error = NIERR_NOTFOUND;
|
||||||
|
|
||||||
e = InternalSetEnts(nid, nim);
|
e = InternalSetEnts(nid, nim);
|
||||||
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
|
D(bug("[NetInfo] %s: Ents @ 0x%p\n", __func__, e));
|
||||||
|
|
||||||
while (e = GetNextEnt(e)) {
|
while (e = GetNextEnt(e)) {
|
||||||
|
D(bug("[NetInfo] %s: ent id %ld\n", __func__, e->e_id));
|
||||||
if (e->e_id == id) {
|
if (e->e_id == id) {
|
||||||
if (Method(copy_out, nim)(req, e)) {
|
if (Method(copy_out, nim)(req, e)) {
|
||||||
retval = 0;
|
req->io_Error = 0;
|
||||||
} else {
|
} else {
|
||||||
retval = NIERR_TOOSMALL;
|
req->io_Error = NIERR_TOOSMALL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req->io_Error = retval;
|
|
||||||
|
|
||||||
InternalEndEnts(nid, nim);
|
InternalEndEnts(nid, nim);
|
||||||
TermIO(req);
|
TermIO(req);
|
||||||
}
|
}
|
||||||
@ -179,24 +178,21 @@ void ReadCmd(struct NetInfoDevice *nid, struct NetInfoReq *req, struct NetInfoMa
|
|||||||
{
|
{
|
||||||
struct NetInfoPointer *p = (struct NetInfoPointer *)req->io_Unit;
|
struct NetInfoPointer *p = (struct NetInfoPointer *)req->io_Unit;
|
||||||
struct Ent *e;
|
struct Ent *e;
|
||||||
BYTE retval;
|
|
||||||
|
|
||||||
D(bug("[NetInfo] %s()\n", __func__));
|
D(bug("[NetInfo] %s()\n", __func__));
|
||||||
|
|
||||||
|
req->io_Error = NIERR_NOTFOUND;
|
||||||
|
|
||||||
InternalSetEnts(nid, nim);
|
InternalSetEnts(nid, nim);
|
||||||
e = p->nip_Ent;
|
e = p->nip_Ent;
|
||||||
if (p->nip_Ent && (p->nip_Ent = GetNextEnt(e))) {
|
if (p->nip_Ent && (p->nip_Ent = GetNextEnt(e))) {
|
||||||
if (Method(copy_out, nim)(req, p->nip_Ent)) {
|
if (Method(copy_out, nim)(req, p->nip_Ent)) {
|
||||||
retval = 0;
|
req->io_Error = 0;
|
||||||
} else {
|
} else {
|
||||||
retval = NIERR_TOOSMALL;
|
req->io_Error = NIERR_TOOSMALL;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
retval = NIERR_NOTFOUND;
|
|
||||||
}
|
}
|
||||||
InternalEndEnts(nid, nim);
|
InternalEndEnts(nid, nim);
|
||||||
|
|
||||||
req->io_Error = retval;
|
|
||||||
TermIO(req);
|
TermIO(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,13 +26,13 @@ struct Ent {
|
|||||||
UBYTE *e_name;
|
UBYTE *e_name;
|
||||||
LONG e_pwd;
|
LONG e_pwd;
|
||||||
LONG e_id;
|
LONG e_id;
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
struct PasswdEnt {
|
struct PasswdEnt {
|
||||||
struct Node pe_node;
|
struct Node pe_node;
|
||||||
UWORD pe_tlen;
|
UWORD pe_tlen;
|
||||||
struct NetInfoPasswd pe_passwd[1];
|
struct NetInfoPasswd pe_passwd[1];
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
/* we may have an extended version of passwd */
|
/* we may have an extended version of passwd */
|
||||||
#define PASSWDFIELDS 7
|
#define PASSWDFIELDS 7
|
||||||
@ -42,7 +42,7 @@ struct GroupEnt {
|
|||||||
UWORD ge_tlen;
|
UWORD ge_tlen;
|
||||||
struct NetInfoGroup ge_group[1];
|
struct NetInfoGroup ge_group[1];
|
||||||
ULONG ge_nmembers; /* actually, # of members + 1 */
|
ULONG ge_nmembers; /* actually, # of members + 1 */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Entry Node Type
|
* Entry Node Type
|
||||||
@ -82,7 +82,7 @@ void InternalEndEnts(struct NetInfoDevice *, struct NetInfoMap *nim);
|
|||||||
struct Ent *GetNextEnt(struct Ent *e);
|
struct Ent *GetNextEnt(struct Ent *e);
|
||||||
|
|
||||||
/* Utility */
|
/* Utility */
|
||||||
static __inline char *stpcopy(char *to, const char *from)
|
static inline char *stpcopy(char *to, const char *from)
|
||||||
{
|
{
|
||||||
while (*to++ = *from++)
|
while (*to++ = *from++)
|
||||||
;
|
;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ struct NetInfoPasswd
|
|||||||
UBYTE *pw_gecos; /* Real name etc */
|
UBYTE *pw_gecos; /* Real name etc */
|
||||||
UBYTE *pw_dir; /* Home directory */
|
UBYTE *pw_dir; /* Home directory */
|
||||||
UBYTE *pw_shell; /* Shell */
|
UBYTE *pw_shell; /* Shell */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
/* The group structure */
|
/* The group structure */
|
||||||
struct NetInfoGroup
|
struct NetInfoGroup
|
||||||
@ -65,6 +65,6 @@ struct NetInfoGroup
|
|||||||
UBYTE *gr_passwd; /* Password. */
|
UBYTE *gr_passwd; /* Password. */
|
||||||
LONG gr_gid; /* Group ID. */
|
LONG gr_gid; /* Group ID. */
|
||||||
UBYTE **gr_mem; /* Member list. */
|
UBYTE **gr_mem; /* Member list. */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
#endif /* DEVICES_NETINFO_H */
|
#endif /* DEVICES_NETINFO_H */
|
||||||
|
|||||||
@ -300,7 +300,7 @@ static struct Ent *ParsePasswd(struct NetInfoDevice *nid, register UBYTE *p)
|
|||||||
to = stpcopy(pe->pe_passwd->pw_dir = to, field[5]);
|
to = stpcopy(pe->pe_passwd->pw_dir = to, field[5]);
|
||||||
to = stpcopy(pe->pe_passwd->pw_shell = to, field[6]);
|
to = stpcopy(pe->pe_passwd->pw_shell = to, field[6]);
|
||||||
|
|
||||||
D(bug("[NetInfo] %s: <%d:%d> '%s'\n", __func__, pe->pe_passwd->pw_uid, pe->pe_passwd->pw_gid, pe->pe_passwd->pw_name));
|
D(bug("[NetInfo] %s: <%ld:%ld> '%s'\n", __func__, pe->pe_passwd->pw_uid, pe->pe_passwd->pw_gid, pe->pe_passwd->pw_name));
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
assert(to == pe->pe_passwd->pw_name + txtlen);
|
assert(to == pe->pe_passwd->pw_name + txtlen);
|
||||||
|
|||||||
@ -147,7 +147,9 @@ AROS_LH1(struct group *, getgrnam,
|
|||||||
gr->gr_name = (char *)name;
|
gr->gr_name = (char *)name;
|
||||||
nreq->io_Command = NI_GETBYNAME;
|
nreq->io_Command = NI_GETBYNAME;
|
||||||
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
|
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
|
||||||
if (ug_DoIO(nreq) != 0) {
|
if (ug_DoIO(nreq) == 0) {
|
||||||
|
D(bug("[UserGroup] %s: -> '%s'\n", __func__, gr->gr_gid));
|
||||||
|
} else {
|
||||||
gr = NULL;
|
gr = NULL;
|
||||||
SetDeviceErr((struct Library *)UserGroupBase);
|
SetDeviceErr((struct Library *)UserGroupBase);
|
||||||
}
|
}
|
||||||
@ -179,7 +181,9 @@ AROS_LH1(struct group *, getgrgid,
|
|||||||
gr->gr_gid = gid;
|
gr->gr_gid = gid;
|
||||||
nreq->io_Command = NI_GETBYID;
|
nreq->io_Command = NI_GETBYID;
|
||||||
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
|
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_GROUP_UNIT));
|
||||||
if (ug_DoIO(nreq) != 0) {
|
if (ug_DoIO(nreq) == 0) {
|
||||||
|
D(bug("[UserGroup] %s: -> '%s'\n", __func__, gr->gr_name));
|
||||||
|
} else {
|
||||||
gr = NULL;
|
gr = NULL;
|
||||||
SetDeviceErr((struct Library *)UserGroupBase);
|
SetDeviceErr((struct Library *)UserGroupBase);
|
||||||
}
|
}
|
||||||
@ -189,6 +193,7 @@ AROS_LH1(struct group *, getgrgid,
|
|||||||
|
|
||||||
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
||||||
|
|
||||||
|
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, gr));
|
||||||
return gr;
|
return gr;
|
||||||
|
|
||||||
AROS_LIBFUNC_EXIT
|
AROS_LIBFUNC_EXIT
|
||||||
@ -251,6 +256,7 @@ AROS_LH0(struct group *, getgrent,
|
|||||||
|
|
||||||
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
||||||
|
|
||||||
|
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, gr));
|
||||||
return gr;
|
return gr;
|
||||||
|
|
||||||
AROS_LIBFUNC_EXIT
|
AROS_LIBFUNC_EXIT
|
||||||
|
|||||||
@ -138,7 +138,9 @@ AROS_LH1(struct passwd *, getpwnam,
|
|||||||
pw->pw_name = (char *)name;
|
pw->pw_name = (char *)name;
|
||||||
nreq->io_Command = NI_GETBYNAME;
|
nreq->io_Command = NI_GETBYNAME;
|
||||||
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
D(bug("[UserGroup] %s: sending NI_GETBYNAME to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
||||||
if (ug_DoIO(nreq) != 0) {
|
if (ug_DoIO(nreq) == 0) {
|
||||||
|
D(bug("[UserGroup] %s: -> %d\n", __func__, pw->pw_uid));
|
||||||
|
} else {
|
||||||
pw = NULL;
|
pw = NULL;
|
||||||
SetDeviceErr((struct Library *)UserGroupBase);
|
SetDeviceErr((struct Library *)UserGroupBase);
|
||||||
}
|
}
|
||||||
@ -166,13 +168,13 @@ AROS_LH1(struct passwd *, getpwuid,
|
|||||||
|
|
||||||
ObtainSemaphore(&UserGroupBase->ni_lock);
|
ObtainSemaphore(&UserGroupBase->ni_lock);
|
||||||
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
|
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
|
||||||
pw = (struct passwd *)nreq->io_Data;
|
pw = (struct passwd *)nreq->io_Data;
|
||||||
pw->pw_uid = uid;
|
pw->pw_uid = uid;
|
||||||
nreq->io_Command = NI_GETBYID;
|
nreq->io_Command = NI_GETBYID;
|
||||||
|
|
||||||
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
D(bug("[UserGroup] %s: sending NI_GETBYID to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
||||||
|
if (ug_DoIO(nreq) == 0) {
|
||||||
if (ug_DoIO(nreq) != 0) {
|
D(bug("[UserGroup] %s: -> '%s'\n", __func__, pw->pw_name));
|
||||||
|
} else {
|
||||||
pw = NULL;
|
pw = NULL;
|
||||||
SetDeviceErr((struct Library *)UserGroupBase);
|
SetDeviceErr((struct Library *)UserGroupBase);
|
||||||
}
|
}
|
||||||
@ -183,6 +185,7 @@ AROS_LH1(struct passwd *, getpwuid,
|
|||||||
|
|
||||||
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
||||||
|
|
||||||
|
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, pw));
|
||||||
return pw;
|
return pw;
|
||||||
|
|
||||||
AROS_LIBFUNC_EXIT
|
AROS_LIBFUNC_EXIT
|
||||||
@ -201,9 +204,7 @@ AROS_LH0(void, setpwent,
|
|||||||
|
|
||||||
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
|
if (nreq = ug_OpenUnit((struct Library *)UserGroupBase, NETINFO_PASSWD_UNIT)) {
|
||||||
nreq->io_Command = CMD_RESET;
|
nreq->io_Command = CMD_RESET;
|
||||||
|
|
||||||
D(bug("[UserGroup] %s: sending CMD_RESET to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
D(bug("[UserGroup] %s: sending CMD_RESET to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
||||||
|
|
||||||
ug_DoIO(nreq);
|
ug_DoIO(nreq);
|
||||||
UserGroupBase->setent_done = 1;
|
UserGroupBase->setent_done = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -234,7 +235,6 @@ AROS_LH0(struct passwd *, getpwent,
|
|||||||
ug_DoIO(nreq);
|
ug_DoIO(nreq);
|
||||||
UserGroupBase->setent_done = 1;
|
UserGroupBase->setent_done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
D(bug("[UserGroup] %s: sending CMD_READ to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
D(bug("[UserGroup] %s: sending CMD_READ to netinfo.device/%d...\n", __func__, NETINFO_PASSWD_UNIT));
|
||||||
nreq->io_Command = CMD_READ;
|
nreq->io_Command = CMD_READ;
|
||||||
if (ug_DoIO(nreq) == 0) {
|
if (ug_DoIO(nreq) == 0) {
|
||||||
@ -248,6 +248,7 @@ AROS_LH0(struct passwd *, getpwent,
|
|||||||
|
|
||||||
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
ReleaseSemaphore(&UserGroupBase->ni_lock);
|
||||||
|
|
||||||
|
D(bug("[UserGroup] %s: returning 0x%p\n", __func__, pw));
|
||||||
return pw;
|
return pw;
|
||||||
|
|
||||||
AROS_LIBFUNC_EXIT
|
AROS_LIBFUNC_EXIT
|
||||||
|
|||||||
Reference in New Issue
Block a user