summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb/pwd_mkdb.c
Commit message (Collapse)AuthorAgeFilesLines
* Following revision r295924, the changes to a db file should be fsynceddwmalone2016-02-231-4/+4
| | | | | | | | | | | | | | before the file is closed. Consequently, it shouldn't be necessary to open the file with O_SYNC any more. This improves the performance of building large .db files for large password files a lot and should resolve this problem: https://forums.freebsd.org/threads/10-2-pre-pwd_mkdb-slow-on-larger-master-passwd.52700/ Differential Revision: https://reviews.freebsd.org/D5186 Reviewed by: garga, vangyzen, bapt, se MFC after: 1 week
* The sdp opens the database with PERM_SECURE mode and it is different thanaraujo2015-12-281-1/+1
| | | | | | | | | | dp that opens the database with PERM_INSECURE, so we need to check sdp->put against sdp instead of use dp->put. PR: bin/191720 Submitted by: Miles Ohlrich <turingsboy@yahoo.com> Approved by: rodrigc (mentor) Differential Revision: https://reviews.freebsd.org/D4255
* When passwd or group information is changed (by pw, vipw, chpass, ...)garga2015-07-021-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | temporary file is created and then a rename() call move it to official file. This operation didn't have any check to make sure data was written to disk and if a power cycle happens system could end up with a 0 length passwd or group database. There is a pfSense bug with more infor about it: https://redmine.pfsense.org/issues/4523 The following changes were made to protect passwd and group operations: * lib/libutil/gr_util.c: - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file - After rename(), fsync() call on directory for faster result * lib/libutil/pw_util.c - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file * usr.sbin/pwd_mkdb/pwd_mkdb.c - Added O_SYNC flag on dbopen() calls - After rename(), fsync() call on directory for faster result * lib/libutil/pw_util.3 - pw_lock() returns a file descriptor to master password file on success Differential Revision: https://reviews.freebsd.org/D2978 Approved by: bapt Sponsored by: Netgate
* Whitespace changes for r283981. No actual code changes.delphij2015-06-041-88/+88
|
* In r113596, version 4 of entries have been added but pwd_mkdb havedelphij2015-06-041-3/+10
| | | | | | | | | | | | been generating both new (machine independent) and legacy version entries (endianness sensitive). The base system have been using the new format for quite some time, so disable the generation by default. An interim option, -l, have been added to re-enable old behavior. The -l, -B and -L options are considered deprecated and will be removed in FreeBSD 12.0 release.
* Mark global functions and/or variables in pwd_mkdb(8) static where possible.ed2011-11-061-1/+1
| | | | This allows compilers and static analyzers to do more thorough analysis.
* Only increment the ypcnt once per data record. The old implementationgordon2011-07-061-4/+4
| | | | | | | was incrementing it twice making it impossible to iterate the table since the records were 1, 3, 5, 7 (or 2, 4, 6, 8 for the v3 records). MFC after: 10 days
* Verify that the username length is smaller than MAXLOGNAME whenbrian2009-05-201-1/+5
| | | | | | | | | | | | | | | | asked to verify a passwd file (pwd_mkdb -C). Entries with oversized usernames are still permitted when building the passwd database. When entries are >= MAXLOGNAME in length, they are correctly stored in passwd, pwd.db and spwd.db but are only correctly retrieved by getpwent*() and getpwuid*(). getpwnam*() truncates to MAXLOGNAME - 1 when reading from a file (breaking at least sh, tcsh and bash) and utilities such as su(1) check, complain and fail if the passed name is >= MAXLOGNAME in length. MFC after: 3 weeks
* Correctly handle an input file without a newline on the last line (anddd2005-06-151-9/+9
| | | | | | | | | avoid the confusing error message about the line being too long). This change uses fgetln to detect the right conditions, but the fixed-width line buffer is kept because too many other places in the program make assumptions about its maximum width. Approved by: re (scottl)
* Even if variable is never used uninitialized by the semantic, reduce compilercharnier2005-05-291-0/+2
| | | | warning by giving an initial value in all cases.
* Add endianness support.ru2005-02-281-36/+41
| | | | | | | | | | | While version 4 entries are architecture-independent, we also store old (version 3) entries in native byte order. Also, the hash itself is created in a native byte order. With this change, pwd_mkdb(8) can be used to cross-build *pwd.db files for another architecture. Tested on: i386, amd64, alpha, sparc64
* Turn K&R functions into prototypes.stefanf2005-02-101-12/+6
|
* Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived softwareimp2004-08-071-4/+0
| | | | (with permission of addtional copyright holders where appropriate)
* Add 'i' to the getopt string.imp2004-08-051-1/+1
| | | | Noticed by: jhein
* Add support for ignoring locking failures. This is only enabled whenimp2004-07-211-4/+8
| | | | | | | | | | you've specified a directory. It is intended to be used in building custom releases over NFS where locking may be unreliable at best and there is no contention that the locking is designed to arbitrate. Other uses of this flag are discouraged. Document same in usage and man page (including the warning about unwise). Sponsored by: Timing Solutions
* Two style related changes:imp2004-07-211-5/+5
| | | | | | | (1) use strlcpy instead of strncpy since the use here of the latter was incorrect. (2) Move 'N' case into proper sorted order (sorted the same way that ls sorts its args).
* Use __FBSDID over rcsid[]. Protect copyright[] where needed.obrien2003-05-031-4/+4
|
* When updating a single entry (i.e. when the `-u' option is given),nectar2003-04-281-13/+29
| | | | | | | | | | | | | | | do not add the "\xFF" "VERSION" key --- it should only be added once ALL entries have been updated. While I'm here, correct the logic that detects whether or not the user-ID has changed so that it works even if all entries have not yet been updated to the new format. Users missing-in-action were Reported by: tjr, Vallo Kallaste <vallo@estcard.ee>, leafy <leafy@leafy.idv.tw> Sponsored by: DARPA, Network Associates Laboratories
* Revert the definitions of _PW_KEY* to their previous values. There isnectar2003-04-181-19/+25
| | | | | | | | | | at least one consumer outside of libc and pwd_mkdb. Adjust the versioning in libc and pwd_mkdb accordingly. named was the application affected, and that fact was first Reported by: Zherdev Anatoly <tolyar@mx.ru> Sponsored by: DARPA, Network Associates Laboratories
* = Implement thread-safe versions of the getpwent(3) and getgrent(3)nectar2003-04-171-11/+124
| | | | | | | | | | | | | | | | | | | | | | family of functions using the new nsdispatch(3) core. Remove arbitrary size limits when using the thread-safe versions. = Re-implement the traditional getpwent(3)/getgrent(3) functions on top of the thread-safe versions. = Update the on-disk format of the hashed version of the passwd(5) databases to allow for versioned entries. The legacy version is `3'. (Don't ask.) = Add support for version `4' entries in the passwd(5) database. Entries in this format are identical to version 3 entries except that all integers are stored as 32-bit integers in network byte order (big endian). = pwd_mkdb is updated to generate both version 3 and version 4 entries. Sponsored by: DARPA, Network Associates Laboratories
* WARNS=4 cleanup, de-__P()alfred2002-07-111-12/+12
|
* When reporting that a line is too long, include the line number in thedd2002-03-091-1/+5
| | | | | | | | error message. While I'm here, add a note that the "line too long" message isn't always accurate. PR: 35395 Submitted by: andrew@ugh.net.au
* Explicitly use int32_t for on-disk records for pw_change and pw_expire,peter2001-10-271-8/+11
| | | | | | since that is what we use now and this insulates us from any time_t tweaks here. We can define a record format that uses 64 bit times if/when we need to.
* Add nsswitch support. By creating an /etc/nsswitch.conf file, you cannectar2000-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | configure FreeBSD so that various databases such as passwd and group can be looked up using flat files, NIS, or Hesiod. = Hesiod has been added to libc (see hesiod(3)). = A library routine for parsing nsswitch.conf and invoking callback functions as specified has been added to libc (see nsdispatch(3)). = The following C library functions have been modified to use nsdispatch: . getgrent, getgrnam, getgrgid . getpwent, getpwnam, getpwuid . getusershell . getaddrinfo . gethostbyname, gethostbyname2, gethostbyaddr . getnetbyname, getnetbyaddr . getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr = host.conf has been removed from src/etc. rc.network has been modified to warn that host.conf is no longer used at boot time. In addition, if there is a host.conf but no nsswitch.conf, the latter is created at boot time from the former. Obtained from: NetBSD
* Fix various unsigned vs signed errors that caused problems with uidspaul2000-03-091-6/+6
| | | | | | | and gids bigger than 16 bits. Added checks for uids and gids that are bigger than 32 bits. Approved by: jkh (partly, this fix is bigger than I first intended)
* Replace the -q option to pwd_mkdb with a test for PW_SCAN_BIG_IDS insheldonh1999-12-021-4/+1
| | | | | | | | | | | the environment. This allows big ID warnings to be suppressed for vipw and chpass as well. Since the environment variable test is only performed for callers of pw_scan() that do not set pw_big_ids_warning, the test can still be overriden. Currently, chpass and pwd_mkdb are the only users of pw_scan() and neither of them overrides the environment variable test.
* Add to pwd_mkdb a -q option to silence warnings about large IDs. Add asheldonh1999-11-151-1/+4
| | | | | | | | | suitably ominous warning in the manual page. The diff applied is not the one provided in the attributed PR. PR: 13344 Reviewed by: bde
* Unifdef -DPASSWD_IGNORE_COMMENTS. This wasn't really optional andpeter1999-09-061-6/+2
| | | | we have enough pseudo-options already.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Enable source file locking in pwd_mkdb by including the proper letterbillf1999-01-011-3/+3
| | | | | | | | | | in getopt(). The code was there, the means to use it wasn't. Also update the usage() statment to reflect reality. PR: bin/9248 Submitted by: Jos Backus <jbackus@plex.nl> Forgotten By: dillon
* PR: bin/3478dillon1998-12-131-6/+36
| | | | | | | | | | | | | | Have pwd_mkdb lock the source file while rebuilding the database. When called by programs such as vipw, the source file is a temporary file and this does not conflict with the lock on /etc/master.passwd already held by vipw. When run manually, however, master.passwd is typically specified as the argument and the locking prevents other programs from messing with master.passwd during the database rebuild. Also pwd_mkdb uses a blocking exclusive lock as it may be called from a script. The -N option was added to cause pwd_mkdb to get the lock non-blocking and exit with an error if the attempt fails, again useful for scripts.
* Close PR bin/8753 pwd_mkdb problem when having comments in passwd filefoxfair1998-12-121-1/+5
| | | | Submitted by Chia-liang Kao clkao@CirX.ORG .
* Rename a static variable, so it will not shadowed by a local variable.dt1998-09-291-7/+7
| | | | | | Now comments will be ignored, rather than put junk in the password database. Broken in: rev. 1.21
* Fix usage stringache1998-06-091-2/+2
|
* Allow specification of cache-size to pwd_mkdbphk1998-04-191-2/+5
| | | | | | PR: 5193 Reviewed by: phk Submitted by: Nick Hilliard <nick@foobar.org>
* Reenable building of /etc/passwd.guido1998-02-191-3/+3
| | | | Pointed out by: "Julie M. Juracich" <julie@xaqti.com>
* Apparently, if fprintf() fails, it can return any negative valueguido1998-02-161-3/+3
| | | | Pointed out by: Bruce
* Check return values of fprintf, fclose (this one is overdone I guess)guido1998-02-151-7/+12
| | | | | | and pw_db->close. PR: 4202 (probably, I askd the submitter) Obtained from: OpenBSD
* Rename the pwd_mkdb(8) option '-c' to '-C' for better compatiblitywosch1998-01-101-7/+7
| | | | with BSD/OS.
* Staticize usage(). Cosmetics.charnier1997-10-101-6/+11
|
* db close routine actually writes data out to disk; return value wasjlemon1997-08-181-2/+4
| | | | | | not being checked. Change code to fail if db->close errors. PR: 4202
* compare return value from getopt against -1 rather than EOF, per the finalimp1997-03-311-1/+1
| | | | posix standard on the topic.
* Fix possible (not stack) overflow from -d <dir> commandline option.davidn1997-03-201-1/+1
|
* Allow comments in password database. The comments are copied fromwosch1997-03-081-4/+25
| | | | | | | | | | | | | the password file into /etc/master.passwd and optional (-p) into /etc/passwd. Enable this feature with the compile option -DPASSWD_IGNORE_COMMENTS. The character `#' introduces a comment. Leading spaces and tabs are ignored: '^[ \t]*#.*\n$' Count an empty line - only spaces, tabs or newline - also as a comment. An empty line at the bottom of /etc/master.passwd is a common novice error and increased my mail load: '^[ \t]*\n$'
* Begin closing out PR #1519 (this requires a change to chpass too,wpaul1996-10-221-4/+12
| | | | | | | | | | and both changes need to be pulled into the stable branch). The problem here is that when pwd_mkdb creates /etc/passwd, it turns empty UID and GID fields into zeroes. To fix this, we check the _PWF_UID and _PWF_GID bits in the pw_fields flag: if the bits are not set, we print an empty field instead of a zero. This way, you don't get zeroes in the UID or GID fields unless you explicit want them.
* New option: [-c]wosch1996-08-191-3/+13
| | | | | Check if the password file is in the correct format. Do not change, add, or remove any files.
* Fixed brackets in usage message.bde1996-07-121-8/+10
| | | | Reformatted some of recent changes to KNF.
* Check if username is a NULL pointer before dereferencing it.martin1996-07-031-1/+1
|
* Implement incremental passwd database updates. This is done by ading a '-u'guido1996-07-011-133/+218
| | | | | | | | | | | | | | option to pwd_mkdb and adding this option to utilities invoking it. Further, the filling of both the secure and insecure databases has been merged into one loop giving also a performance improvemnet. Note that I did *not* change the adduser command. I don't read perl (it is a write only language anyway). The change will drastically improve performance for passwd and friends with large passwd files. Vipw's performance won't change. In order to do that some kind of diff should be made between the old and new master.passwd and depending the amount of changes, an incremental or complete update of the databases should be agreed upon.
* NIS cleanups and fixes, the next generation, continued.wpaul1996-04-161-56/+11
| | | | | | | | | | | | | | | pwd_mkdb.c: - Don't save the PLUSCNT and MINUSCNT tokens: we don't need them anymore. - Count the + and - entires for NIS together instead of counting + and - entries seperately. Index all special NIS entries using new _PW_KEYYPBYNUM token. pwd.h: - Remove the PLUSBYNUM, MINUSBYNUM, PLUSCNT and MINUSCNT tokens and replace then with a single _PW_KEYYPBYNUM token.
OpenPOWER on IntegriCloud