Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
1998-06-16  Thorsten Kukuk  <[email protected]>

	* sunrpc/svc.c: Check for NULL pointer.

	* nis/libnsl.map: Add public NIS+ xdr functions.

	* nis/rpcsvc/nis_callback.h: New file.
	* nis/rpcsvc/nis.h: Move xdr_* functions from here ...
	* nis/nis_xdr.h: ... here.

	* nis/nis_add.c: Use internal _xdr_* functions, check for NULL
	pointers, use NIS+ defines where possible.
	* nis/nis_cache.c: Likewise.
	* nis/nis_cache2_xdr.c: Likewise.
	* nis/nis_call.c: Likewise.
	* nis/nis_checkpoint.c: Likewise.
	* nis/nis_clone_dir.c: Likewise.
	* nis/nis_clone_obj.c: Likewise.
	* nis/nis_clone_res.c: Likewise.
	* nis/nis_creategroup.c: Likewise.
	* nis/nis_file.c: Likewise.
	* nis/nis_free.c: Likewise.
	* nis/nis_getservlist.c: Likewise.
	* nis/nis_local_names.c: likewise.
	* nis/nis_lookup.c: Likewise.
	* nis/nis_mkdir.c: Likewise.
	* nis/nis_modify.c: Likewise.
	* nis/nis_ping.c: Likewise.
	* nis/nis_print.c: Likewise.
	* nis/nis_remove.c: Likewise.
	* nis/nis_removemember.c: Likewise.
	* nis/nis_rmdir.c: Likewise.
	* nis/nis_server.c: Likewise.
	* nis/nis_table.c: Likewise.
	* nis/nis_util.c: Likewise.
	* nis/nis_verifygroup.c: Likewise.
	* nis/nis_xdr.c: Likewise.
	* nis/nis_callback.c: Likewise, and move xdr functions from here ...
	* nis/nis_xdr.c: ... to here.
  • Loading branch information
Ulrich Drepper committed Jun 16, 1998
1 parent fed8f7f commit 91eee4d
Show file tree
Hide file tree
Showing 33 changed files with 579 additions and 481 deletions.
40 changes: 40 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
1998-06-16 Thorsten Kukuk <[email protected]>

* sunrpc/svc.c: Check for NULL pointer.

* nis/libnsl.map: Add public NIS+ xdr functions.

* nis/rpcsvc/nis_callback.h: New file.
* nis/rpcsvc/nis.h: Move xdr_* functions from here ...
* nis/nis_xdr.h: ... here.

* nis/nis_add.c: Use internal _xdr_* functions, check for NULL
pointers, use NIS+ defines where possible.
* nis/nis_cache.c: Likewise.
* nis/nis_cache2_xdr.c: Likewise.
* nis/nis_call.c: Likewise.
* nis/nis_checkpoint.c: Likewise.
* nis/nis_clone_dir.c: Likewise.
* nis/nis_clone_obj.c: Likewise.
* nis/nis_clone_res.c: Likewise.
* nis/nis_creategroup.c: Likewise.
* nis/nis_file.c: Likewise.
* nis/nis_free.c: Likewise.
* nis/nis_getservlist.c: Likewise.
* nis/nis_local_names.c: likewise.
* nis/nis_lookup.c: Likewise.
* nis/nis_mkdir.c: Likewise.
* nis/nis_modify.c: Likewise.
* nis/nis_ping.c: Likewise.
* nis/nis_print.c: Likewise.
* nis/nis_remove.c: Likewise.
* nis/nis_removemember.c: Likewise.
* nis/nis_rmdir.c: Likewise.
* nis/nis_server.c: Likewise.
* nis/nis_table.c: Likewise.
* nis/nis_util.c: Likewise.
* nis/nis_verifygroup.c: Likewise.
* nis/nis_xdr.c: Likewise.
* nis/nis_callback.c: Likewise, and move xdr functions from here ...
* nis/nis_xdr.c: ... to here.

1998-06-15 18:07 Ulrich Drepper <[email protected]>

