Give ypxfr the ability to detect the presence of the YP_INTERDOMAIN

and YP_SECURE flags so that it can properly add them to newly created
maps when needed. This applies only when using the 'standard' method
for map transfers. When using rpc.ypxfrd, the whole map is copied
verbatim, along with any special entries that may be encoded in it.

Also made -Wall a little quieter for ypxfrd_getmap.c.
This commit is contained in:
Bill Paul 1996-10-25 16:13:09 +00:00
parent 9ef7d39520
commit 81a82d4dfd
4 changed files with 91 additions and 7 deletions

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ypxfr_extern.h,v 1.7 1996/06/03 03:10:42 wpaul Exp $
* $Id: ypxfr_extern.h,v 1.7 1996/06/03 03:10:42 wpaul Exp wpaul $
*/
#include <sys/types.h>
#include <limits.h>
@ -56,6 +56,7 @@ extern int yp_get_record __P(( const char *, const char *, const DBT *, DBT *, i
extern int ypxfr_get_map __P(( char *, char *, char *, int (*)() ));
extern char *ypxfr_get_master __P(( char *, char *, char *, const int ));
extern unsigned long ypxfr_get_order __P(( char *, char *, char *, const int ));
extern int ypxfr_match __P(( char *, char *, char *, char *, unsigned long ));
extern char *ypxfxerr_string __P(( ypxfrstat ));
extern int ypxfrd_get_map __P(( char *, char *, char *, char *));
extern int callrpc __P(( char *, int, int, int, xdrproc_t, char *, xdrproc_t, char *));

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ypxfr_main.c,v 1.18 1996/10/20 19:44:45 wpaul Exp $
* $Id: ypxfr_main.c,v 1.19 1996/10/25 15:58:15 wpaul Exp $
*/
#include <stdio.h>
#include <stdlib.h>
@ -51,7 +51,7 @@ struct dom_binding {};
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: ypxfr_main.c,v 1.18 1996/10/20 19:44:45 wpaul Exp $";
static const char rcsid[] = "$Id: ypxfr_main.c,v 1.19 1996/10/25 15:58:15 wpaul Exp $";
#endif
char *progname = "ypxfr";
@ -163,6 +163,8 @@ main(argc,argv)
char buf[MAXPATHLEN + 2];
DBT key, data;
int remoteport;
int interdom = 0;
int secure = 0;
debug = 1;
@ -352,6 +354,14 @@ the local domain name isn't set");
ypxfr_exit(YPXFR_YPERR,NULL);
}
if (ypxfr_match(ypxfr_master, ypxfr_source_domain, ypxfr_mapname,
"YP_INTERDOMAIN", sizeof("YP_INTERDOMAIN") - 1))
interdom++;
if (ypxfr_match(ypxfr_master, ypxfr_source_domain, ypxfr_mapname,
"YP_SECURE", sizeof("YP_SECURE") - 1))
secure++;
key.data = "YP_LAST_MODIFIED";
key.size = sizeof("YP_LAST_MODIFIED") - 1;
@ -469,6 +479,30 @@ the local domain name isn't set");
ypxfr_exit(YPXFR_DBM,&ypxfr_temp_map);
}
if (interdom) {
key.data = "YP_INTERDOMAIN";
key.size = sizeof("YP_INTERDOMAIN") - 1;
data.data = "";
data.size = 0;
if (yp_put_record(dbp, &key, &data, 0) != YP_TRUE) {
yp_error("failed to add interdomain flag to database");
ypxfr_exit(YPXFR_DBM,&ypxfr_temp_map);
}
}
if (secure) {
key.data = "YP_SECURE";
key.size = sizeof("YP_SECURE") - 1;
data.data = "";
data.size = 0;
if (yp_put_record(dbp, &key, &data, 0) != YP_TRUE) {
yp_error("failed to add secure flag to database");
ypxfr_exit(YPXFR_DBM,&ypxfr_temp_map);
}
}
/* Now suck over the contents of the map from the master. */
if (ypxfr_get_map(ypxfr_mapname,ypxfr_source_domain,

View File

@ -29,8 +29,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ypxfr_misc.c,v 1.8 1996/06/02 05:12:00 wpaul Exp $
* $Id: ypxfr_misc.c,v 1.9 1996/10/25 15:58:15 wpaul Exp $
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/param.h>
@ -41,7 +43,7 @@ struct dom_binding {};
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: ypxfr_misc.c,v 1.8 1996/06/02 05:12:00 wpaul Exp $";
static const char rcsid[] = "$Id: ypxfr_misc.c,v 1.9 1996/10/25 15:58:15 wpaul Exp $";
#endif
char *ypxfrerr_string(code)
@ -257,3 +259,47 @@ failed"));
return(resp->ordernum);
}
}
int ypxfr_match(server, domain, map, key, keylen)
char *server;
char *domain;
char *map;
char *key;
unsigned long keylen;
{
ypreq_key ypkey;
ypresp_val *ypval;
CLIENT *clnt;
static char buf[YPMAXRECORD + 2];
bzero((char *)buf, sizeof(buf));
if ((clnt = clnt_create(server, YPPROG,YPVERS,"udp")) == NULL) {
yp_error("failed to create UDP handle: %s",
clnt_spcreateerror(server));
return(0);
}
ypkey.domain = domain;
ypkey.map = map;
ypkey.key.keydat_len = keylen;
ypkey.key.keydat_val = key;
if ((ypval = ypproc_match_2(&ypkey, clnt)) == NULL) {
clnt_destroy(clnt);
yp_error("%s: %s", server,
clnt_sperror(clnt,"YPPROC_MATCH failed"));
return(0);
}
clnt_destroy(clnt);
if (ypval->stat != YP_TRUE) {
xdr_free(xdr_ypresp_val, (char *)ypval);
return(0);
}
xdr_free(xdr_ypresp_val, (char *)ypval);
return(1);
}

View File

@ -29,9 +29,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ypxfrd_getmap.c,v 1.7 1996/06/02 19:51:33 wpaul Exp wpaul $
* $Id: ypxfrd_getmap.c,v 1.9 1996/10/25 15:58:15 wpaul Exp $
*/
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <rpcsvc/ypxfrd.h>
@ -44,7 +47,7 @@
#include "ypxfr_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: ypxfrd_getmap.c,v 1.7 1996/06/02 19:51:33 wpaul Exp wpaul $";
static const char rcsid[] = "$Id: ypxfrd_getmap.c,v 1.9 1996/10/25 15:58:15 wpaul Exp $";
#endif
int fp = 0;