1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00
Commit Graph

1025 Commits

Author SHA1 Message Date
daniel 7ab78e8bd0 FNM_CASEFOLD (and its synonym FNM_IGNORECASE) are now part of POSIX.1-2024
Flagged by Sortix os-test.

ok millert@, guenther@
2026-03-29 14:08:46 +00:00
daniel b75055f7ac psignal(3): align the type of the signal parameter with POSIX
POSIX uses an int for the signal number instead of an unsigned int. NetBSD
made this change in 2010 and FreeBSD made this change in 2016. Follow suit
with the other BSDs and match what POSIX specifies.

This should not have an impact on the ABI and therefore no bump is needed.

Flagged by Sortix os-test.

ok deraadt@, millert@
2026-03-23 21:33:43 +00:00
deraadt 7545cb8cf1 oops, deleted the wrong side of the #ifdef 2026-03-10 04:30:34 +00:00
deraadt 154e586d90 Remove pdp11 support (no joke) 2026-03-10 04:29:08 +00:00
ratchov a7596b3f89 libsndio: Increase the length of display strings and control names
Fixes truncated uaudio(4) device names. As we're at it, increase other
strings and add padding in the sioctl_desc structure, for future use.
2026-01-22 09:31:22 +00:00
ratchov 7d1af24765 libsndio: Add the new sio_onxrun(3) function to report underruns
libsndio recovers after underruns, so in most cases they should just
be ignored. However there are cases where a program may use an external
audio clock (ex. an RTP stream) and resample to make the local audio
rate match the remote rate to keep the latency constant. To do so, the
program must measure continuously the clock drift and calculate the
resampling ratio. Upon underrun, such programs must restart the
measurements, hence the need for this new interface.

ok armani
2026-01-22 09:24:26 +00:00
jca 1f2e215df0 Stop doing XDG setup in setusercontext(LOGIN_SETALL)
As suggested by kettenis@ and deraadt, including LOGIN_SETXDGENV in
LOGIN_SETALL, the latter being used in a bunch of place, appears to be
a mistake. The mkdir(2) and fchown(2) / fchmod(2) calls made by
setusercontext(LOGIN_SETXDGENV) result in pledge(2) violations in at
least calendar(1) and inetd(8), as reported by jmc@ and lucas@
respectively. Also it brings little to no advantage since most of the
login managers analyzed so far require an explicit change to export the
XDG_RUNTIME_DIR variable.

So move LOGIN_SETXDGENV out of LOGIN_SETALL. If you started relying on
this in one of your port, please adapt the code to explicitely pass
LOGIN_SETXDGENV. xenodm(1) will be fixed shortly, patches for login(1)
and sshd(8) are waiting for reviews.

ok deraadt@ robert@
2025-11-24 12:37:15 +00:00
tb 4a796cf042 time.h: const correct tm_zone in struct tm
The Base Specifications, Issue 8 incorporated Austin Group Defect 1533
adding long tm_gmtoff (which we already have) and const char *tm_zone,
which we have but without const. Adapt our struct. This was tested in
an amd64 bulk without fallout and fixes a bunch of compiler warnings
from strptime.c r1.32 where gmt[] and utc[] were moved to rodata.

https://austingroupbugs.net/view.php?id=1533

ok jca millert
2025-11-20 10:58:11 +00:00
jca 2c4f7bac00 Implement XDG_RUNTIME_DIR support through setusercontext(LOGIN_SETXDGENV)
If LOGIN_SETXDGENV is passed in the flags, ensure the presence and
usability of a runtime directory dedicated to <uid>. Set the
XDG_RUNTIME_DIR variable only if the directory is usable.

With feedback from deraadt@, matthieu@ and guenther@.
ok deraadt@ robert@
2025-11-14 10:08:10 +00:00
semarie f90c654102 bump PTHREAD_KEYS_MAX to 512
the rust libstd emutls version is using one pthread_key per thread-variable. it
means the maximum number of thread-variable at a time is PTHREAD_KEYS_MAX.

with recent rustc 1.91.0, we start hiting the limit while compiling some
programs (like sysutils/rustic).

