[Midnightbsd-cvs] src [10336] trunk/usr.sbin/services_mkdb: update
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jun 3 15:57:18 EDT 2018
Revision: 10336
http://svnweb.midnightbsd.org/src/?rev=10336
Author: laffer1
Date: 2018-06-03 15:57:18 -0400 (Sun, 03 Jun 2018)
Log Message:
-----------
update
Modified Paths:
--------------
trunk/usr.sbin/services_mkdb/Makefile
trunk/usr.sbin/services_mkdb/services_mkdb.8
trunk/usr.sbin/services_mkdb/services_mkdb.c
trunk/usr.sbin/services_mkdb/uniq.c
Added Paths:
-----------
trunk/usr.sbin/services_mkdb/extern.h
Property Changed:
----------------
trunk/usr.sbin/services_mkdb/services_mkdb.8
Modified: trunk/usr.sbin/services_mkdb/Makefile
===================================================================
--- trunk/usr.sbin/services_mkdb/Makefile 2018-06-03 19:56:25 UTC (rev 10335)
+++ trunk/usr.sbin/services_mkdb/Makefile 2018-06-03 19:57:18 UTC (rev 10336)
@@ -1,8 +1,9 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/services_mkdb/Makefile 241777 2012-10-20 10:33:15Z ed $
PROG= services_mkdb
MAN= services_mkdb.8
-SRCS= services_mkdb.c uniq.c
+SRCS= services_mkdb.c uniq.c extern.h
DPADD+= ${LIBUTIL}
LDADD+= -lutil
Added: trunk/usr.sbin/services_mkdb/extern.h
===================================================================
--- trunk/usr.sbin/services_mkdb/extern.h (rev 0)
+++ trunk/usr.sbin/services_mkdb/extern.h 2018-06-03 19:57:18 UTC (rev 10336)
@@ -0,0 +1,35 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/10/usr.sbin/services_mkdb/extern.h 263028 2014-03-11 15:28:41Z jhb $
+ */
+
+extern HASHINFO hinfo;
+
+void uniq(const char *);
Property changes on: trunk/usr.sbin/services_mkdb/extern.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.sbin/services_mkdb/services_mkdb.8
===================================================================
--- trunk/usr.sbin/services_mkdb/services_mkdb.8 2018-06-03 19:56:25 UTC (rev 10335)
+++ trunk/usr.sbin/services_mkdb/services_mkdb.8 2018-06-03 19:57:18 UTC (rev 10336)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: services_mkdb.8,v 1.9 2009/05/13 22:36:39 wiz Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -27,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/services_mkdb/services_mkdb.8 263028 2014-03-11 15:28:41Z jhb $
.\"
.Dd April 4, 2010
.Dt SERVICES_MKDB 8
@@ -37,6 +38,7 @@
.Nd generate the services database
.Sh SYNOPSIS
.Nm
+.Op Fl b | l
.Op Fl q
.Op Fl o Ar database
.Op Ar file
@@ -61,15 +63,26 @@
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl b
+Use big-endian byte order for database metadata.
+.It Fl l
+Use little-endian byte order for database metadata.
.It Fl o Ar database
Put the output databases in the named file.
.It Fl q
-Don't warn about duplicate services.
+Do not warn about duplicate services.
.It Fl u
Print the services file to stdout, omitting duplicate entries and comments.
.El
.Pp
The databases are used by the C library services routines (see
+.Pp
+The
+.Fl b
+and
+.Fl l
+flags are mutually exclusive.
+The default byte ordering is the current host order.
.Xr getservent 3 ) .
.Sh FILES
.Bl -tag -width ".Pa /var/db/services.db.tmp" -compact
Property changes on: trunk/usr.sbin/services_mkdb/services_mkdb.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/services_mkdb/services_mkdb.c
===================================================================
--- trunk/usr.sbin/services_mkdb/services_mkdb.c 2018-06-03 19:56:25 UTC (rev 10335)
+++ trunk/usr.sbin/services_mkdb/services_mkdb.c 2018-06-03 19:57:18 UTC (rev 10336)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: services_mkdb.c,v 1.14 2008/04/28 20:24:17 martin Exp $ */
/*-
@@ -30,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/services_mkdb/services_mkdb.c 296424 2016-03-06 08:40:21Z dwmalone $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -44,18 +45,19 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libgen.h>
#include <libutil.h>
#include <ctype.h>
#include <errno.h>
#include <stringlist.h>
+#include "extern.h"
+
static char tname[MAXPATHLEN];
#define PMASK 0xffff
#define PROTOMAX 5
-extern void uniq(const char *);
-
static void add(DB *, StringList *, size_t, const char *, size_t *, int);
static StringList ***parseservices(const char *, StringList *);
static void cleanup(void);
@@ -67,7 +69,7 @@
static const char *mkaliases(StringList *, char *, size_t);
static void usage(void);
-const HASHINFO hinfo = {
+HASHINFO hinfo = {
.bsize = 256,
.ffactor = 4,
.nelem = 32768,
@@ -87,14 +89,23 @@
int warndup = 1;
int unique = 0;
int otherflag = 0;
+ int byteorder = 0;
size_t cnt = 0;
StringList *sl, ***svc;
size_t port, proto;
+ char *dbname_dir;
+ int dbname_dir_fd = -1;
setprogname(argv[0]);
- while ((ch = getopt(argc, argv, "qo:u")) != -1)
+ while ((ch = getopt(argc, argv, "blo:qu")) != -1)
switch (ch) {
+ case 'b':
+ case 'l':
+ if (byteorder != 0)
+ usage();
+ byteorder = ch == 'b' ? 4321 : 1234;
+ break;
case 'q':
otherflag = 1;
warndup = 0;
@@ -119,6 +130,9 @@
if (argc == 1)
fname = argv[0];
+ /* Set byte order. */
+ hinfo.lorder = byteorder;
+
if (unique)
uniq(fname);
@@ -154,9 +168,22 @@
if ((db->close)(db))
err(1, "Error closing temporary database `%s'", tname);
- if (rename(tname, dbname) == -1)
+ /*
+ * Make sure file is safe on disk. To improve performance we will call
+ * fsync() to the directory where file lies
+ */
+ if (rename(tname, dbname) == -1 ||
+ (dbname_dir = dirname(dbname)) == NULL ||
+ (dbname_dir_fd = open(dbname_dir, O_RDONLY|O_DIRECTORY)) == -1 ||
+ fsync(dbname_dir_fd) != 0) {
+ if (dbname_dir_fd != -1)
+ close(dbname_dir_fd);
err(1, "Cannot rename `%s' to `%s'", tname, dbname);
+ }
+ if (dbname_dir_fd != -1)
+ close(dbname_dir_fd);
+
return 0;
}
@@ -423,7 +450,8 @@
static void
usage(void)
{
- (void)fprintf(stderr, "Usage:\t%s [-q] [-o <db>] [<servicefile>]\n"
+ (void)fprintf(stderr,
+ "Usage:\t%s [-b | -l] [-q] [-o <db>] [<servicefile>]\n"
"\t%s -u [<servicefile>]\n", getprogname(), getprogname());
exit(1);
}
Modified: trunk/usr.sbin/services_mkdb/uniq.c
===================================================================
--- trunk/usr.sbin/services_mkdb/uniq.c 2018-06-03 19:56:25 UTC (rev 10335)
+++ trunk/usr.sbin/services_mkdb/uniq.c 2018-06-03 19:57:18 UTC (rev 10336)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: uniq.c,v 1.4 2008/04/28 20:24:17 martin Exp $ */
/*-
@@ -29,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/services_mkdb/uniq.c 241778 2012-10-20 10:34:55Z ed $");
#include <stdio.h>
#include <string.h>
@@ -40,9 +41,8 @@
#include <ctype.h>
#include <fcntl.h>
-extern const HASHINFO hinfo;
+#include "extern.h"
-void uniq(const char *);
static int comp(const char *, char **, size_t *);
/*
More information about the Midnightbsd-cvs
mailing list