"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/yptest.c" between
yp-tools-4.2.2.tar.gz and yp-tools-4.2.3.tar.gz

About: The yp-tools package contains a collection of NIS(YP) client tools.

yptest.c  (yp-tools-4.2.2):yptest.c  (yp-tools-4.2.3)
/* Copyright (C) 2001, 2002, 2013, 2014 Thorsten Kukuk /* Copyright (C) 2001, 2002, 2013, 2014, 2018 Thorsten Kukuk
This file is part of the yp-tools. This file is part of the yp-tools.
Author: Thorsten Kukuk <kukuk@suse.de> Author: Thorsten Kukuk <kukuk@suse.de>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation. published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 40 skipping to change at line 40
#include <string.h> #include <string.h>
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpcsvc/yp_prot.h> #include <rpcsvc/yp_prot.h>
#include "lib/nicknames.h" #include "lib/nicknames.h"
#include "lib/yp_all_host.h" #include "lib/yp_all_host.h"
#ifndef _ #ifndef _
#define _(String) gettext (String) #define _(String) gettext (String)
#endif #endif
#if !defined(HAVE_YPBIND3)
#define ypbind2_resp ypbind_resp
#define xdr_ypbind2_resp xdr_ypbind_resp
#define ypbind2_error ypbind_respbody.ypbind_error
#define ypbind2_addr ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr
#endif
extern int yp_maplist (const char *, struct ypmaplist **); extern int yp_maplist (const char *, struct ypmaplist **);
static int be_quiet = 0; static int be_quiet = 0;
/* Name and version of program. */ /* Name and version of program. */
/* Print the version information. */ /* Print the version information. */
static void static void
print_version (void) print_version (void)
{ {
fprintf (stdout, "yptest (%s) %s\n", PACKAGE, VERSION); fprintf (stdout, "yptest (%s) %s\n", PACKAGE, VERSION);
skipping to change at line 95 skipping to change at line 102
static void static void
print_error (void) print_error (void)
{ {
const char *program = "yptest"; const char *program = "yptest";
print_usage (stderr); print_usage (stderr);
fprintf (stderr, fprintf (stderr,
_("Try `%s --help' or `%s --usage' for more information.\n"), _("Try `%s --help' or `%s --usage' for more information.\n"),
program, program); program, program);
} }
#if defined(HAVE_YPBIND3)
static void static void
dump_nconf (struct netconfig *nconf, char *prefix) dump_nconf (struct netconfig *nconf, char *prefix)
{ {
printf ("%snc_netid: %s\n", prefix, nconf->nc_netid); printf ("%snc_netid: %s\n", prefix, nconf->nc_netid);
printf ("%snc_semantics: %lu\n", prefix, nconf->nc_semantics); printf ("%snc_semantics: %lu\n", prefix, nconf->nc_semantics);
printf ("%snc_flag: %lu\n", prefix, nconf->nc_flag); printf ("%snc_flag: %lu\n", prefix, nconf->nc_flag);
printf ("%snc_protofmly: '%s'\n", prefix, nconf->nc_protofmly); printf ("%snc_protofmly: '%s'\n", prefix, nconf->nc_protofmly);
printf ("%snc_proto: '%s'\n", prefix, nconf->nc_proto); printf ("%snc_proto: '%s'\n", prefix, nconf->nc_proto);
printf ("%snc_device: '%s'\n", prefix, nconf->nc_device); printf ("%snc_device: '%s'\n", prefix, nconf->nc_device);
printf ("%snc_nlookups: %lu\n", prefix, nconf->nc_nlookups); printf ("%snc_nlookups: %lu\n", prefix, nconf->nc_nlookups);
skipping to change at line 131 skipping to change at line 140
taddr2port (ypb3->ypbind_nconf, ypb3->ypbind_svcaddr)); taddr2port (ypb3->ypbind_nconf, ypb3->ypbind_svcaddr));
printf ("ypbind_servername: "); printf ("ypbind_servername: ");
if (ypb3->ypbind_servername) if (ypb3->ypbind_servername)
printf ("%s\n", ypb3->ypbind_servername); printf ("%s\n", ypb3->ypbind_servername);
else else
printf ("NULL\n"); printf ("NULL\n");
printf ("ypbind_hi_vers: %lu\n", (u_long) ypb3->ypbind_hi_vers); printf ("ypbind_hi_vers: %lu\n", (u_long) ypb3->ypbind_hi_vers);
printf ("ypbind_lo_vers: %lu\n", (u_long) ypb3->ypbind_lo_vers); printf ("ypbind_lo_vers: %lu\n", (u_long) ypb3->ypbind_lo_vers);
} }
#endif
/* bind to a special host and print the name ypbind running on this host /* bind to a special host and print the name ypbind running on this host
is bound to */ is bound to */
static int static int
print_bindhost (const char *domain, const char *hostname, int vers) print_bindhost (const char *domain, const char *hostname, int vers)
{ {
struct ypbind2_resp yp_r2; struct ypbind2_resp yp_r2;
#if defined(HAVE_YPBIND3)
struct ypbind3_resp yp_r3; struct ypbind3_resp yp_r3;
#endif
struct timeval tv; struct timeval tv;
CLIENT *client; CLIENT *client;
int ret; int ret;
if (!hostname) if (!hostname)
hostname = "localhost"; hostname = "localhost";
tv.tv_sec = 5; tv.tv_sec = 5;
tv.tv_usec = 0; tv.tv_usec = 0;
client = clnt_create (hostname, YPBINDPROG, vers, "udp"); client = clnt_create (hostname, YPBINDPROG, vers, "udp");
if (client == NULL) if (client == NULL)
{ {
if (!be_quiet) if (!be_quiet)
fprintf (stderr, "%s\n", yperr_string (YPERR_YPBIND)); fprintf (stderr, "%s\n", yperr_string (YPERR_YPBIND));
return 1; return 1;
} }
memset (&yp_r2, 0, sizeof (yp_r2)); memset (&yp_r2, 0, sizeof (yp_r2));
#if defined(HAVE_YPBIND3)
memset (&yp_r3, 0, sizeof (yp_r3)); memset (&yp_r3, 0, sizeof (yp_r3));
#endif
tv.tv_sec = 15; tv.tv_sec = 15;
tv.tv_usec = 0; tv.tv_usec = 0;
#if defined(HAVE_YPBIND3)
if (vers == 1 || vers == 2) if (vers == 1 || vers == 2)
#endif
ret = clnt_call (client, YPBINDPROC_DOMAIN, (xdrproc_t) xdr_domainname, ret = clnt_call (client, YPBINDPROC_DOMAIN, (xdrproc_t) xdr_domainname,
(caddr_t) &domain, (xdrproc_t) xdr_ypbind2_resp, (caddr_t) &domain, (xdrproc_t) xdr_ypbind2_resp,
(caddr_t) &yp_r2, tv); (caddr_t) &yp_r2, tv);
#if defined(HAVE_YPBIND3)
else else
ret = clnt_call (client, YPBINDPROC_DOMAIN, (xdrproc_t) xdr_domainname, ret = clnt_call (client, YPBINDPROC_DOMAIN, (xdrproc_t) xdr_domainname,
(caddr_t) &domain, (xdrproc_t) xdr_ypbind3_resp, (caddr_t) &domain, (xdrproc_t) xdr_ypbind3_resp,
(caddr_t) &yp_r3, tv); (caddr_t) &yp_r3, tv);
#endif
if (ret != RPC_SUCCESS) if (ret != RPC_SUCCESS)
{ {
if (!be_quiet) if (!be_quiet)
fprintf (stderr, "%s\n", yperr_string (YPERR_YPBIND)); fprintf (stderr, "%s\n", yperr_string (YPERR_YPBIND));
clnt_destroy (client); clnt_destroy (client);
return 1; return 1;
} }
else else
{ {
skipping to change at line 192 skipping to change at line 211
if (!be_quiet) if (!be_quiet)
fprintf (stderr, _("can't yp_bind: Reason: %s\n"), fprintf (stderr, _("can't yp_bind: Reason: %s\n"),
ypbinderr_string (yp_r2.ypbind2_error)); ypbinderr_string (yp_r2.ypbind2_error));
clnt_destroy (client); clnt_destroy (client);
return 1; return 1;
} }
if (!be_quiet) if (!be_quiet)
printf (_("Used NIS server: %s\n"), inet_ntoa (yp_r2.ypbind2_addr)); printf (_("Used NIS server: %s\n"), inet_ntoa (yp_r2.ypbind2_addr));
} }
#if defined(HAVE_YPBIND3)
else else
{ {
if (yp_r3.ypbind_status != YPBIND_SUCC_VAL) if (yp_r3.ypbind_status != YPBIND_SUCC_VAL)
{ {
if (!be_quiet) if (!be_quiet)
fprintf (stderr, _("can't yp_bind: Reason: %s\n"), fprintf (stderr, _("can't yp_bind: Reason: %s\n"),
ypbinderr_string (yp_r3.ypbind3_error)); ypbinderr_string (yp_r3.ypbind3_error));
clnt_destroy (client); clnt_destroy (client);
return 1; return 1;
} }
if (!be_quiet) if (!be_quiet)
ypbind3_binding_dump (yp_r3.ypbind3_bindinfo); ypbind3_binding_dump (yp_r3.ypbind3_bindinfo);
} }
#endif
} }
clnt_destroy (client); clnt_destroy (client);
return 0; return 0;
} }
static int static int
print_data (int status, char *inkey, int inkeylen, char *inval, print_data (int status, char *inkey, int inkeylen, char *inval,
int invallen, char *indata __attribute__ ((unused))) int invallen, char *indata __attribute__ ((unused)))
{ {
skipping to change at line 352 skipping to change at line 373
printf ("\nTest 2: ypbind\n"); printf ("\nTest 2: ypbind\n");
if (!be_quiet) if (!be_quiet)
printf (_("Use Protocol V1: ")); printf (_("Use Protocol V1: "));
if (print_bindhost (domainname, hostname, 1)) if (print_bindhost (domainname, hostname, 1))
fprintf (stderr, _("ypbind procotcol v1 test failed\n")); fprintf (stderr, _("ypbind procotcol v1 test failed\n"));
if (!be_quiet) if (!be_quiet)
printf (_("Use Protocol V2: ")); printf (_("Use Protocol V2: "));
if (print_bindhost (domainname, hostname, 2)) if (print_bindhost (domainname, hostname, 2))
fprintf (stderr, _("ypbind procotcol v2 test failed\n")); fprintf (stderr, _("ypbind procotcol v2 test failed\n"));
#if defined(HAVE_YPBIND3)
if (!be_quiet) if (!be_quiet)
printf (_("Use Protocol V3:\n")); printf (_("Use Protocol V3:\n"));
if (print_bindhost (domainname, hostname, 3)) if (print_bindhost (domainname, hostname, 3))
fprintf (stderr, _("ypbind procotcol v3 test failed\n")); fprintf (stderr, _("ypbind procotcol v3 test failed\n"));
#endif
if (!be_quiet) if (!be_quiet)
printf ("\nTest 3: yp_match\n"); printf ("\nTest 3: yp_match\n");
KeyLen = strlen (key); KeyLen = strlen (key);
status = yp_match (domainname, map, key, KeyLen, &Value, &ValLen); status = yp_match (domainname, map, key, KeyLen, &Value, &ValLen);
switch (status) switch (status)
{ {
case YPERR_SUCCESS: case YPERR_SUCCESS:
if (!be_quiet) if (!be_quiet)
printf("%*.*s\n", ValLen, ValLen, Value); printf("%*.*s\n", ValLen, ValLen, Value);
 End of changes. 16 change blocks. 
1 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)