ok robert@
"Let's go 512 and hope someone eventually does proper TLS" deraadt@
2025-11-11 18:54:05 +00:00
claudio 7fe1ab940a Implement ffsl() and ffsll() using the compiler builtin __builtin_ctzl
now that all archs use at least gcc4.
ffsl() and ffsll() are now part of POSIX.
OK deraadt@, input from miod@ and jsg@
2025-10-24 11:30:06 +00:00
miod 27664962f0 Prepare for gcc 3 leaving the building, COMPILER_VERSION can no longer get
set to "gcc3".
2025-10-23 19:06:09 +00:00
brynet 7f0d88c8e0 Drop variable names from the swapctl(2) prototype, per style(9).
ok tb@
2025-10-07 12:02:21 +00:00
yasuoka b7f6c2eb76 Make the FILE object opaque. Move the __sFILE definition into
libc/hidden/_stdio.h.  All programs that refer to the internal
structure of the FILE object can't be compiled from now on.
std{in,out,err} doesn't refer __sF[] now, but the hidden __sF along
with __srget and __swbuf symbols are kept temporarily to make our
transition easier.  But those symbols will be deleted soon.  The shared
library versions are bumped for libc and all the other libraries that
refer to std{in,out,err}.

diff from guenther, tweak by me, tested by many
ok sthen tb
2025-07-16 15:33:05 +00:00
deraadt 7593782931 In the old gprof profiling subsystem, the simplistic profil() syscall
told the kernel about the sample buffer, and then the normal exit-time
_mcleanup() would finalize the buffer, open()'ed a file and write out
the details.  This file opening has become increasingly impossible
because of our privsep / privdrop, chroot, setresuid uid-dropping,
pledge, unveil, and other efforts.  So people stopped using gprof.
Programs which needed profiling needed substantial mitigation removal
changes to put them under test.

In the new gprof profiling subsystem, profil() is enhanced to provide more
buffer information to the kernel, as well as better instructions for where
the file should be written.  At normal exit-time mcleanup(), after finalizing
the buffer, the process simply terminates via _exit(2), and the kernel
does all the opening and writing in a safe way.  The file is now deposited
into the starting directory, or into PROFDIR as determined at program start,
with safety issues taken into consideration.

Additional side effecs:
- The monstartup(3) interface will go away, it cannot be supported.
- profil() is now allowed in pledge "stdio", access is decided by the -pg ELF note
- gmon.out is renamed to gmon.progname.pid.out, due to pervasive multi-process
  privsep practices

prompted originally by job and claudio for use in rpki-client and bgpd
advice from kettenis and claudio
2025-05-24 06:49:16 +00:00
claudio fd3d56f0fa siphash.h needs to include stddef.h for size_t and stdint.h for uint64_t
and friends.
OK tb@ miod@
2025-04-14 08:28:24 +00:00
miod ce1663765c a.out is no longer the commonly encountered binary file format, the world has
moved to ELF.

Move the a.out specific defines and macros, but the MID_xxx values, from
<sys/exec.h> to <a.out.h>, and update the few userland binaries which really
need these defines (i.e. boot-related tools for old architectures) to
explicitly include <a.out.h> when needed.

"Fine" deraadt@
2024-10-16 18:47:47 +00:00
guenther f2ddd4444c dladdr(3) is in POSIX-2024, though the structure type was renamed
to match Solaris and _not_ match glibc/BSDs and no one caught it
before publication.  Provide the new name but keep providing the
existing names under the same conditions as before.  Update #include
visibility and dlfcn(3) manpage and add restrict qualifiers.

ok deraadt@
2024-09-01 04:27:45 +00:00
bluhm 4491bd9062 Evaluate arguments of bitstring macros only once.
According to bit_alloc(3) man page the arguments to bitstring macros
are evaluated only once and may safely have side effects.  Fix the
implementation with temporary variables to fulfill this requirement.

OK florian@ deraadt@
2024-08-26 11:52:54 +00:00
guenther 24f9d669f8 Add <stdio_ext.h> with the seven APIs needed to have gnulib operate
without poking directly into the FILE structure.

Repeated testing, "nope, need a few more" feedback, and ok tb@
2024-08-12 20:56:55 +00:00
guenther bcac9d59b1 asprintf() and vasprintf() are in POSIX-2024. Update #include
visibility and manpages and add restrict qualifiers in all the
specified places to the *printf family.

ok millert@
2024-08-07 05:15:28 +00:00
guenther e490037411 wcslcpy() and wcslcat() are in POSIX-2024. Update #include visibility
and manpages and add restrict qualifiers.

ok millert@
2024-08-07 04:59:45 +00:00
guenther 4af81b37ce The improbable occurred: strlcpy(3) and strlcat(3) are in POSIX-2024.
memmem(3) was also added.  Update #include visibility and manpages
and add restrict qualifiers.