* iconvdata/ksc5601.h: Clean up a bit.
Expand Down
2 changes: 2 additions & 0 deletions nis/libnsl.map
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ GLIBC_2.1 {
nis_sperror; nis_sperror_r; nis_stats;
nis_verifygroup; nis_write_obj;

xdr_cback_data; xdr_obj_p;

# This functions are needed by the NIS+ tools and rpc.nisd,
# they should never be used in a normal user program !
__do_niscall2; __free_fdresult; __nis_default_access;
Expand Down
51 changes: 25 additions & 26 deletions nis/nis_add.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 1997 Free Software Foundation, Inc.
/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <[email protected]>, 1997.
Expand All @@ -19,53 +19,52 @@

#include <rpcsvc/nis.h>

#include "nis_xdr.h"
#include "nis_intern.h"

nis_result *
nis_add (const_nis_name name, const nis_object *obj)
nis_add (const_nis_name name, const nis_object *obj2)
{
nis_object obj;
nis_result *res;
nis_error status;
struct ns_request req;
char *p1, *p2, *p3, *p4;
char buf1 [strlen (name) + 20];
char buf4 [strlen (name) + 20];

res = calloc (1, sizeof (nis_result));
if (res == NULL)
return NULL;

req.ns_name = (char *)name;

req.ns_object.ns_object_len = 1;
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
memcpy (&obj, obj2, sizeof (nis_object));

if (obj.zo_name == NULL || strlen (obj.zo_name) == 0)
obj.zo_name = nis_leaf_of_r (name, buf1, sizeof (buf1));

p1 = req.ns_object.ns_object_val[0].zo_name;
if (p1 == NULL || strlen (p1) == 0)
req.ns_object.ns_object_val[0].zo_name =
nis_leaf_of_r (name, buf1, sizeof (buf1));
if (obj.zo_owner == NULL || strlen (obj.zo_owner) == 0)
obj.zo_owner = nis_local_principal ();

p2 = req.ns_object.ns_object_val[0].zo_owner;
if (p2 == NULL || strlen (p2) == 0)
req.ns_object.ns_object_val[0].zo_owner = nis_local_principal ();
if (obj.zo_group == NULL || strlen (obj.zo_group) == 0)
obj.zo_group = nis_local_group ();

p3 = req.ns_object.ns_object_val[0].zo_group;
if (p3 == NULL || strlen (p3) == 0)
req.ns_object.ns_object_val[0].zo_group = nis_local_group ();
obj.zo_domain = nis_domain_of_r (name, buf4, sizeof (buf4));

p4 = req.ns_object.ns_object_val[0].zo_domain;
req.ns_object.ns_object_val[0].zo_domain =
nis_domain_of_r (name, buf4, sizeof (buf4));
req.ns_object.ns_object_val = nis_clone_object (&obj, NULL);
if (req.ns_object.ns_object_val == NULL)
{
NIS_RES_STATUS (res) = NIS_NOMEMORY;
return res;
}
req.ns_object.ns_object_len = 1;

if ((status = __do_niscall (req.ns_object.ns_object_val[0].zo_domain,
NIS_ADD, (xdrproc_t) xdr_ns_request,
(caddr_t) &req, (xdrproc_t) xdr_nis_result,
NIS_ADD, (xdrproc_t) _xdr_ns_request,
(caddr_t) &req, (xdrproc_t) _xdr_nis_result,
(caddr_t) res, MASTER_ONLY,
NULL)) != RPC_SUCCESS)
res->status = status;

req.ns_object.ns_object_val[0].zo_name = p1;
req.ns_object.ns_object_val[0].zo_owner = p2;
req.ns_object.ns_object_val[0].zo_group = p3;
req.ns_object.ns_object_val[0].zo_domain = p4;
NIS_RES_STATUS (res) = status;

nis_destroy_object (req.ns_object.ns_object_val);

Expand Down
5 changes: 3 additions & 2 deletions nis/nis_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include <string.h>
#include <unistd.h>
#include <rpcsvc/nis.h>
#include "nis_intern.h"

#include "nis_xdr.h"
#include "nis_intern.h"
#include "nis_cache2.h"

static struct timeval TIMEOUT = { 25, 0 };
Expand Down Expand Up @@ -85,7 +86,7 @@ __nis_cache_search (const_nis_name name, u_long flags, cache2_info *cinfo)

xdrmem_create (&xdrs, fsres.dir_data.dir_data_val,
fsres.dir_data.dir_data_len, XDR_DECODE);
xdr_directory_obj (&xdrs, obj);
_xdr_directory_obj (&xdrs, obj);
xdr_destroy (&xdrs);

cinfo->server_used = fsres.server_used;
Expand Down
8 changes: 5 additions & 3 deletions nis/nis_cache2_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpcsvc/nis.h>

#include "nis_xdr.h"
#include "nis_cache2.h"
#include <rpcsvc/nis.h>


bool_t
xdr_fs_result(XDR *xdrs, fs_result *objp)
{
if (!xdr_nis_error(xdrs, &objp->status)) {
if (!_xdr_nis_error(xdrs, &objp->status)) {
return FALSE;
}
if (!xdr_long(xdrs, &objp->class)) {
Expand All @@ -33,7 +35,7 @@ xdr_fs_result(XDR *xdrs, fs_result *objp)
bool_t
xdr_fs_request(XDR *xdrs, fs_request *objp)
{
if (!xdr_nis_name(xdrs, &objp->name)) {
if (!_xdr_nis_name(xdrs, &objp->name)) {
return FALSE;
}
if (!xdr_long(xdrs, &objp->old_class)) {
Expand Down
10 changes: 6 additions & 4 deletions nis/nis_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "nis_xdr.h"
#include "nis_intern.h"

static struct timeval RPCTIMEOUT = {10, 0};
Expand Down Expand Up @@ -461,7 +463,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
obj = calloc(1, sizeof(directory_obj));
xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
xdr_directory_obj(&xdrs, obj);
_xdr_directory_obj(&xdrs, obj);
xdr_destroy(&xdrs);
__free_fdresult (fd_res);
if (obj != NULL)
Expand Down Expand Up @@ -525,7 +527,7 @@ rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,
obj = calloc(1, sizeof(directory_obj));
xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
xdr_directory_obj(&xdrs, obj);
_xdr_directory_obj(&xdrs, obj);
xdr_destroy(&xdrs);
__free_fdresult (fd_res);
if (obj != NULL)
Expand Down Expand Up @@ -576,8 +578,8 @@ first_shoot (const_nis_name name, directory_obj *dir, u_long flags)
return NULL;
xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,
fd_res->dir_data.dir_data_len, XDR_DECODE);
xdr_directory_obj(&xdrs, obj);
xdr_destroy(&xdrs);
_xdr_directory_obj (&xdrs, obj);
xdr_destroy (&xdrs);
__free_fdresult (fd_res);
if (obj != NULL)
{
Expand Down
67 changes: 18 additions & 49 deletions nis/nis_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,23 @@
#include <arpa/inet.h>
#include <rpc/key_prot.h>
#include <rpcsvc/nis.h>
#include <rpcsvc/nis_callback.h>
#include <bits/libc-lock.h>

#include "nis_xdr.h"
#include "nis_intern.h"

/* Sorry, we are not able to make this threadsafe. Stupid. But some
functions doesn't send us a nis_result obj, so we don't have a
cookie. Maybe we could use keys for threads ? Have to learn more
about pthreads -- [email protected] */

#define CB_PROG ((u_long)100302)
#define CB_VERS ((u_long)1)
#define CBPROC_RECEIVE ((u_long)1)
#define CBPROC_FINISH ((u_long)2)
#define CBPROC_ERROR ((u_long)3)

typedef nis_object *obj_p;

struct cback_data
{
struct
{
u_int entries_len;
obj_p *entries_val;
}
entries;
};
typedef struct cback_data cback_data;

static nis_cb *data;

__libc_lock_define_initialized (static, callback)


#if 0
static char *
__nis_getpkey(const char *sname)
{
Expand Down Expand Up @@ -91,7 +75,7 @@ __nis_getpkey(const char *sname)
if (res == NULL)
return NULL;

if (res->status != NIS_SUCCESS)
if (NIS_RES_STATUS (res) != NIS_SUCCESS)
{
nis_freeresult (res);
return NULL;
Expand All @@ -108,9 +92,7 @@ __nis_getpkey(const char *sname)

return strdup (pkey);
}


static bool_t xdr_cback_data (XDR *, cback_data *);
#endif

static void
cb_prog_1 (struct svc_req *rqstp, SVCXPRT *transp)
Expand Down Expand Up @@ -181,7 +163,7 @@ cb_prog_1 (struct svc_req *rqstp, SVCXPRT *transp)
result = (char *) &bool_result;
break;
case CBPROC_ERROR:
xdr_argument = (xdrproc_t) xdr_nis_error;
xdr_argument = (xdrproc_t) _xdr_nis_error;
xdr_result = (xdrproc_t) xdr_void;
memset (&argument, 0, sizeof (argument));
if (!svc_getargs (transp, xdr_argument, (caddr_t) & argument))
Expand All @@ -208,25 +190,6 @@ cb_prog_1 (struct svc_req *rqstp, SVCXPRT *transp)
return;
}

static bool_t
xdr_obj_p (XDR * xdrs, obj_p *objp)
{
if (!xdr_pointer (xdrs, (char **) objp, sizeof (nis_object),
(xdrproc_t) xdr_nis_object))
return FALSE;
return TRUE;
}

static bool_t
xdr_cback_data (XDR *xdrs, cback_data *objp)
{
if (!xdr_array (xdrs, (char **) &objp->entries.entries_val,
(u_int *) & objp->entries.entries_len, ~0, sizeof (obj_p),
(xdrproc_t) xdr_obj_p))
return FALSE;
return TRUE;
}

static nis_error
internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
struct nis_cb *cb)
Expand Down Expand Up @@ -319,7 +282,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
{
free (cb);
syslog (LOG_ERR, "NIS+: out of memory allocating callback");
return (NULL);
return NULL;
}
cb->serv->name = strdup (nis_local_principal ());
cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint));
Expand All @@ -328,14 +291,15 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
cb->callback = callback;
cb->userdata = userdata;

if ((flags & NO_AUTHINFO) && key_secretkey_is_set ())
if ((flags & NO_AUTHINFO) || !key_secretkey_is_set ())
{
cb->serv->key_type = NIS_PK_NONE;
cb->serv->pkey.n_bytes = NULL;
cb->serv->pkey.n_len = 0;
}
else
{
#if 0
if ((cb->serv->pkey.n_bytes = __nis_getpkey (cb->serv->name)) == NULL)
{
cb->serv->pkey.n_len = 0;
Expand All @@ -346,6 +310,11 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
cb->serv->key_type = NIS_PK_DH;
cb->serv->pkey.n_len = strlen(cb->serv->pkey.n_bytes);
}
#else
cb->serv->pkey.n_len =0;
cb->serv->pkey.n_bytes = NULL;
cb->serv->key_type = NIS_PK_DH;
#endif
}

if (flags & USE_DGRAM)
Expand All @@ -363,7 +332,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
{
xprt_unregister (cb->xprt);
svc_destroy (cb->xprt);
xdr_free ((xdrproc_t) xdr_nis_server, (char *) cb->serv);
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
free (cb->serv);
free (cb);
syslog (LOG_ERR, "NIS+: failed to register callback dispatcher");
Expand All @@ -374,11 +343,11 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
{
xprt_unregister (cb->xprt);
svc_destroy (cb->xprt);
xdr_free ((xdrproc_t) xdr_nis_server, (char *) cb->serv);
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
free (cb->serv);
free (cb);
syslog (LOG_ERR, "NIS+: failed to read local socket info");
return (NULL);
return NULL;
}
port = sin.sin_port;
get_myaddress (&sin);
Expand All @@ -395,7 +364,7 @@ __nis_destroy_callback (struct nis_cb *cb)
xprt_unregister (cb->xprt);
svc_destroy (cb->xprt);
close (cb->sock);
xdr_free ((xdrproc_t) xdr_nis_server, (char *) cb->serv);
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
free (cb->serv);
free (cb);

Expand Down
Loading

0 comments on commit 91eee4d

Please sign in to comment.