aboutsummaryrefslogtreecommitdiff
path: root/gnu/libexec
diff options
context:
space:
mode:
authorBill Paul <wpaul@FreeBSD.org>1995-03-30 04:14:46 +0000
committerBill Paul <wpaul@FreeBSD.org>1995-03-30 04:14:46 +0000
commiteffe77366702cf574770491e7b34304f1ef6190f (patch)
tree204308fc8affa62e5ed95828e88065fd11398065 /gnu/libexec
parentcddeed288cffba4d829e9f48c6972d3dbcd5418d (diff)
Notes
Diffstat (limited to 'gnu/libexec')
-rw-r--r--gnu/libexec/ypxfr/ypxfr.816
-rw-r--r--gnu/libexec/ypxfr/ypxfr.c27
2 files changed, 30 insertions, 13 deletions
diff --git a/gnu/libexec/ypxfr/ypxfr.8 b/gnu/libexec/ypxfr/ypxfr.8
index a62ad4bbd66a..1e7ae62a21b3 100644
--- a/gnu/libexec/ypxfr/ypxfr.8
+++ b/gnu/libexec/ypxfr/ypxfr.8
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: ypxfr.8,v 1.1 1995/02/06 22:15:21 wpaul Exp $
.\"
.Dd February 5, 1995
.Dt YPXFR 8
@@ -114,9 +114,16 @@ when
is run on the NIS master server, however it is good practice
on large networks where possible outages could cause NIS servers to
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
The following options are supported by
-.Nm yppxfr :
+.Nm ypxfr :
.Bl -tag -width flag
.It Fl f
Force a map transfer. Normally,
@@ -182,11 +189,6 @@ The NIS maps for a particular NIS domain.
.Xr ypserv 8 ,
.Xr ypxfr 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
This program is covered by the GNU Public License version 2.
.Sh AUTHOR
diff --git a/gnu/libexec/ypxfr/ypxfr.c b/gnu/libexec/ypxfr/ypxfr.c
index d8589e96173b..655ec63d3b03 100644
--- a/gnu/libexec/ypxfr/ypxfr.c
+++ b/gnu/libexec/ypxfr/ypxfr.c
@@ -18,7 +18,7 @@
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>
@@ -29,6 +29,7 @@
#include <paths.h>
#include <rpc/rpc.h>
#include <sys/types.h>
+#include <sys/param.h>
#include <db.h>
#include <limits.h>
#include <sys/stat.h>
@@ -36,7 +37,7 @@
DB *db;
#ifndef _PATH_YP
-#define _PATH_YP "/var/yp"
+#define _PATH_YP "/var/yp/"
#endif
#define PERM_SECURE (S_IRUSR|S_IWUSR)
@@ -190,7 +191,7 @@ ypxfr(char *mapName) {
if (!Force) {
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,
DB_HASH, &openinfo)) == NULL) {
perror("dbopen");
@@ -215,7 +216,7 @@ ypxfr(char *mapName) {
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,
&openinfo)) == NULL) {
fprintf(stderr, "%s: Cannot open\n", dbName);
@@ -240,8 +241,8 @@ ypxfr(char *mapName) {
y=__yp_all(SourceDomain, mapName, &callback);
(void)(db->close)(db);
- sprintf(dbName, "%s/%s/%s~", _PATH_YP, TargetDomain, mapName);
- sprintf(dbName2, "%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);
unlink(dbName2);
rename(dbName, dbName2);
@@ -266,6 +267,20 @@ char *progname;
void
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)
{