"never thought I'd see this day" millert@
2024-08-03 20:13:23 +00:00
guenther dfc5f6fe81 mkostemp(3) and reallocarray(3) are in POSIX-2024:
adjust #include visibility and update the reallocarray(3) manpage

ok millert@
2024-08-03 20:09:24 +00:00
guenther 04933f16a0 The {get,set}res[ug]id(2) family are in POSIX-2024's XSI option,
so adjust the #include visibility and update the manpage.

ok millert@
2024-08-02 22:14:54 +00:00
guenther c1d8b5d1f7 getentropy(2) is in POSIX-2024, so adjust the #include visibility,
change the "too much" error to EINVAL, add GETENTROPY_MAX to
<limits.h> (via sys/syslimits.h), and update the manpage.

ok deraadt@
2024-08-02 01:53:21 +00:00
jca 4ee4ae6a4d Add wcsnlen(3) declaration, missed in previous. 2024-07-14 10:04:17 +00:00
otto bc8a30fccf strmode takes a mode_t, not an int; prompted by Collin Funk.
ok kettenis@ deraadt@ tb@
2024-06-23 07:08:26 +00:00
ratchov 4aaef610e0 sndio: Add a display string to the sioctl_open API
For hardware devices, add a server.device control
with a single item and the device name as display
string.

Add the necessary sndioctl(1) bits to print it.
2024-05-24 15:10:26 +00:00
guenther 5f31b145b2 Add pathconfat(2): pathconf(2) but with at-fd and flags arguments,
the latter supporting the ability to get timestamp resolution of
symlinks.

ok deraadt@ millert@
2024-05-18 05:20:22 +00:00
florian b5a3756551 Add scandirat(3); from freebsd
To be used in httpd(8) shortly to prevent toctu issues.

This makes __fdopendir internally accessible to avoid unnecessary
syscalls in scandirat(3). Suggested & diff by guenther

suggested by & OK millert
tweak & OK guenther
OK tb, jca

This rides the libc crank.
2024-04-15 15:47:58 +00:00
millert 1aa88f2b27 Add mkdtemps(3), like mkdtemp(3) but with a suffix.
OK deraadt@ tb@
2024-03-01 21:30:40 +00:00
jca 0967fc9724 Move ctype.h defines to the _CTYPE_ prefix, avoids clashes with identifiers in ports
Even if those _[BCNLPSUX] defines are in the reserved namespace, some
ports make use of those identifiers and thus need pointless
headscratching and patches.  Just use a longer reserved prefix.
We can't just #undef those defines as they are used in libc.

Change similar to what NetBSD did around 2010.  Went through base builds
and an amd64 bulk build, the only fallout was lib(e)stdc++ base_ctype.h.
"make includes" will install the latest ctype.h and libstdc++ ctype_base.h.

"makes sense" deraadt@, ok sthen@ tb@
2024-02-04 13:03:18 +00:00
deraadt cafeb892b1 remove support for syscall(2) -- the "indirection system call" because
it is a dangerous alternative entry point for all system calls, and thus
incompatible with the precision system call entry point scheme we are
heading towards.  This has been a 3-year mission:
First perl needed a code-generated wrapper to fake syscall(2) as a giant
switch table, then all the ports were cleaned with relatively minor fixes,
except for "go".  "go" required two fixes -- 1) a framework issue with
old library versions, and 2) like perl, a fake syscall(2) wrapper to
handle ioctl(2) and sysctl(2) because "syscall(SYS_ioctl" occurs all over
the place in the "go" ecosystem because the "go developers" are plan9-loving
unix-hating folk who tried to build an ecosystem without allowing "ioctl".
ok kettenis, jsing, afresh1, sthen
2023-12-12 15:30:55 +00:00
miod 9b42e9bf97 Make sure TIB_INIT correctly initializes tib_thread_flags; regression
introduced in 1.3, causing sporadic pthread_main_np() erroneous results
(and possibly more subtle problems).

With and ok kurt@
2023-12-08 19:14:36 +00:00
schwarze ee97048084 According to the C11 standard, char32_t and char16_t are not part
of the C language but are part of the C library and have to be
declared in <uchar.h> - see paragraph 7.28.2.

In stark contrast, according to the C++11 standard, char32_t and char16_t
are part of the C++ language, namely, keywords - see paragraph 2.12.1.
Consequently, they must not be declared in a header file.

