summaryrefslogtreecommitdiff
path: root/nis/nis_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nis_table.c')
-rw-r--r--nis/nis_table.c178
1 files changed, 88 insertions, 90 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c
index 3efba6084e..d2a1df76b2 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -19,7 +19,6 @@
#include <string.h>
#include <rpcsvc/nis.h>
-#include <rpcsvc/nislib.h>
#include "nis_intern.h"
static void
@@ -146,9 +145,7 @@ __create_ib_request (const_nis_name name, struct ib_request *ibreq,
if (ibreq->ibr_name == NULL)
return NULL;
- ibreq->ibr_flags = (flags & (RETURN_RESULT | ADD_OVERWRITE | REM_MULTIPLE |
- MOD_SAMEOBJ | ADD_RESERVED | REM_RESERVED |
- MOD_EXCLUSIVE | ALL_RESULTS));
+ ibreq->ibr_flags = flags;
ibreq->ibr_obj.ibr_obj_len = 0;
ibreq->ibr_obj.ibr_obj_val = NULL;
ibreq->ibr_cbhost.ibr_cbhost_len = 0;
@@ -168,7 +165,7 @@ nis_list (const_nis_name name, u_long flags,
const void *userdata)
{
nis_result *res = NULL;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
int status;
int count_links = 0; /* We will only follow NIS_MAXLINKS links! */
int done = 0;
@@ -179,7 +176,7 @@ nis_list (const_nis_name name, u_long flags,
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, flags) == NULL)
+ if (__create_ib_request (name, ibreq, flags) == NULL)
{
res->status = NIS_BADNAME;
return res;
@@ -187,20 +184,20 @@ nis_list (const_nis_name name, u_long flags,
if (flags & EXPAND_NAME)
{
- names = nis_getnames (ibreq.ibr_name);
- free (ibreq.ibr_name);
- ibreq.ibr_name = NULL;
+ names = nis_getnames (ibreq->ibr_name);
+ free (ibreq->ibr_name);
+ ibreq->ibr_name = NULL;
if (names == NULL)
{
res->status = NIS_BADNAME;
return res;
}
- ibreq.ibr_name = strdup (names[name_nr]);
+ ibreq->ibr_name = strdup (names[name_nr]);
}
else
{
names = namebuf;
- names[name_nr] = ibreq.ibr_name;
+ names[name_nr] = ibreq->ibr_name;
}
cb = NULL;
@@ -228,7 +225,7 @@ nis_list (const_nis_name name, u_long flags,
/* nis_lookup handles FOLLOW_LINKS,
so we must have a table object. */
- if (__type_of (NIS_RES_OBJECT (lres)) != TABLE_OBJ)
+ if (__type_of (NIS_RES_OBJECT (lres)) != NIS_TABLE_OBJ)
{
nis_freeresult (lres);
res->status = NIS_INVALIDOBJ;
@@ -276,17 +273,17 @@ nis_list (const_nis_name name, u_long flags,
if (callback != NULL)
{
cb = __nis_create_callback (callback, userdata, flags);
- ibreq.ibr_cbhost.ibr_cbhost_len = 1;
- ibreq.ibr_cbhost.ibr_cbhost_val = cb->serv;
+ ibreq->ibr_cbhost.ibr_cbhost_len = 1;
+ ibreq->ibr_cbhost.ibr_cbhost_val = cb->serv;
}
while (!done)
{
memset (res, '\0', sizeof (nis_result));
- status = __do_niscall (ibreq.ibr_name, NIS_IBLIST,
+ status = __do_niscall (ibreq->ibr_name, NIS_IBLIST,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
+ (caddr_t) ibreq, (xdrproc_t) xdr_nis_result,
(caddr_t) res, flags, cb);
if (status != NIS_SUCCESS)
res->status = status;
@@ -296,7 +293,7 @@ nis_list (const_nis_name name, u_long flags,
case NIS_PARTIAL:
case NIS_SUCCESS:
case NIS_S_SUCCESS:
- if (__type_of (NIS_RES_OBJECT (res)) == LINK_OBJ &&
+ if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ &&
flags & FOLLOW_LINKS) /* We are following links. */
{
/* If we hit the link limit, bail. */
@@ -307,17 +304,17 @@ nis_list (const_nis_name name, u_long flags,
break;
}
if (count_links)
- free (ibreq.ibr_name);
+ free (ibreq->ibr_name);
++count_links;
- free (ibreq.ibr_name);
- ibreq.ibr_name =
+ free (ibreq->ibr_name);
+ ibreq->ibr_name =
strdup (NIS_RES_OBJECT (res)->LI_data.li_name);
if (NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len)
- if (ibreq.ibr_srch.ibr_srch_len == 0)
+ if (ibreq->ibr_srch.ibr_srch_len == 0)
{
- ibreq.ibr_srch.ibr_srch_len =
+ ibreq->ibr_srch.ibr_srch_len =
NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_len;
- ibreq.ibr_srch.ibr_srch_val =
+ ibreq->ibr_srch.ibr_srch_val =
NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_val;
}
nis_freeresult (res);
@@ -338,7 +335,7 @@ nis_list (const_nis_name name, u_long flags,
/* Try the next domainname if we don't follow a link. */
if (count_links)
{
- free (ibreq.ibr_name);
+ free (ibreq->ibr_name);
res->status = NIS_LINKNAMEERROR;
++done;
break;
@@ -349,7 +346,7 @@ nis_list (const_nis_name name, u_long flags,
++done;
break;
}
- ibreq.ibr_name = names[name_nr];
+ ibreq->ibr_name = names[name_nr];
break;
}
}
@@ -358,10 +355,14 @@ nis_list (const_nis_name name, u_long flags,
if (names != namebuf)
nis_freenames (names);
- nis_free_request (&ibreq);
-
if (cb)
- __nis_destroy_callback (cb);
+ {
+ __nis_destroy_callback (cb);
+ ibreq->ibr_cbhost.ibr_cbhost_len = 0;
+ ibreq->ibr_cbhost.ibr_cbhost_val = NULL;
+ }
+
+ nis_free_request (ibreq);
return res;
}
@@ -372,53 +373,52 @@ nis_add_entry (const_nis_name name, const nis_object *obj,
{
nis_result *res;
nis_error status;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
char *p1, *p2, *p3, *p4;
char buf1[strlen (name) + 20];
char buf4[strlen (name) + 20];
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, flags) == NULL)
+ if (__create_ib_request (name, ibreq, flags) == NULL)
{
res->status = NIS_BADNAME;
return res;
}
- ibreq.ibr_flags = flags;
- ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
- ibreq.ibr_obj.ibr_obj_len = 1;
+ ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
+ ibreq->ibr_obj.ibr_obj_len = 1;
- p1 = ibreq.ibr_obj.ibr_obj_val->zo_name;
+ p1 = ibreq->ibr_obj.ibr_obj_val->zo_name;
if (p1 == NULL || strlen (p1) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_name =
+ ibreq->ibr_obj.ibr_obj_val->zo_name =
nis_leaf_of_r (name, buf1, sizeof (buf1));
- p2 = ibreq.ibr_obj.ibr_obj_val->zo_owner;
+ p2 = ibreq->ibr_obj.ibr_obj_val->zo_owner;
if (p2 == NULL || strlen (p2) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_owner = nis_local_principal ();
+ ibreq->ibr_obj.ibr_obj_val->zo_owner = nis_local_principal ();
- p3 = ibreq.ibr_obj.ibr_obj_val->zo_group;
+ p3 = ibreq->ibr_obj.ibr_obj_val->zo_group;
if (p3 == NULL || strlen (p3) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_group = nis_local_group ();
+ ibreq->ibr_obj.ibr_obj_val->zo_group = nis_local_group ();
- p4 = ibreq.ibr_obj.ibr_obj_val->zo_domain;
- ibreq.ibr_obj.ibr_obj_val->zo_domain =
+ p4 = ibreq->ibr_obj.ibr_obj_val->zo_domain;
+ ibreq->ibr_obj.ibr_obj_val->zo_domain =
nis_domain_of_r (name, buf4, sizeof (buf4));
- if ((status = __do_niscall (ibreq.ibr_name, NIS_IBADD,
+ if ((status = __do_niscall (ibreq->ibr_name, NIS_IBADD,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq,
+ (caddr_t) ibreq,
(xdrproc_t) xdr_nis_result,
(caddr_t) res, 0, NULL)) != NIS_SUCCESS)
res->status = status;
- ibreq.ibr_obj.ibr_obj_val->zo_name = p1;
- ibreq.ibr_obj.ibr_obj_val->zo_owner = p2;
- ibreq.ibr_obj.ibr_obj_val->zo_group = p3;
- ibreq.ibr_obj.ibr_obj_val->zo_domain = p4;
+ ibreq->ibr_obj.ibr_obj_val->zo_name = p1;
+ ibreq->ibr_obj.ibr_obj_val->zo_owner = p2;
+ ibreq->ibr_obj.ibr_obj_val->zo_group = p3;
+ ibreq->ibr_obj.ibr_obj_val->zo_domain = p4;
- nis_free_request (&ibreq);
+ nis_free_request (ibreq);
return res;
}
@@ -429,52 +429,51 @@ nis_modify_entry (const_nis_name name, const nis_object *obj,
{
nis_result *res;
nis_error status;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
char *p1, *p2, *p3, *p4;
char buf1[strlen (name) + 20];
char buf4[strlen (name) + 20];
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, flags) == NULL)
+ if (__create_ib_request (name, ibreq, flags) == NULL)
{
res->status = NIS_BADNAME;
return res;
}
- ibreq.ibr_flags = flags;
- ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
- ibreq.ibr_obj.ibr_obj_len = 1;
+ ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
+ ibreq->ibr_obj.ibr_obj_len = 1;
- p1 = ibreq.ibr_obj.ibr_obj_val->zo_name;
+ p1 = ibreq->ibr_obj.ibr_obj_val->zo_name;
if (p1 == NULL || strlen (p1) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_name =
+ ibreq->ibr_obj.ibr_obj_val->zo_name =
nis_leaf_of_r (name, buf1, sizeof (buf1));
- p2 = ibreq.ibr_obj.ibr_obj_val->zo_owner;
+ p2 = ibreq->ibr_obj.ibr_obj_val->zo_owner;
if (p2 == NULL || strlen (p2) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_owner = nis_local_principal ();
+ ibreq->ibr_obj.ibr_obj_val->zo_owner = nis_local_principal ();
- p3 = ibreq.ibr_obj.ibr_obj_val->zo_group;
+ p3 = ibreq->ibr_obj.ibr_obj_val->zo_group;
if (p3 == NULL || strlen (p3) == 0)
- ibreq.ibr_obj.ibr_obj_val->zo_group = nis_local_group ();
+ ibreq->ibr_obj.ibr_obj_val->zo_group = nis_local_group ();
- p4 = ibreq.ibr_obj.ibr_obj_val->zo_domain;
- ibreq.ibr_obj.ibr_obj_val->zo_domain =
+ p4 = ibreq->ibr_obj.ibr_obj_val->zo_domain;
+ ibreq->ibr_obj.ibr_obj_val->zo_domain =
nis_domain_of_r (name, buf4, sizeof (buf4));
- if ((status = __do_niscall (ibreq.ibr_name, NIS_IBMODIFY,
+ if ((status = __do_niscall (ibreq->ibr_name, NIS_IBMODIFY,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
+ (caddr_t) ibreq, (xdrproc_t) xdr_nis_result,
(caddr_t) res, 0, NULL)) != NIS_SUCCESS)
res->status = status;
- ibreq.ibr_obj.ibr_obj_val->zo_name = p1;
- ibreq.ibr_obj.ibr_obj_val->zo_owner = p2;
- ibreq.ibr_obj.ibr_obj_val->zo_group = p3;
- ibreq.ibr_obj.ibr_obj_val->zo_domain = p4;
+ ibreq->ibr_obj.ibr_obj_val->zo_name = p1;
+ ibreq->ibr_obj.ibr_obj_val->zo_owner = p2;
+ ibreq->ibr_obj.ibr_obj_val->zo_group = p3;
+ ibreq->ibr_obj.ibr_obj_val->zo_domain = p4;
- nis_free_request (&ibreq);
+ nis_free_request (ibreq);
return res;
}
@@ -484,31 +483,30 @@ nis_remove_entry (const_nis_name name, const nis_object *obj,
u_long flags)
{
nis_result *res;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
nis_error status;
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, flags) == NULL)
+ if (__create_ib_request (name, ibreq, flags) == NULL)
{
res->status = NIS_BADNAME;
return res;
}
- ibreq.ibr_flags = flags;
if (obj != NULL)
{
- ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
- ibreq.ibr_obj.ibr_obj_len = 1;
+ ibreq->ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
+ ibreq->ibr_obj.ibr_obj_len = 1;
}
- if ((status = __do_niscall (ibreq.ibr_name, NIS_IBREMOVE,
+ if ((status = __do_niscall (ibreq->ibr_name, NIS_IBREMOVE,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
+ (caddr_t) ibreq, (xdrproc_t) xdr_nis_result,
(caddr_t) res, 0, NULL)) != NIS_SUCCESS)
res->status = status;
- nis_free_request (&ibreq);
+ nis_free_request (ibreq);
return res;
}
@@ -517,24 +515,24 @@ nis_result *
nis_first_entry (const_nis_name name)
{
nis_result *res;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
nis_error status;
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, 0) == NULL)
+ if (__create_ib_request (name, ibreq, 0) == NULL)
{
res->status = NIS_BADNAME;
return res;
}
- if ((status = __do_niscall (ibreq.ibr_name, NIS_IBFIRST,
+ if ((status = __do_niscall (ibreq->ibr_name, NIS_IBFIRST,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
+ (caddr_t) ibreq, (xdrproc_t) xdr_nis_result,
(caddr_t) res, 0, NULL)) != NIS_SUCCESS)
res->status = status;
- nis_free_request (&ibreq);
+ nis_free_request (ibreq);
return res;
}
@@ -543,12 +541,12 @@ nis_result *
nis_next_entry (const_nis_name name, const netobj *cookie)
{
nis_result *res;
- struct ib_request ibreq;
+ ib_request *ibreq = calloc (1, sizeof (ib_request));
nis_error status;
res = calloc (1, sizeof (nis_result));
- if (__create_ib_request (name, &ibreq, 0) == NULL)
+ if (__create_ib_request (name, ibreq, 0) == NULL)
{
res->status = NIS_BADNAME;
return res;
@@ -556,24 +554,24 @@ nis_next_entry (const_nis_name name, const netobj *cookie)
if (cookie != NULL)
{
- ibreq.ibr_cookie.n_bytes = malloc (cookie->n_len);
- if (ibreq.ibr_cookie.n_bytes == NULL)
+ ibreq->ibr_cookie.n_bytes = malloc (cookie->n_len);
+ if (ibreq->ibr_cookie.n_bytes == NULL)
{
res->status = NIS_NOMEMORY;
free (res);
return NULL;
}
- memcpy (ibreq.ibr_cookie.n_bytes, cookie->n_bytes, cookie->n_len);
- ibreq.ibr_cookie.n_len = cookie->n_len;
+ memcpy (ibreq->ibr_cookie.n_bytes, cookie->n_bytes, cookie->n_len);
+ ibreq->ibr_cookie.n_len = cookie->n_len;
}
- if ((status = __do_niscall (ibreq.ibr_name, NIS_IBNEXT,
+ if ((status = __do_niscall (ibreq->ibr_name, NIS_IBNEXT,
(xdrproc_t) xdr_ib_request,
- (caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
+ (caddr_t) ibreq, (xdrproc_t) xdr_nis_result,
(caddr_t) res, 0, NULL)) != NIS_SUCCESS)
res->status = status;
- nis_free_request (&ibreq);
+ nis_free_request (ibreq);
return res;
}