[Midnightbsd-cvs] src [10356] cleanup
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jun 3 18:58:44 EDT 2018
Revision: 10356
http://svnweb.midnightbsd.org/src/?rev=10356
Author: laffer1
Date: 2018-06-03 18:58:43 -0400 (Sun, 03 Jun 2018)
Log Message:
-----------
cleanup
Modified Paths:
--------------
trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8
trunk/usr.sbin/pwd_mkdb/pwd_mkdb.c
Property Changed:
----------------
trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8
Modified: trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8
===================================================================
--- trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8 2018-06-03 22:58:00 UTC (rev 10355)
+++ trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8 2018-06-03 22:58:43 UTC (rev 10356)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)pwd_mkdb.8 8.1 (Berkeley) 6/6/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/pwd_mkdb/pwd_mkdb.8 262567 2014-02-27 17:31:59Z des $
.\"
-.Dd February 28, 2005
+.Dd February 5, 2014
.Dt PWD_MKDB 8
.Os
.Sh NAME
@@ -143,6 +144,12 @@
.It Pa /etc/passwd
A Version 7 format password file.
.El
+.Sh EXAMPLES
+Regenerate the password database after manually editing or replacing
+the password file:
+.Bd -literal -offset -indent
+/usr/sbin/pwd_mkdb -p /etc/master.passwd
+.Ed
.Sh COMPATIBILITY
Previous versions of the system had a program similar to
.Nm ,
Property changes on: trunk/usr.sbin/pwd_mkdb/pwd_mkdb.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/pwd_mkdb/pwd_mkdb.c
===================================================================
--- trunk/usr.sbin/pwd_mkdb/pwd_mkdb.c 2018-06-03 22:58:00 UTC (rev 10355)
+++ trunk/usr.sbin/pwd_mkdb/pwd_mkdb.c 2018-06-03 22:58:43 UTC (rev 10356)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -40,7 +41,7 @@
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/pwd_mkdb/pwd_mkdb.c 296424 2016-03-06 08:40:21Z dwmalone $");
#include <sys/param.h>
#include <sys/endian.h>
@@ -51,6 +52,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <pwd.h>
#include <signal.h>
@@ -68,7 +70,7 @@
#define LEGACY_VERSION(x) _PW_VERSIONED(x, 3)
#define CURRENT_VERSION(x) _PW_VERSIONED(x, 4)
-HASHINFO openinfo = {
+static HASHINFO openinfo = {
4096, /* bsize */
32, /* ffactor */
256, /* nelem */
@@ -714,13 +716,27 @@
mv(char *from, char *to)
{
char buf[MAXPATHLEN];
+ char *to_dir;
+ int to_dir_fd = -1;
- if (rename(from, to)) {
+ /*
+ * Make sure file is safe on disk. To improve performance we will call
+ * fsync() to the directory where file lies
+ */
+ if (rename(from, to) != 0 ||
+ (to_dir = dirname(to)) == NULL ||
+ (to_dir_fd = open(to_dir, O_RDONLY|O_DIRECTORY)) == -1 ||
+ fsync(to_dir_fd) != 0) {
int sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
errno = sverrno;
+ if (to_dir_fd != -1)
+ close(to_dir_fd);
error(buf);
}
+
+ if (to_dir_fd != -1)
+ close(to_dir_fd);
}
void
More information about the Midnightbsd-cvs
mailing list