sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-23 02:06:39 +00:00
parent f913a3fe74
commit 85b7ec3495
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
58 changed files with 10776 additions and 147 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cryptutil.c,v 1.12 2015/09/13 15:33:48 guenther Exp $ */
/* $OpenBSD: cryptutil.c,v 1.13 2024/01/22 19:26:55 deraadt Exp $ */
/*
* Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
*
@ -54,7 +54,7 @@ int
crypt_newhash(const char *pass, const char *pref, char *hash, size_t hashlen)
{
int rv = -1;
const char *defaultpref = "blowfish,8";
const char *defaultpref = "bcrypt,8";
const char *errstr;
const char *choices[] = { "blowfish", "bcrypt" };
size_t maxchoice = sizeof(choices) / sizeof(choices[0]);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: devname.c,v 1.13 2016/07/06 04:35:12 guenther Exp $ */
/* $OpenBSD: devname.c,v 1.14 2024/01/22 17:22:58 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@ -83,7 +83,7 @@ devname(dev_t dev, mode_t type)
char *name = NULL;
if (!db && !failure) {
if (!(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)))
if (!(db = __hash_open(_PATH_DEVDB, O_RDONLY, 0, NULL, 0)))
failure = true;
}
if (!failure) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getcap.c,v 1.36 2022/05/14 05:06:32 guenther Exp $ */
/* $OpenBSD: getcap.c,v 1.37 2024/01/22 17:22:58 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@ -252,7 +252,7 @@ getent(char **cap, u_int *len, char **db_array, FILE *fp,
clen = snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p);
if (clen >= 0 && clen < sizeof(pbuf) && usedb &&
(capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0))) {
(capdbp = __hash_open(pbuf, O_RDONLY, 0, NULL, 0))) {
opened++;
retval = cdbget(capdbp, &dbrecord, name);
if (retval < 0) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getnetgrent.c,v 1.31 2023/02/17 18:00:11 miod Exp $ */
/* $OpenBSD: getnetgrent.c,v 1.32 2024/01/22 17:21:52 deraadt Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@ -630,7 +630,7 @@ setnetgrent(const char *ng)
return;
if (_ng_db == NULL)
_ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL);
_ng_db = __hash_open(_PATH_NETGROUP_DB, O_RDONLY, 0, NULL, 0);
#ifdef YP
/*
@ -682,7 +682,7 @@ innetgr(const char *grp, const char *host, const char *user, const char *domain)
struct stringlist *sl;
if (_ng_db == NULL)
_ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL);
_ng_db = __hash_open(_PATH_NETGROUP_DB, O_RDONLY, 0, NULL, 0);
#ifdef YP
/*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: getpwent.c,v 1.66 2022/08/02 17:00:15 deraadt Exp $ */
/* $OpenBSD: getpwent.c,v 1.68 2024/01/22 21:07:09 deraadt Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@ -960,10 +960,20 @@ __initdb(int shadow)
__ypmode = YPMODE_NONE;
__getpwent_has_yppw = -1;
#endif
if (shadow)
if (shadow) {
#ifdef FORCE_DBOPEN
_pw_db = dbopen(_PATH_SMP_DB, O_RDONLY, 0, DB_HASH, NULL);
if (!_pw_db)
#else
_pw_db = __hash_open(_PATH_SMP_DB, O_RDONLY, 0, NULL, 0);
#endif
}
if (!_pw_db) {
#ifdef FORCE_DBOPEN
_pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL);
#else
_pw_db = __hash_open(_PATH_MP_DB, O_RDONLY, 0, NULL, 0);
#endif
}
if (_pw_db) {
errno = saved_errno;
return (1);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ttyname.c,v 1.20 2017/04/14 15:02:51 deraadt Exp $ */
/* $OpenBSD: ttyname.c,v 1.21 2024/01/22 17:22:58 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@ -87,7 +87,7 @@ ttyname_r(int fd, char *buf, size_t len)
memcpy(buf, _PATH_DEV, sizeof(_PATH_DEV));
if ((db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
if ((db = __hash_open(_PATH_DEVDB, O_RDONLY, 0, NULL, 0))) {
memset(&bkey, 0, sizeof(bkey));
bkey.type = S_IFCHR;
bkey.dev = sb.st_rdev;

View file

@ -1,11 +1,11 @@
# $OpenBSD: Makefile.inc,v 1.18 2016/03/30 06:38:41 jmc Exp $
# $OpenBSD: Makefile.inc,v 1.19 2024/01/22 16:18:06 deraadt Exp $
# librpc sources
.PATH: ${LIBCSRCDIR}/arch/${MACHINE}/rpc ${LIBCSRCDIR}/rpc
SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c \
clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c clnt_tcp.c \
clnt_udp.c get_myaddress.c getrpcent.c getrpcport.c \
clnt_udp.c clnt_udp_bufcreate.c get_myaddress.c getrpcent.c getrpcport.c \
pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \
pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \
svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \

View file

@ -1,4 +1,4 @@
/* $OpenBSD: clnt_udp.c,v 1.40 2022/08/24 01:32:21 deraadt Exp $ */
/* $OpenBSD: clnt_udp.c,v 1.41 2024/01/22 16:18:06 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@ -44,7 +44,7 @@
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include "clnt_udp.h"
/*
* UDP bases client side rpc operations
@ -66,31 +66,65 @@ static const struct clnt_ops udp_ops = {
clntudp_control
};
/*
* Private data kept per client handle
*/
struct cu_data {
int cu_sock;
bool_t cu_closeit;
struct sockaddr_in cu_raddr;
int cu_connected; /* use send() instead */
int cu_rlen;
struct timeval cu_wait;
struct timeval cu_total;
struct rpc_err cu_error;
XDR cu_outxdrs;
u_int cu_xdrpos;
u_int cu_sendsz;
char *cu_outbuf;
u_int cu_recvsz;
char cu_inbuf[1];
};
int
clntudp_bufcreate1(struct clntudp_bufcreate_args *args)
{
args->cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
if (args->cl == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
return -1;
}
args->sendsz = ((args->sendsz + 3) / 4) * 4;
args->recvsz = ((args->recvsz + 3) / 4) * 4;
args->cu = (struct cu_data *)mem_alloc(sizeof(args->cu) +
args->sendsz + args->recvsz);
if (args->cu == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
return -1;
}
args->cu->cu_outbuf = &args->cu->cu_inbuf[args->recvsz];
args->cl->cl_ops = &udp_ops;
args->cl->cl_private = (caddr_t)args->cu;
args->cu->cu_connected = 0;
args->cu->cu_rlen = sizeof (args->cu->cu_raddr);
args->cu->cu_wait = args->wait;
args->cu->cu_total.tv_sec = -1;
args->cu->cu_total.tv_usec = -1;
args->cu->cu_sendsz = args->sendsz;
args->cu->cu_recvsz = args->recvsz;
args->cu->cu_closeit = FALSE;
args->call_msg.rm_xid = arc4random();
args->call_msg.rm_direction = CALL;
args->call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
args->call_msg.rm_call.cb_prog = args->program;
args->call_msg.rm_call.cb_vers = args->version;
return 0;
}
int
clntudp_bufcreate2(struct clntudp_bufcreate_args *args)
{
xdrmem_create(&(args->cu->cu_outxdrs), args->cu->cu_outbuf,
args->sendsz, XDR_ENCODE);
if (!xdr_callhdr(&(args->cu->cu_outxdrs), &args->call_msg))
return -1;
args->cu->cu_xdrpos = XDR_GETPOS(&(args->cu->cu_outxdrs));
args->cl->cl_auth = authnone_create();
if (args->cl->cl_auth == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
return -1;
}
return 0;
}
/*
* Create a UDP based client handle.
* If *sockp<0, *sockp is set to a newly created UPD socket.
* If *sockp<0, *sockp is set to a newly created UPD socket. (***)
* If raddr->sin_port is 0 a binder on the remote machine
* is consulted for the correct port number.
* is consulted for the correct port number. (***)
* NB: It is the client's responsibility to close *sockp, unless
* clntudp_bufcreate() was called with *sockp = -1 (so it created
* the socket), and CLNT_DESTROY() is used.
@ -103,100 +137,45 @@ struct cu_data {
*
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*
* This is a reduced-functionality version of clntudp_bufcreate() that
* does not allocate socket or binding (***, above).
* The official function clntudp_bufcreate(), which does perform those
* two steps, is in clnt_udp_bufcreate.c. This split avoids pulling
* socket / portmap related code into programs only using getpwent / YP code.
*/
CLIENT *
clntudp_bufcreate(struct sockaddr_in *raddr, u_long program, u_long version,
clntudp_bufcreate_simple(struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp, u_int sendsz, u_int recvsz)
{
CLIENT *cl;
struct cu_data *cu = NULL;
struct rpc_msg call_msg;
struct clntudp_bufcreate_args args;
cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
if (cl == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
sendsz = ((sendsz + 3) / 4) * 4;
recvsz = ((recvsz + 3) / 4) * 4;
cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz);
if (cu == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
cu->cu_outbuf = &cu->cu_inbuf[recvsz];
args.raddr = raddr;
args.program = program;
args.version = version;
args.wait = wait;
args.sockp = sockp;
args.sendsz = sendsz;
args.recvsz = recvsz;
args.cl = NULL;
args.cu = NULL;
if (raddr->sin_port == 0) {
u_short port;
if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
goto fooy;
}
raddr->sin_port = htons(port);
}
cl->cl_ops = &udp_ops;
cl->cl_private = (caddr_t)cu;
cu->cu_raddr = *raddr;
cu->cu_connected = 0;
cu->cu_rlen = sizeof (cu->cu_raddr);
cu->cu_wait = wait;
cu->cu_total.tv_sec = -1;
cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz;
cu->cu_recvsz = recvsz;
call_msg.rm_xid = arc4random();
call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program;
call_msg.rm_call.cb_vers = version;
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf,
sendsz, XDR_ENCODE);
if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) {
if (clntudp_bufcreate1(&args) == -1)
goto fooy;
}
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
if (*sockp < 0) {
*sockp = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK,
IPPROTO_UDP);
if (*sockp == -1) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
/* attempt to bind to priv port */
(void)bindresvport(*sockp, NULL);
cu->cu_closeit = TRUE;
} else {
cu->cu_closeit = FALSE;
}
cu->cu_sock = *sockp;
cl->cl_auth = authnone_create();
if (cl->cl_auth == NULL) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
args.cu->cu_raddr = *raddr;
args.cu->cu_sock = *sockp;
if (clntudp_bufcreate2(&args) == -1)
goto fooy;
}
return (cl);
return (args.cl);
fooy:
if (cu)
mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz);
if (cl)
mem_free((caddr_t)cl, sizeof(CLIENT));
if (args.cu)
mem_free((caddr_t)args.cu,
sizeof(*args.cu) + args.sendsz + args.recvsz);
if (args.cl)
mem_free((caddr_t)args.cl, sizeof(CLIENT));
return (NULL);
}
DEF_WEAK(clntudp_bufcreate);
CLIENT *
clntudp_create(struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp)
{
return(clntudp_bufcreate(raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE));
}
DEF_WEAK(clntudp_create);
static enum clnt_stat
clntudp_call(CLIENT *cl, /* client handle */

70
lib/libc/rpc/clnt_udp.h Normal file
View file

@ -0,0 +1,70 @@
/* $OpenBSD: clnt_udp.h,v 1.1 2024/01/22 16:18:06 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the "Oracle America, Inc." nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Private data kept per client handle
*/
struct cu_data {
int cu_sock;
bool_t cu_closeit;
struct sockaddr_in cu_raddr;
int cu_connected; /* use send() instead */
int cu_rlen;
struct timeval cu_wait;
struct timeval cu_total;
struct rpc_err cu_error;
XDR cu_outxdrs;
u_int cu_xdrpos;
u_int cu_sendsz;
char *cu_outbuf;
u_int cu_recvsz;
char cu_inbuf[1];
};
struct clntudp_bufcreate_args {
struct sockaddr_in *raddr;
u_long program;
u_long version;
struct timeval wait;
int *sockp;
u_int sendsz;
u_int recvsz;
CLIENT *cl;
struct cu_data *cu;
struct rpc_msg call_msg;
};
__BEGIN_HIDDEN_DECLS
extern int clntudp_bufcreate1(struct clntudp_bufcreate_args *);
extern int clntudp_bufcreate2(struct clntudp_bufcreate_args *);
__END_HIDDEN_DECLS

View file

@ -0,0 +1,130 @@
/* $OpenBSD: clnt_udp_bufcreate.c,v 1.1 2024/01/22 16:18:06 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the "Oracle America, Inc." nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* clnt_udp.c, Implements a UDP/IP based, client side RPC.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include "clnt_udp.h"
/*
* Create a UDP based client handle.
* If *sockp<0, *sockp is set to a newly created UPD socket.
* If raddr->sin_port is 0 a binder on the remote machine
* is consulted for the correct port number.
* NB: It is the client's responsibility to close *sockp, unless
* clntudp_bufcreate() was called with *sockp = -1 (so it created
* the socket), and CLNT_DESTROY() is used.
* NB: The rpch->cl_auth is initialized to null authentication.
* Caller may wish to set this something more useful.
*
* wait is the amount of time used between retransmitting a call if
* no response has been heard; retransmission occurs until the actual
* rpc call times out.
*
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
CLIENT *
clntudp_bufcreate(struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp, u_int sendsz, u_int recvsz)
{
struct clntudp_bufcreate_args args;
args.raddr = raddr;
args.program = program;
args.version = version;
args.wait = wait;
args.sockp = sockp;
args.sendsz = sendsz;
args.recvsz = recvsz;
if (clntudp_bufcreate1(&args) == -1)
goto fooy;
if (raddr->sin_port == 0) {
u_short port;
if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
goto fooy;
}
raddr->sin_port = htons(port);
}
args.cu->cu_raddr = *raddr;
if (*sockp < 0) {
*sockp = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK,
IPPROTO_UDP);
if (*sockp == -1) {
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
goto fooy;
}
/* attempt to bind to priv port */
(void)bindresvport(*sockp, NULL);
args.cu->cu_closeit = TRUE;
}
args.cu->cu_sock = *args.sockp;
if (clntudp_bufcreate2(&args) == -1)
goto fooy;
return (args.cl);
fooy:
if (args.cu)
mem_free((caddr_t)args.cu,
sizeof(*args.cu) + args.sendsz + args.recvsz);
if (args.cl)
mem_free((caddr_t)args.cl, sizeof(CLIENT));
return (NULL);
}
DEF_WEAK(clntudp_bufcreate);
CLIENT *
clntudp_create(struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp)
{
return(clntudp_bufcreate(raddr, program, version, wait, sockp,
UDPMSGSIZE, UDPMSGSIZE));
}
DEF_WEAK(clntudp_create);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: yp_bind.c,v 1.32 2022/08/02 16:59:29 deraadt Exp $ */
/* $OpenBSD: yp_bind.c,v 1.33 2024/01/22 16:18:06 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
@ -46,6 +46,10 @@
char _yp_domain[HOST_NAME_MAX+1];
int _yplib_timeout = 10;
extern CLIENT *
clntudp_bufcreate_simple(struct sockaddr_in *raddr, u_long program, u_long version,
struct timeval wait, int *sockp, u_int sendsz, u_int recvsz);
int
_yp_dobind(const char *dom, struct dom_binding **ypdb)
{
@ -72,8 +76,8 @@ again:
tv.tv_sec = _yplib_timeout / 2;
tv.tv_usec = 0;
ypbinding->dom_client = clntudp_create(&ypbinding->dom_server_addr,
YPPROG, YPVERS, tv, &ypbinding->dom_socket);
ypbinding->dom_client = clntudp_bufcreate_simple(&ypbinding->dom_server_addr,
YPPROG, YPVERS, tv, &ypbinding->dom_socket, UDPMSGSIZE, UDPMSGSIZE);
if (ypbinding->dom_client == NULL) {
close(ypbinding->dom_socket);
ypbinding->dom_socket = -1;

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: CMS_ContentInfo_new.3,v 1.3 2019/11/02 15:39:46 schwarze Exp $
.\" $OpenBSD: CMS_ContentInfo_new.3,v 1.4 2024/01/22 14:00:13 tb Exp $
.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@ -13,7 +13,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: November 2 2019 $
.Dd $Mdocdate: January 22 2024 $
.Dt CMS_CONTENTINFO_NEW 3
.Os
.Sh NAME
@ -104,6 +104,7 @@ if an error occurs.
.Xr CMS_get1_ReceiptRequest 3 ,
.Xr CMS_sign 3 ,
.Xr CMS_sign_receipt 3 ,
.Xr CMS_signed_add1_attr 3 ,
.Xr CMS_uncompress 3 ,
.Xr CMS_verify 3 ,
.Xr CMS_verify_receipt 3 ,

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.8 2023/07/26 19:30:43 tb Exp $
.\" $OpenBSD: CMS_get0_SignerInfos.3,v 1.9 2024/01/22 14:00:13 tb Exp $
.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
.\"
.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@ -48,7 +48,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: July 26 2023 $
.Dd $Mdocdate: January 22 2024 $
.Dt CMS_GET0_SIGNERINFOS 3
.Os
.Sh NAME
@ -187,6 +187,7 @@ Any error can be obtained from
.Xr ERR_get_error 3 .
.Sh SEE ALSO
.Xr CMS_ContentInfo_new 3 ,
.Xr CMS_signed_add1_attr 3 ,
.Xr CMS_verify 3
.Sh STANDARDS
RFC 5652: Cryptographic Message Syntax (CMS)

View file

@ -0,0 +1,371 @@
.\" $OpenBSD: CMS_signed_add1_attr.3,v 1.3 2024/01/22 14:00:13 tb Exp $
.\"
.\" Copyright (c) 2024 Job Snijders <job@openbsd.org>
.\" Copyright (c) 2024 Theo Buehler <tb@openbsd.org>
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: January 22 2024 $
.Dt CMS_SIGNED_ADD1_ATTR 3
.Os
.Sh NAME
.Nm CMS_signed_add1_attr ,
.Nm CMS_signed_add1_attr_by_NID ,
.Nm CMS_signed_add1_attr_by_OBJ ,
.Nm CMS_signed_add1_attr_by_txt ,
.Nm CMS_signed_delete_attr ,
.Nm CMS_signed_get0_data_by_OBJ ,
.Nm CMS_signed_get_attr ,
.Nm CMS_signed_get_attr_by_NID ,
.Nm CMS_signed_get_attr_by_OBJ ,
.Nm CMS_signed_get_attr_count ,
.Nm CMS_unsigned_add1_attr ,
.Nm CMS_unsigned_add1_attr_by_NID ,
.Nm CMS_unsigned_add1_attr_by_OBJ ,
.Nm CMS_unsigned_add1_attr_by_txt ,
.Nm CMS_unsigned_delete_attr ,
.Nm CMS_unsigned_get0_data_by_OBJ ,
.Nm CMS_unsigned_get_attr ,
.Nm CMS_unsigned_get_attr_by_NID ,
.Nm CMS_unsigned_get_attr_by_OBJ ,
.Nm CMS_unsigned_get_attr_count
.Nd change signed and unsigned attributes of a CMS SignerInfo object
.Sh SYNOPSIS
.In openssl/cms.h
.Ft int
.Fo CMS_signed_add1_attr
.Fa "CMS_SignerInfo *si"
.Fa "X509_ATTRIBUTE *attr"
.Fc
.Ft int
.Fo CMS_signed_add1_attr_by_NID
.Fa "CMS_SignerInfo *si"
.Fa "int nid"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft int
.Fo CMS_signed_add1_attr_by_OBJ
.Fa "CMS_SignerInfo *si"
.Fa "const ASN1_OBJECT *obj"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft int
.Fo CMS_signed_add1_attr_by_txt
.Fa "CMS_SignerInfo *si"
.Fa "const char *attrname"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft "X509_ATTRIBUTE *"
.Fo CMS_signed_delete_attr
.Fa "CMS_SignerInfo *si"
.Fa "int loc"
.Fc
.Ft "void *"
.Fo CMS_signed_get0_data_by_OBJ
.Fa "CMS_SignerInfo *si"
.Fa "const ASN1_OBJECT *oid"
.Fa "int lastpos"
.Fa "int type"
.Fc
.Ft "X509_ATTRIBUTE *"
.Fo CMS_signed_get_attr
.Fa "const CMS_SignerInfo *si"
.Fa "int loc"
.Fc
.Ft int
.Fo CMS_signed_get_attr_by_NID
.Fa "const CMS_SignerInfo *si"
.Fa "int nid"
.Fa "int lastpos"
.Fc
.Ft int
.Fo CMS_signed_get_attr_by_OBJ
.Fa "const CMS_SignerInfo *si"
.Fa "const ASN1_OBJECT *obj"
.Fa "int lastpos"
.Fc
.Ft int
.Fo CMS_signed_get_attr_count
.Fa "const CMS_SignerInfo *si"
.Fc
.Ft int
.Fo CMS_unsigned_add1_attr
.Fa "CMS_SignerInfo *si"
.Fa "X509_ATTRIBUTE *attr"
.Fc
.Ft int
.Fo CMS_unsigned_add1_attr_by_NID
.Fa "CMS_SignerInfo *si"
.Fa "int nid"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft int
.Fo CMS_unsigned_add1_attr_by_OBJ
.Fa "CMS_SignerInfo *si"
.Fa "const ASN1_OBJECT *obj"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft int
.Fo CMS_unsigned_add1_attr_by_txt
.Fa "CMS_SignerInfo *si"
.Fa "const char *attrname"
.Fa "int type"
.Fa "const void *bytes"
.Fa "int len"
.Fc
.Ft "X509_ATTRIBUTE *"
.Fo CMS_unsigned_delete_attr
.Fa "CMS_SignerInfo *si"
.Fa "int loc"
.Fc
.Ft "void *"
.Fo CMS_unsigned_get0_data_by_OBJ
.Fa "CMS_SignerInfo *si"
.Fa "ASN1_OBJECT *oid"
.Fa "int lastpos"
.Fa "int type"
.Fc
.Ft "X509_ATTRIBUTE *"
.Fo CMS_unsigned_get_attr
.Fa "const CMS_SignerInfo *si"
.Fa "int loc"
.Fc
.Ft int
.Fo CMS_unsigned_get_attr_by_NID
.Fa "const CMS_SignerInfo *si"
.Fa "int nid"
.Fa "int lastpos"
.Fc
.Ft int
.Fo CMS_unsigned_get_attr_by_OBJ
.Fa "const CMS_SignerInfo *si"
.Fa "const ASN1_OBJECT *obj"
.Fa "int lastpos"
.Fc
.Ft int
.Fo CMS_unsigned_get_attr_count
.Fa "const CMS_SignerInfo *si"
.Fc
.Sh DESCRIPTION
A
.Em CMS_SignerInfo
object has two optional sets of X.501 attributes:
a set of signed attributes in the
.Fa signedAttrs
array and a set of unsigned attributes in the
.Fa unsignedAttrs
array.
The functions in this manual are wrappers of the
.Fn X509at_*
functions.
All arguments except
.Fa si
are passed to
.Fn X509at_* .
The
.Fn CMS_signed_*
and
.Fn CMS_unsigned_*
functions are similar, except
.Fn CMS_signed_*
calls
.Fn X509at_*
with the
.Em CMS_SignerInfo
object's set of signed attributes and
.Fn CMS_unsigned_*
calls
.Fn X509at_*
with the
.Em CMS_SignerInfo
object's set of unsigned attributes.
For brevity only the
.Fn CMS_signed_*
functions are described below.
.Pp
.Fn CMS_signed_add1_attr
appends a deep copy of
.Fa attr
to the
.Fa signedAttrs
array of
.Fa si ,
allocating a new array if necessary.
.Pp
.Fn CMS_signed_add1_attr_by_NID ,
.Fn CMS_signed_add1_attr_by_OBJ ,
and
.Fn CMS_signed_add1_attr_by_txt
create a new X.501 Attribute object using
.Xr X509at_add1_attr_by_NID 3 ,
.Xr X509at_add1_attr_by_OBJ 3 ,
and
.Xr X509at_add1_attr_by_txt 3 ,
and append it to the
.Fa signedAttrs
array of
.Fa si .
.Pp
.Fn CMS_signed_delete_attr
deletes the element with the zero-based
.Fa loc
in
.Fa signedAttrs
of
.Fa si .
.Pp
.Fn CMS_signed_get0_data_by_OBJ ,
.Fn CMS_signed_get_attr_by_NID ,
and
.Fn CMS_signed_get_attr_by_OBJ
search the array starting after the index
.Fa lastpos .
They fail if no matching object is found.
.Fn CMS_signed_get0_data_by_OBJ
also fails if the data is not of the requested
.Fa type .
.Pp
Additionally, the
.Fa lastpos
argument of
.Fn CMS_signed_get0_data_by_OBJ
is interpreted in a special way.
If
.Fa lastpos
is \-2 or smaller, the function also fails if the
.Fa signedAttrs
array of
.Fa si ,
contains more than one matching object.
If
.Fa lastpos
is \-3 or smaller, it also fails unless the matching object contains exactly
one value.
.Pp
.Fn CMS_signed_get_attr
returns the array element at the zero-based
.Fa loc .
It fails if the
.Fa loc
argument is negative or greater than or equal to the number of objects in the
array.
.Pp
.Fn CMS_signed_get_attr_count
returns the number of objects currently stored in the
.Fa signedAttrs
array of
.Fa si .
.Sh RETURN VALUES
.Fn CMS_signed_add1_attr ,
.Fn CMS_signed_add1_attr_by_NID ,
.Fn CMS_signed_add1_attr_by_OBJ ,
.Fn CMS_signed_add1_attr_by_txt ,
.Fn CMS_unsigned_add1_attr ,
.Fn CMS_unsigned_add1_attr_by_NID ,
.Fn CMS_unsigned_add1_attr_by_OBJ ,
and
.Fn CMS_unsigned_add1_attr_by_txt
return 1 for success or 0 if an error occurs.
.Pp
.Fn CMS_signed_delete_attr
returns the deleted element or
.Dv NULL
if the
.Fa signedAttrs
array is
.Dv NULL ,
or if the requested
.Fa loc
argument is negative, or greater than or equal to the number of objects in it.
.Pp
.Fn CMS_unsigned_delete_attr
returns the deleted element or
.Dv NULL
if the
.Fa unsignedAttrs
array is
.Dv NULL ,
or if the requested
.Fa loc
argument is negative, or greater than or equal to the number of objects in it.
.Pp
.Fn CMS_signed_get0_data_by_OBJ
and
.Fn CMS_unsigned_get0_data_by_OBJ
return an internal pointer to the data contained in the value of the first
object that has an index greater than
.Fa lastpos
and a type matching
.Fa type ,
or NULL on failure.
.Pp
.Fn CMS_signed_get_attr
and
.Fn CMS_unsigned_get_attr
return an internal pointer or NULL on failure.
.Pp
.Fn CMS_signed_get_attr_by_NID ,
.Fn CMS_signed_get_attr_by_OBJ ,
.Fn CMS_unsigned_get_attr_by_NID ,
and
.Fn CMS_unsigned_get_attr_by_OBJ
return the index of the first object in the array that has an index greater than
.Fa lastpos
and a type matching
.Fa nid
or
.Fa oid ,
respectively, or \-1 on failure.
In addition,
.Fn CMS_signed_get_attr_by_OBJ
and
.Fn CMS_unsigned_get_attr_by_OBJ
return \-2 if
.Xr OBJ_nid2obj 3
fails on the requested
.Fa nid .
.Pp
.Fn CMS_signed_get_attr_count
and
.Fn CMS_unsigned_get_attr_count
return the number of array elements or \-1 on failure.
.Sh SEE ALSO
.Xr CMS_add1_signer 3 ,
.Xr CMS_ContentInfo_new 3 ,
.Xr CMS_get0_SignerInfos 3 ,
.Xr OBJ_nid2obj 3 ,
.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
.Xr X509_ATTRIBUTE_new 3 ,
.Xr X509at_add1_attr 3
.Sh STANDARDS
RFC 5652: Cryptographic Message Syntax (CMS)
.Bl -dash -compact -offset indent
.It
section 5.3: SignerInfo Type
.It
section 11: Useful Attributes
.El
.Sh HISTORY
These functions first appeared in OpenSSL 0.9.9 and have been available since
.Ox 6.6 .

View file

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.280 2023/12/29 19:15:15 tb Exp $
# $OpenBSD: Makefile,v 1.281 2024/01/22 13:44:59 job Exp $
.include <bsd.own.mk>
@ -100,6 +100,7 @@ MAN= \
CMS_get1_ReceiptRequest.3 \
CMS_sign.3 \
CMS_sign_receipt.3 \
CMS_signed_add1_attr.3 \
CMS_uncompress.3 \
CMS_verify.3 \
CMS_verify_receipt.3 \