Fix up the way _PATH_YP is used to put together the pathname to the
NIS maps (get rid of extraneous slash a la /var/yp//domainname). Have ypxfr log all output to /var/yp/ypxfr.log if stdin is not a tty. This should allow logging to be done when ypxfr is called from inside ypserv in response to a yppush request. Update man page to reflect the change (and fix a typo).
This commit is contained in:
parent
cddeed288c
commit
effe773667
@ -29,7 +29,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" $Id$
|
.\" $Id: ypxfr.8,v 1.1 1995/02/06 22:15:21 wpaul Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd February 5, 1995
|
.Dd February 5, 1995
|
||||||
.Dt YPXFR 8
|
.Dt YPXFR 8
|
||||||
@ -114,9 +114,16 @@ when
|
|||||||
is run on the NIS master server, however it is good practice
|
is run on the NIS master server, however it is good practice
|
||||||
on large networks where possible outages could cause NIS servers to
|
on large networks where possible outages could cause NIS servers to
|
||||||
fall out of sync with each other.
|
fall out of sync with each other.
|
||||||
|
.Pp
|
||||||
|
When
|
||||||
|
.Nm ypxfr
|
||||||
|
is invoked without a controlling terminal, e.g. from inside
|
||||||
|
.Xr ypserv 8 ,
|
||||||
|
it logs all its output to
|
||||||
|
.Pa /var/yp/ypxfr.log .
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
The following options are supported by
|
The following options are supported by
|
||||||
.Nm yppxfr :
|
.Nm ypxfr :
|
||||||
.Bl -tag -width flag
|
.Bl -tag -width flag
|
||||||
.It Fl f
|
.It Fl f
|
||||||
Force a map transfer. Normally,
|
Force a map transfer. Normally,
|
||||||
@ -182,11 +189,6 @@ The NIS maps for a particular NIS domain.
|
|||||||
.Xr ypserv 8 ,
|
.Xr ypserv 8 ,
|
||||||
.Xr ypxfr 8 ,
|
.Xr ypxfr 8 ,
|
||||||
.Xr yp 8
|
.Xr yp 8
|
||||||
.Sh BUGS
|
|
||||||
.Nm ypxfr
|
|
||||||
should log its output to /var/yp/ypxfr.log when it is started without
|
|
||||||
a controlling terminal. Hopefully this feature will be added in the
|
|
||||||
next release of FreeBSD.
|
|
||||||
.Sh LICENSE
|
.Sh LICENSE
|
||||||
This program is covered by the GNU Public License version 2.
|
This program is covered by the GNU Public License version 2.
|
||||||
.Sh AUTHOR
|
.Sh AUTHOR
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
|
Modified for use with FreeBSD 2.x by Bill Paul (wpaul@ctr.columbia.edu)
|
||||||
|
|
||||||
$Id: ypxfr.c,v 1.1 1995/01/31 09:28:47 wpaul Exp $
|
$Id: ypxfr.c,v 1.2 1995/02/06 23:35:49 wpaul Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -29,6 +29,7 @@
|
|||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <db.h>
|
#include <db.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -36,7 +37,7 @@
|
|||||||
DB *db;
|
DB *db;
|
||||||
|
|
||||||
#ifndef _PATH_YP
|
#ifndef _PATH_YP
|
||||||
#define _PATH_YP "/var/yp"
|
#define _PATH_YP "/var/yp/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PERM_SECURE (S_IRUSR|S_IWUSR)
|
#define PERM_SECURE (S_IRUSR|S_IWUSR)
|
||||||
@ -190,7 +191,7 @@ ypxfr(char *mapName) {
|
|||||||
|
|
||||||
if (!Force) {
|
if (!Force) {
|
||||||
DBT inKey, inVal;
|
DBT inKey, inVal;
|
||||||
sprintf(dbName, "%s/%s/%s", _PATH_YP, TargetDomain, mapName);
|
sprintf(dbName, "%s%s/%s", _PATH_YP, TargetDomain, mapName);
|
||||||
if ((db = dbopen(dbName,O_RDWR|O_EXCL, PERM_SECURE,
|
if ((db = dbopen(dbName,O_RDWR|O_EXCL, PERM_SECURE,
|
||||||
DB_HASH, &openinfo)) == NULL) {
|
DB_HASH, &openinfo)) == NULL) {
|
||||||
perror("dbopen");
|
perror("dbopen");
|
||||||
@ -215,7 +216,7 @@ ypxfr(char *mapName) {
|
|||||||
if (localOrderNum>=masterOrderNum) return YPXFR_AGE;
|
if (localOrderNum>=masterOrderNum) return YPXFR_AGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(dbName, "%s/%s/%s~", _PATH_YP, TargetDomain, mapName);
|
sprintf(dbName, "%s%s/%s~", _PATH_YP, TargetDomain, mapName);
|
||||||
if ((db = dbopen(dbName,O_RDWR|O_EXCL|O_CREAT, PERM_SECURE, DB_HASH,
|
if ((db = dbopen(dbName,O_RDWR|O_EXCL|O_CREAT, PERM_SECURE, DB_HASH,
|
||||||
&openinfo)) == NULL) {
|
&openinfo)) == NULL) {
|
||||||
fprintf(stderr, "%s: Cannot open\n", dbName);
|
fprintf(stderr, "%s: Cannot open\n", dbName);
|
||||||
@ -240,8 +241,8 @@ ypxfr(char *mapName) {
|
|||||||
y=__yp_all(SourceDomain, mapName, &callback);
|
y=__yp_all(SourceDomain, mapName, &callback);
|
||||||
|
|
||||||
(void)(db->close)(db);
|
(void)(db->close)(db);
|
||||||
sprintf(dbName, "%s/%s/%s~", _PATH_YP, TargetDomain, mapName);
|
sprintf(dbName, "%s%s/%s~", _PATH_YP, TargetDomain, mapName);
|
||||||
sprintf(dbName2, "%s/%s/%s", _PATH_YP, TargetDomain, mapName);
|
sprintf(dbName2, "%s%s/%s", _PATH_YP, TargetDomain, mapName);
|
||||||
unlink(dbName2);
|
unlink(dbName2);
|
||||||
rename(dbName, dbName2);
|
rename(dbName, dbName2);
|
||||||
|
|
||||||
@ -266,6 +267,20 @@ char *progname;
|
|||||||
void
|
void
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
if (!isatty(0)) {
|
||||||
|
int fd;
|
||||||
|
char logfile[MAXPATHLEN];
|
||||||
|
sprintf (logfile, "%sypxfr.log", _PATH_YP);
|
||||||
|
if ((fd = open("/var/yp/ypxfr.log",
|
||||||
|
O_CREAT|O_WRONLY|O_APPEND, 0644))) {
|
||||||
|
close(0);
|
||||||
|
dup(fd);
|
||||||
|
close(1);
|
||||||
|
dup(fd);
|
||||||
|
close(2);
|
||||||
|
dup(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user