summaryrefslogtreecommitdiffstats
path: root/libutil/libutil.h
Commit message (Collapse)AuthorAgeFilesLines
* Recommit everything, add chpass, improve history (except for a few files ↵Cameron Katri2021-05-021-26/+2
| | | | that git-filter-repo dislikes for some reason [_secure_path.c and login_cap.h])
* Add function getlocalbase() to libutil.Stefan Eßer2020-11-181-0/+2
| | | | | | | | | | | | | | | This function returns the path to the local software base directory, by default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.h when building the world). The value returned can be overridden by 2 methods: - the LOCALBASE environment variable (ignored by SUID programs) - else a non-default user.localbase sysctl value Reviewed by: hps (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27236
* Revert the whole getlocalbase() set of changes while a different design isScott Long2020-11-151-6/+0
| | | | hashed out.
* Fix a problem with r367686 related to the use of ssize_t. Not sure how thisScott Long2020-11-141-0/+5
| | | | | | escaped prior testing, but it should be better now. Reported by: lots
* Add the library function getlocalbase and its manual page. This helps toScott Long2020-11-141-0/+1
| | | | | | | | unify the retrieval of the various ways that the local software base directory, typically "/usr/local", is expressed in the system. Reviewed by: se Differential Revision: https://reviews.freebsd.org/D27022
* Make pw_scan(3) more compatible with getpwent(3) et. al. when processingIan Lepore2018-07-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | data from /etc/passwd rather than /etc/master.passwd. The libc getpwent(3) and related functions automatically read master.passwd when run by root, or passwd when run by a non-root user. When run by non- root, getpwent() copes with the missing data by setting the corresponding fields in the passwd struct to known values (zeroes for numbers, or a pointer to an empty string for literals). When libutil's pw_scan(3) was used to parse a line without the root-accessible data, it was leaving garbage in the corresponding fields. These changes rename the static pw_init() function used by getpwent() and friends to __pw_initpwd(), and move it into pw_scan.c so that common init code can be shared between libc and libutil. pw_scan(3) now calls __pw_initpwd() before __pw_scan(), just like the getpwent() family does, so that reading an arbitrary passwd file in either format and parsing it with pw_scan(3) returns the same results as getpwent(3) would. This also adds a new pw_initpwd(3) function to libutil, so that code which creates passwd structs from scratch in some manner that doesn't involve pw_scan() can initialize the struct to the values expected by lots of existing code, which doesn't expect to encounter NULL pointers or garbage values in some fields.
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-261-1/+3
| | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts.
* Introduce the flopenat(3) function.Mariusz Zaborski2017-08-041-0/+1
| | | | | Reviewed by: des, emaste Differential Revision: https://reviews.freebsd.org/D11690
* 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)
* Cleanup gr_add() so it does not leak memDiane Bruce2013-03-071-1/+1
| | | | | | | | | This is part of ongoing work on sbin/pw M libutil.h M gr_util.c Approved by: theraven
* - Clean up previous gr_add use malloc instead of callocBaptiste Daroussin2012-12-271-1/+1
| | | | | | - Fix tinderbox error Submitted by: db
* New gr_add function to provide a clean and safe method to append a new memberBaptiste Daroussin2012-12-271-0/+2
| | | | | | into an existing group. Submitted by: db
* 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-051-0/+1
| | | | | | while here, fix missing parentheses of the return statement of pw_make. Approved by: des (mentor)
* Modify pw_copy:Baptiste Daroussin2011-12-151-1/+7
| | | | | | | | | | | | | - 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-101-212/+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.
* 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.
* 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.
* Merge hexdump(9) to userland as hexdump(3) in libutil. I'm tired of doingJohn Baldwin2008-07-011-0/+8
| | | | | | this by hand in userland utilities. MFC after: 1 month
* Add four utility functions related to struct grp processing modeled in-partSean Farley2008-04-231-0/+7
| | | | | | | | | | | | | | | | | | | after similar calls related to struct pwd in libutil/pw_util.c: - gr_equal() Perform a deep comparison of two struct grp's. It does a thorough, yet unoptimized comparison of all the members regardless of order. - gr_make() Create a string (see group(5)) from a struct grp. - gr_dup() Duplicate a struct grp. Returns a value that is a single contiguous block of memory. - gr_scan() Create a struct grp from a string (as produced by gr_make()). MFC after: 3 weeks
* Constify the first argument to expand_number() so that it canJohn Birrell2007-11-181-1/+1
| | | | be called with a const without the compiler grisling.
* Implement expand_number(3), which is the opposite of humanize_number(3), ie.Pawel Jakub Dawidek2007-09-011-0/+1
| | | | | | | | | | a number in human-readable form is converted to int64_t, for example: 123b -> 123 10k -> 10240 16G -> 17179869184 First version submitted by: Eric Anderson <anderson@freebsd.org> Approved by: re (bmah)
* Well gag me with a spoon... I'm so used to working at high WARNS levelsDag-Erling Smørgrav2007-05-101-1/+1
| | | | that I make stupid fundamental mistakes like this when I don't.
* I'm tired of seeing this done incorrectly and non-portably, so add aDag-Erling Smørgrav2007-05-101-0/+1
| | | | | | flopen(3) function which reliably opens and locks a file. MFC after: 3 weeks
* Add utility functions for checking if a given kernel module is loaded,Dag-Erling Smørgrav2006-02-181-0/+5
| | | | and loading it.
* Add a family of functions for reliable pidfiles handling.Pawel Jakub Dawidek2005-08-241-0/+17
| | | | | Idea from: jmg Discussed on: arch@
* Add humanize_number(3) to libutil for formating numbers into a humanPawel Jakub Dawidek2004-05-241-0/+11
| | | | | | readable form. Obtained from: NetBSD
* Add the clean_environment call to libutil.h also.Tim Kientzle2004-02-261-0/+2
| | | | MFC after: 2 weeks
* ANSIfy, WARNSify, CONSTify. Bit of style(9)-ify.Mark Murray2003-10-181-6/+4
|
* Add passwd manipulation code based on parts of vipw and chpass.Dag-Erling Smørgrav2002-05-081-0/+29
| | | | Sponsored by: DARPA, NAI Labs
* Remove multi-line __P() usage.David E. O'Brien2002-03-221-8/+7
|
* Remove __P() usage.David E. O'Brien2002-03-211-17/+17
|
* remove emalloc,ecalloc,erealloc,estrdupAssar Westerlund2001-07-231-4/+0
|
* add ecalloc, emalloc, erealloc, estrdup - versions of the e-lessAssar Westerlund2001-07-221-0/+4
| | | | functions that exit instead of failing
* o Slap some "_"'s in front of variable names relating to extattr functions,Robert Watson2001-03-221-3/+3
| | | | | | so as not to pollute application namespace. Submitted by: bde
* o Rename "namespace" argument to "attrnamespace" as namespace is a C++Robert Watson2001-03-191-2/+3
| | | | | | | | reserved word, causing breakage when a C++ program included libutil.h This change will be propagated elsewhere shortly. Submitted by: jkh Obtained from: TrustedBSD Project