summaryrefslogtreecommitdiffstats
path: root/libutil
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* sigset() is the name of function specified by SUSv4.Konstantin Belousov2009-11-261-4/+4
| | | | | | Replace it to avoid conflict. MFC after: 3 weeks
* Revert (once again, and hopefully for the last time) to flock(2) locks.Dag-Erling Smørgrav2009-06-061-8/+5
| | | | | | The problem with fcntl(2) locks is that they are not inherited by child processes. This breaks pidfile(3), where the common idiom is to open and lock the PID file before daemonizing.
* Merge user/peter/kinfo branch as of r185547 into head.Peter Wemm2008-12-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes struct kinfo_filedesc and kinfo_vmentry such that they are same on both 32 and 64 bit platforms like i386/amd64 and won't require sysctl wrapping. Two new OIDs are assigned. The old ones are available under COMPAT_FREEBSD7 - but it isn't that simple. The superceded interface was never actually released on 7.x. The other main change is to pack the data passed to userland via the sysctl. kf_structsize and kve_structsize are reduced for the copyout. If you have a process with 100,000+ sockets open, the unpacked records require a 132MB+ copyout. With packing, it is "only" ~35MB. (Still seriously unpleasant, but not quite as devastating). A similar problem exists for the vmentry structure - have lots and lots of shared libraries and small mmaps and its copyout gets expensive too. My immediate problem is valgrind. It traditionally achieves this functionality by parsing procfs output, in a packed format. Secondly, when tracing 32 bit binaries on amd64 under valgrind, it uses a cross compiled 32 bit binary which ran directly into the differing data structures in 32 vs 64 bit mode. (valgrind uses this to track file descriptor operations and this therefore affected every single 32 bit binary) I've added two utility functions to libutil to unpack the structures into a fixed record length and to make it a little more convenient to use.
* Fixed style issues with variable ordering and naming, spacing andSean Farley2008-11-231-75/+97
| | | | | | | | | | | | | | | | | parentheses. Fixed alignment issue in gr_dup() in its assignment of gr_mem using a struct to force alignment without performing alignment mathematics. This was noticed recently with libutil was built with WARNS=6 on platform such as sparc64. Added checks to gr_dup(), gr_equal() and gr_make() to prevent segfaults when examining struct group's with the struct members pointing to NULL's. With fix of alignment issue, restore WARNS?=6. Reviewed by: des MFC after: 1 week
* style(9) fixes.Sean Farley2008-11-111-20/+14
| | | | MFC after: 1 week