4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/etc/examples/mixerctl.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: mixerctl.conf,v 1.1 2014/07/16 13:21:33 deraadt Exp $
2 | #
3 | # mixerctl(1) configurable parameters. See mixerctl.conf(5) for details.
4 | #
5 |
6 | # output volume value for most audio cards
7 | #outputs.master=200
8 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/dirfd.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Written by Matthew Dempsky, 2011.
3 | * Public domain.
4 | */
5 |
6 | #include
7 | #include "telldir.h"
8 |
9 | int
10 | dirfd(DIR *dirp)
11 | {
12 | return (dirp->dd_fd);
13 | }
14 | DEF_WEAK(dirfd);
15 |
--------------------------------------------------------------------------------
/src/etc/examples/login_ldap.conf:
--------------------------------------------------------------------------------
1 | host=ldap+tls://1.2.3.4:8389
2 | host=ldap://localhost
3 | cacert=/etc/ssl/ca-ldap.pem
4 | scope=sub
5 | basedn=dc=openbsd,dc=org
6 | binddn=cn=admin,dc=openbsd,dc=org:\
7 | bindpw=password
8 | filter=(&(objectClass=user)(sAMAccountName=%u))
9 |
--------------------------------------------------------------------------------
/src/etc/examples/exports:
--------------------------------------------------------------------------------
1 | # $OpenBSD: exports,v 1.1 2014/07/12 03:52:39 deraadt Exp $
2 | #
3 | # NFS exports Database
4 | # See exports(5) for more information. Be very careful: misconfiguration
5 | # of this file can result in your filesystems being readable by the world.
6 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/fdatasync.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: fdatasync.c,v 1.1 2013/04/15 16:38:21 matthew Exp $ */
2 | /*
3 | * Written by Matthew Dempsky, 2013.
4 | * Public domain.
5 | */
6 |
7 | #include
8 |
9 | int
10 | fdatasync(int fd)
11 | {
12 | return (fsync(fd));
13 | }
14 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bgplg...
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/lib/libc/net/htonl.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: htonl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */
2 | /*
3 | * Public domain.
4 | */
5 |
6 | #include
7 | #include
8 |
9 | #undef htonl
10 |
11 | uint32_t
12 | htonl(uint32_t x)
13 | {
14 | return htobe32(x);
15 | }
16 |
--------------------------------------------------------------------------------
/src/lib/libc/net/htons.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: htons.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */
2 | /*
3 | * Public domain.
4 | */
5 |
6 | #include
7 | #include
8 |
9 | #undef htons
10 |
11 | uint16_t
12 | htons(uint16_t x)
13 | {
14 | return htobe16(x);
15 | }
16 |
--------------------------------------------------------------------------------
/src/lib/libc/net/ntohl.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ntohl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */
2 | /*
3 | * Public domain.
4 | */
5 |
6 | #include
7 | #include
8 |
9 | #undef ntohl
10 |
11 | uint32_t
12 | ntohl(uint32_t x)
13 | {
14 | return be32toh(x);
15 | }
16 |
--------------------------------------------------------------------------------
/src/lib/libc/net/ntohs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ntohs.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */
2 | /*
3 | * Public domain.
4 | */
5 |
6 | #include
7 | #include
8 |
9 | #undef ntohs
10 |
11 | uint16_t
12 | ntohs(uint16_t x)
13 | {
14 | return be16toh(x);
15 | }
16 |
--------------------------------------------------------------------------------
/src/etc/examples/printcap:
--------------------------------------------------------------------------------
1 | # $OpenBSD: printcap,v 1.2 2016/03/05 16:24:56 ajacoutot Exp $
2 |
3 | #lp|local line printer:\
4 | # :lp=/dev/lp:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:
5 |
6 | #rp|remote line printer:\
7 | # :lp=:rm=printhost:rp=lp:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:
8 |
--------------------------------------------------------------------------------
/src/etc/examples/dvmrpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: dvmrpd.conf,v 1.1 2014/07/11 16:36:35 deraadt Exp $
2 |
3 | # macros
4 | #fast="10"
5 |
6 | # global configuration
7 | #mfc-update no
8 |
9 | group {
10 | robustness 4
11 |
12 | interface bge0
13 | interface vlan5
14 | interface vlan6
15 | interface gre0
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/src/etc/examples/rc.shutdown:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # $OpenBSD: rc.shutdown,v 1.3 2014/07/14 10:15:33 ajacoutot Exp $
4 | #
5 | # If it exists, this script is run at system-shutdown by reboot(8),
6 | # halt(8). If the architecture supports keyboard requested halting,
7 | # it is also run by init(8) when such an event happens.
8 | #
9 |
--------------------------------------------------------------------------------
/src/include/curses.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: curses.h,v 1.5 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Placed in the public domain by Todd C. Miller
5 | * on June 17, 2003.
6 | */
7 |
8 | #ifndef _CURSES_H_
9 | #define _CURSES_H_
10 |
11 | #include
12 |
13 | #endif /* _CURSES_H_ */
14 |
--------------------------------------------------------------------------------
/src/lib/libc/crypt/Makefile.inc:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile.inc,v 1.27 2016/03/30 06:38:41 jmc Exp $
2 |
3 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt
4 |
5 | SRCS+= crypt.c cryptutil.c arc4random.c arc4random_uniform.c \
6 | blowfish.c bcrypt.c
7 |
8 | MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3
9 |
--------------------------------------------------------------------------------
/src/include/poll.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: poll.h,v 1.3 2003/10/29 16:41:13 deraadt Exp $ */
2 |
3 | /*
4 | * Written by Theo de Raadt, Public Domain
5 | *
6 | * Typical poll() implementations expect poll.h to be in /usr/include.
7 | * However this is not a convenient place for the real definitions.
8 | */
9 | #include
10 |
--------------------------------------------------------------------------------
/src/etc/examples/rc.local:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # $OpenBSD: rc.local,v 1.3 2014/07/14 10:15:33 ajacoutot Exp $
4 | #
5 | # Site-specific startup actions, daemons, and other things which
6 | # can be done AFTER your system goes into securemode. For actions
7 | # which should be done BEFORE your system has gone into securemode
8 | # please see /etc/rc.securelevel.
9 | #
10 |
--------------------------------------------------------------------------------
/src/lib/libc/string/ffsl.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ffsl.c,v 1.1 2025/10/24 11:30:06 claudio Exp $ */
2 |
3 | /*
4 | * Public domain.
5 | * Written by Claudio Jeker.
6 | */
7 |
8 | #include
9 |
10 | /*
11 | * ffs -- find the first (least significant) bit set
12 | */
13 | int
14 | ffsl(long mask)
15 | {
16 | return (mask ? __builtin_ctzl(mask) + 1 : 0);
17 | }
18 |
--------------------------------------------------------------------------------
/src/etc/examples/rc.securelevel:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # $OpenBSD: rc.securelevel,v 1.3 2014/07/14 10:15:33 ajacoutot Exp $
4 | #
5 | # site-specific startup actions, daemons, and other things which
6 | # can be done BEFORE your system goes into securemode. For actions
7 | # which should be done AFTER your system has gone into securemode
8 | # please see /etc/rc.local.
9 | #
10 |
--------------------------------------------------------------------------------
/src/etc/examples/ripd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ripd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 |
3 | fib-update yes
4 | redistribute static
5 | split-horizon poisoned
6 | triggered-updates yes
7 |
8 | interface rl0 {
9 | auth-type crypt
10 | auth-md-keyid 1
11 | auth-md 1 test
12 | cost 2
13 | }
14 |
15 | interface rl1 {
16 | auth-type simple
17 | auth-key secret
18 | }
19 |
--------------------------------------------------------------------------------
/src/lib/libc/string/ffsll.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ffsll.c,v 1.1 2025/10/24 11:30:06 claudio Exp $ */
2 |
3 | /*
4 | * Public domain.
5 | * Written by Claudio Jeker.
6 | */
7 |
8 | #include
9 |
10 | /*
11 | * ffs -- find the first (least significant) bit set
12 | */
13 | int
14 | ffsll(long long mask)
15 | {
16 | return (mask ? __builtin_ctzll(mask) + 1 : 0);
17 | }
18 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/bgpctl/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.2 2014/12/23 19:32:16 pascal Exp $
2 |
3 | PROGDIR= ${.CURDIR}/../../../usr.sbin/bgpctl
4 |
5 | LDSTATIC= ${STATIC}
6 | CFLAGS+= -I${PROGDIR} -I${PROGDIR}/../bgpd
7 | NOMAN= yes
8 |
9 | .include "${PROGDIR}/Makefile"
10 |
11 | BINDIR= /var/www/bin
12 | BINMODE= 000
13 |
14 | .PATH: ${PROGDIR} ${PROGDIR}/../bgpd
15 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/ping/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.3 2016/09/17 15:03:40 florian Exp $
2 |
3 | PROGDIR= ${.CURDIR}/../../../sbin/ping
4 |
5 | LDSTATIC= ${STATIC}
6 | CFLAGS+= -I${PROGDIR}
7 | NOMAN= yes
8 |
9 | BINDIR= /var/www/bin
10 | LINKS= ${BINDIR}/ping ${BINDIR}/ping6
11 |
12 | .include "${PROGDIR}/Makefile"
13 |
14 | BINMODE= 000
15 |
16 | .PATH: ${PROGDIR}
17 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strcoll_l.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strcoll_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */
2 | /*
3 | * Written in 2017 by Ingo Schwarze .
4 | * Released into the public domain.
5 | */
6 |
7 | #include
8 |
9 | int
10 | strcoll_l(const char *s1, const char *s2,
11 | locale_t locale __attribute__((__unused__)))
12 | {
13 | return strcmp(s1, s2);
14 | }
15 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/traceroute/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.4 2014/12/23 19:32:16 pascal Exp $
2 |
3 | PROGDIR= ${.CURDIR}/../../../usr.sbin/traceroute
4 |
5 | LDSTATIC= ${STATIC}
6 | CFLAGS+= -I${PROGDIR}
7 | NOMAN= yes
8 |
9 | BINDIR= /var/www/bin
10 | LINKS= ${BINDIR}/traceroute ${BINDIR}/traceroute6
11 |
12 | .include "${PROGDIR}/Makefile"
13 |
14 | BINMODE= 000
15 |
16 | .PATH: ${PROGDIR}
17 |
--------------------------------------------------------------------------------
/src/etc/examples/rbootd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: rbootd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 | #
3 | # Configuration file for rbootd server.
4 | #
5 |
6 | #
7 | # ethernet addr boot file(s) comments
8 | #
9 | #08:00:09:00:66:ad SYSHPBSD # snake (4.3BSD)
10 | #08:00:09:00:59:17 # vandy (anything)
11 | #8::9:10:1e:9b SYSHPUX,hp-ux # critter (HP-UX)
12 | #8::9:10:8A:14 SYSHPBSD,SYSHPUX,hp-ux # jaguar (either)
13 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strxfrm_l.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strxfrm_l.c,v 1.1 2017/09/05 03:16:14 schwarze Exp $ */
2 | /*
3 | * Written in 2017 by Ingo Schwarze .
4 | * Released into the public domain.
5 | */
6 |
7 | #include
8 |
9 | size_t
10 | strxfrm_l(char *dst, const char *src, size_t n,
11 | locale_t locale __attribute__((__unused__)))
12 | {
13 | return strxfrm(dst, src, n);
14 | }
15 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/pause.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: pause.c,v 1.7 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Written by Todd C. Miller
5 | * Public domain.
6 | */
7 |
8 | #include
9 | #include
10 |
11 | /*
12 | * Backwards compatible pause(3).
13 | */
14 | int
15 | pause(void)
16 | {
17 | sigset_t mask;
18 |
19 | return (sigprocmask(SIG_BLOCK, NULL, &mask) ? -1 : sigsuspend(&mask));
20 | }
21 |
--------------------------------------------------------------------------------
/src/etc/examples/rad.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: rad.conf,v 1.2 2018/07/25 05:11:49 jasper Exp $
2 |
3 | # The most simple configuration is a single interface section which uses the
4 | # interface IPv6 address to discover the prefix to announce.
5 | #interface em0
6 |
7 | # A slightly more complex case sets a prefix and basic DNS options.
8 | interface em1 {
9 | prefix 2001:db8::/32
10 | dns {
11 | nameserver 2001:db8::53
12 | search example.org
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/etc/examples/chio.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: chio.conf,v 1.1 2014/07/11 16:36:35 deraadt Exp $
2 | # Configuration file for chio(1).
3 | # Each stanza configures a changer, to enumerate the st(4) devices
4 | # corresponding to each ch(4) drive. This file is only required
5 | # if you need a non-default behavior. See chio(1) for details.
6 | #
7 | # Example: tell chio that drive 0 corresponds to rst3 and drive 1 to rst2
8 | # changer ch0 {
9 | # drive rst3
10 | # drive rst2
11 | # }
12 |
--------------------------------------------------------------------------------
/src/lib/libc/string/explicit_bzero.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
2 | /*
3 | * Public domain.
4 | * Written by Matthew Dempsky.
5 | */
6 |
7 | #include
8 |
9 | __attribute__((weak)) void
10 | __explicit_bzero_hook(void *buf, size_t len)
11 | {
12 | }
13 |
14 | void
15 | explicit_bzero(void *buf, size_t len)
16 | {
17 | memset(buf, 0, len);
18 | __explicit_bzero_hook(buf, len);
19 | }
20 | DEF_WEAK(explicit_bzero);
21 |
--------------------------------------------------------------------------------
/src/etc/examples/sasyncd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: sasyncd.conf,v 1.2 2020/06/30 21:58:13 benno Exp $
2 | # sample sasyncd configuration file
3 | # see sasyncd.conf(5)
4 |
5 | # IP addresses or hostnames of sasyncd(8) peers.
6 | #peer 10.0.0.2
7 | #peer 10.0.0.3
8 | #peer 10.0.0.4
9 |
10 | # Track master/backup state on this carp(4) interface.
11 | #interface carp1
12 |
13 | # Shared AES key, 16/24/32 bytes.
14 | #sharedkey 0x349fec85c11f6b658d5c457d4668e035f11dfdccb849d5053a8763787b74db70
15 |
--------------------------------------------------------------------------------
/src/etc/examples/ldapd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ldapd.conf,v 1.2 2020/09/19 09:46:35 tb Exp $
2 |
3 | schema "/etc/ldap/core.schema"
4 | schema "/etc/ldap/inetorgperson.schema"
5 | schema "/etc/ldap/nis.schema"
6 | schema "/etc/ldap/bsd.schema"
7 |
8 | listen on lo0
9 | listen on "/var/run/ldapi"
10 |
11 | #namespace "dc=example,dc=com" {
12 | # rootdn "cn=admin,dc=example,dc=com"
13 | # rootpw "secret"
14 | # index sn
15 | # index givenName
16 | # index cn
17 | # index mail
18 | #}
19 |
20 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgplgd/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.2 2024/01/26 18:11:49 job Exp $
2 |
3 | PROG= bgplgd
4 | SRCS= bgplgd.c slowcgi.c qs.c
5 | CFLAGS+= -Wall
6 | CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
7 | CLFAGS+= -Wmissing-declarations -Wredundant-decls
8 | CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
9 | CFLAGS+= -Wsign-compare
10 | CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../bgpd
11 | LDADD= -levent
12 | DPADD= ${LIBEVENT}
13 | MAN= bgplgd.8
14 |
15 | .include
16 |
--------------------------------------------------------------------------------
/src/lib/libc/crypt/crypt.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: crypt.c,v 1.31 2015/09/12 14:56:50 guenther Exp $ */
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | char *
8 | crypt(const char *key, const char *setting)
9 | {
10 | if (setting[0] == '$') {
11 | switch (setting[1]) {
12 | case '2':
13 | return bcrypt(key, setting);
14 | default:
15 | errno = EINVAL;
16 | return (NULL);
17 | }
18 | }
19 | errno = EINVAL;
20 | return (NULL);
21 | }
22 | DEF_WEAK(crypt);
23 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/bgplg/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.2 2014/12/23 19:32:16 pascal Exp $
2 |
3 | .PATH: ${.CURDIR}/..
4 |
5 | PROG= bgplg
6 | SRCS= bgplg.c misc.c
7 | CFLAGS+= -Wall
8 | CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
9 | CLFAGS+= -Wmissing-declarations -Wredundant-decls
10 | CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
11 | CFLAGS+= -Wsign-compare
12 | CFLAGS+= -I${.CURDIR}
13 | LDSTATIC= ${STATIC}
14 | MAN= bgplg.8
15 |
16 | BINDIR= /var/www/cgi-bin
17 | BINMODE= 000
18 |
19 | .include
20 |
--------------------------------------------------------------------------------
/src/etc/examples/remote:
--------------------------------------------------------------------------------
1 | # $OpenBSD: remote,v 1.3 2016/03/09 16:28:46 deraadt Exp $
2 | #
3 | # Remote host descriptions -- see cu(1), cgetcap(3), tty(4), remote(5)
4 | #
5 | # On OpenBSD the serial ports are typically called /dev/cua* or /dev/tty*.
6 | # The /dev/cua* calling unit should be used if available (some drivers do not
7 | # provide it). See tty(4) for more information.
8 | #
9 |
10 | unixhost:\
11 | :br#9600:
12 |
13 | cua00|For i386,macppc:\
14 | :dv=/dev/cua00:tc=unixhost:
15 |
16 | cuaa|For sparc:\
17 | :dv=/dev/cuaa:tc=unixhost:
18 |
--------------------------------------------------------------------------------
/src/etc/examples/man.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: man.conf,v 1.2 2015/03/27 21:17:16 schwarze Exp $
2 | # man(1)/apropos(1)/makewhatis(8) configuration, see man.conf(5).
3 | # This sample file shows the default settings.
4 |
5 | # Default search path for manual pages.
6 | # Copy these three lines, then add, delete, or reorder as desired.
7 | manpath /usr/share/man
8 | manpath /usr/X11R6/man
9 | manpath /usr/local/man
10 |
11 | # Options for terminal output.
12 | output width 78
13 | output indent 5
14 |
15 | # Option for PostScript and PDF output.
16 | output paper letter
17 |
--------------------------------------------------------------------------------
/src/etc/examples/ospf6d.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ospf6d.conf,v 1.2 2021/03/27 10:23:25 remi Exp $
2 |
3 | # global configuration
4 | # router-id 10.0.0.1
5 | # fib-update no
6 | # stub router no
7 | # spf-delay 1
8 | # spf-holdtime 5
9 |
10 | # hello-interval 10
11 | # metric 10
12 | # retransmit-interval 5
13 | # router-dead-time 40
14 | # router-priority 1
15 | # transmit-delay 1
16 |
17 | # rtlabel "DMZ" external-tag 1
18 |
19 | # areas
20 | area 0.0.0.5 {
21 | interface em0 {
22 | router-dead-time 20
23 | router-priority 5
24 | }
25 |
26 | interface em1 {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/etc/examples/httpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: httpd.conf,v 1.23 2025/02/21 10:19:52 mbuhl Exp $
2 |
3 | server "example.com" {
4 | listen on * port 80
5 | location "/.well-known/acme-challenge/*" {
6 | root "/acme"
7 | request strip 2
8 | }
9 | location * {
10 | block return 302 "https://$HTTP_HOST$REQUEST_URI"
11 | }
12 | }
13 |
14 | server "example.com" {
15 | listen on * tls port 443
16 | tls {
17 | certificate "/etc/ssl/example.com.fullchain.pem"
18 | key "/etc/ssl/private/example.com.key"
19 | }
20 | location "/pub/*" {
21 | directory auto index
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strcasecmp_l.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strcasecmp_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */
2 | /*
3 | * Written in 2017 by Ingo Schwarze .
4 | * Released into the public domain.
5 | */
6 |
7 | #include
8 |
9 | int
10 | strcasecmp_l(const char *s1, const char *s2,
11 | locale_t locale __attribute__((__unused__)))
12 | {
13 | return strcasecmp(s1, s2);
14 | }
15 |
16 | int
17 | strncasecmp_l(const char *s1, const char *s2, size_t n,
18 | locale_t locale __attribute__((__unused__)))
19 | {
20 | return strncasecmp(s1, s2, n);
21 | }
22 |
--------------------------------------------------------------------------------
/src/include/iso646.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: iso646.h,v 1.3 2001/10/11 00:05:21 espie Exp $ */
2 | /* $NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $ */
3 |
4 | /*
5 | * Written by J.T. Conklin 02/16/95.
6 | * Public domain.
7 | */
8 |
9 | #ifndef _ISO646_H_
10 | #define _ISO646_H_
11 |
12 | #ifndef __cplusplus
13 | #define and &&
14 | #define and_eq &=
15 | #define bitand &
16 | #define bitor |
17 | #define compl ~
18 | #define not !
19 | #define not_eq !=
20 | #define or ||
21 | #define or_eq |=
22 | #define xor ^
23 | #define xor_eq ^=
24 | #endif
25 |
26 | #endif /* !_ISO646_H_ */
27 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/bgplgsh/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.4 2025/07/12 05:28:33 miod Exp $
2 |
3 | .PATH: ${.CURDIR}/..
4 |
5 | PROG= bgplgsh
6 | SRCS= bgplgsh.c misc.c
7 | CFLAGS+= -Wall
8 | CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
9 | CLFAGS+= -Wmissing-declarations -Wredundant-decls
10 | CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
11 | CFLAGS+= -Wsign-compare
12 | CPPFLAGS+= -I${.CURDIR}
13 | CPPFLAGS+= -I${.CURDIR}/../../lib/libedit
14 | LDADD= -ledit -lcurses
15 | DPADD+= ${LIBEDIT} ${LIBCURSES}
16 | MAN= bgplgsh.8
17 |
18 | BINDIR= /usr/bin
19 |
20 | .include
21 |
--------------------------------------------------------------------------------
/src/include/ieeefp.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ieeefp.h,v 1.4 2009/09/27 21:23:55 martynas Exp $ */
2 |
3 | /*
4 | * Written by J.T. Conklin, Apr 6, 1995
5 | * Public domain.
6 | */
7 |
8 | #ifndef _IEEEFP_H_
9 | #define _IEEEFP_H_
10 |
11 | #include
12 | #include
13 |
14 | __BEGIN_DECLS
15 | extern fp_rnd fpgetround(void);
16 | extern fp_rnd fpsetround(fp_rnd);
17 | extern fp_except fpgetmask(void);
18 | extern fp_except fpsetmask(fp_except);
19 | extern fp_except fpgetsticky(void);
20 | extern fp_except fpsetsticky(fp_except);
21 | __END_DECLS
22 |
23 | #endif /* _IEEEFP_H_ */
24 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgpctl/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.20 2025/02/20 19:48:14 claudio Exp $
2 |
3 | .PATH: ${.CURDIR}/../bgpd
4 |
5 | PROG= bgpctl
6 | SRCS= bgpctl.c output.c output_json.c output_ometric.c parser.c \
7 | mrtparser.c json.c ometric.c
8 | SRCS+= util.c flowspec.c monotime.c
9 | CFLAGS+= -Wall
10 | CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
11 | CFLAGS+= -Wmissing-declarations
12 | CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
13 | CFLAGS+= -Wsign-compare
14 | CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../bgpd
15 | MAN= bgpctl.8
16 | LDADD= -lutil -lm
17 | DPADD+= ${LIBUTIL} ${LIBM}
18 |
19 | .include
20 |
--------------------------------------------------------------------------------
/src/etc/examples/doas.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: doas.conf,v 1.1 2016/09/03 11:58:32 pirofti Exp $
2 | # Configuration sample file for doas(1).
3 | # See doas.conf(5) for syntax and examples.
4 |
5 | # Non-exhaustive list of variables needed to build release(8) and ports(7)
6 | #permit nopass setenv { \
7 | # FTPMODE PKG_CACHE PKG_PATH SM_PATH SSH_AUTH_SOCK \
8 | # DESTDIR DISTDIR FETCH_CMD FLAVOR GROUP MAKE MAKECONF \
9 | # MULTI_PACKAGES NOMAN OKAY_FILES OWNER PKG_DBDIR \
10 | # PKG_DESTDIR PKG_TMPDIR PORTSDIR RELEASEDIR SHARED_ONLY \
11 | # SUBPACKAGE WRKOBJDIR SUDO_PORT_V1 } :wsrc
12 |
13 | # Allow wheel by default
14 | permit keepenv :wheel
15 |
--------------------------------------------------------------------------------
/src/etc/examples/wsconsctl.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: wsconsctl.conf,v 1.2 2021/03/24 18:50:54 bru Exp $
2 | #
3 | # wscons configurable parameters
4 | #
5 | #keyboard.repeat.del1=200 # change keyboard repeat/delay
6 | #keyboard.repeat.deln=50
7 | #keyboard.encoding=ru # use different keyboard encoding
8 | #keyboard.bell.volume=0 # mute keyboard beep
9 | #display.vblank=on # enable vertical sync blank for screen burner
10 | #display.screen_off=60000 # set screen burner timeout to 60 seconds
11 | #display.msact=off # disable screen unburn w/ mouse
12 | #mouse.tp.tapping=1 # enable tapping with default button mappings;
13 | # for customized mappings, list 3 button codes
14 |
--------------------------------------------------------------------------------
/src/usr.bin/bgplg/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.4 2016/09/17 15:03:39 florian Exp $
2 |
3 | .include
4 |
5 | SUBDIR= bgplg bgplgsh bgpctl ping traceroute
6 |
7 | INCFILES= bgplg.head \
8 | bgplg.foot \
9 | bgplg.css
10 |
11 | WWWDIR= ${DESTDIR}/var/www/htdocs/bgplg
12 | WWWFILES= openbgpd.gif \
13 | index.html
14 |
15 | distribution:
16 | for i in ${INCFILES}; do \
17 | ${INSTALL} -C -o root -g wheel -m 0644 $$i ${DESTDIR}/var/www/conf/; \
18 | done
19 | ${INSTALL} -d -o root -g wheel -m 0755 ${WWWDIR}
20 | for i in ${WWWFILES}; do \
21 | ${INSTALL} -C -o root -g wheel -m 0644 $$i ${WWWDIR}; \
22 | done
23 |
24 | .include
25 |
--------------------------------------------------------------------------------
/src/lib/libc/string/ffs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: ffs.c,v 1.10 2018/01/18 08:23:44 guenther Exp $ */
2 |
3 | /*
4 | * Public domain.
5 | * Written by Dale Rahn.
6 | */
7 |
8 | #include
9 |
10 | /*
11 | * ffs -- vax ffs instruction
12 | */
13 | int
14 | ffs(int mask)
15 | {
16 | int bit;
17 | unsigned int r = mask;
18 | static const signed char t[16] = {
19 | -28, 1, 2, 1,
20 | 3, 1, 2, 1,
21 | 4, 1, 2, 1,
22 | 3, 1, 2, 1
23 | };
24 |
25 | bit = 0;
26 | if (!(r & 0xffff)) {
27 | bit += 16;
28 | r >>= 16;
29 | }
30 | if (!(r & 0xff)) {
31 | bit += 8;
32 | r >>= 8;
33 | }
34 | if (!(r & 0xf)) {
35 | bit += 4;
36 | r >>= 4;
37 | }
38 |
39 | return (bit + t[ r & 0xf ]);
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/_Exit.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: _Exit.c,v 1.3 2013/04/03 03:39:29 guenther Exp $ */
2 |
3 | /*
4 | * Placed in the public domain by Todd C. Miller on January 21, 2004.
5 | */
6 |
7 | #include
8 | #include
9 |
10 | /*
11 | * _Exit() is the ISO/ANSI C99 equivalent of the POSIX _exit() function.
12 | * No atexit() handlers are called and no signal handlers are run.
13 | * Whether or not stdio buffers are flushed or temporary files are removed
14 | * is implementation-dependent in C99. Indeed, POSIX specifies that
15 | * _Exit() must *not* flush stdio buffers or remove temporary files, but
16 | * rather must behave exactly like _exit()
17 | */
18 | void
19 | _Exit(int status)
20 | {
21 | _exit(status);
22 | }
23 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/jrand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: jrand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | long
18 | jrand48(unsigned short xseed[3])
19 | {
20 | __dorand48(xseed);
21 | return ((long) xseed[2] << 16) + (long) xseed[1];
22 | }
23 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/nrand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: nrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | long
18 | nrand48(unsigned short xseed[3])
19 | {
20 | __dorand48(xseed);
21 | return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1);
22 | }
23 |
--------------------------------------------------------------------------------
/src/etc/examples/acme-client.conf:
--------------------------------------------------------------------------------
1 | #
2 | # $OpenBSD: acme-client.conf,v 1.6 2025/08/18 15:51:57 job Exp $
3 | #
4 | authority letsencrypt {
5 | api url "https://acme-v02.api.letsencrypt.org/directory"
6 | account key "/etc/acme/letsencrypt-privkey.pem"
7 | }
8 |
9 | authority letsencrypt-staging {
10 | api url "https://acme-staging-v02.api.letsencrypt.org/directory"
11 | account key "/etc/acme/letsencrypt-staging-privkey.pem"
12 | }
13 |
14 | domain example.com {
15 | alternative names { secure.example.com }
16 | domain key "/etc/ssl/private/example.com.key"
17 | domain full chain certificate "/etc/ssl/example.com.fullchain.pem"
18 | # Test with the staging server to avoid aggressive rate-limiting.
19 | #sign with letsencrypt-staging
20 | sign with letsencrypt
21 | }
22 |
--------------------------------------------------------------------------------
/src/etc/examples/ospfd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ospfd.conf,v 1.2 2018/08/07 07:06:20 claudio Exp $
2 |
3 | # macros
4 | id="192.0.2.5"
5 |
6 | # global configuration
7 | # router-id $id
8 | # fib-update no
9 | # stub router no
10 | # spf-delay 1
11 | # spf-holdtime 5
12 |
13 | # auth-key secret
14 | # auth-type simple
15 | # hello-interval 10
16 | # metric 10
17 | # retransmit-interval 5
18 | # router-dead-time 40
19 | # router-priority 1
20 | # transmit-delay 1
21 |
22 | # rtlabel "DMZ" external-tag 1
23 |
24 | # areas
25 | area 0.0.0.5 {
26 | interface em0 {
27 | auth-type simple
28 | auth-key secret
29 | }
30 |
31 | interface em1 {
32 | auth-type simple
33 | auth-key unknown
34 | }
35 | }
36 |
37 | area 0.0.0.7 {
38 | interface em2 {
39 | router-priority 5
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/charclass.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Public domain, 2008, Todd C. Miller
3 | *
4 | * $OpenBSD: charclass.h,v 1.3 2020/10/13 04:42:28 guenther Exp $
5 | */
6 |
7 | /*
8 | * POSIX character class support for fnmatch() and glob().
9 | */
10 | static const struct cclass {
11 | const char *name;
12 | int (*isctype)(int);
13 | } cclasses[] = {
14 | { "alnum", isalnum },
15 | { "alpha", isalpha },
16 | { "blank", isblank },
17 | { "cntrl", iscntrl },
18 | { "digit", isdigit },
19 | { "graph", isgraph },
20 | { "lower", islower },
21 | { "print", isprint },
22 | { "punct", ispunct },
23 | { "space", isspace },
24 | { "upper", isupper },
25 | { "xdigit", isxdigit },
26 | { NULL, NULL }
27 | };
28 |
29 | #define NCCLASSES (sizeof(cclasses) / sizeof(cclasses[0]) - 1)
30 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/l64a.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: l64a.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Written by J.T. Conklin .
4 | * Public domain.
5 | */
6 |
7 | #include
8 | #include
9 |
10 | char *
11 | l64a(long value)
12 | {
13 | static char buf[8];
14 | char *s = buf;
15 | int digit;
16 | int i;
17 |
18 | if (value < 0) {
19 | errno = EINVAL;
20 | return(NULL);
21 | }
22 |
23 | for (i = 0; value != 0 && i < 6; i++) {
24 | digit = value & 0x3f;
25 |
26 | if (digit < 2)
27 | *s = digit + '.';
28 | else if (digit < 12)
29 | *s = digit + '0' - 2;
30 | else if (digit < 38)
31 | *s = digit + 'A' - 12;
32 | else
33 | *s = digit + 'a' - 38;
34 |
35 | value >>= 6;
36 | s++;
37 | }
38 |
39 | *s = '\0';
40 |
41 | return(buf);
42 | }
43 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/mrand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: mrand48.c,v 1.6 2015/08/27 04:33:31 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | long
18 | mrand48(void)
19 | {
20 | if (__rand48_deterministic == 0)
21 | return (int)arc4random();
22 | __dorand48(__rand48_seed);
23 | return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
24 | }
25 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/lrand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: lrand48.c,v 1.5 2015/08/27 04:33:31 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | long
18 | lrand48(void)
19 | {
20 | if (__rand48_deterministic == 0)
21 | return arc4random() & 0x7fffffff;
22 | __dorand48(__rand48_seed);
23 | return ((long) __rand48_seed[2] << 15) + ((long) __rand48_seed[1] >> 1);
24 | }
25 |
--------------------------------------------------------------------------------
/src/etc/examples/ldpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ldpd.conf,v 1.3 2018/08/06 17:26:31 mestre Exp $
2 |
3 | # macros
4 | peer1="192.168.1.10"
5 |
6 | # global configuration
7 | # router-id 10.0.0.1
8 | # fib-update no
9 | # transport-preference ipv4
10 |
11 | address-family ipv4 {
12 | # explicit-null yes
13 | # keepalive 120
14 | # targeted-hello-accept yes
15 | # transport-address 10.0.0.1
16 |
17 | interface em0
18 | interface vlan5 {
19 | link-hello-holdtime 9
20 | link-hello-interval 3
21 | }
22 | targeted-neighbor 172.16.1.10
23 | }
24 |
25 | neighbor $peer1 {
26 | password "secret"
27 | }
28 |
29 | l2vpn CUST_A type vpls {
30 | bridge bridge0
31 | interface em1
32 | pseudowire mpw0 {
33 | # control-word no
34 | # status-tlv no
35 | neighbor-id 10.0.1.5
36 | pw-id 100
37 | }
38 | pseudowire mpw1 {
39 | neighbor-id 10.0.2.8
40 | pw-id 100
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/erand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: erand48.c,v 1.5 2015/09/14 13:30:17 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include
16 | #include "rand48.h"
17 |
18 | double
19 | erand48(unsigned short xseed[3])
20 | {
21 | __dorand48(xseed);
22 | return ldexp((double) xseed[0], -48) +
23 | ldexp((double) xseed[1], -32) +
24 | ldexp((double) xseed[2], -16);
25 | }
26 | DEF_WEAK(erand48);
27 |
--------------------------------------------------------------------------------
/src/etc/examples/dhcpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: dhcpd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 | #
3 | # DHCP server options.
4 | # See dhcpd.conf(5) and dhcpd(8) for more information.
5 | #
6 |
7 | # Network: 192.168.1.0/255.255.255.0
8 | # Domain name: my.domain
9 | # Name servers: 192.168.1.3 and 192.168.1.5
10 | # Default router: 192.168.1.1
11 | # Addresses: 192.168.1.32 - 192.168.1.127
12 | #
13 | option domain-name "my.domain";
14 | option domain-name-servers 192.168.1.3, 192.168.1.5;
15 |
16 | subnet 192.168.1.0 netmask 255.255.255.0 {
17 | option routers 192.168.1.1;
18 |
19 | range 192.168.1.32 192.168.1.127;
20 |
21 | host static-client {
22 | hardware ethernet 22:33:44:55:66:77;
23 | fixed-address 192.168.1.200;
24 | }
25 |
26 | host pxe-client {
27 | hardware ethernet 02:03:04:05:06:07;
28 | filename "pxeboot";
29 | next-server 192.168.1.1;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/a64l.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: a64l.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Written by J.T. Conklin .
4 | * Public domain.
5 | */
6 |
7 | #include
8 | #include
9 |
10 | long
11 | a64l(const char *s)
12 | {
13 | long value, digit, shift;
14 | int i;
15 |
16 | if (s == NULL) {
17 | errno = EINVAL;
18 | return(-1L);
19 | }
20 |
21 | value = 0;
22 | shift = 0;
23 | for (i = 0; *s && i < 6; i++, s++) {
24 | if (*s >= '.' && *s <= '/')
25 | digit = *s - '.';
26 | else if (*s >= '0' && *s <= '9')
27 | digit = *s - '0' + 2;
28 | else if (*s >= 'A' && *s <= 'Z')
29 | digit = *s - 'A' + 12;
30 | else if (*s >= 'a' && *s <= 'z')
31 | digit = *s - 'a' + 38;
32 | else {
33 | errno = EINVAL;
34 | return(-1L);
35 | }
36 |
37 | value |= digit << shift;
38 | shift += 6;
39 | }
40 |
41 | return(value);
42 | }
43 |
--------------------------------------------------------------------------------
/src/etc/examples/ntpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ntpd.conf,v 1.5 2019/11/11 16:44:37 deraadt Exp $
2 | # sample ntpd configuration file, see ntpd.conf(5)
3 |
4 | # Addresses to listen on (ntpd does not listen by default)
5 | #listen on *
6 |
7 | # sync to a single server
8 | #server ntp.example.org
9 |
10 | # use a random selection of NTP Pool Time Servers
11 | # see http://support.ntp.org/bin/view/Servers/NTPPoolServers
12 | servers pool.ntp.org
13 |
14 | # time server with excellent global adjacency
15 | server time.cloudflare.com
16 |
17 | # use a specific local timedelta sensor (radio clock, etc)
18 | sensor nmea0 trusted
19 |
20 | # use all detected timedelta sensors
21 | #sensor *
22 |
23 | # get the time constraint from a well-known HTTPS site
24 | constraint from "9.9.9.9" # quad9 v4 without DNS
25 | constraint from "2620:fe::fe" # quad9 v6 without DNS
26 | constraints from "www.google.com" # intentionally not 8.8.8.8
27 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wcsdup.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wcsdup.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */
2 | /* $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $ */
3 |
4 | /*
5 | * Copyright (C) 2006 Aleksey Cheusov
6 | *
7 | * This material is provided "as is", with absolutely no warranty expressed
8 | * or implied. Any use is at your own risk.
9 | *
10 | * Permission to use or copy this software for any purpose is hereby granted
11 | * without fee. Permission to modify the code and to distribute modified
12 | * code is also granted without any restrictions.
13 | */
14 |
15 | #include
16 | #include
17 |
18 | wchar_t *
19 | wcsdup(const wchar_t *str)
20 | {
21 | wchar_t *copy;
22 | size_t len;
23 |
24 | len = wcslen(str) + 1;
25 | copy = reallocarray(NULL, len, sizeof(wchar_t));
26 |
27 | if (!copy)
28 | return (NULL);
29 |
30 | return (wmemcpy(copy, str, len));
31 | }
32 | DEF_WEAK(wcsdup);
33 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/drand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: drand48.c,v 1.7 2015/09/14 13:30:17 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include
16 | #include "rand48.h"
17 |
18 | double
19 | drand48(void)
20 | {
21 | if (__rand48_deterministic == 0) {
22 | unsigned short rseed[3];
23 |
24 | arc4random_buf(rseed, sizeof rseed);
25 | return ldexp((double) rseed[0], -48) +
26 | ldexp((double) rseed[1], -32) +
27 | ldexp((double) rseed[2], -16);
28 | }
29 | return erand48(__rand48_seed);
30 | }
31 |
--------------------------------------------------------------------------------
/src/etc/examples/eigrpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: eigrpd.conf,v 1.2 2015/12/25 21:50:07 gsoares Exp $
2 |
3 | # global configuration
4 | # router-id 10.0.0.1
5 | # rdomain 1
6 | # fib-update yes
7 | # fib-priority-internal 28
8 | # fib-priority-external 52
9 |
10 | # IPv4
11 | address-family ipv4 {
12 | autonomous-system 1 {
13 | maximum-paths 4
14 | variance 8
15 |
16 | default-metric 100000 10 255 1 1500
17 | redistribute default
18 | redistribute connected
19 | redistribute 30.0.1.0/24
20 |
21 | interface em1
22 | interface em2 {
23 | hello-interval 3
24 | holdtime 10
25 | delay 20
26 | bandwidth 1000000
27 | }
28 | interface em3 {
29 | passive
30 | }
31 | }
32 | }
33 |
34 | # IPv6
35 | address-family ipv6 {
36 | maximum-paths 2
37 | variance 3
38 | bandwidth 100000
39 | delay 10
40 |
41 | autonomous-system 1 {
42 | default-metric 100000 10 255 1 1500
43 | redistribute default
44 |
45 | interface em1
46 | interface em2
47 | }
48 | autonomous-system 2 {
49 | interface em3
50 | interface em4
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/getprogname.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getprogname.c,v 1.4 2016/03/13 18:34:20 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2013 Antoine Jacoutot
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 |
20 | const char *
21 | getprogname(void)
22 | {
23 | return (__progname);
24 | }
25 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/lcong48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: lcong48.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | void
18 | lcong48(unsigned short p[7])
19 | {
20 | lcong48_deterministic(p);
21 | __rand48_deterministic = 0;
22 | }
23 |
24 | void
25 | lcong48_deterministic(unsigned short p[7])
26 | {
27 | __rand48_deterministic = 1;
28 | __rand48_seed[0] = p[0];
29 | __rand48_seed[1] = p[1];
30 | __rand48_seed[2] = p[2];
31 | __rand48_mult[0] = p[3];
32 | __rand48_mult[1] = p[4];
33 | __rand48_mult[2] = p[5];
34 | __rand48_add = p[6];
35 | }
36 | DEF_WEAK(lcong48_deterministic);
37 |
--------------------------------------------------------------------------------
/src/include/link_elf.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: link_elf.h,v 1.8 2022/01/28 04:59:15 guenther Exp $ */
2 |
3 | /*
4 | * Public domain.
5 | */
6 |
7 | #ifndef _LINK_ELF_H
8 | #define _LINK_ELF_H
9 |
10 | #include
11 |
12 | #ifndef DT_PROCNUM
13 | #define DT_PROCNUM 0
14 | #endif
15 |
16 | /*
17 | * struct link_map is a part of the protocol between the debugger and
18 | * ld.so. ld.so may have additional fields in its version of this
19 | * structure but those are ld.so private fields.
20 | */
21 | struct link_map {
22 | caddr_t l_addr; /* Base address of library */
23 | const char *l_name; /* Absolute path to library */
24 | void *l_ld; /* pointer to _DYNAMIC */
25 | struct link_map *l_next;
26 | struct link_map *l_prev;
27 | };
28 |
29 | struct dl_phdr_info {
30 | Elf_Addr dlpi_addr;
31 | const char *dlpi_name;
32 | const Elf_Phdr *dlpi_phdr;
33 | Elf_Half dlpi_phnum;
34 | };
35 |
36 | __BEGIN_DECLS
37 | int dl_iterate_phdr (int (*)(struct dl_phdr_info *, size_t, void *),
38 | void *);
39 | void *dl_unwind_find_exidx(const void *, int *);
40 | __END_DECLS
41 |
42 | #endif /* !_LINK_ELF_H */
43 |
--------------------------------------------------------------------------------
/src/include/stdbool.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: stdbool.h,v 1.7 2015/09/04 23:47:09 daniel Exp $ */
2 |
3 | /*
4 | * Written by Marc Espie, September 25, 1999
5 | * Public domain.
6 | */
7 |
8 | #ifndef _STDBOOL_H_
9 | #define _STDBOOL_H_
10 |
11 | #ifndef __cplusplus
12 |
13 | #if defined(__GNUC__) || \
14 | (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
15 | /* Support for C99: type _Bool is already built-in. */
16 | #define false 0
17 | #define true 1
18 |
19 | #else
20 | /* `_Bool' type must promote to `int' or `unsigned int'. */
21 | typedef enum {
22 | false = 0,
23 | true = 1
24 | } _Bool;
25 |
26 | /* And those constants must also be available as macros. */
27 | #define false false
28 | #define true true
29 |
30 | #endif
31 |
32 | /* User visible type `bool' is provided as a macro which may be redefined */
33 | #define bool _Bool
34 |
35 | #else /* __cplusplus */
36 | #define _Bool bool
37 | #define bool bool
38 | #define false false
39 | #define true true
40 | #endif /* __cplusplus */
41 |
42 | /* Inform that everything is fine */
43 | #define __bool_true_false_are_defined 1
44 |
45 | #endif /* _STDBOOL_H_ */
46 |
--------------------------------------------------------------------------------
/src/etc/examples/radiusd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: radiusd.conf,v 1.6 2025/03/10 04:05:14 yasuoka Exp $
2 |
3 | listen on 0.0.0.0
4 | listen on 0.0.0.0 accounting
5 | #listen on ::
6 | #listen on :: accounting
7 |
8 | client 127.0.0.1/32 {
9 | secret "secret"
10 | # "msgauth-required no" to disable message authentication check for
11 | # some implementations (e.g. login_radius(8)) don't support msgauth
12 | msgauth-required no
13 | }
14 | client 192.168.0.0/24 {
15 | secret "secret"
16 | }
17 |
18 | module bsdauth {
19 | set restrict-group users
20 | # set restrict-group operator
21 | }
22 |
23 | module file {
24 | set path "/etc/npppd/npppd-users"
25 | }
26 |
27 | module radius {
28 | set secret "testing123"
29 | set server "127.0.0.1"
30 | }
31 |
32 | module standard
33 |
34 | # Use a special name "strip-realm", then the path must be sepecified
35 | module strip-realm "/usr/libexec/radiusd/radiusd_standard" {
36 | set strip-atmark-realm true
37 | }
38 |
39 | authenticate *@local by bsdauth decorate-by strip-realm
40 | authenticate *@file by file decorate-by strip-realm
41 | authenticate * by radius
42 |
43 | account * to standard
44 |
--------------------------------------------------------------------------------
/src/include/libgen.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: libgen.h,v 1.10 2020/10/20 19:30:14 naddy Exp $ */
2 |
3 | /*
4 | * Copyright (c) 1997 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #ifndef _LIBGEN_H_
20 | #define _LIBGEN_H_
21 |
22 | #include
23 |
24 | __BEGIN_DECLS
25 | char *basename(char *);
26 | char *dirname(char *);
27 | __END_DECLS
28 |
29 | #endif /* _LIBGEN_H_ */
30 |
--------------------------------------------------------------------------------
/src/include/uchar.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: uchar.h,v 1.2 2023/09/05 23:16:01 schwarze Exp $ */
2 | /*
3 | * Written by Ingo Schwarze
4 | * and placed in the public domain on March 19, 2022.
5 | */
6 |
7 | #ifndef _UCHAR_H_
8 | #define _UCHAR_H_
9 |
10 | #include
11 | #include
12 |
13 | #ifndef _MBSTATE_T_DEFINED_
14 | #define _MBSTATE_T_DEFINED_
15 | typedef __mbstate_t mbstate_t;
16 | #endif
17 |
18 | #ifndef _SIZE_T_DEFINED_
19 | #define _SIZE_T_DEFINED_
20 | typedef __size_t size_t;
21 | #endif
22 |
23 | #define __STDC_UTF_16__ 1
24 | #define __STDC_UTF_32__ 1
25 |
26 | #if !defined(__cplusplus) || __cplusplus < 201103L
27 | typedef __uint16_t char16_t;
28 | typedef __uint32_t char32_t;
29 | #endif
30 |
31 | __BEGIN_DECLS
32 | size_t mbrtoc16(char16_t * __restrict, const char * __restrict, size_t,
33 | mbstate_t * __restrict);
34 | size_t c16rtomb(char * __restrict, char16_t, mbstate_t * __restrict);
35 | size_t mbrtoc32(char32_t * __restrict, const char * __restrict, size_t,
36 | mbstate_t * __restrict);
37 | size_t c32rtomb(char * __restrict, char32_t, mbstate_t * __restrict);
38 | __END_DECLS
39 |
40 | #endif /* !_UCHAR_H_ */
41 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/srand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: srand48.c,v 1.6 2015/09/13 08:31:48 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | int __rand48_deterministic;
18 |
19 | void
20 | srand48(long seed)
21 | {
22 | srand48_deterministic(seed);
23 | __rand48_deterministic = 0;
24 | }
25 |
26 | void
27 | srand48_deterministic(long seed)
28 | {
29 | __rand48_deterministic = 1;
30 | __rand48_seed[0] = RAND48_SEED_0;
31 | __rand48_seed[1] = (unsigned short) seed;
32 | __rand48_seed[2] = (unsigned short) (seed >> 16);
33 | __rand48_mult[0] = RAND48_MULT_0;
34 | __rand48_mult[1] = RAND48_MULT_1;
35 | __rand48_mult[2] = RAND48_MULT_2;
36 | __rand48_add = RAND48_ADD;
37 | }
38 | DEF_WEAK(srand48_deterministic);
39 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/tfind.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: tfind.c,v 1.7 2015/09/26 16:03:48 guenther Exp $ */
2 |
3 | /*
4 | * Tree search generalized from Knuth (6.2.2) Algorithm T just like
5 | * the AT&T man page says.
6 | *
7 | * The node_t structure is for internal use only
8 | *
9 | * Written by reading the System V Interface Definition, not the code.
10 | *
11 | * Totally public domain.
12 | */
13 | #include
14 |
15 | typedef struct node_t
16 | {
17 | char *key;
18 | struct node_t *llink, *rlink;
19 | } node;
20 |
21 | /* find a node, or return 0 */
22 | void *
23 | tfind(const void *vkey, void * const *vrootp,
24 | int (*compar)(const void *, const void *))
25 | {
26 | char *key = (char *)vkey;
27 | node **rootp = (node **)vrootp;
28 |
29 | if (rootp == (struct node_t **)0)
30 | return ((struct node_t *)0);
31 | while (*rootp != (struct node_t *)0) { /* T1: */
32 | int r;
33 | if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
34 | return (*rootp); /* key found */
35 | rootp = (r < 0) ?
36 | &(*rootp)->llink : /* T3: follow left branch */
37 | &(*rootp)->rlink; /* T4: follow right branch */
38 | }
39 | return (node *)0;
40 | }
41 |
--------------------------------------------------------------------------------
/src/etc/examples/vm.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: vm.conf,v 1.12 2024/07/12 12:35:32 florian Exp $
2 |
3 | #
4 | # Macros
5 | #
6 | sets="/var/www/htdocs/pub/OpenBSD/snapshots/amd64/"
7 |
8 | #
9 | # Virtual machines
10 | #
11 |
12 | switch "uplink" {
13 | # This switch will use veb0, defined by /etc/hostname.veb0, as
14 | # the underlying interface. bridge(4) is also supported
15 | interface veb0
16 | }
17 |
18 | switch "local" {
19 | interface veb1
20 | down
21 | }
22 |
23 | # OpenBSD snapshot install test
24 | vm "openbsd.vm" {
25 | boot $sets "bsd.rd"
26 |
27 | # First disk from 'vmctl create -s 4G "/home/vm/OpenBSD.img"'
28 | disk "/home/vm/OpenBSD.img"
29 |
30 | # Second disk from OpenBSD contains the install sets
31 | disk $sets "install60.img"
32 |
33 | # Interface will show up as tap(4) on the host and as vio(4) in the VM
34 | interface { switch "uplink" }
35 | interface { switch "local" }
36 | }
37 |
38 | # Another VM that is disabled on startup
39 | vm "vm1.example.com" {
40 | disable
41 | memory 1G
42 | disk "/home/vm/vm1-disk.img"
43 |
44 | # Use a specific tap(4) interface with a hardcoded MAC address
45 | interface tap3 {
46 | lladdr 00:11:22:aa:bb:cc
47 | down
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgpd/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.45 2025/12/11 12:18:27 claudio Exp $
2 |
3 | PROG= bgpd
4 | SRCS= bgpd.c
5 | SRCS+= bitmap.c
6 | SRCS+= carp.c
7 | SRCS+= chash.c
8 | SRCS+= config.c
9 | SRCS+= control.c
10 | SRCS+= flowspec.c
11 | SRCS+= kroute.c
12 | SRCS+= log.c
13 | SRCS+= logmsg.c
14 | SRCS+= monotime.c
15 | SRCS+= mrt.c
16 | SRCS+= name2id.c
17 | SRCS+= parse.y
18 | SRCS+= pfkey.c
19 | SRCS+= pftable.c
20 | SRCS+= printconf.c
21 | SRCS+= rde.c
22 | SRCS+= rde_adjout.c
23 | SRCS+= rde_aspa.c
24 | SRCS+= rde_attr.c
25 | SRCS+= rde_community.c
26 | SRCS+= rde_decide.c
27 | SRCS+= rde_filter.c
28 | SRCS+= rde_peer.c
29 | SRCS+= rde_prefix.c
30 | SRCS+= rde_rib.c
31 | SRCS+= rde_sets.c
32 | SRCS+= rde_trie.c
33 | SRCS+= rde_update.c
34 | SRCS+= rtr.c
35 | SRCS+= rtr_proto.c
36 | SRCS+= session.c
37 | SRCS+= session_bgp.c
38 | SRCS+= timer.c
39 | SRCS+= util.c
40 |
41 | CFLAGS+= -Wall -I${.CURDIR}
42 | CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
43 | CFLAGS+= -Wmissing-declarations
44 | CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
45 | CFLAGS+= -Wsign-compare
46 | YFLAGS=
47 |
48 | LDADD+= -lutil
49 | DPADD+= ${LIBUTIL}
50 | MAN= bgpd.8 bgpd.conf.5
51 |
52 | .include
53 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/rand48.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1993 Martin Birgmeier
3 | * All rights reserved.
4 | *
5 | * You may redistribute unmodified or modified versions of this source
6 | * code provided that the above copyright notice and this and the
7 | * following conditions are retained.
8 | *
9 | * This software is provided ``as is'', and comes with no warranties
10 | * of any kind. I shall in no event be liable for anything that happens
11 | * to anyone/anything when using this software.
12 | *
13 | * $OpenBSD: rand48.h,v 1.6 2015/09/14 13:30:17 guenther Exp $
14 | */
15 |
16 | #ifndef _RAND48_H_
17 | #define _RAND48_H_
18 |
19 | #include
20 |
21 | __BEGIN_HIDDEN_DECLS
22 | extern unsigned short __rand48_seed[3];
23 | extern unsigned short __rand48_mult[3];
24 | extern unsigned short __rand48_add;
25 |
26 | void __dorand48(unsigned short[3]);
27 | extern int __rand48_deterministic;
28 | __END_HIDDEN_DECLS
29 |
30 | #define RAND48_SEED_0 (0x330e)
31 | #define RAND48_SEED_1 (0xabcd)
32 | #define RAND48_SEED_2 (0x1234)
33 | #define RAND48_MULT_0 (0xe66d)
34 | #define RAND48_MULT_1 (0xdeec)
35 | #define RAND48_MULT_2 (0x0005)
36 | #define RAND48_ADD (0x000b)
37 |
38 | #endif /* _RAND48_H_ */
39 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/setprogname.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: setprogname.c,v 1.6 2017/09/17 06:38:03 otto Exp $ */
2 | /*
3 | * Copyright (c) 2013 Antoine Jacoutot
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 |
21 | void
22 | setprogname(const char *progname)
23 | {
24 | char *tmpn;
25 |
26 | tmpn = strrchr(progname, '/');
27 | if (tmpn == NULL)
28 | __progname = (char *)progname;
29 | else
30 | __progname = tmpn + 1;
31 | }
32 |
--------------------------------------------------------------------------------
/src/etc/examples/ipsec.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ipsec.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 | #
3 | # See ipsec.conf(5) for syntax and examples.
4 |
5 | # Set up two tunnels using automatic keying with isakmpd(8):
6 | #
7 | # First between the networks 10.1.1.0/24 and 10.1.2.0/24,
8 | # second between the machines 192.168.3.1 and 192.168.3.2.
9 | # Use FQDNs as IDs.
10 |
11 | #ike esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2 \
12 | # srcid me.mylan.net dstid the.others.net
13 | #ike esp from 192.168.3.1 to 192.168.3.2 \
14 | # srcid me.mylan.net dstid the.others.net
15 |
16 | # Set up a tunnel using static keying:
17 | #
18 | # The first rule sets up the flow; the second sets up the SA. As default
19 | # transforms, ipsecctl(8) will use hmac-sha2-256 for authentication
20 | # and aes for encryption. hmac-sha2-256 uses a 256-bit key; aes
21 | # a 128-bit key.
22 |
23 | #flow esp from 192.168.7.0/24 to 192.168.8.0/24 peer 192.168.3.2
24 | #esp from 192.168.3.1 to 192.168.3.2 spi 0xabd9da39:0xc9dbb83d \
25 | # authkey 0x54f79f479a32814347bb768d3e01b2b58e49ce674ec6e2d327b63408c56ef4e8:0x7f48ee352c626cdc2a731b9d90bd63e29db2a9c683044b70b2f4441521b622d6 \
26 | # enckey 0xb341aa065c3850edd6a61e150d6a5fd3:0xf7795f6bdd697a43a4d28dcf1b79062d
27 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strnlen.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strnlen.c,v 1.9 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2010 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 |
21 | #include
22 |
23 | size_t
24 | strnlen(const char *str, size_t maxlen)
25 | {
26 | const char *cp;
27 |
28 | for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--)
29 | ;
30 |
31 | return (size_t)(cp - str);
32 | }
33 | DEF_WEAK(strnlen);
34 |
--------------------------------------------------------------------------------
/src/lib/libc/string/timingsafe_bcmp.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: timingsafe_bcmp.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2010 Damien Miller. All rights reserved.
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 |
20 | int
21 | timingsafe_bcmp(const void *b1, const void *b2, size_t n)
22 | {
23 | const unsigned char *p1 = b1, *p2 = b2;
24 | int ret = 0;
25 |
26 | for (; n > 0; n--)
27 | ret |= *p1++ ^ *p2++;
28 | return (ret != 0);
29 | }
30 | DEF_WEAK(timingsafe_bcmp);
31 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/clock_getcpuclockid.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: clock_getcpuclockid.c,v 1.1 2013/06/17 19:11:54 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2013 Philip Guenther
4 | * All Rights Reserved.
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
25 | {
26 | if (pid != 0 && pid != getpid())
27 | return (EPERM);
28 |
29 | *clock_id = CLOCK_PROCESS_CPUTIME_ID;
30 | return (0);
31 | }
32 |
--------------------------------------------------------------------------------
/src/etc/examples/snmpd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: snmpd.conf,v 1.2 2021/08/08 13:43:10 sthen Exp $
2 |
3 | # Default listens on all addresses for SNMPv3 only; "listen on" overrides this
4 | # See snmpd.conf(5) for more options (tcp, alternative ports, trap listener)
5 | #listen on 192.0.2.1 # SNMPv3 on one specific address
6 | #listen on 0.0.0.0 snmpv2c snmpv3 # All IPv4 addresses, both v2c + v3
7 | #listen on :: snmpv2c snmpv3 # All IPv6 addresses, both v2c + v3
8 | #listen on 127.0.0.1 snmpv2c # IPv4 localhost only, v2c
9 |
10 | # Define a RO community if you use SNMPv2c (there is no default)
11 | #read-only community MWgp3MWbD2khaYnwy2B
12 |
13 | # At least one user must be defined to use SNMPv3
14 | #user "user1" auth hmac-sha1 authkey "password123" enc aes enckey "321drowssap"
15 | #user "user2" auth hmac-sha256 authkey "password456" enc aes enckey "654drowssap"
16 |
17 | # Send traps from snmpd(8) to one or more receivers
18 | #trap receiver nms.localdomain.local community PAV9kpE02gDPvAi source-address 192.0.2.1
19 |
20 | # Adjust the local system information
21 | #system contact "Charlie Root (root@myhost.example.com)"
22 | #system description "Powered by OpenBSD"
23 | #system location "Rack A1-24, Room 13"
24 |
25 | # Required by some management software
26 | #system services 74
27 |
--------------------------------------------------------------------------------
/src/lib/libc/string/swab.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: swab.c,v 1.9 2014/12/11 23:05:38 tedu Exp $ */
2 | /*
3 | * Copyright (c) 2014 Ted Unangst
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 | #include
18 |
19 | void
20 | swab(const void *__restrict from, void *__restrict to, ssize_t len)
21 | {
22 | const unsigned char *src = from;
23 | unsigned char *dst = to;
24 | unsigned char t0, t1;
25 |
26 | while (len > 1) {
27 | t0 = src[0];
28 | t1 = src[1];
29 | dst[0] = t1;
30 | dst[1] = t0;
31 | src += 2;
32 | dst += 2;
33 | len -= 2;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/include/stdio_ext.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: stdio_ext.h,v 1.1 2024/08/12 20:56:55 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2024 Philip Guenther
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #ifndef _STDIO_EXT_H_
19 | #define _STDIO_EXT_H_
20 |
21 | #include
22 |
23 | size_t __fpending(FILE *);
24 | size_t __freadahead(FILE *);
25 | int __freading(FILE *);
26 | const char *__freadptr(FILE *, size_t *_sizep);
27 | void __freadptrinc(FILE *, size_t _inc);
28 | void __fseterr(FILE *);
29 | int __fwriting(FILE *);
30 |
31 | #endif /* _STDIO_EXT_H_ */
32 |
33 |
--------------------------------------------------------------------------------
/src/lib/libutil/Makefile:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile,v 1.45 2023/12/12 15:49:21 claudio Exp $
2 | # $NetBSD: Makefile,v 1.8 1996/05/16 07:03:28 thorpej Exp $
3 |
4 | LIB= util
5 |
6 | VERSION_SCRIPT= ${.CURDIR}/Symbols.map
7 |
8 | HDRS= ber.h util.h imsg.h
9 | SRCS= bcrypt_pbkdf.c ber.c check_expire.c duid.c getmaxpartitions.c \
10 | getrawpartition.c login.c \
11 | login_tty.c logout.c logwtmp.c opendev.c passwd.c pty.c readlabel.c \
12 | login_fbtab.c uucplock.c fparseln.c opendisk.c pidfile.c \
13 | fmt_scaled.c imsg.c imsg-buffer.c pkcs5_pbkdf2.c
14 |
15 | MAN= bcrypt_pbkdf.3 \
16 | check_expire.3 getmaxpartitions.3 \
17 | getrawpartition.3 \
18 | isduid.3 login.3 \
19 | ober_add_string.3 ober_get_string.3 ober_oid_cmp.3 \
20 | ober_read_elements.3 ober_set_header.3 \
21 | opendev.3 openpty.3 pw_init.3 pw_lock.3 readlabelfs.3 uu_lock.3 \
22 | fparseln.3 opendisk.3 login_fbtab.3 pidfile.3 fmt_scaled.3 imsg_init.3 \
23 | ibuf_add.3 pkcs5_pbkdf2.3
24 |
25 | SRCS+= ohash.c
26 | HDRS += ohash.h
27 |
28 | MAN += ohash_init.3 ohash_interval.3
29 |
30 | includes:
31 | @cd ${.CURDIR}; for i in $(HDRS); do \
32 | j="cmp -s $$i ${DESTDIR}/usr/include/$$i || \
33 | ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \
34 | -m 444 $$i ${DESTDIR}/usr/include"; \
35 | echo $$j; \
36 | eval "$$j"; \
37 | done
38 |
39 | .include
40 |
--------------------------------------------------------------------------------
/src/etc/examples/iked.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: iked.conf,v 1.3 2023/03/06 13:57:45 sthen Exp $
2 | #
3 | # See iked.conf(5) for syntax and examples.
4 |
5 | # Configure users for the Extensible Authentication Protocol (EAP)
6 | #user "user1" "password123"
7 | #user "user2" "password456"
8 |
9 | # Configuration for clients connecting with EAP authentication
10 | # and sending all traffic over the IKEv2 tunnel.
11 | #
12 | # EAP requires a server certificate; see ikectl(8) for more details
13 | # on generating this with an iked-specific local CA.
14 | #
15 | #ikev2 "eapclient" passive esp \
16 | # from any to dynamic \
17 | # local any peer any \
18 | # eap "mschap-v2" \
19 | # config address 10.2.0.0/24 \
20 | # config name-server 10.1.0.2 \
21 | # tag "$name-$id"
22 |
23 | # Configuration for a client authenticating with a pre-shared key,
24 | # mostly useful for LAN-to-LAN tunnels between static IP endpoints.
25 | #
26 | # For iked->iked tunnels you can use a simple config using public
27 | # keys instead - omit psk and copy /etc/iked/local.pub on each side to
28 | # /etc/iked/pubkeys/ipv4/ on the other.
29 | #
30 | #ikev2 esp \
31 | # from 10.3.0.0/24 to 10.1.0.0/24 \
32 | # from 10.5.0.0/24 to 10.1.0.0/24 \
33 | # from 10.5.0.0/24 to 172.16.1.0/24 \
34 | # local 192.168.1.1 peer 192.168.2.1 \
35 | # psk "tyBNv13zuo3rg1WVXlaI1g1tTYNzwk962mMUYIvaLh2x8vvvyA-replace-me"
36 |
--------------------------------------------------------------------------------
/src/etc/examples/sensorsd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: sensorsd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 |
3 | #
4 | # Sample sensorsd.conf file. See sensorsd.conf(5) for details.
5 | #
6 |
7 | # +5 voltage (volts)
8 | #hw.sensors.lm0.volt3:low=4.8V:high=5.2V
9 |
10 | # +12 voltage (volts)
11 | #hw.sensors.lm0.volt4:low=11.5V:high=12.5V
12 |
13 | # Chipset temperature (degrees Celsius)
14 | #hw.sensors.lm0.temp0:high=50C
15 |
16 | # CPU temperature (degrees Celsius)
17 | #hw.sensors.lm0.temp1:high=60C
18 |
19 | # CPU fan (RPM)
20 | #hw.sensors.lm0.fan1:low=3000
21 |
22 | # ignore certain indicators on ipmi(4)
23 | #hw.sensors.ipmi0.indicator1:istatus
24 |
25 | # Warn if any temperature sensor is over 70 degC.
26 | # This entry will match only those temperature sensors
27 | # that don't have their own entry.
28 | #temp:high=70C
29 |
30 |
31 | # By default, sensorsd(8) reports status changes of all sensors that
32 | # keep their state. Uncomment the following lines if you want to
33 | # suppress reports about status changes of specific sensor types.
34 |
35 | #temp:istatus
36 | #fan:istatus
37 | #volt:istatus
38 | #acvolt:istatus
39 | #resistance:istatus
40 | #power:istatus
41 | #current:istatus
42 | #watthour:istatus
43 | #amphour:istatus
44 | #indicator:istatus
45 | #raw:istatus
46 | #percentage:istatus
47 | #illuminance:istatus
48 | #drive:istatus
49 | #timedelta:istatus
50 |
--------------------------------------------------------------------------------
/src/lib/libc/net/getpeereid.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getpeereid.c,v 1.1 2010/07/01 19:15:30 deraadt Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2010 Theo de Raadt
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | int
23 | getpeereid(int s, uid_t *euid, gid_t *egid)
24 | {
25 | struct sockpeercred creds;
26 | socklen_t credslen = sizeof(creds);
27 | int error;
28 |
29 | error = getsockopt(s, SOL_SOCKET, SO_PEERCRED,
30 | &creds, &credslen);
31 | if (error)
32 | return (error);
33 | *euid = creds.uid;
34 | *egid = creds.gid;
35 | return (0);
36 | }
37 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strndup.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strndup.c,v 1.3 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2010 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | char *
26 | strndup(const char *str, size_t maxlen)
27 | {
28 | char *copy;
29 | size_t len;
30 |
31 | len = strnlen(str, maxlen);
32 | copy = malloc(len + 1);
33 | if (copy != NULL) {
34 | (void)memcpy(copy, str, len);
35 | copy[len] = '\0';
36 | }
37 |
38 | return copy;
39 | }
40 | DEF_WEAK(strndup);
41 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/seed48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: seed48.c,v 1.6 2015/09/13 15:20:40 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | unsigned short *
18 | seed48(unsigned short xseed[3])
19 | {
20 | unsigned short *res;
21 |
22 | res = seed48_deterministic(xseed);
23 | __rand48_deterministic = 0;
24 | return res;
25 | }
26 |
27 | unsigned short *
28 | seed48_deterministic(unsigned short xseed[3])
29 | {
30 | static unsigned short sseed[3];
31 |
32 | __rand48_deterministic = 1;
33 | sseed[0] = __rand48_seed[0];
34 | sseed[1] = __rand48_seed[1];
35 | sseed[2] = __rand48_seed[2];
36 | __rand48_seed[0] = xseed[0];
37 | __rand48_seed[1] = xseed[1];
38 | __rand48_seed[2] = xseed[2];
39 | __rand48_mult[0] = RAND48_MULT_0;
40 | __rand48_mult[1] = RAND48_MULT_1;
41 | __rand48_mult[2] = RAND48_MULT_2;
42 | __rand48_add = RAND48_ADD;
43 | return sseed;
44 | }
45 | DEF_WEAK(seed48_deterministic);
46 |
--------------------------------------------------------------------------------
/src/etc/examples/ypldap.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ypldap.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 |
3 | domain "example.com"
4 | interval 60
5 | provide map "passwd.byname"
6 | provide map "passwd.byuid"
7 | provide map "group.byname"
8 | provide map "group.bygid"
9 | provide map "netid.byname"
10 |
11 | directory "127.0.0.1" {
12 | # directory options
13 | binddn "cn=admin,dc=example,dc=com"
14 | bindcred "secret"
15 | basedn "dc=example,dc=com"
16 | # starting point for groups directory search, default to basedn
17 | #groupdn "ou=Groups,dc=example,dc=com"
18 |
19 | # passwd maps configuration (RFC 2307 posixAccount object class)
20 | passwd filter "(objectClass=posixAccount)"
21 |
22 | attribute name maps to "uid"
23 | fixed attribute passwd "*"
24 | attribute uid maps to "uidNumber"
25 | attribute gid maps to "gidNumber"
26 | attribute gecos maps to "cn"
27 | attribute home maps to "homeDirectory"
28 | attribute shell maps to "loginShell"
29 | fixed attribute change "0"
30 | fixed attribute expire "0"
31 | fixed attribute class ""
32 |
33 | # group maps configuration (RFC 2307 posixGroup object class)
34 | group filter "(objectClass=posixGroup)"
35 |
36 | attribute groupname maps to "cn"
37 | fixed attribute grouppasswd "*"
38 | attribute groupgid maps to "gidNumber"
39 | # memberUid returns multiple group members
40 | list groupmembers maps to "memberUid"
41 | }
42 |
--------------------------------------------------------------------------------
/src/lib/libc/net/Makefile.inc:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile.inc,v 1.61 2024/04/15 14:30:48 naddy Exp $
2 |
3 | # net sources
4 | .PATH: ${LIBCSRCDIR}/net
5 |
6 | CFLAGS+=-DRESOLVSORT
7 |
8 | SRCS+= base64.c ethers.c freeaddrinfo.c \
9 | gai_strerror.c getaddrinfo.c gethostnamadr.c \
10 | getifaddrs.c getnameinfo.c getnetent.c \
11 | getnetnamadr.c getpeereid.c getproto.c getprotoent.c getprotoname.c \
12 | getservbyname.c getservbyport.c getservent.c getrrsetbyname.c \
13 | herror.c htonl.c htons.c \
14 | if_indextoname.c if_nameindex.c if_nametoindex.c inet_addr.c \
15 | inet_lnaof.c inet_makeaddr.c inet_neta.c inet_netof.c inet_network.c \
16 | inet_net_ntop.c inet_net_pton.c inet_ntoa.c inet_ntop.c inet_pton.c \
17 | linkaddr.c ntohl.c ntohs.c rcmd.c rcmdsh.c ruserok.c \
18 | rresvport.c recv.c res_comp.c res_data.c \
19 | res_debug.c res_debug_syms.c res_init.c res_mkquery.c res_query.c \
20 | res_random.c res_send.c \
21 | send.c sethostent.c sockatmark.c
22 |
23 | # IPv6
24 | SRCS+= ip6opt.c rthdr.c vars6.c
25 |
26 | MAN+= htobe64.3 ether_aton.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \
27 | getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \
28 | getrrsetbyname.3 getservent.3 htonl.3 if_indextoname.3 \
29 | inet_addr.3 inet_lnaof.3 inet_net_ntop.3 inet_ntop.3 \
30 | inet6_opt_init.3 inet6_rth_space.3 link_ntoa.3 \
31 | rcmd.3 rcmdsh.3 res_init.3 sockatmark.3
32 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/mkdtemp.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: mkdtemp.c,v 1.2 2024/03/01 21:30:40 millert Exp $ */
2 | /*
3 | * Copyright (c) 2024 Todd C. Miller
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 |
21 | static int
22 | mkdtemp_cb(const char *path, int flags)
23 | {
24 | return mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR);
25 | }
26 |
27 | char *
28 | mkdtemp(char *path)
29 | {
30 | if (__mktemp4(path, 0, 0, mkdtemp_cb) == 0)
31 | return path;
32 | return NULL;
33 | }
34 |
35 | char *
36 | mkdtemps(char *path, int slen)
37 | {
38 | if (__mktemp4(path, slen, 0, mkdtemp_cb) == 0)
39 | return path;
40 | return NULL;
41 | }
42 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strerror_l.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strerror_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */
2 | /*
3 | * Copyright (c) 2017 Ingo Schwarze
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 |
21 | #include "thread_private.h"
22 |
23 | char *
24 | strerror_l(int errnum, locale_t locale)
25 | {
26 | static char sel_buf[NL_TEXTMAX];
27 | _THREAD_PRIVATE_KEY(strerror_l);
28 | char *p = _THREAD_PRIVATE(strerror_l, sel_buf, NULL);
29 |
30 | return p == NULL ? "no buffer available in strerror_l" :
31 | strerror_r(errnum, p, sizeof(sel_buf)) ?
32 | "strerror_r failure" : p;
33 | }
34 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isfdtype.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isfdtype.c,v 1.5 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2002 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | *
18 | * Sponsored in part by the Defense Advanced Research Projects
19 | * Agency (DARPA) and Air Force Research Laboratory, Air Force
20 | * Materiel Command, USAF, under agreement number F39502-99-1-0512.
21 | */
22 |
23 | #include
24 | #include
25 |
26 | int
27 | isfdtype(int fd, int fdtype)
28 | {
29 | struct stat sb;
30 |
31 | if (fstat(fd, &sb) != 0)
32 | return (-1);
33 |
34 | return ((sb.st_mode & S_IFMT) == fdtype);
35 | }
36 |
--------------------------------------------------------------------------------
/src/lib/libc/string/memrchr.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: memrchr.c,v 1.4 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2007 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 |
21 | /*
22 | * Reverse memchr()
23 | * Find the last occurrence of 'c' in the buffer 's' of size 'n'.
24 | */
25 | void *
26 | memrchr(const void *s, int c, size_t n)
27 | {
28 | const unsigned char *cp;
29 |
30 | if (n != 0) {
31 | cp = (unsigned char *)s + n;
32 | do {
33 | if (*(--cp) == (unsigned char)c)
34 | return((void *)cp);
35 | } while (--n != 0);
36 | }
37 | return(NULL);
38 | }
39 | DEF_WEAK(memrchr);
40 |
--------------------------------------------------------------------------------
/src/lib/libutil/duid.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: duid.c,v 1.2 2012/07/09 14:26:40 nicm Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2010 Joel Sing
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 |
21 | #include "util.h"
22 |
23 | int
24 | isduid(const char *duid, int dflags)
25 | {
26 | char c;
27 | int i;
28 |
29 | /* Basic format check. */
30 | if (!((strlen(duid) == 16 && (dflags & OPENDEV_PART)) ||
31 | (strlen(duid) == 18 && duid[16] == '.')))
32 | return 0;
33 |
34 | /* Check UID. */
35 | for (i = 0; i < 16; i++) {
36 | c = duid[i];
37 | if ((c < '0' || c > '9') && (c < 'a' || c > 'f'))
38 | return 0;
39 | }
40 |
41 | return 1;
42 | }
43 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/signbit.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: signbit.c,v 1.7 2013/07/03 04:46:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 2008 Martynas Venckus
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | __signbit(double d)
25 | {
26 | struct ieee_double *p = (struct ieee_double *)&d;
27 |
28 | return p->dbl_sign;
29 | }
30 |
31 | int
32 | __signbitf(float f)
33 | {
34 | struct ieee_single *p = (struct ieee_single *)&f;
35 |
36 | return p->sng_sign;
37 | }
38 |
39 | #if LDBL_MANT_DIG == DBL_MANT_DIG
40 | __strong_alias(__signbitl, __signbit);
41 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
42 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/getcwd.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getcwd.c,v 1.22 2023/05/18 16:11:09 guenther Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2005 Marius Eriksen
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | char *
25 | getcwd(char *buf, size_t size)
26 | {
27 | char *allocated = NULL;
28 |
29 | if (buf != NULL && size == 0) {
30 | errno = EINVAL;
31 | return (NULL);
32 | }
33 |
34 | if (buf == NULL &&
35 | (allocated = buf = malloc(size = PATH_MAX)) == NULL)
36 | return (NULL);
37 |
38 | if (__getcwd(buf, size) == -1) {
39 | free(allocated);
40 | return (NULL);
41 | }
42 |
43 | return (buf);
44 | }
45 | DEF_WEAK(getcwd);
46 |
--------------------------------------------------------------------------------
/src/include/search.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: search.h,v 1.10 2014/07/18 04:16:09 matthew Exp $ */
2 | /* $NetBSD: search.h,v 1.9 1995/08/08 21:14:45 jtc Exp $ */
3 |
4 | /*
5 | * Written by J.T. Conklin
6 | * Public domain.
7 | */
8 |
9 | #ifndef _SEARCH_H_
10 | #define _SEARCH_H_
11 |
12 | #include
13 | #include
14 |
15 | #ifndef _SIZE_T_DEFINED_
16 | #define _SIZE_T_DEFINED_
17 | typedef __size_t size_t;
18 | #endif
19 |
20 | typedef struct entry {
21 | char *key;
22 | void *data;
23 | } ENTRY;
24 |
25 | typedef enum {
26 | FIND, ENTER
27 | } ACTION;
28 |
29 | typedef enum {
30 | preorder,
31 | postorder,
32 | endorder,
33 | leaf
34 | } VISIT;
35 |
36 | __BEGIN_DECLS
37 | int hcreate(size_t);
38 | void hdestroy(void);
39 | ENTRY *hsearch(ENTRY, ACTION);
40 |
41 | void *lfind(const void *, const void *, size_t *, size_t,
42 | int (*)(const void *, const void *));
43 | void *lsearch(const void *, void *, size_t *, size_t,
44 | int (*)(const void *, const void *));
45 | void insque(void *, void *);
46 | void remque(void *);
47 |
48 | void *tdelete(const void * __restrict, void ** __restrict,
49 | int (*)(const void *, const void *));
50 | void *tfind(const void *, void * const *,
51 | int (*)(const void *, const void *));
52 | void *tsearch(const void *, void **,
53 | int (*)(const void *, const void *));
54 | void twalk(const void *, void (*)(const void *, VISIT, int));
55 | __END_DECLS
56 |
57 | #endif /* !_SEARCH_H_ */
58 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/realpath.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: realpath.c,v 1.28 2023/05/18 16:11:10 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2019 Bob Beck
4 | * Copyright (c) 2019 Theo de Raadt
5 | *
6 | * Permission to use, copy, modify, and/or distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | /*
28 | * wrapper for kernel __realpath
29 | */
30 |
31 | char *
32 | realpath(const char *path, char *resolved)
33 | {
34 | char rbuf[PATH_MAX];
35 |
36 | if (__realpath(path, rbuf) == -1)
37 | return NULL;
38 | if (resolved == NULL)
39 | return (strdup(rbuf));
40 | strlcpy(resolved, rbuf, PATH_MAX);
41 | return (resolved);
42 | }
43 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isnormal.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isnormal.c,v 1.8 2013/07/03 04:46:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 2008 Martynas Venckus
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | __isnormal(double d)
25 | {
26 | struct ieee_double *p = (struct ieee_double *)&d;
27 |
28 | return (p->dbl_exp != 0 && p->dbl_exp != DBL_EXP_INFNAN);
29 | }
30 |
31 | int
32 | __isnormalf(float f)
33 | {
34 | struct ieee_single *p = (struct ieee_single *)&f;
35 |
36 | return (p->sng_exp != 0 && p->sng_exp != SNG_EXP_INFNAN);
37 | }
38 |
39 | #if LDBL_MANT_DIG == DBL_MANT_DIG
40 | __strong_alias(__isnormall, __isnormal);
41 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
42 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/Makefile.inc:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile.inc,v 1.66 2024/01/19 19:45:02 millert Exp $
2 |
3 | # stdlib sources
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/stdlib ${LIBCSRCDIR}/stdlib
5 |
6 | SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c atoll.c bsearch.c \
7 | exit.c ecvt.c gcvt.c getenv.c getopt_long.c \
8 | getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c insque.c \
9 | l64a.c llabs.c lldiv.c lsearch.c malloc.c __mktemp4.c mkdtemp.c \
10 | mkstemp.c mktemp.c reallocarray.c merge.c posix_pty.c qsort.c \
11 | radixsort.c rand.c random.c realpath.c remque.c setenv.c strtoimax.c \
12 | strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \
13 | system.c \
14 | tfind.c thread_atexit.c tsearch.c \
15 | _rand48.c drand48.c erand48.c jrand48.c \
16 | lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c \
17 | _Exit.c icdb.c
18 |
19 | .if (${MACHINE_CPU} == "i386")
20 | SRCS+= abs.S div.S labs.S ldiv.S
21 | .elif (${MACHINE_CPU} == "alpha")
22 | # XXX should be .S's
23 | SRCS+= abs.c div.c labs.c ldiv.c
24 | .else
25 | SRCS+= abs.c div.c labs.c ldiv.c
26 | .endif
27 |
28 | MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
29 | bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \
30 | getsubopt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 \
31 | lldiv.3 lsearch.3 malloc.3 mktemp.3 posix_memalign.3 posix_openpt.3 \
32 | ptsname.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \
33 | strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3
34 |
--------------------------------------------------------------------------------
/src/etc/examples/pf.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: pf.conf,v 1.4 2018/07/10 19:28:35 henning Exp $
2 | #
3 | # See pf.conf(5) for syntax and examples.
4 | # Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
5 | # in /etc/sysctl.conf if packets are to be forwarded between interfaces.
6 |
7 | # increase default state limit from 100'000 states on busy systems
8 | #set limit states 500000
9 |
10 | set skip on lo
11 |
12 | # filter rules and anchor for ftp-proxy(8)
13 | #anchor "ftp-proxy/*"
14 | #pass in quick inet proto tcp to port ftp divert-to 127.0.0.1 port 8021
15 |
16 | # anchor for relayd(8)
17 | #anchor "relayd/*"
18 |
19 | block return # block stateless traffic
20 | pass # establish keep-state
21 |
22 | # rules for spamd(8)
23 | #table persist
24 | #table persist file "/etc/mail/nospamd"
25 | #pass in on egress inet proto tcp from any to any port smtp \
26 | # divert-to 127.0.0.1 port spamd
27 | #pass in on egress proto tcp from to any port smtp
28 | #pass in log on egress proto tcp from to any port smtp
29 | #pass out log on egress proto tcp to any port smtp
30 |
31 |
32 | #block in quick from urpf-failed to any # use with care
33 |
34 | # rules for vmd(8) - NAT and DNS forwarding for VMs (100.64.0.0/10 default)
35 | #pass out on egress from 100.64.0.0/10 to any nat-to (egress)
36 | #pass in proto udp from 100.64.0.0/10 to any port domain \
37 | # rdr-to $dns_server port domain
38 |
39 | # By default, do not permit remote connections to X11
40 | block return in on ! lo0 proto tcp to port 6000:6010
41 |
--------------------------------------------------------------------------------
/src/lib/libc/hash/Makefile.inc:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile.inc,v 1.25 2019/08/30 22:20:43 deraadt Exp $
2 |
3 | # hash functions
4 | .PATH: ${LIBCSRCDIR}/hash
5 |
6 | HELPER= md5hl.c rmd160hl.c sha1hl.c sha224hl.c sha256hl.c sha384hl.c sha512hl.c sha512_256hl.c
7 | SRCS+= md5.c rmd160.c sha1.c sha2.c ${HELPER} siphash.c
8 | MAN+= MD5Init.3 RMD160Init.3 SHA1Init.3 SHA256Init.3 SipHash24_Init.3
9 |
10 | CLEANFILES+= ${HELPER}
11 |
12 | md5hl.c: helper.c
13 | sed -e 's/hashinc/md5.h/g' -e 's/HASH/MD5/g' $> > $@
14 |
15 | rmd160hl.c: helper.c
16 | sed -e 's/hashinc/rmd160.h/g' -e 's/HASH/RMD160/g' $> > $@
17 |
18 | sha1hl.c: helper.c
19 | sed -e 's/hashinc/sha1.h/g' -e 's/HASH/SHA1/g' $> > $@
20 |
21 | sha224hl.c: helper.c
22 | sed -e 's/hashinc/sha2.h/g' \
23 | -e 's/HASH/SHA224/g' \
24 | -e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $> > $@
25 |
26 | sha256hl.c: helper.c
27 | sed -e 's/hashinc/sha2.h/g' \
28 | -e 's/HASH/SHA256/g' \
29 | -e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $> > $@
30 |
31 | sha384hl.c: helper.c
32 | sed -e 's/hashinc/sha2.h/g' \
33 | -e 's/HASH/SHA384/g' \
34 | -e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $> > $@
35 |
36 | sha512hl.c: helper.c
37 | sed -e 's/hashinc/sha2.h/g' \
38 | -e 's/HASH/SHA512/g' \
39 | -e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $> > $@
40 |
41 | sha512_256hl.c: helper.c
42 | sed -e 's/hashinc/sha2.h/g' \
43 | -e 's/HASH/SHA512_256/g' \
44 | -e 's/SHA512_256_CTX/SHA2_CTX/g' $> > $@
45 |
46 | beforedepend: md5hl.c rmd160hl.c sha1hl.c sha256hl.c sha384hl.c sha512hl.c sha512_256hl.c
47 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/reallocarray.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: reallocarray.c,v 1.3 2015/09/13 08:31:47 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2008 Otto Moerbeek
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | /*
24 | * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
25 | * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
26 | */
27 | #define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
28 |
29 | void *
30 | reallocarray(void *optr, size_t nmemb, size_t size)
31 | {
32 | if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
33 | nmemb > 0 && SIZE_MAX / nmemb < size) {
34 | errno = ENOMEM;
35 | return NULL;
36 | }
37 | return realloc(optr, size * nmemb);
38 | }
39 | DEF_WEAK(reallocarray);
40 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/thread_atexit.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: thread_atexit.c,v 1.2 2019/06/02 01:03:01 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2017 Mark Kettenis
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "atexit.h"
23 |
24 | __weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl);
25 |
26 | int
27 | __cxa_thread_atexit_impl(void (*func)(void *), void *arg, void *dso)
28 | {
29 | struct thread_atexit_fn *fnp;
30 | struct tib *tib = TIB_GET();
31 |
32 | fnp = calloc(1, sizeof(struct thread_atexit_fn));
33 | if (fnp == NULL)
34 | return -1;
35 |
36 | dlctl(NULL, DL_REFERENCE, dso);
37 |
38 | fnp->func = func;
39 | fnp->arg = arg;
40 | fnp->next = tib->tib_atexit;
41 | tib->tib_atexit = fnp;
42 |
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/mktemp.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: mktemp.c,v 1.2 2024/01/19 19:45:02 millert Exp $ */
2 | /*
3 | * Copyright (c) 2024 Todd C. Miller
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | static int
23 | mktemp_cb(const char *path, int flags)
24 | {
25 | struct stat sb;
26 |
27 | if (lstat(path, &sb) == 0)
28 | errno = EEXIST;
29 | return (errno == ENOENT ? 0 : -1);
30 | }
31 |
32 | /* Also called via tmpnam(3) and tempnam(3). */
33 | char *
34 | _mktemp(char *path)
35 | {
36 | if (__mktemp4(path, 0, 0, mktemp_cb) == 0)
37 | return path;
38 | return NULL;
39 | }
40 |
41 | __warn_references(mktemp,
42 | "mktemp() possibly used unsafely; consider using mkstemp()");
43 |
44 | char *
45 | mktemp(char *path)
46 | {
47 | return _mktemp(path);
48 | }
49 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgpctl/json.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: json.h,v 1.8 2023/06/05 16:24:05 claudio Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2020 Claudio Jeker
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | void json_do_start(FILE *);
23 | int json_do_finish(void);
24 | void json_do_array(const char *);
25 | void json_do_object(const char *, int);
26 | void json_do_end(void);
27 | void json_do_printf(const char *, const char *, ...)
28 | __attribute__((__format__ (printf, 2, 3)));
29 | void json_do_string(const char *, const char *);
30 | void json_do_hexdump(const char *, void *, size_t);
31 | void json_do_bool(const char *, int);
32 | void json_do_uint(const char *, unsigned long long);
33 | void json_do_int(const char *, long long);
34 | void json_do_double(const char *, double);
35 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isfinite.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isfinite.c,v 1.8 2013/07/03 04:46:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 2008 Martynas Venckus
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | __isfinite(double d)
25 | {
26 | struct ieee_double *p = (struct ieee_double *)&d;
27 |
28 | return (p->dbl_exp != DBL_EXP_INFNAN);
29 | }
30 |
31 | int
32 | __isfinitef(float f)
33 | {
34 | struct ieee_single *p = (struct ieee_single *)&f;
35 |
36 | return (p->sng_exp != SNG_EXP_INFNAN);
37 | }
38 |
39 | #if LDBL_MANT_DIG == DBL_MANT_DIG
40 | __strong_alias(__isfinitel, __isfinite);
41 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
42 |
43 | /*
44 | * 3BSD compatibility aliases.
45 | */
46 | __strong_alias(finite, __isfinite);
47 | __strong_alias(finitef, __isfinitef);
48 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/_rand48.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: _rand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 1993 Martin Birgmeier
4 | * All rights reserved.
5 | *
6 | * You may redistribute unmodified or modified versions of this source
7 | * code provided that the above copyright notice and this and the
8 | * following conditions are retained.
9 | *
10 | * This software is provided ``as is'', and comes with no warranties
11 | * of any kind. I shall in no event be liable for anything that happens
12 | * to anyone/anything when using this software.
13 | */
14 |
15 | #include "rand48.h"
16 |
17 | unsigned short __rand48_seed[3] = {
18 | RAND48_SEED_0,
19 | RAND48_SEED_1,
20 | RAND48_SEED_2
21 | };
22 | unsigned short __rand48_mult[3] = {
23 | RAND48_MULT_0,
24 | RAND48_MULT_1,
25 | RAND48_MULT_2
26 | };
27 | unsigned short __rand48_add = RAND48_ADD;
28 |
29 | void
30 | __dorand48(unsigned short xseed[3])
31 | {
32 | unsigned long accu;
33 | unsigned short temp[2];
34 |
35 | accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
36 | (unsigned long) __rand48_add;
37 | temp[0] = (unsigned short) accu; /* lower 16 bits */
38 | accu >>= sizeof(unsigned short) * 8;
39 | accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] +
40 | (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0];
41 | temp[1] = (unsigned short) accu; /* middle 16 bits */
42 | accu >>= sizeof(unsigned short) * 8;
43 | accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0];
44 | xseed[0] = temp[0];
45 | xseed[1] = temp[1];
46 | xseed[2] = (unsigned short) accu;
47 | }
48 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isinf.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isinf.c,v 1.10 2013/11/12 06:09:48 deraadt Exp $ */
2 | /*
3 | * Copyright (c) 2008 Martynas Venckus
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | __isinf(double d)
25 | {
26 | struct ieee_double *p = (struct ieee_double *)&d;
27 |
28 | return (p->dbl_exp == DBL_EXP_INFNAN &&
29 | p->dbl_frach == 0 && p->dbl_fracl == 0);
30 | }
31 |
32 | int
33 | __isinff(float f)
34 | {
35 | struct ieee_single *p = (struct ieee_single *)&f;
36 |
37 | return (p->sng_exp == SNG_EXP_INFNAN && p->sng_frac == 0);
38 | }
39 |
40 | #if LDBL_MANT_DIG == DBL_MANT_DIG
41 | __strong_alias(__isinfl, __isinf);
42 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
43 |
44 | /*
45 | * 3BSD compatibility aliases.
46 | */
47 | __strong_alias(isinf, __isinf);
48 | __strong_alias(isinff, __isinff);
49 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isnan.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isnan.c,v 1.9 2013/11/12 06:09:48 deraadt Exp $ */
2 | /*
3 | * Copyright (c) 2008 Martynas Venckus
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | int
24 | __isnan(double d)
25 | {
26 | struct ieee_double *p = (struct ieee_double *)&d;
27 |
28 | return (p->dbl_exp == DBL_EXP_INFNAN &&
29 | (p->dbl_frach != 0 || p->dbl_fracl != 0));
30 | }
31 |
32 | int
33 | __isnanf(float f)
34 | {
35 | struct ieee_single *p = (struct ieee_single *)&f;
36 |
37 | return (p->sng_exp == SNG_EXP_INFNAN && p->sng_frac != 0);
38 | }
39 |
40 | #if LDBL_MANT_DIG == DBL_MANT_DIG
41 | __strong_alias(__isnanl, __isnan);
42 | #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */
43 |
44 | /*
45 | * 3BSD compatibility aliases.
46 | */
47 | __strong_alias(isnan, __isnan);
48 | __strong_alias(isnanf, __isnanf);
49 |
--------------------------------------------------------------------------------
/src/etc/examples/ifstated.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: ifstated.conf,v 1.3 2024/02/11 01:31:28 jsg Exp $
2 | # This is a sample config for a pair of firewalls with three physical interfaces
3 | #
4 | # The two firewall interfaces are made redundant on each side using
5 | # carp0 and carp1.
6 | #
7 | # A third interface em2 connects each firewall to the DMZ where it can
8 | # reach a syslog server with the IP 192.168.1.10
9 | #
10 | # This config does two things:
11 | # 1. Monitor the reachability of the syslog server and demote
12 | # the carp interface group to provoke a failover if the syslog server
13 | # is not reachable. We do that by using ping(1) and checking
14 | # the link state of em2.
15 | # 2. Log carp failovers
16 |
17 |
18 | dmz_if_up = 'em2.link.up'
19 | dmz_if_down = 'em2.link.down'
20 |
21 | syslog_ok = '"ping -q -c 1 -w 1 192.168.1.10 >/dev/null 2>&1" every 10'
22 |
23 | # ifstated starts up with the first defined state
24 | state neutral {
25 | if $dmz_if_down {
26 | run "logger -st ifstated 'interface to syslog server em2 is down'"
27 | set-state demoted
28 | }
29 | if ! $syslog_ok {
30 | run "logger -st ifstated 'could not reach syslog server'"
31 | set-state demoted
32 | }
33 | }
34 |
35 | state demoted {
36 | init {
37 | run "ifconfig -g carp carpdemote"
38 | }
39 | if $dmz_if_up && $syslog_ok {
40 | run "logger -st ifstated 'syslog server is ok again'"
41 | # remove our carp demotion
42 | run "ifconfig -g carp -carpdemote"
43 | set-state neutral
44 | }
45 | }
46 |
47 | # commands in the global scope are always run
48 | if carp0.link.up
49 | run "logger -st ifstated 'carp0 is master'"
50 | if carp0.link.down
51 | run "logger -st ifstated 'carp0 is backup'"
52 |
53 |
--------------------------------------------------------------------------------
/src/etc/examples/mrouted.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: mrouted.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 | #
3 | # This is the configuration file for "mrouted", an IP multicast router.
4 | # mrouted looks for it in "/etc/mrouted.conf".
5 | #
6 | # Command formats:
7 | #
8 | # name /
9 | # cache_lifetime 3600 # seconds
10 | # pruning on
11 | #
12 | # phyint [disable] [metric ] [threshold ] [rate_limit ]
13 | # [boundary (|/)]
14 | # [altnet (/|)]
15 | # tunnel [srcrt] [metric ]
16 | # [threshold ] [rate_limit ]
17 | # [boundary (|/)]
18 | #
19 | # NOTE: any phyint commands MUST precede any tunnel commands
20 | # NOTE: the mask-len is the no. of leading 1's in the mask
21 | # NOTE: rate_limit is in kilobits, and defaults to 500 for tunnels
22 | #
23 | # Example of named boundary:
24 | #name LOCAL 239.255.0.0/16
25 | #name EE 239.254.0.0/16 # i.e. the EE dept wants local groups
26 | #
27 | # Example of use of named boundary
28 | #phyint le1 boundary EE # le1 is our interface to comp sci,
29 | # # keep them away from our local groups
30 | #
31 | #
32 | # Template tunnel for mcast_install
33 | #tunnel 128.4.0.77 128.4.0.8 metric 1 threshold 64 rate_limit 500 # <-- REPLACE
34 | # boundary LOCAL
35 | #
36 | # You might want to specify a boundary on your tunnel to the outside world,
37 | # as above.
38 | #
39 | # NOTE: ONLY uncomment the following if you are running mrouted.snmp!
40 | #sysName "mymrouter"
41 | #sysContact "Me +x.yyy.zzz-zzzz"
42 | #sysVersion "MyOS 4.1.3 and mrouted"
43 | #sysLocation "The MBONE"
44 |
--------------------------------------------------------------------------------
/src/lib/libc/net/sockatmark.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2002 William C. Fenner. All rights reserved.
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | * 1. Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * 2. Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 | * SUCH DAMAGE.
24 | *
25 | * $FreeBSD$
26 | */
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | int
33 | sockatmark(int s)
34 | {
35 | int atmark;
36 |
37 | if (ioctl(s, SIOCATMARK, &atmark) == -1)
38 | return (-1);
39 | return (atmark);
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/libutil/login_fbtab.3:
--------------------------------------------------------------------------------
1 | .\" $OpenBSD: login_fbtab.3,v 1.16 2025/06/06 22:01:40 schwarze Exp $
2 | .\"
3 | .\" Copyright 1995 by Wietse Venema. All rights reserved. Some individual
4 | .\" files may be covered by other copyrights.
5 | .\"
6 | .\" This material was originally written and compiled by Wietse Venema at
7 | .\" Eindhoven University of Technology, The Netherlands, in 1990, 1991,
8 | .\" 1992, 1993, 1994 and 1995.
9 | .\"
10 | .\" Redistribution and use in source and binary forms, with or without
11 | .\" modification, are permitted provided that this entire copyright notice
12 | .\" is duplicated in all such copies.
13 | .\"
14 | .\" This software is provided "as is" and without any expressed or implied
15 | .\" warranties, including, without limitation, the implied warranties of
16 | .\" merchantibility and fitness for any particular purpose.
17 | .\"
18 | .Dd $Mdocdate: June 6 2025 $
19 | .Dt LOGIN_FBTAB 3
20 | .Os
21 | .Sh NAME
22 | .Nm login_fbtab
23 | .Nd implement device security based on fbtab(5)
24 | .Sh SYNOPSIS
25 | .Lb libutil
26 | .In sys/types.h
27 | .In util.h
28 | .Ft void
29 | .Fn login_fbtab "const char *tty" "uid_t uid" "gid_t gid"
30 | .Sh DESCRIPTION
31 | The
32 | .Fn login_fbtab
33 | function reads the
34 | .Pa /etc/fbtab
35 | file and implements device security as described in the
36 | .Xr fbtab 5
37 | manual page.
38 | .Sh FILES
39 | .Bl -tag -width /etc/fbtab -compact
40 | .It Pa /etc/fbtab
41 | .El
42 | .Sh DIAGNOSTICS
43 | Problems are reported via the
44 | .Xr syslogd 8
45 | daemon with the severity of
46 | .Dv LOG_ERR .
47 | .Sh SEE ALSO
48 | .Xr fbtab 5
49 | .Sh AUTHORS
50 | .An Wietse Venema Aq Mt wietse@wzv.win.tue.nl
51 | .br
52 | Eindhoven University of Technology
53 | .br
54 | The Netherlands
55 |
--------------------------------------------------------------------------------
/src/include/elf_abi.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: elf_abi.h,v 1.4 1996/05/22 07:46:22 etheisen Exp $ */
2 | /*
3 | * Copyright (c) 1996 Erik Theisen
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. The name of the author may not be used to endorse or promote products
15 | * derived from this software without specific prior written permission
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 | #ifndef _ELF_ABI_H_
29 | #define _ELF_ABI_H_
30 |
31 | #include
32 |
33 | #endif /* _ELF_ABI_H_ */
34 |
--------------------------------------------------------------------------------
/src/include/icdb.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: icdb.h,v 1.4 2016/09/04 14:51:39 nicm Exp $ */
2 | /*
3 | * Copyright (c) 2015 Ted Unangst
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #ifndef _ICDB_H_
19 | #define _ICDB_H_
20 |
21 | #include
22 |
23 | __BEGIN_DECLS
24 |
25 | struct icdb;
26 |
27 | struct icdb *icdb_new(uint32_t version, uint32_t nentries, uint32_t entrysize,
28 | uint32_t nkeys, const uint32_t *keysizes, const uint32_t *keyoffsets);
29 |
30 | struct icdb *icdb_open(const char *name, int flags, uint32_t version);
31 | int icdb_get(struct icdb *db, void *entry, uint32_t idx);
32 | int icdb_lookup(struct icdb *db, int keynum, const void *key, void *entry,
33 | uint32_t *idxp);
34 | int icdb_nentries(struct icdb *db);
35 | const void *icdb_entries(struct icdb *db);
36 | int icdb_update(struct icdb *db, const void *entry, int offset);
37 | int icdb_add(struct icdb *db, const void *entry);
38 | int icdb_rehash(struct icdb *db);
39 | int icdb_save(struct icdb *db, int fd);
40 | int icdb_close(struct icdb *db);
41 |
42 | __END_DECLS
43 |
44 | #endif /* !_ICDB_H_ */
45 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strlcpy.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 1998, 2015 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | /*
23 | * Copy string src to buffer dst of size dsize. At most dsize-1
24 | * chars will be copied. Always NUL terminates (unless dsize == 0).
25 | * Returns strlen(src); if retval >= dsize, truncation occurred.
26 | */
27 | size_t
28 | strlcpy(char *dst, const char *src, size_t dsize)
29 | {
30 | const char *osrc = src;
31 | size_t nleft = dsize;
32 |
33 | /* Copy as many bytes as will fit. */
34 | if (nleft != 0) {
35 | while (--nleft != 0) {
36 | if ((*dst++ = *src++) == '\0')
37 | break;
38 | }
39 | }
40 |
41 | /* Not enough room in dst, add NUL and traverse rest of src. */
42 | if (nleft == 0) {
43 | if (dsize != 0)
44 | *dst = '\0'; /* NUL-terminate dst */
45 | while (*src++)
46 | ;
47 | }
48 |
49 | return(src - osrc - 1); /* count does not include NUL */
50 | }
51 | DEF_WEAK(strlcpy);
52 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgpd/monotime.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: monotime.c,v 1.1 2025/02/20 19:47:31 claudio Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2025 Claudio Jeker
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 | #include
19 |
20 | #include "monotime.h"
21 |
22 | static inline monotime_t
23 | monotime_from_ts(struct timespec *ts)
24 | {
25 | monotime_t mt;
26 |
27 | mt = monotime_from_sec(ts->tv_sec);
28 | mt.monotime += ts->tv_nsec / (1000 * 1000 * 1000LL / MONOTIME_RES);
29 | return mt;
30 | }
31 |
32 | monotime_t
33 | getmonotime(void)
34 | {
35 | struct timespec ts;
36 |
37 | if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
38 | return monotime_clear();
39 | return monotime_from_ts(&ts);
40 | }
41 |
42 | time_t
43 | monotime_to_time(monotime_t mt)
44 | {
45 | mt = monotime_sub(getmonotime(), mt);
46 | return time(NULL) - monotime_to_sec(mt);
47 | }
48 |
49 | monotime_t
50 | time_to_monotime(time_t t)
51 | {
52 | time_t now = time(NULL);
53 |
54 | if (now < t)
55 | return monotime_clear();
56 | t = now - t;
57 | return monotime_sub(getmonotime(), monotime_from_sec(t));
58 | }
59 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wcslcpy.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wcslcpy.c,v 1.8 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 1998, 2015 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #include
20 | #include
21 |
22 | /*
23 | * Copy string src to buffer dst of size dsize. At most dsize-1
24 | * chars will be copied. Always NUL terminates (unless dsize == 0).
25 | * Returns wcslen(src); if retval >= dsize, truncation occurred.
26 | */
27 | size_t
28 | wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize)
29 | {
30 | const wchar_t *osrc = src;
31 | size_t nleft = dsize;
32 |
33 | /* Copy as many bytes as will fit. */
34 | if (nleft != 0) {
35 | while (--nleft != 0) {
36 | if ((*dst++ = *src++) == L'\0')
37 | break;
38 | }
39 | }
40 |
41 | /* Not enough room in dst, add NUL and traverse rest of src. */
42 | if (nleft == 0) {
43 | if (dsize != 0)
44 | *dst = L'\0'; /* NUL-terminate dst */
45 | while (*src++)
46 | ;
47 | }
48 |
49 | return(src - osrc - 1); /* count does not include NUL */
50 | }
51 | DEF_WEAK(wcslcpy);
52 |
--------------------------------------------------------------------------------
/src/lib/libcrypto/arc4random/getentropy_win.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getentropy_win.c,v 1.6 2020/11/11 10:41:24 bcook Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2014, Theo de Raadt
5 | * Copyright (c) 2014, Bob Beck
6 | *
7 | * Permission to use, copy, modify, and distribute this software for any
8 | * purpose with or without fee is hereby granted, provided that the above
9 | * copyright notice and this permission notice appear in all copies.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 | *
19 | * Emulation of getentropy(2) as documented at:
20 | * http://man.openbsd.org/getentropy.2
21 | */
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | int getentropy(void *buf, size_t len);
30 |
31 | /*
32 | * On Windows, BCryptGenRandom with BCRYPT_USE_SYSTEM_PREFERRED_RNG is supposed
33 | * to be a well-seeded, cryptographically strong random number generator.
34 | * https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
35 | */
36 | int
37 | getentropy(void *buf, size_t len)
38 | {
39 | if (len > 256) {
40 | errno = EIO;
41 | return (-1);
42 | }
43 |
44 | if (FAILED(BCryptGenRandom(NULL, buf, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG))) {
45 | errno = EIO;
46 | return (-1);
47 | }
48 |
49 | return (0);
50 | }
51 |
--------------------------------------------------------------------------------
/src/include/readpassphrase.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: readpassphrase.h,v 1.6 2019/01/25 00:19:25 millert Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2000, 2002 Todd C. Miller
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | *
18 | * Sponsored in part by the Defense Advanced Research Projects
19 | * Agency (DARPA) and Air Force Research Laboratory, Air Force
20 | * Materiel Command, USAF, under agreement number F39502-99-1-0512.
21 | */
22 |
23 | #ifndef _READPASSPHRASE_H_
24 | #define _READPASSPHRASE_H_
25 |
26 | #define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
27 | #define RPP_ECHO_ON 0x01 /* Leave echo on. */
28 | #define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */
29 | #define RPP_FORCELOWER 0x04 /* Force input to lower case. */
30 | #define RPP_FORCEUPPER 0x08 /* Force input to upper case. */
31 | #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */
32 | #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */
33 |
34 | #include
35 |
36 | __BEGIN_DECLS
37 | char * readpassphrase(const char *, char *, size_t, int);
38 | __END_DECLS
39 |
40 | #endif /* !_READPASSPHRASE_H_ */
41 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/labs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: labs.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
2 | /*-
3 | * Copyright (c) 1990 The Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | long
34 | labs(long j)
35 | {
36 | return(j < 0 ? -j : j);
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/string/timingsafe_memcmp.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: timingsafe_memcmp.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */
2 | /*
3 | * Copyright (c) 2014 Google Inc.
4 | *
5 | * Permission to use, copy, modify, and distribute this software for any
6 | * purpose with or without fee is hereby granted, provided that the above
7 | * copyright notice and this permission notice appear in all copies.
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 | */
17 |
18 | #include
19 | #include
20 |
21 | int
22 | timingsafe_memcmp(const void *b1, const void *b2, size_t len)
23 | {
24 | const unsigned char *p1 = b1, *p2 = b2;
25 | size_t i;
26 | int res = 0, done = 0;
27 |
28 | for (i = 0; i < len; i++) {
29 | /* lt is -1 if p1[i] < p2[i]; else 0. */
30 | int lt = (p1[i] - p2[i]) >> CHAR_BIT;
31 |
32 | /* gt is -1 if p1[i] > p2[i]; else 0. */
33 | int gt = (p2[i] - p1[i]) >> CHAR_BIT;
34 |
35 | /* cmp is 1 if p1[i] > p2[i]; -1 if p1[i] < p2[i]; else 0. */
36 | int cmp = lt - gt;
37 |
38 | /* set res = cmp if !done. */
39 | res |= cmp & ~done;
40 |
41 | /* set done if p1[i] != p2[i]. */
42 | done |= lt | gt;
43 | }
44 |
45 | return (res);
46 | }
47 | DEF_WEAK(timingsafe_memcmp);
48 |
--------------------------------------------------------------------------------
/src/etc/examples/inetd.conf:
--------------------------------------------------------------------------------
1 | # $OpenBSD: inetd.conf,v 1.1 2014/07/11 21:20:10 deraadt Exp $
2 | #
3 | # Internet server configuration database
4 | #
5 | # define *both* IPv4 and IPv6 entries for dual-stack support.
6 | #
7 | #ftp stream tcp nowait root /usr/libexec/ftpd ftpd -US
8 | #ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -US
9 | #finger stream tcp nowait _fingerd /usr/libexec/fingerd fingerd -lsm
10 | #finger stream tcp6 nowait _fingerd /usr/libexec/fingerd fingerd -lsm
11 | 127.0.0.1:comsat dgram udp wait root /usr/libexec/comsat comsat
12 | [::1]:comsat dgram udp6 wait root /usr/libexec/comsat comsat
13 | #ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd
14 | # Internal services
15 | #echo stream tcp nowait root internal
16 | #echo stream tcp6 nowait root internal
17 | #discard stream tcp nowait root internal
18 | #discard stream tcp6 nowait root internal
19 | #chargen stream tcp nowait root internal
20 | #chargen stream tcp6 nowait root internal
21 | daytime stream tcp nowait root internal
22 | daytime stream tcp6 nowait root internal
23 | #time stream tcp nowait root internal
24 | #time stream tcp6 nowait root internal
25 | #echo dgram udp wait root internal
26 | #echo dgram udp6 wait root internal
27 | #discard dgram udp wait root internal
28 | #discard dgram udp6 wait root internal
29 | #chargen dgram udp wait root internal
30 | #chargen dgram udp6 wait root internal
31 | #daytime dgram udp wait root internal
32 | #daytime dgram udp6 wait root internal
33 | #time dgram udp wait root internal
34 | #time dgram udp6 wait root internal
35 | # RPC based services
36 | #rstatd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rstatd rpc.rstatd
37 | #rusersd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rusersd rpc.rusersd
38 | #walld/1 dgram rpc/udp wait root /usr/libexec/rpc.rwalld rpc.rwalld
39 | #rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad
40 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wcslen.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wcslen.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */
2 | /* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
3 |
4 | /*-
5 | * Copyright (c)1999 Citrus Project,
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
30 | */
31 |
32 | #include
33 |
34 | size_t
35 | wcslen(const wchar_t *s)
36 | {
37 | const wchar_t *p;
38 |
39 | p = s;
40 | while (*p)
41 | p++;
42 |
43 | return p - s;
44 | }
45 | DEF_STRONG(wcslen);
46 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/rewinddir.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: rewinddir.c,v 1.12 2017/08/12 22:59:52 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1990, 1993
4 | * The Regents of the University of California. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | void
34 | rewinddir(DIR *dirp)
35 | {
36 | seekdir(dirp, 0);
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/abs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: abs.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
2 | /*-
3 | * Copyright (c) 1990 The Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | int
34 | abs(int j)
35 | {
36 | return(j < 0 ? -j : j);
37 | }
38 | DEF_STRONG(abs);
39 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/atol.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: atol.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 1988 Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | long
34 | atol(const char *str)
35 | {
36 | return(strtol(str, (char **)NULL, 10));
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wcsnlen.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wcsnlen.c,v 1.1 2024/07/14 09:51:18 jca Exp $ */
2 | /* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */
3 |
4 | /*-
5 | * Copyright (c)1999 Citrus Project,
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
30 | */
31 |
32 | #include
33 |
34 | size_t
35 | wcsnlen(const wchar_t *s, size_t maxlen)
36 | {
37 | const wchar_t *p;
38 |
39 | p = s;
40 | while (maxlen-- && *p)
41 | p++;
42 |
43 | return p - s;
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/atof.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: atof.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
2 | /*
3 | * Copyright (c) 1988 The Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | double
34 | atof(const char *ascii)
35 | {
36 | return(strtod(ascii, (char **)NULL));
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/atoll.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: atoll.c,v 1.4 2021/10/24 10:05:23 jsg Exp $ */
2 | /*
3 | * Copyright (c) 1988 Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | long long
34 | atoll(const char *str)
35 | {
36 | return(strtoll(str, (char **)NULL, 10));
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/imaxabs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: imaxabs.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */
2 |
3 | /*-
4 | * Copyright (c) 1990 The Regents of the University of California.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the University nor the names of its contributors
16 | * may be used to endorse or promote products derived from this software
17 | * without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 | * SUCH DAMAGE.
30 | */
31 |
32 | #include
33 |
34 | intmax_t
35 | imaxabs(intmax_t j)
36 | {
37 | return (j < 0 ? -j : j);
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/libc/string/Makefile.inc:
--------------------------------------------------------------------------------
1 | # $OpenBSD: Makefile.inc,v 1.41 2025/10/24 11:30:06 claudio Exp $
2 |
3 | # string sources
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/string ${LIBCSRCDIR}/string
5 |
6 | SRCS+= explicit_bzero.c ffsl.c ffsll.c memccpy.c memmem.c memrchr.c \
7 | stpcpy.c stpncpy.c strcasecmp.c strcasecmp_l.c strcasestr.c \
8 | strcoll.c strcoll_l.c strdup.c strerror.c strerror_l.c strerror_r.c \
9 | strmode.c strndup.c strnlen.c strsignal.c strtok.c strxfrm.c \
10 | strxfrm_l.c timingsafe_bcmp.c timingsafe_memcmp.c \
11 | wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \
12 | wcslen.c wcsncat.c wcsncmp.c wcsncpy.c wcsnlen.c wcspbrk.c wcsrchr.c \
13 | wcsspn.c wcsstr.c wcstok.c wcswcs.c wcswidth.c wmemchr.c wmemcmp.c \
14 | wmemcpy.c wmemmove.c wmemset.c wcsdup.c wcscasecmp.c wcscasecmp_l.c
15 |
16 | # machine-dependent net sources
17 | # ../arch/ARCH/Makefile.inc must include sources for:
18 | # bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset()
19 | # memcpy() memmove() memset() rindex() strcat() strchr()
20 | # strcmp() strcpy() strcspn() strlen() strlcat() strlcpy()
21 | # strncat() strncmp() strncpy() strpbrk() strrchr() strsep()
22 | # strspn() strstr() swab()
23 |
24 | .include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/string/Makefile.inc"
25 |
26 | MAN+= bcmp.3 bcopy.3 bzero.3 ffs.3 memccpy.3 memchr.3 \
27 | memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 stpcpy.3 strcasecmp.3 \
28 | strcat.3 strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 \
29 | strerror.3 strlen.3 strmode.3 strncat.3 strncpy.3 strpbrk.3 \
30 | strrchr.3 strsep.3 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 \
31 | swab.3 strlcpy.3 timingsafe_bcmp.3 \
32 | wcscasecmp.3 wcscat.3 wcschr.3 wcscmp.3 wcscpy.3 \
33 | wcscspn.3 wcsdup.3 wcslcpy.3 wcslen.3 wcspbrk.3 wcsrchr.3 wcsspn.3 \
34 | wcsstr.3 wcstok.3 wcswidth.3 wmemchr.3 wmemcmp.3 wmemcpy.3 wmemmove.3 \
35 | wmemset.3
36 |
--------------------------------------------------------------------------------
/src/include/memory.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: memory.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
2 | /* $NetBSD: memory.h,v 1.3 1994/10/26 00:56:06 cgd Exp $ */
3 |
4 | /*
5 | * Copyright (c) 1988 Regents of the University of California.
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | * 3. Neither the name of the University nor the names of its contributors
17 | * may be used to endorse or promote products derived from this software
18 | * without specific prior written permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 | * SUCH DAMAGE.
31 | *
32 | * @(#)memory.h 5.5 (Berkeley) 6/1/90
33 | */
34 |
35 | #include
36 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wmemcpy.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wmemcpy.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */
2 | /* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
3 |
4 | /*-
5 | * Copyright (c)1999 Citrus Project,
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp
30 | */
31 |
32 | #include
33 | #include
34 |
35 | wchar_t *
36 | wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
37 | {
38 |
39 | return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
40 | }
41 | DEF_STRONG(wmemcpy);
42 |
--------------------------------------------------------------------------------
/src/lib/libcrypto/arc4random/getentropy_freebsd.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getentropy_freebsd.c,v 1.4 2020/10/12 22:08:33 deraadt Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2014 Pawel Jakub Dawidek
5 | * Copyright (c) 2014 Brent Cook
6 | *
7 | * Permission to use, copy, modify, and distribute this software for any
8 | * purpose with or without fee is hereby granted, provided that the above
9 | * copyright notice and this permission notice appear in all copies.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 | *
19 | * Emulation of getentropy(2) as documented at:
20 | * http://man.openbsd.org/getentropy.2
21 | */
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | /*
30 | * Derived from lib/libc/gen/arc4random.c from FreeBSD.
31 | */
32 | static size_t
33 | getentropy_sysctl(u_char *buf, size_t size)
34 | {
35 | const int mib[2] = { CTL_KERN, KERN_ARND };
36 | size_t len, done;
37 |
38 | done = 0;
39 |
40 | do {
41 | len = size;
42 | if (sysctl(mib, 2, buf, &len, NULL, 0) == -1)
43 | return (done);
44 | done += len;
45 | buf += len;
46 | size -= len;
47 | } while (size > 0);
48 |
49 | return (done);
50 | }
51 |
52 | int
53 | getentropy(void *buf, size_t len)
54 | {
55 | if (len <= 256 && getentropy_sysctl(buf, len) == len)
56 | return (0);
57 |
58 | errno = EIO;
59 | return (-1);
60 | }
61 |
--------------------------------------------------------------------------------
/src/lib/libc/string/strsignal.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1988 Regents of the University of California.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the University nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | */
29 |
30 | #include
31 | #include
32 |
33 | char *
34 | strsignal(int sig)
35 | {
36 | static char buf[NL_TEXTMAX];
37 |
38 | return __strsignal(sig, buf);
39 | }
40 | DEF_WEAK(strsignal);
41 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wmemmove.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wmemmove.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */
2 | /* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
3 |
4 | /*-
5 | * Copyright (c)1999 Citrus Project,
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp
30 | */
31 |
32 | #include
33 | #include
34 |
35 | wchar_t *
36 | wmemmove(wchar_t *d, const wchar_t *s, size_t n)
37 | {
38 |
39 | return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
40 | }
41 | DEF_STRONG(wmemmove);
42 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/atoi.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: atoi.c,v 1.6 2015/09/13 08:31:47 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1988 Regents of the University of California.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | int
34 | atoi(const char *str)
35 | {
36 | return((int)strtol(str, (char **)NULL, 10));
37 | }
38 | DEF_STRONG(atoi);
39 |
--------------------------------------------------------------------------------
/src/lib/libc/crypt/arc4random.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: arc4random.h,v 1.4 2015/01/15 06:57:18 deraadt Exp $ */
2 |
3 | /*
4 | * Copyright (c) 1996, David Mazieres
5 | * Copyright (c) 2008, Damien Miller
6 | * Copyright (c) 2013, Markus Friedl
7 | * Copyright (c) 2014, Theo de Raadt
8 | *
9 | * Permission to use, copy, modify, and distribute this software for any
10 | * purpose with or without fee is hereby granted, provided that the above
11 | * copyright notice and this permission notice appear in all copies.
12 | *
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 | */
21 |
22 | /*
23 | * Stub functions for portability.
24 | */
25 | #include
26 |
27 | #include
28 |
29 | #include "thread_private.h"
30 |
31 | static inline void
32 | _getentropy_fail(void)
33 | {
34 | raise(SIGKILL);
35 | }
36 |
37 | static inline int
38 | _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
39 | {
40 | struct {
41 | struct _rs rs;
42 | struct _rsx rsx;
43 | } *p;
44 |
45 | if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE,
46 | MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
47 | return (-1);
48 | if (minherit(p, sizeof(*p), MAP_INHERIT_ZERO) == -1) {
49 | munmap(p, sizeof(*p));
50 | return (-1);
51 | }
52 |
53 | *rsp = &p->rs;
54 | *rsxp = &p->rsx;
55 | return (0);
56 | }
57 |
58 | static inline void
59 | _rs_forkdetect(void)
60 | {
61 | }
62 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/wait.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wait.c,v 1.6 2015/10/25 19:15:56 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1988, 1993
4 | * The Regents of the University of California. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 | #include
33 |
34 | pid_t
35 | wait(int *istat)
36 | {
37 | return (wait4(WAIT_ANY, istat, 0, NULL));
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/libcrypto/arc4random/getentropy_netbsd.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: getentropy_netbsd.c,v 1.4 2020/10/12 22:08:33 deraadt Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2014 Pawel Jakub Dawidek
5 | * Copyright (c) 2014 Brent Cook
6 | *
7 | * Permission to use, copy, modify, and distribute this software for any
8 | * purpose with or without fee is hereby granted, provided that the above
9 | * copyright notice and this permission notice appear in all copies.
10 | *
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 | *
19 | * Emulation of getentropy(2) as documented at:
20 | * http://man.openbsd.org/getentropy.2
21 | */
22 |
23 | #include
24 | #include
25 |
26 | #include
27 | #include
28 |
29 | /*
30 | * Derived from lib/libc/gen/arc4random.c from FreeBSD.
31 | */
32 | static size_t
33 | getentropy_sysctl(u_char *buf, size_t size)
34 | {
35 | const int mib[2] = { CTL_KERN, KERN_ARND };
36 | size_t len, done;
37 |
38 | done = 0;
39 |
40 | do {
41 | len = size;
42 | if (sysctl(mib, 2, buf, &len, NULL, 0) == -1)
43 | return (done);
44 | done += len;
45 | buf += len;
46 | size -= len;
47 | } while (size > 0);
48 |
49 | return (done);
50 | }
51 |
52 | int
53 | getentropy(void *buf, size_t len)
54 | {
55 | if (len <= 256 &&
56 | getentropy_sysctl(buf, len) == len) {
57 | return (0);
58 | }
59 |
60 | errno = EIO;
61 | return (-1);
62 | }
63 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/raise.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: raise.c,v 1.8 2015/11/10 04:30:59 guenther Exp $ */
2 | /*-
3 | * Copyright (c) 1990, 1993
4 | * The Regents of the University of California. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 | #include
33 |
34 | int
35 | raise(int s)
36 | {
37 | return (thrkill(0, s, NULL));
38 | }
39 | DEF_STRONG(raise);
40 |
--------------------------------------------------------------------------------
/src/lib/libc/stdlib/llabs.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: llabs.c,v 1.4 2016/08/14 23:18:03 guenther Exp $ */
2 |
3 | /*-
4 | * Copyright (c) 1990 The Regents of the University of California.
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the University nor the names of its contributors
16 | * may be used to endorse or promote products derived from this software
17 | * without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 | * SUCH DAMAGE.
30 | */
31 |
32 | #include
33 |
34 | long long
35 | llabs(long long j)
36 | {
37 | return (j < 0 ? -j : j);
38 | }
39 |
40 | __weak_alias(qabs, llabs);
41 |
--------------------------------------------------------------------------------
/src/usr.sbin/bgpd/log.h:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: log.h,v 1.20 2020/10/21 06:48:33 claudio Exp $ */
2 |
3 | /*
4 | * Copyright (c) 2003, 2004 Henning Brauer
5 | *
6 | * Permission to use, copy, modify, and distribute this software for any
7 | * purpose with or without fee is hereby granted, provided that the above
8 | * copyright notice and this permission notice appear in all copies.
9 | *
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 | */
18 |
19 | #ifndef LOG_H
20 | #define LOG_H
21 |
22 | #include
23 | #include
24 |
25 | void log_init(int, int);
26 | void log_procinit(const char *);
27 | void log_setverbose(int);
28 | int log_getverbose(void);
29 | void log_warn(const char *, ...)
30 | __attribute__((__format__ (printf, 1, 2)));
31 | void log_warnx(const char *, ...)
32 | __attribute__((__format__ (printf, 1, 2)));
33 | void log_info(const char *, ...)
34 | __attribute__((__format__ (printf, 1, 2)));
35 | void log_debug(const char *, ...)
36 | __attribute__((__format__ (printf, 1, 2)));
37 | void logit(int, const char *, ...)
38 | __attribute__((__format__ (printf, 2, 3)));
39 | void vlog(int, const char *, va_list)
40 | __attribute__((__format__ (printf, 2, 0)));
41 | __dead void fatal(const char *, ...)
42 | __attribute__((__format__ (printf, 1, 2)));
43 | __dead void fatalx(const char *, ...)
44 | __attribute__((__format__ (printf, 1, 2)));
45 |
46 | #endif /* LOG_H */
47 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/isatty.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: isatty.c,v 1.11 2015/09/12 14:56:50 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1988, 1993
4 | * The Regents of the University of California. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 | #include
33 |
34 | int
35 | isatty(int fd)
36 | {
37 | return fcntl(fd, F_ISATTY) != -1;
38 | }
39 | DEF_WEAK(isatty);
40 |
--------------------------------------------------------------------------------
/src/lib/libc/gen/wait3.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wait3.c,v 1.6 2015/10/25 19:15:56 guenther Exp $ */
2 | /*
3 | * Copyright (c) 1988, 1993
4 | * The Regents of the University of California. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | * 3. Neither the name of the University nor the names of its contributors
15 | * may be used to endorse or promote products derived from this software
16 | * without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 | * SUCH DAMAGE.
29 | */
30 |
31 | #include
32 |
33 | pid_t
34 | wait3(int *istat, int options, struct rusage *rup)
35 | {
36 | return (wait4(WAIT_ANY, istat, options, rup));
37 | }
38 |
--------------------------------------------------------------------------------
/src/lib/libc/string/wmemset.c:
--------------------------------------------------------------------------------
1 | /* $OpenBSD: wmemset.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */
2 | /* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
3 |
4 | /*-
5 | * Copyright (c)1999 Citrus Project,
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without
9 | * modification, are permitted provided that the following conditions
10 | * are met:
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp
30 | */
31 |
32 | #include