summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
AgeCommit message (Collapse)AuthorFilesLines
2021-02-02article fixes; from eddie yousephjmc1-3/+3
2021-01-08Make fts_{alloc,safe_changed}() const correcttb1-5/+5
Previously, this code was passing string constants to functions that did not declare their parameters as const. After this patch, the functions now declare that they do not modify these arguments, making it safe to pass string constants. Fixes -Wincompatible-pointer-types-discards-qualifiers. From Adam Barth <abarth google com> ok millert
2021-01-07sleep(3): don't bypass nanosleep(2) if seconds is zerocheloha1-4/+1
sleep(3) does not call nanosleep(2) if seconds is zero. This is bad. As a simplified interface to nanosleep(2), sleep(3) should delegate all decisions about whether or not to yield the CPU to nanosleep(2). This patch removes the nanosleep(2) bypass from sleep(3). This means that this code: sleep(0); will block for up to 1 tick, just like the equivalent nanosleep(2) call. Neither FreeBSD nor NetBSD bypass nanosleep(2) in the zero case, so this commit brings our sleep(3) closer to theirs in behavior. As an added bonus, sleep(3) will now *always* appear in a ktrace(1) as a call to nanosleep(2). ok millert@
2020-11-14Constify dktypenames and fstypenames in libc.guenther1-3/+3
Adjust variable declaration in disklabel to match. ok millert@ deraadt@
2020-10-20Align the basename(3) and dirname(3) prototypes with the POSIX spec:naddy4-10/+10
Both functions take a non-const parameter. Implementations may modify the passed string, even though ours do not. ok stsp@ deraadt@ millert@
2020-10-13Do some easy .data -> .rodata/.data.rel.ro conversionsguenther4-8/+8
ok millert@ deraadt@
2020-10-12make fixed-sized fixed-value mib[] arrays be constderaadt7-28/+15
ok guenther tb millert
2020-10-12mib[2] is no longer used; ok guentherderaadt1-2/+2
2020-07-06Add support for timeconting in userland.pirofti4-9/+9
This diff exposes parts of clock_gettime(2) and gettimeofday(2) to userland via libc eliberating processes from the need for a context switch everytime they want to count the passage of time. If a timecounter clock can be exposed to userland than it needs to set its tc_user member to a non-zero value. Tested with one or multiple counters per architecture. The timing data is shared through a pointer found in the new ELF auxiliary vector AUX_openbsd_timekeep containing timehands information that is frequently updated by the kernel. Timing differences between the last kernel update and the current time are adjusted in userland by the tc_get_timecount() function inside the MD usertc.c file. This permits a much more responsive environment, quite visible in browsers, office programs and gaming (apparently one is are able to fly in Minecraft now). Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others! OK from at least kettenis@, cheloha@, naddy@, sthen@
2020-04-21Prevent infinite for loop since i went from ssize_t to size_t. Patch fromdtucker1-3/+3
eagleoflqj via OpenSSH github PR#178, ok djm@, feedback & ok millert@
2020-03-13typo in commentdjm1-2/+2
spotted at https://fossies.org/linux/misc/openssh-8.2p1.tar.gz/codespell.html
2020-02-08correct Research Unix edition "appeared in" use in HISTORYjsg2-6/+6
Starting from "Combined Table of Contents" in Doug McIlroy's "A Research UNIX Reader" a table of which edition manuals appeared in. Checked against manuals from bitsavers/TUHS and source from TUHS where available. Ingo points out there are cases where something is included but not documented until a later release. bcd(6) v6 v7 printf(3) v2 v4 abort(3) v5 v6 system(3) v6 v7 fmod(3) v5 v6 ok schwarze@
2020-02-05More precision regarding the openlog(3) *ident argument;schwarze1-21/+61
direction suggested by Laurence Tratt <laurie at tratt dot net>, part of the wording from deraadt@. While here, add the missing STANDARDS section, correct HISTORY, drop redundant verbiage from RETURN VALUES, and garbage collect .Tn. OK sthen@ jmc@ millert@ and Laurence Tratt, and deraadt@ likes one line of the patch in particular.
2019-12-21Warn that auth_call(3) users should include a "--" argument beforejsg1-2/+7
non-optional arguments to stop getopt(3) processing. ok deraadt@
2019-12-10Remove includes that are no longer neeed after tedu's simplification.millert1-4/+1
OK jca@
2019-12-04libc's authentication privsep layer performed insufficient usernamederaadt2-10/+39
validation. Repair work mostly by markus and millert, first of all solving the primary problem, then adding some additional validation points. And then futher validation in login and su. This will be 6.5/021_libcauth.patch.sig and 6.6/010_libcauth.patch.sig Reported by Qualys
2019-10-18setting uid to -1 won't work with setresuid, so detect that conditiontedu1-1/+19
and return an error instead. may prevent some unset/missing confusion. ok deraadt millert
2019-09-02More correction of section 3 layout. directory->opendir, fts->fts_open,deraadt7-59/+36
getcap->cgetent. pwcache->user_from_uid. And then repair references. ok jmc
2019-08-30ypclnt -> yp_bind;jmc1-3/+3
2019-08-30mop up stdarg rename; ok deraadtjmc1-3/+3
2019-08-11No specific called "exec(3)", so move primary manpage to a name whichderaadt3-14/+10
does exist -- execv(3). Still call this a family but without "Nm". Adjust Xr in various pages to refer to the precise function used rather than the family, in most cases the semantics of execve(2) are being referenced, so change the Xr. ok jmc
2019-07-26Replace cross-references to sigvec(3) with sigaction(2).millert1-5/+3
OK guenther@
2019-07-05improve verb-tense for explaining the calling convention of __deraadt1-3/+3
ok guenther jmc
2019-07-03snprintf/vsnprintf return < 0 on error, rather than -1.deraadt1-2/+2
2019-07-02The "always hint that getpw operation is happening with access() the YPderaadt3-3/+16
lock file" would trash errno, creating confusion. One instance found by richardipsum@fastmail, other two identified from original commit ok millert
2019-06-30tweak previous; ok guentherjmc1-5/+6
2019-06-29Document that getcwd() and realpath() are built on system calls thatguenther1-2/+17
have a different calling convention than the standard function...as seen in kdump output. ok deraadt@ schwarze@
2019-06-28When system calls indicate an error they return -1, not some arbitraryderaadt17-55/+55
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2019-06-28delete duplicate .Xr below SEE ALSOschwarze1-3/+2
2019-05-16More consistently put remarks about the less useful LC_* categoties,schwarze3-6/+37
i.e. those other than LC_CTYPE, into the CAVEATS section, and standardize wording somewhat. OK jmc@
2019-05-13The fd used by nlist() isn't application visible, so mark it close-on-execguenther1-2/+2
to avoid leaking it ok deraadt@
2019-03-23Remove useless secure_path(3) calls.millert2-25/+12
There is no point in checking permissions of files in root-owned directories. If it even was a problem, secure_path(3) suffers from unsolvable TOCTOU issues. OK deraadt@
2019-03-08remove a sentence that was once helpful when dirname.3 and basename.3benno1-3/+3
shared one manpage. ok florian@
2019-02-04Make gl_pathc, gl_matchc and gl_offs size_t in glob_t to match POSIX.millert2-25/+24
This requires a libc major version bump. OK deraadt@
2019-01-25I am retiring my old email address; replace it with my OpenBSD one.millert17-40/+40
2019-01-13Restore .Xr to pthread_sigmaskjca1-3/+4
Pointed out by naddy@
2019-01-12Move sigwait(3) from libpthread to libcjca3-3/+153
POSIX wants it in libc, that's where the function can be found on other systems. Reported by naddy@, input from naddy@ and guenther@. "looks ok" guenther@, ok deraadt@ Note: riding the libc/libpthread major cranks earlier today.
2018-12-28getgruid_r -> getgrgid_rtb1-3/+3
from Lauri Tirkkonen
2018-11-05Mention aligned_alloc(), prompted by Brad; ok jmc@otto1-4/+6
2018-10-31typo; fix from hiltjo posthumaderaadt1-3/+3
2018-10-30use Mdocdate;jmc1-2/+2
2018-10-30Add C11's timespec_get(3); minor bump for libc.guenther3-3/+136
Tweaked diff from brad@ manpage tweaks florian@ and jmc@ ok deraadt@ millert@
2018-10-09Fix a "copy-and-paste" error that Coverity picked up in the augment codedlg1-2/+2
This brings it back in line with the macros. via Paco A. and the FRRouting project. ok deraadt@ visa@ guenther@ tb@
2018-09-22Correct the uid_from_user() and gid_from_group() comments.millert1-7/+7
2018-09-13missing comma in previous;jmc1-2/+2
2018-09-13Add uid_from_user() and gid_from_group(), derived from pax's cache.c.millert3-84/+440
It replaces the existing pwcache.c functions user_from_uid(3) and group_from_gid(3) with the pax equivalents. Adapted from NetBSD (mycroft) changes from our own pax's cache.c. OK guenther@
2018-08-21Use an mmap()'d buffer instead of a static buffer for the contentsmillert3-80/+136
of the pointer returned by getpw{ent,nam,uid}(). We unmap the buffer each time to catch callers using a stale passwd struct pointer. As a special case, we do not unmap the buffer if the previous lookup was for the same name or uid. This special case may be removed in the future. OK deraadt@
2018-07-12Add hw.ncpuonline to count the number of online CPUs.cheloha1-2/+2
The introduction of hw.smt means that logical CPUs can be disabled after boot and prior to suspend/resume. If hw.smt=0 (the default), there needs to be a way to count the number of hardware threads available on the system at any given time. So, import HW_NCPUONLINE/hw.ncpuonline from NetBSD and document it. hw.ncpu becomes equal to the number of CPUs given to sched_init_cpu() during boot, while hw.ncpuonline is equal to the number of CPUs available to the scheduler in the cpuset "sched_all_cpus". Set_SC_NPROCESSORS_ONLN equal to this new sysctl and keep _SC_NPROCESSORS_CONF equal to hw.ncpu. This is preferable to adding a new sysctl to count the number of configured CPUs and keeping hw.ncpu equal to the number of online CPUs because such a change would break software in the ecosystem that relies on HW_NCPU/hw.ncpu to measure CPU usage and the like. Such software in base includes top(1), systat(1), and snmpd(8), and perhaps others. We don't need additional locking to count the cardinality of a cpuset in this case because the only interfaces that can modify said cardinality are sysctl(2) and ioctl(2), both of which are under the KERNEL_LOCK. Software using HW_NCPU/hw.ncpu to determine optimal parallism will need to be updated to use HW_NCPUONLINE/hw.ncpuonline. Until then, such software may perform suboptimally. However, most changes will be similar to the change included here for libcxx's std::thread:hardware_concurrency(): using HW_NCPUONLINE in lieu of HW_NCPU should be sufficient for determining optimal parallelism for most software if the change to _SC_NPROCESSORS_ONLN is insufficient. Prompted by deraadt. Discussed at length with kettenis, deraadt, and sthen. Lots of patch tweaks from kettenis. ok kettenis, "proceed" deraadt
2018-04-27<sys/mount.h> and <sys/swap.h> no longer require <sys/param.h>guenther1-3/+3
ok krw@
2018-03-16improve markup quality in the cases found by the new "--" style messageschwarze1-5/+4