To resolve this vile contradiction, use the predefined macro __cplusplus
to find out which language is in use for the current compilation unit -
see C11 paragraph 6.10.8.3 and C++11 paragraph 16.8.1.

Reminded of the problem by naddy@.
OK naddy@ who tested in make build / make release.
Looks reasonable to millert@.
2023-09-05 23:16:01 +00:00
schwarze 46c354aa2b Provide C11 <uchar.h>.
OK millert@.
Tested by naddy@ in a bulk and by matthieu@ in the new foot(1) port.
I originally wrote the code in 2022 at the prodding of espie@.
Using one improvement to a manual page from jmc@.
2023-08-20 15:02:50 +00:00
guenther cef5a146e6 Add {get,set}thrname(2) for putting thread names in the kernel and
exposed in a new field returned by sysctl(KERN_PROC).  Update
pthread_{get,set}_name_np(3) to use the syscalls.  Show them, when
set, in ps -H and top -H output.

libc and libpthread minor bumps

ok mpi@, mvs@, deraadt@
2023-01-07 05:24:58 +00:00
jsg 893695cea0 Christos Zoulas agreed to rescind clause 3 and 4 in
NetBSD fsck.8 rev 1.35 fsutil.h rev 1.14 pathnames.h rev 1.2
netgroup_mkdb.8 rev 1.9 netgroup_mkdb.c rev 1.18 str.c rev 1.7
str.h rev 1.4 rdate.8 rev 1.11 rdate.c rev 1.19 extern.h rev 1.14
getnetgrent.c rev 1.41 netgroup.h rev 1.10
fparseln.3 rev 1.4 fparseln.c rev 1.10

our stringlist.c/stringlist.h are derived from getnetgrent.c
rfc868time.c from rdate.c
newfs/pathnames.h from fsck/pathnames.h

https://mail-index.netbsd.org/source-changes/2009/10/21/msg002182.html
Not all files are covered as some had copyright assigned to TNF in 1998.
2023-01-04 13:00:11 +00:00
jmc 2811b70e6c spelling fixes; from paul tagliamonte 2022-12-27 07:44:56 +00:00
millert 3d0c28f3eb Move CLOCKS_PER_SEC to sys/_time.h so the kernel has access to it.
This will be used in waitid(2) to set si_utime and si_stime.
The definition of struct timespec also moves from time.h to sys/_time.h
for struct itimerspec.  OK kettenis@
2022-10-25 16:30:30 +00:00
krw 5b146c4de6 Remove now unused and unreferenced disktab.h. 2022-08-31 11:04:41 +00:00
krw 55a3ec3029 Nuke disktab.h references in preparation for nuking disktab.h.
disktab.h has not been used or useful for a looooong time.

Detailed historical research by jsg@.

ok jsg@ deraadt@
2022-08-30 18:50:06 +00:00
tb c1d0be48fa Add #define for RTLD_NOLOAD missed in last ld.so commit. 2022-08-20 17:39:22 +00:00
guenther e0b9be3e0f POSIX 2008 TC2 requires <inttypes.h> to provide wchar_t
ok kettenis@ espie@
2022-07-31 01:27:31 +00:00
deraadt 91fc4dda8d Add a new clnt*_control CLSET_CONNECTED, which says the socket has already
been connected.  In the udp case, this means to use send(), not sendto()
ok jmatthew, claudio, miod
2022-07-15 17:33:28 +00:00
ratchov ec8a3410fb Add sio_flush(3) function to stop playback immediately
The new sio_flush(3) functions works the same way as sio_stop(3),
except that it doesn't wait for play buffer to be drained. Instead,
it discards its contents and returns immediately.
2022-04-29 08:30:48 +00:00
tedu 805ea04014 add rtable capability to login.conf.
from Matthew Martin
2022-03-01 01:22:11 +00:00
guenther 8d4335cb9b Mark all the rpc 'ops' vectors, for auth, client, service, and xdr,
as const, moving them from .data to .data.rel.ro.  The other BSDs
did this a long time ago; NetBSD did a chunk in 1998, which is long
enough I didn't bother to get exact dates for others.

ok deraadt@ millert@
2022-02-14 03:38:59 +00:00
robert d7bd1adbda introduce support for storing capability databases in /etc/login.conf.d;
anytime a class is looked up, the /etc/login.conf.d/${class} file will be
checked first for a matching class definition; this will allow us to easily
add custom login classes from packages

ok millert@
2022-02-10 13:06:07 +00:00