From owner-svn-src-head@freebsd.org Tue Apr 7 16:40:42 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D6ECF274A50; Tue, 7 Apr 2020 16:40:42 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48xY7G5Nnqz3Px6; Tue, 7 Apr 2020 16:40:42 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4327CBE0; Tue, 7 Apr 2020 16:40:42 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 037Gegaq048349; Tue, 7 Apr 2020 16:40:42 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 037GeftS048343; Tue, 7 Apr 2020 16:40:41 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202004071640.037GeftS048343@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 7 Apr 2020 16:40:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r359696 - in head/lib/libcasper/services: cap_dns cap_fileargs cap_grp cap_pwd cap_sysctl cap_syslog X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/lib/libcasper/services: cap_dns cap_fileargs cap_grp cap_pwd cap_sysctl cap_syslog X-SVN-Commit-Revision: 359696 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2020 16:40:42 -0000 Author: cem Date: Tue Apr 7 16:40:41 2020 New Revision: 359696 URL: https://svnweb.freebsd.org/changeset/base/359696 Log: libcasper(3): Export functions to C++ We must wrap C declarations in __BEGIN / __END_DECLS to avoid C++ name-mangling of the declaration when including the C header; name-mangling causes the linker to attempt to locate the wrong (C++ ABI) symbol name. Reviewed by: markj, oshogbo (earlier version both) Differential Revision: https://reviews.freebsd.org/D24323 Modified: head/lib/libcasper/services/cap_dns/cap_dns.h head/lib/libcasper/services/cap_fileargs/cap_fileargs.h head/lib/libcasper/services/cap_grp/cap_grp.h head/lib/libcasper/services/cap_pwd/cap_pwd.h head/lib/libcasper/services/cap_sysctl/cap_sysctl.h head/lib/libcasper/services/cap_syslog/cap_syslog.h Modified: head/lib/libcasper/services/cap_dns/cap_dns.h ============================================================================== --- head/lib/libcasper/services/cap_dns/cap_dns.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_dns/cap_dns.h Tue Apr 7 16:40:41 2020 (r359696) @@ -36,12 +36,15 @@ #define WITH_CASPER #endif +#include #include /* socklen_t */ struct addrinfo; struct hostent; #ifdef WITH_CASPER +__BEGIN_DECLS + struct hostent *cap_gethostbyname(cap_channel_t *chan, const char *name); struct hostent *cap_gethostbyname2(cap_channel_t *chan, const char *name, int type); @@ -58,6 +61,8 @@ int cap_dns_type_limit(cap_channel_t *chan, const char size_t ntypes); int cap_dns_family_limit(cap_channel_t *chan, const int *families, size_t nfamilies); + +__END_DECLS #else #define cap_gethostbyname(chan, name) gethostbyname(name) #define cap_gethostbyname2(chan, name, type) gethostbyname2(name, type) Modified: head/lib/libcasper/services/cap_fileargs/cap_fileargs.h ============================================================================== --- head/lib/libcasper/services/cap_fileargs/cap_fileargs.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_fileargs/cap_fileargs.h Tue Apr 7 16:40:41 2020 (r359696) @@ -31,6 +31,7 @@ #ifndef _FILEARGS_H_ #define _FILEARGS_H_ +#include #include #include @@ -44,6 +45,8 @@ struct fileargs; typedef struct fileargs fileargs_t; struct stat; +__BEGIN_DECLS + fileargs_t *fileargs_init(int argc, char *argv[], int flags, mode_t mode, cap_rights_t *rightsp, int operations); fileargs_t *fileargs_cinit(cap_channel_t *cas, int argc, char *argv[], @@ -57,6 +60,9 @@ FILE *fileargs_fopen(fileargs_t *fa, const char *name, fileargs_t *fileargs_wrap(cap_channel_t *chan, int fdflags); cap_channel_t *fileargs_unwrap(fileargs_t *fa, int *fdflags); + +__END_DECLS + #else typedef struct fileargs { int fa_flags; Modified: head/lib/libcasper/services/cap_grp/cap_grp.h ============================================================================== --- head/lib/libcasper/services/cap_grp/cap_grp.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_grp/cap_grp.h Tue Apr 7 16:40:41 2020 (r359696) @@ -36,7 +36,11 @@ #define WITH_CASPER #endif +#include + #ifdef WITH_CASPER +__BEGIN_DECLS + struct group *cap_getgrent(cap_channel_t *chan); struct group *cap_getgrnam(cap_channel_t *chan, const char *name); struct group *cap_getgrgid(cap_channel_t *chan, gid_t gid); @@ -58,6 +62,9 @@ int cap_grp_limit_fields(cap_channel_t *chan, const ch size_t nfields); int cap_grp_limit_groups(cap_channel_t *chan, const char * const *names, size_t nnames, const gid_t *gids, size_t ngids); + +__END_DECLS + #else #define cap_getgrent(chan) getgrent() #define cap_getgrnam(chan, name) getgrnam(name) Modified: head/lib/libcasper/services/cap_pwd/cap_pwd.h ============================================================================== --- head/lib/libcasper/services/cap_pwd/cap_pwd.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_pwd/cap_pwd.h Tue Apr 7 16:40:41 2020 (r359696) @@ -36,7 +36,11 @@ #define WITH_CASPER #endif +#include + #ifdef WITH_CASPER +__BEGIN_DECLS + struct passwd *cap_getpwent(cap_channel_t *chan); struct passwd *cap_getpwnam(cap_channel_t *chan, const char *login); struct passwd *cap_getpwuid(cap_channel_t *chan, uid_t uid); @@ -58,6 +62,9 @@ int cap_pwd_limit_fields(cap_channel_t *chan, const ch size_t nfields); int cap_pwd_limit_users(cap_channel_t *chan, const char * const *names, size_t nnames, uid_t *uids, size_t nuids); + +__END_DECLS + #else #define cap_getpwent(chan) getpwent() #define cap_getpwnam(chan, login) getpwnam(login) Modified: head/lib/libcasper/services/cap_sysctl/cap_sysctl.h ============================================================================== --- head/lib/libcasper/services/cap_sysctl/cap_sysctl.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_sysctl/cap_sysctl.h Tue Apr 7 16:40:41 2020 (r359696) @@ -36,12 +36,16 @@ #define WITH_CASPER #endif +#include + #ifdef WITH_CASPER #define CAP_SYSCTL_READ 0x01 #define CAP_SYSCTL_WRITE 0x02 #define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE) #define CAP_SYSCTL_RECURSIVE 0x04 +__BEGIN_DECLS + int cap_sysctl(cap_channel_t *chan, const int *name, u_int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp, @@ -58,6 +62,9 @@ cap_sysctl_limit_t *cap_sysctl_limit_name(cap_sysctl_l cap_sysctl_limit_t *cap_sysctl_limit_mib(cap_sysctl_limit_t *limit, const int *mibp, u_int miblen, int flags); int cap_sysctl_limit(cap_sysctl_limit_t *limit); + +__END_DECLS + #else /* !WITH_CASPER */ #define cap_sysctl(chan, name, namelen, oldp, oldlenp, newp, newlen) \ sysctl((name), (namelen), (oldp), (oldlenp), (newp), (newlen)) Modified: head/lib/libcasper/services/cap_syslog/cap_syslog.h ============================================================================== --- head/lib/libcasper/services/cap_syslog/cap_syslog.h Tue Apr 7 16:29:11 2020 (r359695) +++ head/lib/libcasper/services/cap_syslog/cap_syslog.h Tue Apr 7 16:40:41 2020 (r359696) @@ -29,7 +29,11 @@ #ifndef _CAP_SYSLOG_H_ #define _CAP_SYSLOG_H_ +#include + #ifdef WITH_CASPER +__BEGIN_DECLS + void cap_syslog(cap_channel_t *chan, int pri, const char *fmt, ...) __printflike(3, 4); void cap_vsyslog(cap_channel_t *chan, int priority, const char *fmt, @@ -40,6 +44,9 @@ void cap_openlog(cap_channel_t *chan, const char *iden void cap_closelog(cap_channel_t *chan); int cap_setlogmask(cap_channel_t *chan, int maskpri); + +__END_DECLS + #else #define cap_syslog(chan, pri, ...) syslog(pri, __VA_ARGS__) #define cap_vsyslog(chan, pri, fmt, ap) vsyslog(pri, fmt, ap)