summaryrefslogtreecommitdiffstats
path: root/libutil
Commit message (Collapse)AuthorAgeFilesLines
* When passwd or group information is changed (by pw, vipw, chpass, ...)Renato Botelho2015-07-022-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* revert r283969,283970 not needed anymore after r283981Baptiste Daroussin2015-06-042-29/+3
|
* Add a pw_mkdb2(3) function which does the same thing as pw_mkdb(3) exceptBaptiste Daroussin2015-06-032-3/+29
| | | | | | | | it takes a new argument allowing to specify the endianness of the database to generate Differential Revision: https://reviews.freebsd.org/D2730 Reviewed by: ian
* Export a list of VM objects in the system via a sysctl. The list can beJohn Baldwin2015-05-271-0/+2
| | | | | | | | | | examined via 'vmstat -o'. It can be used to determine which files are using physical pages of memory and how much each is using. Differential Revision: https://reviews.freebsd.org/D2277 Reviewed by: alc, kib MFC after: 2 weeks Sponsored by: Norse Corp, Inc. (forward porting to HEAD/10)
* gr_equal(): Fix a crash that could occur if the first group's member listMark Johnston2015-01-251-15/+10
| | | | | | | | was longer than the second's. There is no need to compute and compare the member list lengths in a separate pass, since we now just return false when comparing member names if the list lengths are not equal. MFC after: 2 weeks
* Fix renaming a group via the gr_copy functionBaptiste Daroussin2014-10-281-5/+12
| | | | | | | | | | Add a regression test to pw(8) because the bug was discovered via using: pw groupmod PR: 187189 Reported by: mcdouga9@egr.msu.edu Tested by: mcdouga9@egr.msu.edu Patch by: Marc de la Gueronniere
* libutil: Use O_CLOEXEC for internal file descriptors from open().Jilles Tjoelker2013-08-281-0/+819
|
* commit correct tested fix for gr_util.cDiane Bruce2013-03-091-46/+58
| | | | Approved by: theraven
* Cleanup gr_add() so it does not leak memDiane Bruce2013-03-072-53/+86
| | | | | | | | | This is part of ongoing work on sbin/pw M libutil.h M gr_util.c Approved by: theraven
* libutil: fix typo in comment for gr_fini.Mateusz Guzik2013-01-131-1/+1
| | | | Submitted by: Christoph Mallon <christoph.mallon gmx.de>
* libutil: utilize strsep instead of strcat in a loop in gr_makeMateusz Guzik2013-01-131-6/+10
| | | | Submitted by: Christoph Mallon <christoph.mallon gmx.de>
* libutil: move group_line_format into the scop of its only user.Mateusz Guzik2013-01-131-2/+1
| | | | Submitted by: Christoph Mallon <christoph.mallon gmx.de>
* libutil: eliminate 'found' variable in gr_equalMateusz Guzik2013-01-131-8/+5
| | | | Submitted by: Christoph Mallon <christoph.mallon gmx.de>
* Simplify pointing dst after the end of all the gr_mem pointers in newgrBaptiste Daroussin2012-12-281-2/+1
| | | | | Submitted by: pjd Reviewed by: db
* errno = ENOMEM was supposed to be removed not return (NULL);Baptiste Daroussin2012-12-281-1/+1
| | | | Submitted by: gcooper
* malloc() sets errno to ENOMEM already.Baptiste Daroussin2012-12-281-5/+1
| | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
* Do not leave parts of the new group uninitialized in gr_dup().Baptiste Daroussin2012-12-281-0/+4
| | | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de> Reported by: pjd
* avoid arithmetic on uintptr_tBaptiste Daroussin2012-12-271-1/+1
| | | | | Submitted by: pjd Reviewed by: jilles
* cast to uintptr_t to properly calculate offsetBaptiste Daroussin2012-12-271-1/+1
| | | | | Reported by: mdf Submitted by: db
* Add O_CLOEXEC to flopenBaptiste Daroussin2012-12-272-2/+2
| | | | Requested by: jilles
* gr_dup: simplify duplication of groupBaptiste Daroussin2012-12-271-21/+20
| | | | Submitted by: db
* - Clean up previous gr_add use malloc instead of callocBaptiste Daroussin2012-12-272-5/+4
| | | | | | - Fix tinderbox error Submitted by: db
* New gr_add function to provide a clean and safe method to append a new memberBaptiste Daroussin2012-12-272-0/+42
| | | | | | into an existing group. Submitted by: db
* Use flopen(3) instead of open(2) + flock(2)Baptiste Daroussin2012-12-272-9/+4
|
* only rename(2) after chmod(2) has succeedBaptiste Daroussin2012-11-201-7/+3
| | | | | | report error if chmod(2) fails Reported by: jh
* change mode the group file to 0644 after a successfull rename(2)Baptiste Daroussin2012-11-201-1/+8
|
* backout r242319, racy and not done in the right placeBaptiste Daroussin2012-10-292-18/+0
| | | | Reported by: Garrett Cooper <yanegomi@gmail.com>
* make pw_init and gr_init fail if the specified master password or group file isBaptiste Daroussin2012-10-292-0/+20
| | | | | | a directory. MFC after: 1 month
* Revert user comparison back to user names as some user can share uids (root/toorBaptiste Daroussin2012-06-191-6/+13
| | | | | | | | | | | for example) get the username information from old_pw structures to still allow renaming of a user. Reported by: Claude Buisson <clbuisson@orange.fr> Approved by: des (mentor) MFC after: 3 weeks
* Detect file modification properly by using tv_nsec.Ed Schouten2012-02-101-1/+2
| | | | | | | POSIX 2008 standardizes st_mtim, meaning we can simply use nanosecond precision to detect file modification. MFC after: 2 weeks
* Consensus between bde and pjd seemed to be that if the function namesGuy Helmer2012-01-261-8/+8
| | | | | | are lined up, then any * after a long type should appear after the type instead of being in front of the function name on the following line.
* Make the comments consistent (capitalization, punctuation, andGuy Helmer2012-01-261-6/+10
| | | | | | format). Requested by bde
* Restore the parenthesis that are necessary around the constant values.Guy Helmer2012-01-261-7/+7
| | | | Requested by bde.
* Fix more disorder in prototypes and constants.Guy Helmer2012-01-161-46/+43
| | | | | | Fix header comments for each section of constants. Fix whitespace in #define lines. Fix unnecessary parenthesis in constants.
* Move struct pidfh definition into pidfile.c, and leave a forward declarationGuy Helmer2012-01-121-12/+6
| | | | | | | | | for pidfh in libutil.h in its place. This allows us to hide the contents of the pidfh structure, and also allowed removal of the "#ifdef _SYS_PARAM_H" guard from around the pidfile_* function prototypes. Suggested by pjd.
* More prototype formatting fixes, struct member formatting fixes,Guy Helmer2012-01-121-10/+17
| | | | | | and namespace fix for property_find() prototype. Provided by bde.
* Fix prototype formatting (indentation, long lines, and continued lines).Guy Helmer2012-01-111-23/+30
| | | | Requested by bde.
* Fix namespace issues with prototype parameter names.Guy Helmer2012-01-111-32/+32
| | | | | | Add missing prototype parameter names. Requested by bde.
* Fix forward structure declaration and prototype disorder.Guy Helmer2012-01-111-34/+33
| | | | Requested by bde.
* Constify arguments.Pawel Jakub Dawidek2012-01-111-1/+1
|
* Add pidfile_fileno() to obtain the file descriptor for an openGuy Helmer2012-01-101-0/+1
| | | | pidfile.
* Add new pw_make_v7 to make a passwd line (in v7 format) out of a struct passwdBaptiste Daroussin2012-01-052-1/+16
| | | | | | while here, fix missing parentheses of the return statement of pw_make. Approved by: des (mentor)
* Modify pw_copy:Baptiste Daroussin2011-12-153-1/+1198
| | | | | | | | | | | | | - if pw is NULL and oldpw is not NULL then the oldpw is deleted - if pw->pw_name != oldpw->pw_name but pw->pw_uid == oldpw->pw_uid then it renames the user add new gr_* functions so now gr_util API is similar to pw_util API, this allow to manipulate groups in a safe way. Reviewed by: des Approved by: des MFC after: 1 month
* - Commit work from libprocstat project. These patches add support for runtimeStanislav Sedov2011-05-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | file and processes information retrieval from the running kernel via sysctl in the form of new library, libprocstat. The library also supports KVM backend for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have been modified to take advantage of the library (as the bonus point the fstat(1) utility no longer need superuser privileges to operate), and the procstat(1) utility is now able to display information from memory dumps as well. The newly introduced fuser(1) utility also uses this library and able to operate via sysctl and kvm backends. The library is by no means complete (e.g. KVM backend is missing vnode name resolution routines, and there're no manpages for the library itself) so I plan to improve it further. I'm commiting it so it will get wider exposure and review. We won't be able to MFC this work as it relies on changes in HEAD, which was introduced some time ago, that break kernel ABI. OTOH we may be able to merge the library with KVM backend if we really need it there. Discussed with: rwatson
* Don't duplicate define the stdint types.David E. O'Brien2011-05-051-10/+1
|
* Add support for IEE/IEC (and now also SI) power of two notions ofXin LI2011-04-121-0/+236
| | | | | | | | | | prefixes (Ki, Mi, Gi...) for humanize_number(3). Note that applications has to pass HN_IEC_PREFIXES to use this feature for backward compatibility reasons. Reviewed by: arundel MFC after: 2 weeks
* Create the altix project branch. The altix project will add supportMarcel Moolenaar2010-03-108-2297/+0
| | | | | | | for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting is a two-module system, consisting of a base compute module and a CPU expansion module. SGI's NUMAFlex architecture can be an excellent platform to test CPU affinity and NUMA-aware features in FreeBSD.
* Remove login(3), logout(3) and logwtmp(3) from libutil.Ed Schouten2010-01-131-4/+0
| | | | | | | | | | These functions only apply to utmp(5). They cannot be kept intact when moving towards utmpx. The login(3) function would break, because its argument is an utmp structure. The logout(3) and logwtmp(3) functions cannot be used, since they provide a functionality which partially overlaps. Increment SHLIB_MAJOR to 9 to indicate the removal.
* Remove a dead store.Sean Farley2009-12-121-2/+2
| | | | MFC after: 5 days
* Make <libutil.h> work when included by itself.Ed Schouten2009-12-021-0/+28
| | | | | | | There are several reasons why it didn't work: - It was missing <sys/cdefs.h> for __BEGIN_DECLS. - It uses various primitive types that were not declared.