diff -u -r --new-file ypserv-1.3.1/BUGS ypserv-1.3.2/BUGS --- ypserv-1.3.1/BUGS Thu Jan 1 01:00:00 1970 +++ ypserv-1.3.2/BUGS Fri May 29 16:55:16 1998 @@ -0,0 +1,3 @@ + +Please look at the TODO file for bugs and things to do. + diff -u -r --new-file ypserv-1.3.1/BUILD ypserv-1.3.2/BUILD --- ypserv-1.3.1/BUILD Sun Dec 21 19:19:32 1997 +++ ypserv-1.3.2/BUILD Sun Jun 7 10:36:34 1998 @@ -4,7 +4,7 @@ # # Author: Thorsten Kukuk # -# $Id: BUILD,v 1.7 1997/12/21 18:19:32 kukuk Exp $ +# $Id: BUILD,v 1.8 1998/06/07 08:36:34 kukuk Exp $ if [ ! "$arch" -a ! "$os" -a ! "$rel" ] then @@ -24,7 +24,7 @@ cd $arch.$os-$rel -../configure --enable-checkroot --disable-yppasswd +../configure --enable-fqdn --disable-yppasswd if make then diff -u -r --new-file ypserv-1.3.1/ChangeLog ypserv-1.3.2/ChangeLog --- ypserv-1.3.1/ChangeLog Tue Apr 7 19:43:26 1998 +++ ypserv-1.3.2/ChangeLog Sun Jun 7 14:27:28 1998 @@ -1,10 +1,38 @@ +1998-06-07 Thorsten Kukuk + + * release version 1.3.2 + + * ypMakefile.in: Add some of the RedHat 5.1 changes. + + * configure.in: Enable check for root passwords by default. + + * README: Add some comments about ndbm/db and gdbm. + + * README.secure: Add some comments about tcp-wrappers. + + * INSTALL: Add comment for --with-ndbm option. + + * server.c: Rewrite database handling. + + * yp_db.c: Make it faster, and fix ndbm support. + +1998-05-28 Bernd Rinn + + * ypmake/ypmake.in (openout): Add -c to makedbm call. + * ypmake/automount.in: reset master and keys for new maps. + +1998-05-29 Thorsten Kukuk + + * ypMakefile.in: Move some more defines in the "Don't edit !" + section. + 1998-04-07 Thorsten Kukuk * release version 1.3.1 1998-04-06 Thorsten Kukuk - * ypxfr.c (ypxfr_foreach): If we keylen/vallen include + * ypxfr.c (ypxfr_foreach): If keylen/vallen include the trailing 0, decrement it. 1998-04-01 Thorsten Kukuk diff -u -r --new-file ypserv-1.3.1/INSTALL ypserv-1.3.2/INSTALL --- ypserv-1.3.1/INSTALL Sun May 11 12:05:10 1997 +++ ypserv-1.3.2/INSTALL Sun Jun 7 10:34:46 1998 @@ -8,13 +8,21 @@ Normally, you only need the following: --with-gdbm-dir=BASE-DIR : - If your system do not have the gdbm library in /lib, /usr/lib + If your system do not have the GDBM library in /lib, /usr/lib or /usr/local/lib, and the header files in a usually place, you could tell the linker where to find the library and header files. On our Sun's, the libgdbm.a is installed under /usr/local/gnu/gdbm/[lib|include], so the option is: --with-gdbm-dir=/usr/local/gnu/gdbm + --with-ndbm=[yes|no] : + If you doesn't have the GDBM library installed, or wishes to + use libdb in ndbm compat mode, use this option. It was primarly + for Solaris, which has ndbm support. + + PLEASE read the README file for more information and problems + with this !! + --enable-tcp-wrapper[=BASE-DIR] : By default, ypserv will look in the /var/yp/securenets file, if a host is allow to connect to the server. The tcp wrapper lib @@ -24,18 +32,28 @@ For more information, look at the README.secure file. + THIS OPTION WILL NOT BE SUPPORTED ANY LONGER FROM ME !! + --enable-yppasswd : Compile and install the yppasswd client. By default, this program will be not installed. --enable-ypmake : ypmake is a perl script, which creates the maps faster for smaller - sites. + sites. By default, it will not be installed. --enable-checkroot : Allow root to change NIS passwords with yppasswd for normal users. At first, the old password will be checked against the old user - password, then against the root password. + password, then against the root password. This is by default + enabled. + + --enable-fqdn : + With this option, all hostnames will be checked against DNS. + You need this, if your servers are in different DNS domains, + but in the same NIS domain. The communication between the + NIS server will be a little bit slower. The communication + with the clients is not affected from this. 2. Edit the "Makefile" to suit your needs. @@ -53,17 +71,26 @@ create the /var/yp/securenets file. If not, everybod on the world could connect to your server, if he knows the NIS domainname. - 7. Possible modify /var/yp/Makefile to suit your setup. + DON'T USE THE setenv OPTION IN THIS CONFIGURATION FILES ! + + 7. Make sure your domainname is set ! /bin/domainname shouldn't + return an empty string or "(none)". If, you have real problems + or forget to set the domainname. After setting the domainname, + make sure it will be set on the next boot again, and reboot ! + + 8. Possible modify /var/yp/Makefile to suit your setup. Remove/add + all maps to the all: line, which should be build and distributed + by your NIS server. - 8. If you will use "ypmake", copy /var/yp/ypmake.conf.sample + 9. If you will use "ypmake", copy /var/yp/ypmake.conf.sample to /var/yp//ypmake.conf and modify it for your system. - 9. If you only have one ypserv server in your domain, do: + 10. If you only have one ypserv server in your domain, do: cd /var/yp; make or call ypmake This will create the maps. - 10 If you have more then one ypserv server in your domain (you should + 11. If you have more then one ypserv server in your domain (you should have one for every subnet), run "/usr/lib/yp/ypinit -m" on the master host. ypinit will ask some Questions and create all neccessary maps. You must comment out the NOPUSH = "True" line @@ -76,7 +103,7 @@ to find the maps, install ypwhich from the ypwhich-nys directory. This ypwhich will not work with GNU libc ! - 11. If you have slave NYS server, you should start rpc.ypxfrd on the + 12. If you have slave NIS server, you should start rpc.ypxfrd on the master host. You don't need rpc.ypxfrd on any slave server. You could start rpc.ypxfrd from a /etc/rc* script or by inetd. For the last, you have to add: @@ -91,10 +118,10 @@ ypxfrd needs a lot of time by starting from inetd, you should start it by a /etc/rc* script. - 12. On bootup, start ypserv from a /etc/rc* script. If this server is a + 13. On bootup, start ypserv from a /etc/rc* script. If this server is a master or the only one, you have to start rpc.yppasswdd, too. - 13. If your users are allowed to change the shell, add -e chsh to + 14. If your users are allowed to change the shell, add -e chsh to rpc.yppasswdd as parameter. For changing the GECOS field, add -e chfn. diff -u -r --new-file ypserv-1.3.1/NEWS ypserv-1.3.2/NEWS --- ypserv-1.3.1/NEWS Tue Apr 7 19:47:45 1998 +++ ypserv-1.3.2/NEWS Sun Jun 7 10:43:51 1998 @@ -6,66 +6,46 @@ . -Version 1.3.1 +Version 1.3.2 +* Upate documentation +* Fix NDBM support +Version 1.3.1 * Bugfixes - Version 1.3.0 - * Support for ndbm (SunOS 4.x/5.x) (Not complete) - * Add FQDN support (configure --enable-fqdn). All hostnames will go through gethostbyname to determine the offical hostname - * Add YP V1 protocol - Version 1.2.8 - * Bugfixes - Version 1.2.7 - * Bugfixes - Version 1.2.6 - * pwupdate and makedbm man pages - * Remove tryresolve, hacker could stop ypserv with it - Version 1.2.5 - * Add patches from SuSE distribution - Version 1.2.4 - * yppasswd and rpc.yppasswdd bugfixes Version 1.2.3 - * Fix _dns_gethostbyname problem with Linux/libc5 - Version 1.2.2 - * rpc.yppasswdd bugfixes - * ypMakefile improvements - Version 1.2.1 - * Fix ypserv DB file caching - * A lot of rpc.yppasswdd bugfixes - Version 1.2.0 - * Cache the DB file handles + diff -u -r --new-file ypserv-1.3.1/README ypserv-1.3.2/README --- ypserv-1.3.1/README Fri Mar 6 21:18:58 1998 +++ ypserv-1.3.2/README Sun Jun 7 10:18:21 1998 @@ -1,5 +1,5 @@ -This is version 1.3.0 of an YP (NIS version 2) Server for Linux, but it +This is version 1.3.2 of an YP (NIS version 2) Server for Linux, but it also runs under other OS like SunOS 4.1.x, Solaris 2.x, AIX, HP-UX, IRIS, Ultrix and OSF1 (alpha). @@ -19,8 +19,13 @@ The old site's will not be updated any longer from me. This version has support for the ndbm database from Sun and the -db ndbm emulation. It isn't completly tested, and there are still -a lot of known bugs. Be careful with it. +db ndbm emulation. gdbm is about 3 times faster for most YP +functions, except yp_first/yp_next. gdbm has a runtime from O(n) +for viewing all entries with this, ndbm/db has a runtime from O(n*n) ! +Very bad for big maps and initgroups, initgroups will need about 22 +minutes for a group file with 10.000 entries and ndbm/db, with gdbm, +only 20 seconds. The load of the server is the same, but gdbm +needs much more memory for caching. I have the rpc.yppasswdd daemon included. This version based on the yppasswd 0.9 from Olaf Kirch. I have rewritten the update routine for @@ -58,4 +63,4 @@ Thanks to Terje Malmedal , who had send patches for AIX, HP-UX, IRIX, Ultrix and OSF1(alpha). -Thorsten Kukuk , 6. March 1998 +Thorsten Kukuk , 7. June 1998 diff -u -r --new-file ypserv-1.3.1/README.secure ypserv-1.3.2/README.secure --- ypserv-1.3.1/README.secure Tue Nov 19 19:57:52 1996 +++ ypserv-1.3.2/README.secure Sat Jun 6 19:04:20 1998 @@ -3,30 +3,30 @@ look like: # allow connections from local host -- necessary -255.255.255.255 127.0.0.1 +255.255.255.255 127.0.0.1 # allow connections from any host # on the 131.234.223.0 network -255.255.255.0 131.234.223.0 +255.255.255.0 131.234.223.0 # allow connections from any host # between 131.234.214.0 to 131.234.215.255 -255.255.254.0 131.234.214.0 +255.255.254.0 131.234.214.0 -An expression of the form `m.m.m.m n.n.n.n' is interpreted as a -`netmask network' pair. A host address is matched if `network' is equal -to the bitwise AND of the address and the `netmask'. If you doesen't -have such a file or the file is empty, and you don't enable the tcp +An expression of the form `m.m.m.m n.n.n.n' is interpreted as a +`netmask network' pair. A host address is matched if `network' is equal +to the bitwise AND of the address and the `netmask'. If you doesen't +have such a file or the file is empty, and you don't enable the tcp wrappers, all hosts in the world could connect to your sever. This -file uses the same notation as the SunOS/Solaris ypserv. FreeBSD ypserv +file uses the same notation as the SunOS/Solaris ypserv. FreeBSD ypserv use a different notation, be carefull with copying this file. If you enable the tcp wrappers security lookups in the Makefile, then the server `ypserv' will use your /etc/hosts.allow and /etc/hosts.deny files -(which most people already have) and not the /var/yp/securenets. You must -have the library libwrap.a and log_tcp.h from the tcp_wrappers source +(which most people already have) and not the /var/yp/securenets. You must +have the library libwrap.a and log_tcp.h from the tcp_wrappers source distribution. I used version 7.4 of the wrappers. -You can enable the tcp wrappers with the configure option: +You can enable the tcp wrappers with the configure option: configure --enable-tcp-wrapper[=BASE-DIR], where BASE-DIR is an optional parameter and includes the path to the library and the includefiles. @@ -51,3 +51,15 @@ ypserv: ALL +WARNING: the tcp_wrappers have some well known, but not documented memory +leaks with some configurations. For example, the setenv option uses the +setenv() functions. The author has the opinion, that it is enough if the +memory leaks of C functions are documented in the manual pages of this +C functions. But no user knows, which C functions are called with which +configuration option. I don't agree with the opinion of the author, and +with ypserv running on a big system, you will call setenv() very often. +This causes a very, very big memory hole. Since the tcp_wrappers make +some more problems for a lot of people, I will not support them any longer. +I will leave the code in, as long as it works. + + Thorsten Kukuk, 6. June 1998 diff -u -r --new-file ypserv-1.3.1/TODO ypserv-1.3.2/TODO --- ypserv-1.3.1/TODO Sun Mar 29 15:51:29 1998 +++ ypserv-1.3.2/TODO Sun Jun 7 12:37:29 1998 @@ -5,10 +5,7 @@ o Change ypinit -s, so that ypwhich isn't needed o Make yppasswd and rpc.yppasswdd PAM aware (for choosing better - passwords) + passwords) or add cracklib - o Make sure there are no memory leaks + o ypmaplist needs to be fixed for Sun's NDBM - o yp_all doesn't work with NDBM - - o Remove all remaining bugs :-) diff -u -r --new-file ypserv-1.3.1/configure ypserv-1.3.2/configure --- ypserv-1.3.1/configure Fri Feb 27 19:57:20 1998 +++ ypserv-1.3.2/configure Sun Jun 7 10:06:05 1998 @@ -17,7 +17,7 @@ ac_help="$ac_help --enable-yppasswd Install yppasswd [default=no]" ac_help="$ac_help - --enable-checkroot Allow root to change passwords [default=no]" + --disable-checkroot Disable check for root password [default=yes]" ac_help="$ac_help --enable-ypmake Install and use ypmake [default=no]" ac_help="$ac_help @@ -25,7 +25,7 @@ ac_help="$ac_help --with-gdbm-dir=BASE-DIR Specifies the base gdbm directory" ac_help="$ac_help - --with-ndbm=[yes|no] Use ndbm instead of gdbm" + --with-ndbm=[yes|no] Use ndbm instead of gdbm" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -1197,7 +1197,7 @@ enableval="$enable_checkroot" CHECKROOT=$enableval else - CHECKROOT=no + CHECKROOT=yes fi diff -u -r --new-file ypserv-1.3.1/configure.in ypserv-1.3.2/configure.in --- ypserv-1.3.1/configure.in Fri Mar 6 21:01:11 1998 +++ ypserv-1.3.2/configure.in Sun Jun 7 10:36:38 1998 @@ -1,7 +1,7 @@ # # Copyright (C) 1997, 1998 Thorsten Kukuk # -# $Id: configure.in,v 1.23 1998/03/06 20:01:11 kukuk Exp $ +# $Id: configure.in,v 1.24 1998/06/07 08:36:38 kukuk Exp $ # dnl Process this file with autoconf to produce a configure script. AC_INIT(server.c) @@ -100,10 +100,10 @@ YPWDCLIENT=$enableval, YPWDCLIENT=no) AC_SUBST(YPWDCLIENT) -dnl Should we allow root to change a password with yppasswd ? default: no +dnl Should we allow root to change a password with yppasswd ? default: yes AC_ARG_ENABLE(checkroot, - [ --enable-checkroot Allow root to change passwords [default=no]], - CHECKROOT=$enableval, CHECKROOT=no) + [ --disable-checkroot Disable check for root password [default=yes]], + CHECKROOT=$enableval, CHECKROOT=yes) AC_SUBST(CHECKROOT) dnl Should we install ypmake? default no @@ -147,7 +147,7 @@ ) AC_ARG_WITH(ndbm, - [ --with-ndbm=[yes|no] Use ndbm instead of gdbm], + [ --with-ndbm=[yes|no] Use ndbm instead of gdbm], if test x$libdb_parameter != xno then AC_MSG_WARN(You could specify only one database!) diff -u -r --new-file ypserv-1.3.1/server.c ypserv-1.3.2/server.c --- ypserv-1.3.1/server.c Fri Mar 6 21:01:11 1998 +++ ypserv-1.3.2/server.c Sun Jun 7 10:36:39 1998 @@ -26,13 +26,15 @@ */ #ifndef LINT -static const char rcsid[] = "$Id: server.c,v 1.21 1998/03/06 20:01:11 kukuk Exp $"; +static const char rcsid[] = "$Id: server.c,v 1.22 1998/06/07 08:36:39 kukuk Exp $"; #endif #if defined(HAVE_CONFIG_H) #include "config.h" #endif +#define _GNU_SOURCE + #include "system.h" #include @@ -87,6 +89,60 @@ #endif +/* repleace "field" with x, if field 3 != user id and user id != 0 */ +static int +mangle_field (datum * val, int field) +{ + int i, j, k, anz; + char *p; + + /* allocate a little bit more memory, it's safer, because the + field could be empty */ + if ((p = malloc (val->dsize + 3)) == NULL) + { + yp_msg ("ERROR: could not allocate enough memory! [%s|%d]\n", + __FILE__, __LINE__); + return -1; + } + + anz = 0; + for (i = 0; i < val->dsize; i++) + { + if (val->dptr[i] == ':') + anz++; + if (anz + 1 == field) + { + anz = i; + strncpy (p, val->dptr, anz); + p[anz] = 0; + /* if field == 1, we don't need a beginning ":" */ + if (field == 1) + { + strcat (p, "x"); + anz += 1; + } + else + { + strcat (p, ":x"); + anz += 2; + } + for (j = anz; j < val->dsize && val->dptr[j] != ':'; j++); + for (k = j; k < val->dsize; k++) + { + p[anz] = val->dptr[k]; + anz++; + } + free (val->dptr); + val->dptr = p; + val->dsize = anz; + return 0; + } + } + free (p); + return 0; +} + + void * ypproc_null_2_svc (void *dummy, struct svc_req *rqstp) { @@ -204,12 +260,12 @@ ** YP function "MATCH" implementation */ ypresp_val * -ypproc_match_2_svc (ypreq_key * key, struct svc_req *rqstp) +ypproc_match_2_svc (ypreq_key *key, struct svc_req *rqstp) { static ypresp_val result; struct sockaddr_in *rqhost; int valid; - int mangle_field = 0; + int mangle = 0; if (debug_flag) { @@ -228,6 +284,13 @@ key->key.keydat_val); } + result.val.valdat_len = 0; + if (result.val.valdat_val) + { + ypdb_free (result.val.valdat_val); + result.val.valdat_val = NULL; + } + if ((valid = is_valid_host (rqstp, key->map, key->domain)) < 1) { if (valid == 0) @@ -246,14 +309,7 @@ return &result; } else if (valid > 200) - mangle_field = valid - 200; - - result.val.valdat_len = 0; - if (result.val.valdat_val) - { - ypdb_free (result.val.valdat_val); - result.val.valdat_val = NULL; - } + mangle = valid - 200; if (key->domain[0] == '\0' || key->map[0] == '\0' || key->key.keydat_len == 0 || key->key.keydat_val[0] == '\0') @@ -270,14 +326,19 @@ qdat.dsize = key->key.keydat_len; qdat.dptr = key->key.keydat_val; - result.stat = ypdb_read (dbp, &qdat, NULL, &rdat, - F_ALL, mangle_field); + rdat = ypdb_fetch (dbp, qdat); - if (result.stat == YP_TRUE) - { - result.val.valdat_len = rdat.dsize; - result.val.valdat_val = rdat.dptr; - } + if (rdat.dptr != NULL) + { + result.stat = YP_TRUE; + if (mangle) + if (mangle_field (&rdat, mangle) < 0) + result.stat = YP_YPERR; + result.val.valdat_len = rdat.dsize; + result.val.valdat_val = rdat.dptr; + } + else + result.stat = YP_NOKEY; ypdb_close (dbp); } @@ -400,12 +461,12 @@ } ypresp_key_val * -ypproc_first_2_svc (ypreq_nokey * key, struct svc_req * rqstp) +ypproc_first_2_svc (ypreq_nokey *key, struct svc_req *rqstp) { static ypresp_key_val result; struct sockaddr_in *rqhost; int valid; - int mangle_field = 0; + int mangle = 0; if (debug_flag) { @@ -416,11 +477,20 @@ yp_msg ("\tdomainname = \"%s\"\n", key->domain); yp_msg ("\tmapname = \"%s\"\n", key->map); -#if 0 - yp_msg ("\tkeydat = \"%.*s\"\n", - (int) key->key.keydat_len, - key->key.keydat_val); -#endif + } + + result.key.keydat_len = 0; + if (result.key.keydat_val) + { + ypdb_free (result.key.keydat_val); + result.key.keydat_val = NULL; + } + + result.val.valdat_len = 0; + if (result.val.valdat_val) + { + ypdb_free (result.val.valdat_val); + result.val.valdat_val = NULL; } if ((valid = is_valid_host (rqstp, key->map, key->domain)) < 1) @@ -440,44 +510,46 @@ return &result; } else if (valid > 200) - mangle_field = valid - 200; - - result.key.keydat_len = 0; - if (result.key.keydat_val) - { - ypdb_free (result.key.keydat_val); - result.key.keydat_val = NULL; - } - - result.val.valdat_len = 0; - if (result.val.valdat_val) - { - ypdb_free (result.val.valdat_val); - result.val.valdat_val = NULL; - } + mangle = valid - 200; if (key->map[0] == '\0' || key->domain[0] == '\0') result.stat = YP_BADARGS; else { - datum dkey, dval; - DB_FILE dbp = ypdb_open (key->domain, key->map); if (dbp == NULL) - result.stat = YP_NOMAP; + result.stat = YP_NOMAP; else - { - result.stat = ypdb_read (dbp, NULL, &dkey, &dval, 0, mangle_field); + { + datum dkey = ypdb_firstkey (dbp); + while (dkey.dptr != NULL && strncmp (dkey.dptr, "YP_", 3) == 0) + { +#if defined(HAVE_NDBM) /* This is much more faster then ypdb_nextkey, but + it is terrible to port to other databases */ + dkey = dbm_nextkey (dbp); +#else + datum tkey = dkey; + dkey = ypdb_nextkey (dbp, tkey); + ypdb_free (tkey.dptr); +#endif + } - if (result.stat == YP_TRUE) + if (dkey.dptr != NULL) { + datum dval = ypdb_fetch (dbp, dkey); + result.stat = YP_TRUE; + if (mangle) + if (mangle_field (&dval, mangle) < 0) + result.stat = YP_YPERR; + result.key.keydat_len = dkey.dsize; result.key.keydat_val = dkey.dptr; result.val.valdat_len = dval.dsize; result.val.valdat_val = dval.dptr; } - + else + result.stat = YP_NOKEY; ypdb_close (dbp); } } @@ -501,12 +573,12 @@ } ypresp_key_val * -ypproc_next_2_svc (ypreq_key * key, struct svc_req * rqstp) +ypproc_next_2_svc (ypreq_key *key, struct svc_req *rqstp) { static ypresp_key_val result; struct sockaddr_in *rqhost; int valid; - int mangle_field = 0; + int mangle = 0; if (debug_flag) { @@ -523,6 +595,20 @@ key->key.keydat_val); } + result.key.keydat_len = 0; + if (result.key.keydat_val) + { + ypdb_free (result.key.keydat_val); + result.key.keydat_val = NULL; + } + + result.val.valdat_len = 0; + if (result.val.valdat_val) + { + ypdb_free (result.val.valdat_val); + result.val.valdat_val = NULL; + } + if ((valid = is_valid_host (rqstp, key->map, key->domain)) < 1) { if (valid == 0) @@ -540,21 +626,7 @@ return &result; } else if (valid > 200) - mangle_field = valid - 200; - - result.key.keydat_len = 0; - if (result.key.keydat_val) - { - ypdb_free (result.key.keydat_val); - result.key.keydat_val = NULL; - } - - result.val.valdat_len = 0; - if (result.val.valdat_val) - { - ypdb_free (result.val.valdat_val); - result.val.valdat_val = NULL; - } + mangle = valid - 200; if (key->map[0] == '\0' || key->domain[0] == '\0') result.stat = YP_BADARGS; @@ -562,41 +634,47 @@ result.stat = YP_NODOM; else { - datum dkey, dval, okey; - DB_FILE dbp = ypdb_open (key->domain, key->map); if (dbp == NULL) - result.stat = YP_NOMAP; + result.stat = YP_NOMAP; else - { - dkey.dsize = key->key.keydat_len; - dkey.dptr = key->key.keydat_val; + { + datum oldkey, dkey; - result.stat = ypdb_read (dbp, &dkey, &okey, &dval, - F_NEXT, mangle_field); - /* - ** If the key is empty, get the next one, until we - ** get a key which is not empty - */ - while ((okey.dsize == 0) && (result.stat == YP_TRUE)) - { - dkey.dsize = okey.dsize; - dkey.dptr = okey.dptr; + oldkey.dsize = key->key.keydat_len; + oldkey.dptr = strndup (key->key.keydat_val, oldkey.dsize); - result.stat = ypdb_read (dbp, &dkey, &okey, &dval, - F_NEXT, mangle_field); + dkey = ypdb_nextkey (dbp, oldkey); + while (dkey.dptr != NULL && strncmp (dkey.dptr, "YP_", 3) == 0) + { + free (oldkey.dptr); + oldkey.dsize = dkey.dsize; + oldkey.dptr = strndup (dkey.dptr, dkey.dsize); + ypdb_free (dkey.dptr); + dkey = ypdb_nextkey (dbp, oldkey); } - if (result.stat == YP_TRUE) - { - result.key.keydat_len = okey.dsize; - result.key.keydat_val = okey.dptr; + free (oldkey.dptr); - result.val.valdat_len = dval.dsize; - result.val.valdat_val = dval.dptr; - } - ypdb_close (dbp); - } + if (dkey.dptr == NULL) + result.stat = YP_NOMORE; + else + { + datum dval = ypdb_fetch (dbp, dkey); + + result.stat = YP_TRUE; + if (mangle) + if (mangle_field (&dval, mangle) < 0) + result.stat = YP_YPERR; + + result.key.keydat_len = dkey.dsize; + result.key.keydat_val = dkey.dptr; + + result.val.valdat_len = dval.dsize; + result.val.valdat_val = dval.dptr; + } + ypdb_close (dbp); + } } if (debug_flag) @@ -828,47 +906,63 @@ } static int -ypall_encode (ypresp_key_val * val, void *data) +ypall_encode (ypresp_key_val *val, void *data) { - datum dkey, dval, okey; + datum dkey; - dkey.dptr = val->key.keydat_val; - dkey.dsize = val->key.keydat_len; +#if defined(HAVE_NDBM) - val->stat = ypdb_read (((ypall_data_t) data)->dbm, &dkey, &okey, &dval, - F_NEXT, ((ypall_data_t) data)->field); + dkey = dbm_nextkey (((ypall_data_t) data)->dbm); + while (dkey.dptr != NULL && strncmp (dkey.dptr, "YP_", 3) == 0) + dkey = dbm_nextkey (((ypall_data_t) data)->dbm); - /* - ** If key is empty, search the next one which is not empty - */ - while ((okey.dsize == 0) && (val->stat == YP_TRUE)) +#else + datum oldkey; + + oldkey.dsize = val->key.keydat_len; + oldkey.dptr = strndup (val->key.keydat_val, oldkey.dsize); + + dkey = ypdb_nextkey (((ypall_data_t) data)->dbm, oldkey); + while (dkey.dptr != NULL && strncmp (dkey.dptr, "YP_", 3) == 0) { - dkey.dptr = okey.dptr; - dkey.dsize = okey.dsize; + free (oldkey.dptr); + oldkey.dsize = dkey.dsize; + oldkey.dptr = strndup (dkey.dptr, dkey.dsize); + ypdb_free (dkey.dptr); - val->stat = ypdb_read (((ypall_data_t) data)->dbm, &dkey, &okey, &dval, - F_NEXT, ((ypall_data_t) data)->field); + dkey = ypdb_nextkey (((ypall_data_t) data)->dbm, oldkey); } - if (val->stat == YP_TRUE) + free (oldkey.dptr); +#endif + + if (dkey.dptr == NULL) + val->stat = YP_NOMORE; + else { - val->key.keydat_val = okey.dptr; - val->key.keydat_len = okey.dsize; + datum dval = ypdb_fetch (((ypall_data_t) data)->dbm, dkey); + + val->stat = YP_TRUE; + if (((ypall_data_t) data)->field) + if (mangle_field (&dval, ((ypall_data_t) data)->field) < 0) + val->stat = YP_YPERR; + + val->key.keydat_val = dkey.dptr; + val->key.keydat_len = dkey.dsize; val->val.valdat_val = dval.dptr; val->val.valdat_len = dval.dsize; } - return val->stat; } ypresp_all * -ypproc_all_2_svc (ypreq_nokey * nokey, struct svc_req * rqstp) +ypproc_all_2_svc (ypreq_nokey *nokey, struct svc_req *rqstp) { static ypresp_all result; extern xdr_ypall_cb_t xdr_ypall_cb; int valid; - int mangle_field = 0; + int mangle = 0; if (debug_flag) { @@ -901,7 +995,7 @@ return &result; } if (valid > 200) - mangle_field = valid - 200; + mangle = valid - 200; if (children < MAX_CHILDREN && fork ()) { @@ -921,12 +1015,12 @@ result.ypresp_all_u.val.stat = YP_BADARGS; else { - datum dkey, dval; ypall_data_t data; if ((data = malloc (sizeof (struct ypall_data))) == NULL) { - yp_msg ("ERROR: could not allocate enough memory! [%s|%d]\n", __FILE__, __LINE__); + yp_msg ("ERROR: could not allocate enough memory! [%s|%d]\n", + __FILE__, __LINE__); result.ypresp_all_u.val.stat = YP_YPERR; return &result; } @@ -936,28 +1030,42 @@ result.ypresp_all_u.val.stat = YP_NOMAP; else { - result.ypresp_all_u.val.stat = - ypdb_read (data->dbm, NULL, &dkey, &dval, 0, mangle_field); - - if (result.ypresp_all_u.val.stat == YP_TRUE) + datum dkey = ypdb_firstkey (data->dbm); + while (dkey.dptr != NULL && strncmp (dkey.dptr, "YP_", 3) == 0) { - result.ypresp_all_u.val.key.keydat_len = dkey.dsize; - result.ypresp_all_u.val.key.keydat_val = dkey.dptr; + datum tkey = dkey; + dkey = ypdb_nextkey (data->dbm, tkey); + ypdb_free (tkey.dptr); + } - result.ypresp_all_u.val.val.valdat_len = dval.dsize; - result.ypresp_all_u.val.val.valdat_val = dval.dptr; + if (dkey.dptr != NULL) + { + datum dval = ypdb_fetch (data->dbm, dkey); - data->field = mangle_field; + result.ypresp_all_u.val.stat = YP_TRUE; - xdr_ypall_cb.u.encode = ypall_encode; - xdr_ypall_cb.u.close = ypall_close; - xdr_ypall_cb.data = (void *) data; + if (mangle) + if (mangle_field (&dval, mangle) < 0) + result.ypresp_all_u.val.stat = YP_YPERR; - if (debug_flag) - yp_msg ("\t -> First value returned.\n"); + result.ypresp_all_u.val.key.keydat_len = dkey.dsize; + result.ypresp_all_u.val.key.keydat_val = dkey.dptr; - return &result; - } + result.ypresp_all_u.val.val.valdat_len = dval.dsize; + result.ypresp_all_u.val.val.valdat_val = dval.dptr; + + data->field = mangle; + + xdr_ypall_cb.u.encode = ypall_encode; + xdr_ypall_cb.u.close = ypall_close; + xdr_ypall_cb.data = (void *) data; + + if (debug_flag) + yp_msg ("\t -> First value returned.\n"); + + if (result.ypresp_all_u.val.stat == YP_TRUE) + return &result; + } ypdb_close (data->dbm); } @@ -990,6 +1098,12 @@ yp_msg ("\t\tmap = \"%s\"\n", nokey->map); } + if (result.peer) + { + free (result.peer); + result.peer = NULL; + } + if ((valid = is_valid_host (rqstp, nokey->map, nokey->domain)) < 1) { if (valid == 0) @@ -1008,12 +1122,6 @@ return &result; } - if (result.peer) - { - free (result.peer); - result.peer = NULL; - } - if (nokey->map[0] == '\0') result.stat = YP_BADARGS; else @@ -1042,7 +1150,7 @@ { struct hostent *hp; - if (!(hp = gethostbyname (hostbuf))) + if (!(hp = res_gethostbyname (hostbuf))) perror ("gethostbyname()"); else { @@ -1184,6 +1292,16 @@ add_maplist (ypmaplist ** mlhp, char *map) { ypmaplist *mlp; +#if defined(HAVE_NDBM) +#if defined(sun) || defined(__sun__) + /* XXX We have real NDBM support. Need some more hacks here */ +#else + int len = strlen (map); + + if (map[len - 3] == '.' && map[len - 2] == 'd' && map[len - 1] == 'b') + map[len - 3] = '\0'; +#endif +#endif if ((mlp = malloc (sizeof (*mlp))) == NULL) return -1; diff -u -r --new-file ypserv-1.3.1/version.h ypserv-1.3.2/version.h --- ypserv-1.3.1/version.h Wed Apr 1 16:50:08 1998 +++ ypserv-1.3.2/version.h Sat May 30 18:10:58 1998 @@ -1,4 +1,4 @@ #ifndef __VERSION_H__ #define __VERSION_H__ -static char version[] = "1.3.1"; +static char version[] = "1.3.2"; #endif diff -u -r --new-file ypserv-1.3.1/ypMakefile.in ypserv-1.3.2/ypMakefile.in --- ypserv-1.3.1/ypMakefile.in Wed Feb 4 20:45:12 1998 +++ ypserv-1.3.2/ypMakefile.in Sun Jun 7 14:28:57 1998 @@ -1,7 +1,7 @@ # # Makefile for the NIS databases # -# $Id: ypMakefile.in,v 1.16 1998/02/04 19:45:12 kukuk Exp $ +# $Id: ypMakefile.in,v 1.18 1998/06/07 12:28:57 kukuk Exp $ # # This Makefile should only be run on the NIS master server of a domain. # All updated maps will be pushed to all NIS slave servers listed in the @@ -51,13 +51,6 @@ YPDIR = @YPMAPDIR@ YPMAPDIR = $(YPDIR)/$(DOMAIN) -DBLOAD = @MAKEDBMPRG@ -c -m `hostname` -MKNETID = $(YPBINDIR)/mknetid -YPPUSH = $(YPSBINDIR)/yppush -DOMAIN = `basename \`pwd\`` -LOCALDOMAIN = `/bin/domainname` -REVNETGROUP = $(YPBINDIR)/revnetgroup - # These are the files from which the NIS databases are built. You may edit # these to taste in the event that you wish to keep your NIS source files # seperate from your NIS server's actual configuration files. @@ -82,7 +75,7 @@ YPSERVERS = $(YPDIR)/ypservers # List of all NIS servers for a domain -target: +target: Makefile @test ! -d $(LOCALDOMAIN) && mkdir $(LOCALDOMAIN) ; \ cd $(LOCALDOMAIN) ; \ $(NOPUSH) || $(MAKE) -f ../Makefile ypservers; \ @@ -92,8 +85,8 @@ # them out from this list. all: passwd group hosts rpc services netid protocols netgrp mail \ - shadow publickey # networks ethers bootparams \ -# amd.home auto.master auto.home + shadow publickey # networks ethers bootparams amd.home \ + #auto.master auto.home ######################################################################## @@ -102,6 +95,13 @@ # # ######################################################################## +DBLOAD = @MAKEDBMPRG@ -c -m `hostname` +MKNETID = $(YPBINDIR)/mknetid +YPPUSH = $(YPSBINDIR)/yppush +DOMAIN = `basename \`pwd\`` +LOCALDOMAIN = `/bin/domainname` +REVNETGROUP = $(YPBINDIR)/revnetgroup + ethers: ethers.byname ethers.byaddr hosts: hosts.byname hosts.byaddr networks: networks.byaddr networks.byname @@ -116,21 +116,24 @@ publickey: publickey.byname mail: mail.aliases -ypservers: $(YPSERVERS) +ypservers: $(YPSERVERS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#") print $$0"\t"$$0 }' $^ \ | $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ +$(YPSERVERS): + @echo -n "Generating $*..." + @uname -n > $(YPSERVERS) -bootparams: $(BOOTPARAMS) +bootparams: $(BOOTPARAMS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#" && $$1 != "+") \ print $$0 }' $^ | $(DBLOAD) -r -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -ethers.byname: $(ETHERS) +ethers.byname: $(ETHERS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#" && $$1 != "+") \ print $$2"\t"$$0 }' $^ | $(DBLOAD) -r -i $^ \ @@ -138,7 +141,7 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -ethers.byaddr: $(ETHERS) +ethers.byaddr: $(ETHERS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#" && $$1 != "+") \ print $$1"\t"$$0 }' $^ | $(DBLOAD) -r -i $^ \ @@ -146,40 +149,40 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -netgroup: $(NETGROUP) +netgroup: $(NETGROUP) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#" && $$1 != "+") \ print $$0 }' $^ | $(DBLOAD) -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -netgroup.byhost: $(NETGROUP) +netgroup.byhost: $(NETGROUP) Makefile @echo "Updating $@..." @$(REVNETGROUP) -h < $^ | $(DBLOAD) -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -netgroup.byuser: $(NETGROUP) +netgroup.byuser: $(NETGROUP) Makefile @echo "Updating $@..." @$(REVNETGROUP) -u < $^ | $(DBLOAD) -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -hosts.byname: $(HOSTS) +hosts.byname: $(HOSTS) Makefile @echo "Updating $@..." @$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "#"; n++) \ print $$n"\t"$$0 }' $^ | $(DBLOAD) -r $(B) -l -i $^ \ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -hosts.byaddr: $(HOSTS) +hosts.byaddr: $(HOSTS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") print $$1"\t"$$0 }' $^ \ | $(DBLOAD) -r $(B) -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -networks.byname: $(NETWORKS) +networks.byname: $(NETWORKS) Makefile @echo "Updating $@..." @$(AWK) '{ if($$1 !~ "#" && $$1 != "") { print $$1"\t"$$0; \ for (n=3; n<=NF && $$n !~ "#"; n++) print $$n"\t"$$0 \ @@ -187,14 +190,14 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -networks.byaddr: $(NETWORKS) +networks.byaddr: $(NETWORKS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") print $$2"\t"$$0 }' $^ \ | $(DBLOAD) -r -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -protocols.byname: $(PROTOCOLS) +protocols.byname: $(PROTOCOLS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") { print $$1"\t"$$0; \ for (n=3; n<=NF && $$n !~ "#"; n++) \ @@ -203,14 +206,14 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -protocols.bynumber: $(PROTOCOLS) +protocols.bynumber: $(PROTOCOLS) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") print $$2"\t"$$0 }' $^ \ | $(DBLOAD) -r -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -rpc.byname: $(RPC) +rpc.byname: $(RPC) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") { print $$1"\t"$$0; \ for (n=3; n<=NF && $$n !~ "#"; n++) print $$n"\t"$$0 \ @@ -218,21 +221,21 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -rpc.bynumber: $(RPC) +rpc.bynumber: $(RPC) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") print $$2"\t"$$0 }' $^ \ | $(DBLOAD) -r -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -services.byname: $(SERVICES) +services.byname: $(SERVICES) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 !~ "#" && $$1 != "") print $$2"\t"$$0 }' $^ \ | $(DBLOAD) -r -i $^ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -passwd.byname: $(PASSWD) +passwd.byname: $(PASSWD) Makefile @echo "Updating $@..." @$(UMASK); \ $(AWK) -F: '!/^[-+#]/ { if ($$1 != "" && $$3 >= $(MINUID) ) \ @@ -240,7 +243,7 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -passwd.byuid: $(PASSWD) +passwd.byuid: $(PASSWD) Makefile @echo "Updating $@..." @$(UMASK); \ $(AWK) -F: '!/^[-+#]/ { if ($$1 != "" && $$3 >= $(MINUID) ) \ @@ -248,7 +251,7 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -shadow.byname: $(SHADOW) +shadow.byname: $(SHADOW) Makefile @echo "Updating $@..." @$(UMASK); \ $(AWK) -F: '!/^[-+#]/ { if ($$1 != "" ) print $$1"\t"$$0 }' $^ \ @@ -256,7 +259,7 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -group.byname: $(GROUP) +group.byname: $(GROUP) Makefile @echo "Updating $@..." @$(AWK) -F: '!/^[-+#]/ { if ($$1 != "" && $$3 >= $(MINGID) ) \ print $$1"\t"$$0 }' $^ \ @@ -264,7 +267,7 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -group.bygid: $(GROUP) +group.bygid: $(GROUP) Makefile @echo "Updating $@..." @$(AWK) -F: '!/^[-+#]/ { if ($$1 != "" && $$3 >= $(MINGID) ) \ print $$3"\t"$$0 }' $^ \ @@ -273,14 +276,14 @@ $(NETID): -netid.byname: $(GROUP) $(PASSWD) $(HOSTS) $(NETID) +netid.byname: $(GROUP) $(PASSWD) $(HOSTS) $(NETID) Makefile @echo "Updating $@..." @$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -d $(DOMAIN) \ -n $(NETID) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -mail.aliases: $(ALIASES) +mail.aliases: $(ALIASES) Makefile @echo "Updating $@..." @$(AWK) '{ if ($$1 != "" && $$1 !~ "#" && $$1 != "+") \ print $$0 }' $^ | $(DBLOAD) --aliases \ @@ -288,27 +291,27 @@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -publickey.byname: $(PUBLICKEYS) +publickey.byname: $(PUBLICKEYS) Makefile @echo "Updating $@..." @$(AWK) '{ if($$1 !~ "#" && $$1 != "") { print $$1"\t"$$2 }}' $^ \ | $(DBLOAD) -i $^ -o $(YPMAPDIR)/$@ - $@ @$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -auto.master: $(AUTO_MASTER) +auto.master: $(AUTO_MASTER) Makefile @echo "Updating $@..." -@sed -e "/^#/d" -e s/#.*$$// $^ | $(DBLOAD) -i $^ \ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -auto.home: $(AUTO_HOME) +auto.home: $(AUTO_HOME) Makefile @echo "Updating $@..." -@sed -e "/^#/d" -e s/#.*$$// $^ | $(DBLOAD) -i $^ \ -o $(YPMAPDIR)/$@ - $@ -@$(NOPUSH) || $(YPPUSH) -d $(DOMAIN) $@ -amd.home: $(AMD_HOME) +amd.home: $(AMD_HOME) Makefile @echo "Updating $@..." -@sed -e "s/#.*$$//" -e "/^$$/d" $^ | \ $(AWK) '{\ diff -u -r --new-file ypserv-1.3.1/yp_db.c ypserv-1.3.2/yp_db.c --- ypserv-1.3.1/yp_db.c Sun Mar 29 16:00:28 1998 +++ ypserv-1.3.2/yp_db.c Sun Jun 7 10:36:40 1998 @@ -22,7 +22,7 @@ */ #ifndef LINUT -static const char rcsid[] = "$Id: yp_db.c,v 1.18 1998/03/29 14:00:28 kukuk Exp $"; +static const char rcsid[] = "$Id: yp_db.c,v 1.19 1998/06/07 08:36:40 kukuk Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -49,59 +49,6 @@ #include #endif -/* repleace "field" with x, if field 3 != user id and user id != 0 */ -static inline int -mangle_field (datum * val, int field) -{ - int i, j, k, anz; - char *p; - - /* allocate a little bit more memory, it's safer, because the - field could be empty */ - if ((p = malloc (val->dsize + 3)) == NULL) - { - yp_msg ("ERROR: could not allocate enough memory! [%s|%d]\n", - __FILE__, __LINE__); - return -1; - } - - anz = 0; - for (i = 0; i < val->dsize; i++) - { - if (val->dptr[i] == ':') - anz++; - if (anz + 1 == field) - { - anz = i; - strncpy (p, val->dptr, anz); - p[anz] = 0; - /* if field == 1, we don't need a beginning ":" */ - if (field == 1) - { - strcat (p, "x"); - anz += 1; - } - else - { - strcat (p, ":x"); - anz += 2; - } - for (j = anz; j < val->dsize && val->dptr[j] != ':'; j++); - for (k = j; k < val->dsize; k++) - { - p[anz] = val->dptr[k]; - anz++; - } - free (val->dptr); - val->dptr = p; - val->dsize = anz; - return 0; - } - } - free (p); - return 0; -} - #if defined(HAVE_LIBGDBM) /* Open a GDBM database */ @@ -148,88 +95,6 @@ return 0; } -/* Get a record from a GDBM database. */ -int -ypdb_read (GDBM_FILE dbp, const datum * ikey, datum * okey, - datum * dval, int flags, int mangle) -{ - int first_flag = 0; - datum nkey, ckey; - - if (ikey == NULL || ikey->dptr == NULL) - { - if (debug_flag) - yp_msg ("\tread_database(), gdbm_firstkey()\n"); - - ckey = gdbm_firstkey (dbp); - first_flag = 1; - } - else - { - if (debug_flag) - yp_msg ("\tread_database(), gdbm_nextkey()\n"); - - if ((flags & F_NEXT)) - ckey = gdbm_nextkey (dbp, *ikey); - else - ckey = *ikey; - } - - if (ckey.dptr == NULL) - { - return (flags & F_NEXT) ? YP_NOMORE : YP_NOKEY; - } - - while (1) - { - *dval = gdbm_fetch (dbp, ckey); - if (dval->dptr == NULL) - { - /* Free key, unless it comes from the caller! */ - if (ikey == NULL || ckey.dptr != ikey->dptr) - free (ckey.dptr); - - if (ikey && ikey->dptr != NULL) - { - return YP_NOKEY; - } - else if (first_flag) - return YP_BADDB; - else - return YP_FALSE; - } - - if ((flags & F_ALL) || strncmp (ckey.dptr, "YP_", 3) != 0) - { - if (okey) - *okey = ckey; - else if (ikey == NULL || ikey->dptr != ckey.dptr) - free (ckey.dptr); - - if (mangle) - if (mangle_field (dval, mangle) < 0) - return YP_YPERR; - - return YP_TRUE; - } - - /* Free old value */ - free (dval->dptr); - - nkey = gdbm_nextkey (dbp, ckey); - - /* Free old key, unless it comes from the caller! */ - if (ikey == NULL || ckey.dptr != ikey->dptr) - free (ckey.dptr); - - if (ckey.dptr == NULL || nkey.dptr == NULL) - return YP_NOMORE; - - ckey = nkey; - } -} - - #elif defined(HAVE_NDBM) /***************************************************** @@ -291,96 +156,24 @@ return 0; } -/* Get a record from a GDBM database. */ -int -ypdb_read (DB_FILE dbp, const datum *ikey, datum *okey, - datum *dval, int flags, int mangle) +datum +ypdb_nextkey (DB_FILE file, datum key) { - int first_flag = 0; - datum nkey, ckey; + datum tkey; - if (ikey == NULL || ikey->dptr == NULL) + tkey = dbm_firstkey (file); + while ((key.dsize != tkey.dsize) || + (strncmp (key.dptr, tkey.dptr, tkey.dsize) != 0)) { - if (debug_flag) - yp_msg ("\tread_database(), dbm_firstkey()\n"); - - ckey = dbm_firstkey (dbp); - first_flag = 1; + tkey = dbm_nextkey (file); + if (tkey.dptr == NULL) + return tkey; } - else - { - if (debug_flag) - yp_msg ("\tread_database(), dbm_nextkey()\n"); - - ckey = dbm_firstkey (dbp); - while (ckey.dptr) - { - if (((ikey->dsize == ckey.dsize) && - strncmp (ikey->dptr, ckey.dptr, ikey->dsize) == 0)) - break; - ckey = dbm_nextkey (dbp); - } - - if ((flags & F_NEXT)) - ckey = dbm_nextkey (dbp); - else - ckey = *ikey; - } - - if (ckey.dptr == NULL) - { - return (flags & F_NEXT) ? YP_NOMORE : YP_NOKEY; - } - - while (1) - { - *dval = dbm_fetch (dbp, ckey); - if (dval->dptr == NULL) - { - /* Free key, unless it comes from the caller! */ - if (ikey == NULL || ckey.dptr != ikey->dptr) - ypdb_free (ckey.dptr); - - if (ikey && ikey->dptr != NULL) - { - return YP_NOKEY; - } - else if (first_flag) - return YP_BADDB; - else - return YP_FALSE; - } - - if ((flags & F_ALL) || strncmp (ckey.dptr, "YP_", 3) != 0) - { - if (okey) - *okey = ckey; - else if (ikey == NULL || ikey->dptr != ckey.dptr) - ypdb_free (ckey.dptr); - - if (mangle) - if (mangle_field (dval, mangle) < 0) - return YP_YPERR; - - return YP_TRUE; - } - - /* Free old value */ - ypdb_free (dval->dptr); - - /* XXX Check this */ - nkey = dbm_nextkey (dbp); - - /* Free old key, unless it comes from the caller! */ - if (ikey == NULL || ckey.dptr != ikey->dptr) - ypdb_free (ckey.dptr); + tkey = dbm_nextkey (file); - if (ckey.dptr == NULL || nkey.dptr == NULL) - return YP_NOMORE; - - ckey = nkey; - } + return tkey; } + #else diff -u -r --new-file ypserv-1.3.1/yp_db.h ypserv-1.3.2/yp_db.h --- ypserv-1.3.1/yp_db.h Fri Mar 6 21:01:11 1998 +++ ypserv-1.3.2/yp_db.h Sun Jun 7 10:36:41 1998 @@ -1,7 +1,7 @@ #ifndef __YP_DB_H__ #define __YP_DB_H__ -/* $Id: yp_db.h,v 1.8 1998/03/06 20:01:11 kukuk Exp $ */ +/* $Id: yp_db.h,v 1.9 1998/06/07 08:36:41 kukuk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -17,6 +17,9 @@ #define ypdb_fetch(a,b) gdbm_fetch(a,b) #define ypdb_exists(a,b) gdbm_exists(a,b) #define ypdb_free(a) free(a) +#define ypdb_firstkey(a) gdbm_firstkey(a) +#define ypdb_nextkey(a,b) gdbm_nextkey(a,b) +#define ypdb_fetch(a,b) gdbm_fetch(a,b) #elif defined(HAVE_NDBM) @@ -27,6 +30,10 @@ #define ypdb_free(a) extern int ypdb_exists (DB_FILE file, datum key); +/* extern datum ypdb_firstkey (DB_FILE file); */ +#define ypdb_firstkey(a) dbm_firstkey(a) +extern datum ypdb_nextkey (DB_FILE file, datum key); +extern datum ypdb_fetch (DB_FILE file, datum key); #else @@ -37,7 +44,5 @@ extern DB_FILE ypdb_open (const char *domain, const char *map); extern int ypdb_close_all (void); extern int ypdb_close (DB_FILE file); -extern int ypdb_read (DB_FILE dbp, const datum *ikey, datum *okey, - datum *dval, int flags, int mangle); #endif diff -u -r --new-file ypserv-1.3.1/ypmake/automount.in ypserv-1.3.2/ypmake/automount.in --- ypserv-1.3.1/ypmake/automount.in Thu Feb 6 21:50:53 1997 +++ ypserv-1.3.2/ypmake/automount.in Sun Jun 7 12:18:10 1998 @@ -46,6 +46,9 @@ local($src) = @_; local($_); + %master = (); + %keys = (); + &read_master($src); foreach (keys master) { diff -u -r --new-file ypserv-1.3.1/ypmake/ypmake.in ypserv-1.3.2/ypmake/ypmake.in --- ypserv-1.3.1/ypmake/ypmake.in Thu Feb 6 21:50:55 1997 +++ ypserv-1.3.2/ypmake/ypmake.in Sun Jun 7 12:15:32 1998 @@ -167,7 +167,7 @@ # XXX: Should open lock file with specified mode and O_EXCL? # OTOH, /var/yp/* should not be writable by anyone but root... $debug && open(OUT, ">&STDOUT") || - open(OUT, "|$makedbm -m $master -i \"$source{$map}\" -o $mapfile - $lock") + open(OUT, "|$makedbm -c -m $master -i \"$source{$map}\" -o $mapfile - $lock") || &fatal("can't open DBM file $lock: $!"); select((select(OUT), $| = 1)[0]); diff -u -r --new-file ypserv-1.3.1/ypserv.spec ypserv-1.3.2/ypserv.spec --- ypserv-1.3.1/ypserv.spec Sat Mar 7 09:58:56 1998 +++ ypserv-1.3.2/ypserv.spec Thu Jun 11 10:56:47 1998 @@ -1,19 +1,40 @@ Summary: NIS/YP Server +Url: http://www-vt.uni-paderborn.de/~kukuk/linux/nis.html Name: ypserv -Version: 1.3.0 +Version: 1.3.3 Release: 1 Copyright: GNU Group: Networking/Daemons -Source: weber.uni-paderborn.de:/pub/linux/NIS/ypserv-%{PACKAGE_VERSION}.tar.gz +Source: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypserv-%{PACKAGE_VERSION}.tar.gz Packager: Thorsten Kukuk -URL: http://www-vt.uni-paderborn.de/~kukuk/linux/nis.html BuildRoot: /var/tmp/ypserv-root Requires: portmap -Requires: mawk Obsoletes: yppasswd +Summary(de): NIS/YP-Server + +%description +ypserv is an implementation of the standard NIS/YP networking protocol. +It allows network-wide distribution of hostname, username, and other +information databases. This is the NIS server, and is not needed on NIS +clients. rpc.yppasswdd implements the password-changing part of the +NIS/YP networking standard. + +%description -l de +ypserv ist eine Implementierung des NIS/YP-Netzwerkprotokolls. +Es ermöglicht die netwerkweite Verteilung von Hostname, Benutzername +und anderen Information. Dies ist der NIS-Server und wird auf NIS- +Clients nicht benötigt. rpc.yppasswdd implementiert den Teil des +NIS/YP Netzwerkprotokolls, der für die Änderung des Passworts zuständig +ist. + %changelog +* Thu Jun 11 1998 Thorsten Kukuk +- update to new version 1.3.2 +- update spec file +- merge RedHat 5.1 changes + * Sat Mar 7 1998 Thorsten Kukuk - update to new version 1.3.0 @@ -30,12 +51,6 @@ - supports chkconfig - updated initscript for status and restart -%description -ypserv is an implementation of the standard NIS/YP networking -protocol. It allows network-wide distribution of hostname, username, -and other information databases. rpc.yppasswdd implements the -password-changing part of the NIS/YP networking standard. - %prep %setup @@ -46,19 +61,13 @@ %build cp etc/README etc/README.etc # There are memory problems if ypserv uses tcp_wrapper, don't use it at first -./configure +./configure --enable-fqdn --enable-checkroot make %install +rm -rf $RPM_BUILD_ROOT make ROOT="$RPM_BUILD_ROOT" install -mkdir -p $RPM_BUILD_ROOT/var/yp $RPM_BUILD_ROOT/etc/rc.d/init.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc0.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc1.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc2.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc3.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc4.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc5.d -mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc6.d +mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d install -m644 etc/ypserv.conf $RPM_BUILD_ROOT/etc install -m644 etc/securenets $RPM_BUILD_ROOT/var/yp install -m755 etc/ypserv.init $RPM_BUILD_ROOT/etc/rc.d/init.d/ypserv @@ -70,37 +79,13 @@ /sbin/chkconfig --del ypserv %files -%doc README README.secure INSTALL ChangeLog TODO +%doc README README.secure INSTALL ChangeLog TODO NEWS BUGS %doc etc/ypserv.conf etc/securenets etc/README.etc %config /etc/ypserv.conf %config /var/yp %config /etc/rc.d/init.d/ypserv %config /etc/netgroup -/usr/include/rpcsvc/ypxfrd.x -/usr/lib/yp/ypxfr -/usr/lib/yp/ypxfr_1perhour -/usr/lib/yp/ypxfr_2perday -/usr/lib/yp/ypxfr_1perday -/usr/lib/yp/makedbm -/usr/lib/yp/ypinit -/usr/lib/yp/revnetgroup -/usr/lib/yp/mknetid -/usr/lib/yp/pwupdate -/usr/sbin/yppush -/usr/sbin/ypserv -/usr/sbin/rpc.ypxfrd -/usr/sbin/rpc.yppasswdd -/usr/man/man5/ypserv.conf.5 -/usr/man/man5/netgroup.5 -/usr/man/man8/mknetid.8 -/usr/man/man8/yppush.8 -/usr/man/man8/ypserv.8 -/usr/man/man8/ypinit.8 -/usr/man/man8/revnetgroup.8 -/usr/man/man8/ypxfr.8 -/usr/man/man8/ypxfrd.8 -/usr/man/man8/rpc.ypxfrd.8 -/usr/man/man8/rpc.yppasswdd.8 -/usr/man/man8/yppasswdd.8 -/usr/man/man8/makedbm.8 -/usr/man/man8/pwupdate.8 +/usr/include/*/* +/usr/lib/yp/* +/usr/sbin/* +/usr/man/*/*