diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..009cc5c
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "plasma"]
+ path = plasma
+ url = https://github.com/gstrauss/plasma.git
diff --git a/CREDITS b/CREDITS
new file mode 100644
index 0000000..b6bf322
--- /dev/null
+++ b/CREDITS
@@ -0,0 +1,20 @@
+plasma/ git submodule: https://github.com/gstrauss/plasma.git
+(see plasma/CREDITS for additional credits)
+
+/* Copyright (c) 2013, Glue Logic LLC. All rights reserved. code()gluelogic.com
+ *
+ * This file is part of plasma.
+ *
+ * plasma is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * plasma is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with plasma. If not, see .
+ */
diff --git a/bsock/Makefile b/bsock/Makefile
index 00351f8..9cc9747 100644
--- a/bsock/Makefile
+++ b/bsock/Makefile
@@ -80,7 +80,7 @@ $(bsock_sobjs): CFLAGS+=-fpic
bsock_preload.o: CFLAGS+=-fpic
PTHREAD_FLAGS?=-pthread -D_THREAD_SAFE
-%.o: CFLAGS+=-std=c99 -D_XOPEN_SOURCE=600 $(PTHREAD_FLAGS) -DNDEBUG -I.
+%.o: CFLAGS+=-std=c99 -D_XOPEN_SOURCE=600 $(PTHREAD_FLAGS) -DNDEBUG -I. -I..
%.o: %.c
$(CC) -o $@ $(CFLAGS) -c $<
@@ -135,7 +135,7 @@ bsock.t: bsock.t.o libbsock.so
$(CC) -o $@ $(RPATH) $(LDFLAGS) $^
# (Note: not currently installing libbsock.so with any version suffix)
-.PHONY: install install-suid install-headers install-doc
+.PHONY: install install-suid install-headers install-headers-plasma install-doc
BSOCK_MODE=0550
install-suid: BSOCK_MODE=4550
install-suid: install ;
@@ -150,9 +150,14 @@ install: bsock libbsock.so libbsock_preload.so
(/bin/touch $(BSOCK_CONFIG) && \
/bin/chmod 0644 $(BSOCK_CONFIG))
install-headers: bsock_addrinfo.h bsock_bind.h bsock_unix.h \
- bsock_daemon.h bsock_syslog.h
+ bsock_daemon.h bsock_syslog.h | install-headers-plasma
/bin/mkdir -p -m 0755 $(PREFIX)/include/bsock
/usr/bin/install -m 0444 -p $^ $(PREFIX)/include/bsock/
+install-headers-plasma: ../plasma/plasma_attr.h \
+ ../plasma/plasma_feature.h \
+ ../plasma/plasma_stdtypes.h
+ /bin/mkdir -p -m 0755 $(PREFIX)/include/bsock/plasma
+ /usr/bin/install -m 0444 -p $^ $(PREFIX)/include/bsock/plasma/
install-doc: CHANGELOG COPYING FAQ INSTALL NOTES README
/bin/mkdir -p -m 0755 $(BSOCK_DOC_DIR)
/usr/bin/install -m 0444 -p $^ $(BSOCK_DOC_DIR)
@@ -173,3 +178,6 @@ bsock_daemon.o: bsock_daemon.h bsock_syslog.h bsock_unix.h
bsock_resvaddr.o: bsock_addrinfo.h bsock_resvaddr.h bsock_syslog.h
bsock_unix.o: bsock_unix.h
bsock_syslog.o: bsock_syslog.h
+%.o: ../plasma/plasma_attr.h \
+ ../plasma/plasma_feature.h \
+ ../plasma/plasma_stdtypes.h
diff --git a/bsock/bsock.m.c b/bsock/bsock.m.c
index e1147a2..ed5bab5 100644
--- a/bsock/bsock.m.c
+++ b/bsock/bsock.m.c
@@ -26,6 +26,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include
+#include
+
#include
#include
#include
@@ -37,7 +40,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -112,19 +114,21 @@
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
-static int __attribute__((noinline))
+__attribute_noinline__
+static int
retry_poll_fd (const int fd, const short events, const int timeout)
{
struct pollfd pfd = { .fd = fd, .events = events, .revents = 0 };
int n; /*EINTR results in retrying poll with same timeout again and again*/
- do { n = poll(&pfd, 1, timeout); } while (-1 == n && errno == EINTR);
+ retry_eintr_do_while(n = poll(&pfd, 1, timeout), -1 == n);
if (0 == n) errno = ETIME; /* specific for bsock; not generic */
return n;
}
-static void __attribute__((nonnull))
+__attribute_nonnull__
+static void
bsock_cleanup_close (void * const arg)
{
const int fd = *(int *)arg;
@@ -158,7 +162,8 @@ bsock_thread_table_init (void)
bsock_thread_elts[BSOCK_THREAD_MAX-1].next = NULL;
}
-static struct bsock_client_st * __attribute__((nonnull))
+__attribute_nonnull__
+static struct bsock_client_st *
bsock_thread_table_query (const struct bsock_client_st * const c)
{
const uid_t uid = c->uid;
@@ -169,7 +174,8 @@ bsock_thread_table_query (const struct bsock_client_st * const c)
return t;
}
-static struct bsock_client_st * __attribute__((nonnull))
+__attribute_nonnull__
+static struct bsock_client_st *
bsock_thread_table_add (struct bsock_client_st * const c)
{
/* (not checking for multiple-add of same uid (do not do that)) */
@@ -184,7 +190,8 @@ bsock_thread_table_add (struct bsock_client_st * const c)
return (*next = t);
}
-static void __attribute__((nonnull))
+__attribute_nonnull__
+static void
bsock_thread_table_remove (struct bsock_client_st * const c)
{
/* (removes only first uid found if multiple (should not happen)) */
@@ -203,7 +210,8 @@ bsock_thread_table_remove (struct bsock_client_st * const c)
}
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bsock_client_handler (struct bsock_client_st * const restrict c,
struct addrinfo * const restrict ai,
int * const restrict fd)
@@ -309,7 +317,8 @@ uint32_to_str(uint32_t u, char * const buf)
return (int)(out - buf);
}
-static void __attribute__((noinline))
+__attribute_noinline__
+static void
bsock_infostr (char * restrict infobuf,
const int fd, const uid_t uid, const gid_t gid)
{
@@ -339,7 +348,8 @@ bsock_infostr (char * restrict infobuf,
infobuf[0] = '\0';
}
-static void __attribute__((nonnull))
+__attribute_nonnull__
+static void
bsock_cleanup_client (void * const arg)
{
struct bsock_client_st * const c = (struct bsock_client_st *)arg;
@@ -352,7 +362,8 @@ bsock_cleanup_client (void * const arg)
}
}
-static void * __attribute__((nonnull))
+__attribute_nonnull__
+static void *
bsock_client_thread (void * const arg)
{
struct bsock_client_st c; /* copy so that not referencing hash entry */
@@ -405,7 +416,9 @@ bsock_client_thread (void * const arg)
return NULL; /* end of thread; identical to pthread_exit() */
}
-static void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+static void
bsock_sigaction_sighup (void)
{
/* efficiency: keep databases open (advantageous for nss_mcdb module) */
@@ -423,7 +436,8 @@ bsock_sigaction_sighup (void)
endservent();
}
-static void __attribute__((nonnull))
+__attribute_nonnull__
+static void
bsock_sigaction (sigset_t * const restrict sigs, const int signo)
{
switch (signo) {
@@ -441,7 +455,9 @@ bsock_sigaction (sigset_t * const restrict sigs, const int signo)
}
}
-static void __attribute__((nonnull)) __attribute__((noreturn))
+__attribute_nonnull__
+__attribute_noreturn__
+static void
bsock_sigwait (void * const arg)
{
sigset_t * const sigs = (sigset_t *)arg;
@@ -473,7 +489,9 @@ bsock_thread_signals (void)
bsock_syslog(errnum, LOG_ERR, "pthread_create");
}
-static void __attribute__((noinline)) __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+static void
bsock_client_send_errno (const int fd, int errnum)
{
/* one-shot response; send buffer should be empty and should not block */
@@ -553,8 +571,10 @@ bsock_thread_event_loop (const int sfd, pthread_attr_t * const restrict attr)
}
/* one-shot mode; handle single request and exit */
+__attribute_cold__
+__attribute_noinline__
+__attribute_nonnull__
static int
- __attribute__((nonnull)) __attribute__((noinline)) __attribute_cold__
bsock_client_once (const int argc, char ** const restrict argv)
{
struct bsock_client_st m;
@@ -646,7 +666,8 @@ bsock_client_once (const int argc, char ** const restrict argv)
return rc;
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
main (int argc, char *argv[])
{
int sfd, opt, daemon = false, supervised = false;
diff --git a/bsock/bsock.t.c b/bsock/bsock.t.c
index e240843..ffe8084 100644
--- a/bsock/bsock.t.c
+++ b/bsock/bsock.t.c
@@ -26,6 +26,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include
+
#include
#include
#include
@@ -35,7 +37,8 @@
#include
#include
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
main (int argc, char *argv[])
{
int nfd;
diff --git a/bsock/bsock_addrinfo.c b/bsock/bsock_addrinfo.c
index b137cde..e3c3f9f 100644
--- a/bsock/bsock_addrinfo.c
+++ b/bsock/bsock_addrinfo.c
@@ -127,7 +127,8 @@ extern int getprotobynumber_r(int proto, struct protoent *protoptr,
* Similarly, simple string parsing routines like strtok() are used, even though
* less string traversals could be achieved through additional coding */
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bsock_addrinfo_family_from_str (const char * const restrict family)
{
/* list of protocol families below is not complete */
@@ -167,7 +168,8 @@ bsock_addrinfo_family_to_str (const int family)
}
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bsock_addrinfo_socktype_from_str (const char * const restrict socktype)
{
if ( 0 == memcmp_constr(socktype, "SOCK_STREAM"))
@@ -218,7 +220,8 @@ bsock_addrinfo_socktype_to_str (const int socktype)
}
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bsock_addrinfo_protocol_from_str (const char * const restrict protocol)
{
#ifdef _AIX
@@ -269,7 +272,8 @@ bsock_addrinfo_protocol_from_str (const char * const restrict protocol)
}
#ifdef HAVE_GETPROTOBYNUMBER_R
-static char * __attribute__((nonnull))
+__attribute_nonnull__
+static char *
bsock_addrinfo_protocol_to_str (const int proto,
char * const buf, const size_t bufsz)
{
@@ -304,7 +308,8 @@ bsock_addrinfo_protocol_to_str (const int proto)
bsock_addrinfo_protocol_to_str(proto)
#endif
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_from_strs(struct addrinfo * const restrict ai,
const struct bsock_addrinfo_strs *
const restrict aistr)
@@ -373,7 +378,8 @@ bsock_addrinfo_from_strs(struct addrinfo * const restrict ai,
}
}
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_to_strs(const struct addrinfo * const restrict ai,
struct bsock_addrinfo_strs * const aistr,
char * const restrict buf, const size_t bufsz)
@@ -415,7 +421,8 @@ bsock_addrinfo_to_strs(const struct addrinfo * const restrict ai,
return false;
}
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_split_str(struct bsock_addrinfo_strs * const aistr,
char * const restrict str)
{
@@ -428,7 +435,8 @@ bsock_addrinfo_split_str(struct bsock_addrinfo_strs * const aistr,
) || (errno = EINVAL, false);
}
-bool __attribute__((nonnull (2,3)))
+__attribute_nonnull_x__((2,3))
+bool
bsock_addrinfo_recv_ex (const int fd,
struct addrinfo * const restrict ai,
int * const restrict rfd,
@@ -499,7 +507,8 @@ bsock_addrinfo_recv_ex (const int fd,
}
#if 0 /* see #define bsock_addrinfo_recv(fd, ai, rfd) in bsock_addrinfo.h */
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_recv (const int fd,
struct addrinfo * const restrict ai,
int * const restrict rfd)
@@ -508,7 +517,8 @@ bsock_addrinfo_recv (const int fd,
}
#endif
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_send (const int fd,
const struct addrinfo * const restrict ai, const int sfd)
{
diff --git a/bsock/bsock_addrinfo.h b/bsock/bsock_addrinfo.h
index a92ffe5..0fb8ca8 100644
--- a/bsock/bsock_addrinfo.h
+++ b/bsock/bsock_addrinfo.h
@@ -29,10 +29,11 @@
#ifndef INCLUDED_BSOCK_ADDRINFO_H
#define INCLUDED_BSOCK_ADDRINFO_H
-#include
+#include "plasma/plasma_attr.h"
+#include "plasma/plasma_stdtypes.h"
+
#include
#include
-#include
#ifdef __cplusplus
extern "C" {
@@ -66,21 +67,25 @@ struct bsock_addrinfo_strs {
/* ai->ai_addr must be provided containing usable storage of len ai->ai_addrlen
* (recommended: #include and use struct sockaddr_storage) */
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_from_strs(struct addrinfo * const restrict ai,
const struct bsock_addrinfo_strs *
const restrict aistr);
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_to_strs(const struct addrinfo * const restrict ai,
struct bsock_addrinfo_strs * const aistr,
char * const restrict buf, const size_t bufsz);
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_split_str(struct bsock_addrinfo_strs * const aistr,
char * const restrict str);
-bool __attribute__((nonnull (2,3)))
+__attribute_nonnull_x__((2,3))
+bool
bsock_addrinfo_recv_ex (const int fd,
struct addrinfo * const restrict ai,
int * const restrict rfd,
@@ -90,7 +95,8 @@ bsock_addrinfo_recv_ex (const int fd,
#define bsock_addrinfo_recv(fd, ai, rfd) \
bsock_addrinfo_recv_ex((fd),(ai),(rfd),0,0)
-bool __attribute__((nonnull))
+__attribute_nonnull__
+bool
bsock_addrinfo_send (const int fd,
const struct addrinfo * const restrict ai, const int sfd);
diff --git a/bsock/bsock_authz.c b/bsock/bsock_authz.c
index ed9aee2..8919995 100644
--- a/bsock/bsock_authz.c
+++ b/bsock/bsock_authz.c
@@ -45,14 +45,14 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
#include
#include
+#include
+
#include
#include
@@ -60,22 +60,10 @@
#error "BSOCK_CONFIG must be defined"
#endif
-#ifndef __has_attribute
-#define __has_attribute(x) 0
-#endif
-#if (defined(__GNUC__) && __GNUC_PREREQ(4,3)) || __has_attribute(cold)
-#ifndef __attribute_cold__
-#define __attribute_cold__ __attribute__((cold))
-#endif
-#endif
-#ifndef __attribute_cold__
-#define __attribute_cold__
-#endif
-
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
struct bsock_authz_hash_st {
uid_t mask;
@@ -86,7 +74,8 @@ struct bsock_authz_hash_st {
static struct bsock_authz_hash_st * restrict bsock_authz_hash;
-static bool __attribute__((nonnull))
+__attribute_nonnull__
+static bool
bsock_authz_valid (const struct addrinfo * const restrict ai,
const uid_t uid, const gid_t gid)
{
@@ -107,7 +96,8 @@ bsock_authz_valid (const struct addrinfo * const restrict ai,
return ((errno = EACCES), false);
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_authz_validate (struct addrinfo * const restrict ai,
const uid_t uid, const gid_t gid)
{
@@ -143,7 +133,9 @@ bsock_authz_validate (struct addrinfo * const restrict ai,
return false;
}
-static int __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+static int
bsock_authz_config_parse (struct bsock_authz_hash_st* const restrict authz_hash,
char * const restrict buf)
{
@@ -210,7 +202,9 @@ bsock_authz_config_parse (struct bsock_authz_hash_st* const restrict authz_hash,
/* XXX: future
* bsock_resvaddr_config() and bsock_authz_config() should share parsing code */
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_authz_config (void)
{
char * restrict buf = NULL;
diff --git a/bsock/bsock_authz.h b/bsock/bsock_authz.h
index bdaa7f5..e771dda 100644
--- a/bsock/bsock_authz.h
+++ b/bsock/bsock_authz.h
@@ -29,6 +29,8 @@
#ifndef INCLUDED_BSOCK_AUTHZ_H
#define INCLUDED_BSOCK_AUTHZ_H
+#include "plasma/plasma_attr.h"
+
#include
#include
#include
@@ -41,7 +43,8 @@
extern "C" {
#endif
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_authz_validate (struct addrinfo * const restrict ai,
const uid_t uid, const gid_t gid);
diff --git a/bsock/bsock_bind.c b/bsock/bsock_bind.c
index 73238bb..1e7ab93 100644
--- a/bsock/bsock_bind.c
+++ b/bsock/bsock_bind.c
@@ -37,13 +37,13 @@
#include
#include
#include
-#include
-#include
#include
#include
extern char **environ;
+#include
+
#include
#include
@@ -69,19 +69,21 @@ extern char **environ;
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
-static int __attribute__((noinline)) /*(most client time is spent waiting)*/
+__attribute_noinline__ /*(most client time is spent waiting)*/
+static int
retry_poll_fd (const int fd, const short events, const int timeout)
{
struct pollfd pfd = { .fd = fd, .events = events, .revents = 0 };
int n; /*EINTR results in retrying poll with same timeout again and again*/
- do { n = poll(&pfd, 1, timeout); } while (-1 == n && errno == EINTR);
+ retry_eintr_do_while(n = poll(&pfd, 1, timeout), -1 == n);
if (0 == n) errno = ETIME; /* specific for bsock; not generic */
return n;
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bsock_bind_send_addr_and_recv (const int fd,
const struct addrinfo * const restrict ai,
const int sfd)
@@ -124,7 +126,8 @@ bsock_bind_send_addr_and_recv (const int fd,
return errnum;
}
-static bool __attribute__((nonnull))
+__attribute_nonnull__
+static bool
bsock_bind_viafork (const int fd, const struct addrinfo * const restrict ai)
{
/* (ai->ai_next is ignored) */
@@ -156,7 +159,7 @@ bsock_bind_viafork (const int fd, const struct addrinfo * const restrict ai)
else if (-1 != pid) { /* parent */
nointr_close(sv[0]);
errnum = bsock_bind_send_addr_and_recv(fd, ai, sv[1]);
- while (pid != waitpid(pid,NULL,0) && errno == EINTR) ;
+ retry_eintr_while(pid != waitpid(pid,NULL,0));
/* reap child process but ignore exit status; program might be ignoring
* SIGCHLD or might have custom SIGCHLD handler, either of which would
* prevent waitpid() above from reliably obtaining child status */
@@ -171,7 +174,8 @@ bsock_bind_viafork (const int fd, const struct addrinfo * const restrict ai)
return (0 == errnum);
}
-static bool __attribute__((nonnull))
+__attribute_nonnull__
+static bool
bsock_bind_viasock (const int fd, const struct addrinfo * const restrict ai)
{
int errnum;
@@ -196,7 +200,8 @@ bsock_bind_viasock (const int fd, const struct addrinfo * const restrict ai)
return (0 == errnum);
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_bind_addrinfo (const int fd, const struct addrinfo * const restrict ai)
{
/* (return value 0 for success, -1 upon error; match return value of bind())
diff --git a/bsock/bsock_bind.h b/bsock/bsock_bind.h
index e6ba36b..aeec311 100644
--- a/bsock/bsock_bind.h
+++ b/bsock/bsock_bind.h
@@ -29,6 +29,8 @@
#ifndef INCLUDED_BSOCK_BIND_H
#define INCLUDED_BSOCK_BIND_H
+#include "plasma/plasma_attr.h"
+
#include
#include
#include
@@ -41,7 +43,8 @@
extern "C" {
#endif
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_bind_addrinfo (const int fd, const struct addrinfo * const restrict ai);
#ifdef __cplusplus
diff --git a/bsock/bsock_bindresvport.c b/bsock/bsock_bindresvport.c
index 705325d..448e49e 100644
--- a/bsock/bsock_bindresvport.c
+++ b/bsock/bsock_bindresvport.c
@@ -138,7 +138,7 @@ bsock_bindresvport_random_port (void)
int r;
if (-1 == fd || read(fd, &r, sizeof(int)) != sizeof(int)) {
if (-1 != fd)
- while (0 != close(fd) && errno == EINTR) ;
+ retry_eintr_while(0 != close(fd));
fd = open("/dev/urandom", O_RDONLY|O_NONBLOCK);
if (-1 == fd || read(fd, &r, sizeof(int)) != sizeof(int))
r = -1;
@@ -150,7 +150,8 @@ bsock_bindresvport_random_port (void)
return(IPPORT_RESERVEDSTART + (r % (IPPORT_RESERVED-IPPORT_RESERVEDSTART)));
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_bindresvport_sa (const int sockfd, struct sockaddr *sa)
{
/* (code below honors sin_addr or sin6_addr, if specified) */
diff --git a/bsock/bsock_bindresvport.h b/bsock/bsock_bindresvport.h
index 3853d2e..10e0170 100644
--- a/bsock/bsock_bindresvport.h
+++ b/bsock/bsock_bindresvport.h
@@ -29,6 +29,8 @@
#ifndef INCLUDED_BSOCK_BINDRESVPORT_H
#define INCLUDED_BSOCK_BINDRESVPORT_H
+#include "plasma/plasma_attr.h"
+
#include
#include
@@ -36,7 +38,8 @@
extern "C" {
#endif
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_bindresvport_sa (const int sockfd, struct sockaddr *sa);
#ifdef __cplusplus
diff --git a/bsock/bsock_daemon.c b/bsock/bsock_daemon.c
index 1e71c7c..b6b2ae5 100644
--- a/bsock/bsock_daemon.c
+++ b/bsock/bsock_daemon.c
@@ -34,7 +34,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -42,13 +41,15 @@
extern char **environ; /* avoid #define _GNU_SOURCE for visibility of environ */
+#include
+
#include
#include
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
bool
bsock_daemon_setuid_stdinit (void)
@@ -75,13 +76,14 @@ bsock_daemon_setuid_stdinit (void)
}
static void
-bsock_daemon_sa_ignore (int signum __attribute__((unused)))
+bsock_daemon_sa_ignore (int signum __attribute_unused__)
{ /*(handler gets reset to SIG_DFL by execve(); SIG_IGN would be inherited)*/
/* ignore signal */
}
-static void __attribute__((noreturn))
-bsock_daemon_sa_handler (int signum __attribute__((unused)))
+__attribute_noreturn__
+static void
+bsock_daemon_sa_handler (int signum __attribute_unused__)
{
exit(EXIT_SUCCESS); /* executes atexit() handlers */
}
@@ -228,7 +230,8 @@ bsock_daemon_atexit (void)
(void)unlink(bsock_daemon_socket_path);
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_daemon_init_socket (const char * const restrict sockpath,
const uid_t uid, const gid_t gid, const mode_t mode)
{
diff --git a/bsock/bsock_daemon.h b/bsock/bsock_daemon.h
index 59cf3e4..d685de3 100644
--- a/bsock/bsock_daemon.h
+++ b/bsock/bsock_daemon.h
@@ -29,8 +29,8 @@
#ifndef INCLUDED_BSOCK_DAEMON_H
#define INCLUDED_BSOCK_DAEMON_H
-#include
-#include
+#include "plasma/plasma_attr.h"
+#include "plasma/plasma_stdtypes.h"
#ifdef __cplusplus
extern "C" {
@@ -42,7 +42,8 @@ bsock_daemon_setuid_stdinit (void);
bool
bsock_daemon_init (const int supervised, const bool check);
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_daemon_init_socket (const char * const restrict sockpath, /*(persistent)*/
const uid_t uid, const gid_t gid,
const mode_t mode);
diff --git a/bsock/bsock_preload.c b/bsock/bsock_preload.c
index 5794a14..206bdcb 100644
--- a/bsock/bsock_preload.c
+++ b/bsock/bsock_preload.c
@@ -26,6 +26,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include
+
#include
#include
#include
@@ -41,7 +43,8 @@ int bindresvport (const int, struct sockaddr_in * restrict);
int bindresvport6 (const int, struct sockaddr_in6 * restrict);
static int (*bind_rtld_next)(int, const struct sockaddr *, socklen_t);
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
bind_rtld_findnext (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
bind_rtld_next = (int(*)(int,const struct sockaddr *,socklen_t))(uintptr_t)
@@ -53,7 +56,9 @@ bind_rtld_findnext (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
static int (*bind_rtld_next)(int, const struct sockaddr *, socklen_t) =
bind_rtld_findnext;
-static int __attribute__((nonnull)) __attribute__((noinline))
+__attribute_noinline__
+__attribute_nonnull__
+static int
bsock_preload_bind (const int sockfd, const struct sockaddr *addr,
const socklen_t addrlen)
{
diff --git a/bsock/bsock_resvaddr.c b/bsock/bsock_resvaddr.c
index ae561e7..651f6e9 100644
--- a/bsock/bsock_resvaddr.c
+++ b/bsock/bsock_resvaddr.c
@@ -36,14 +36,14 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
#include
#include
+#include
+
#include
#include
@@ -55,22 +55,13 @@
#define BSOCK_RESVADDR_CONFIG BSOCK_CONFIG".resvaddr"
#endif
-#ifndef __has_attribute
-#define __has_attribute(x) 0
-#endif
-#if (defined(__GNUC__) && __GNUC_PREREQ(4,3)) || __has_attribute(cold)
-#ifndef __attribute_cold__
-#define __attribute_cold__ __attribute__((cold))
-#endif
-#endif
-#ifndef __attribute_cold__
-#define __attribute_cold__
-#endif
-
+/* GPS: should this be noinline elsewhere, too? or document how used in this
+ * file as on less-used code paths; maybe mark this cold, too */
/* nointr_close() - make effort to avoid leaking open file descriptors */
-static int __attribute__((noinline))
+__attribute_noinline__
+static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
struct bsock_resvaddr {
struct bsock_resvaddr *next;
@@ -106,7 +97,8 @@ bsock_resvaddr_count (void)
#define __builtin_expect(x,y) (x)
#endif
#endif
-static uint32_t __attribute__((nonnull))
+__attribute_nonnull__
+static uint32_t
bsock_resvaddr_hash (const struct addrinfo * const restrict ai)
{
const unsigned char * restrict addr = (const unsigned char *)ai->ai_addr;
@@ -117,7 +109,9 @@ bsock_resvaddr_hash (const struct addrinfo * const restrict ai)
return h;
}
-static int __attribute__((nonnull)) __attribute__((noinline))
+__attribute_noinline__
+__attribute_nonnull__
+static int
bsock_resvaddr_rebind (const struct addrinfo * restrict ai,
int * const restrict tfd)
{
@@ -165,7 +159,8 @@ bsock_resvaddr_rebind (const struct addrinfo * restrict ai,
return *tfd;
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_resvaddr_fd (const struct addrinfo * const restrict ai)
{
const uint32_t h = bsock_resvaddr_hash(ai);
@@ -191,7 +186,10 @@ struct bsock_resvaddr_cleanup {
struct bsock_resvaddr_alloc *ar;
};
-static void __attribute__((nonnull)) __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+__attribute_nonnull__
+static void
bsock_resvaddr_cleanup (void * const arg)
{
struct bsock_resvaddr_cleanup * const cleanup =
@@ -238,7 +236,9 @@ bsock_resvaddr_cleanup (void * const arg)
/* XXX: future
* bsock_resvaddr_config() and bsock_authz_config() should share parsing code */
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_resvaddr_config (void)
{
FILE *cfg;
diff --git a/bsock/bsock_resvaddr.h b/bsock/bsock_resvaddr.h
index f6283d0..711ba8c 100644
--- a/bsock/bsock_resvaddr.h
+++ b/bsock/bsock_resvaddr.h
@@ -29,6 +29,8 @@
#ifndef INCLUDED_BSOCK_RESVADDR_H
#define INCLUDED_BSOCK_RESVADDR_H
+#include "plasma/plasma_attr.h"
+
#include
#include
#include
@@ -44,7 +46,8 @@ extern "C" {
/* use ai->ai_flags for bsock flags since otherwise unused by bsock */
#define BSOCK_FLAGS_REBIND AI_PASSIVE /* close() and re-bind() resv addr */
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_resvaddr_fd (const struct addrinfo * const restrict ai);
void
diff --git a/bsock/bsock_syslog.c b/bsock/bsock_syslog.c
index ca28281..ca7d8cf 100644
--- a/bsock/bsock_syslog.c
+++ b/bsock/bsock_syslog.c
@@ -43,19 +43,25 @@ static int bsock_syslog_logfd = STDERR_FILENO;
static const char *bsock_syslog_ident;
static size_t bsock_syslog_identlen = 0;
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_setlevel (const int level)
{
bsock_syslog_level = level;
}
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_setlogfd (const int fd)
{
bsock_syslog_logfd = fd;
}
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_openlog (const char * const ident,
const int option, const int facility)
{
@@ -65,7 +71,10 @@ bsock_syslog_openlog (const char * const ident,
bsock_syslog_identlen = (NULL != ident) ? strlen(ident) : 0;
}
-void __attribute_cold__ __attribute__((format(printf,3,4)))
+__attribute_cold__
+__attribute_noinline__
+__attribute_format__((printf,3,4))
+void
bsock_syslog (const int errnum, const int priority,
const char * const restrict fmt, ...)
{
diff --git a/bsock/bsock_syslog.h b/bsock/bsock_syslog.h
index 76cfebc..3aff172 100644
--- a/bsock/bsock_syslog.h
+++ b/bsock/bsock_syslog.h
@@ -29,30 +29,7 @@
#ifndef INCLUDED_BSOCK_SYSLOG_H
#define INCLUDED_BSOCK_SYSLOG_H
-#include /*(for __GNUC_PREREQ(), if available)*/
-
-#ifndef __has_attribute
-#define __has_attribute(x) 0
-#endif
-#ifndef __GNUC_PREREQ
-# ifdef __GNUC_PREREQ__
-# define __GNUC_PREREQ __GNUC_PREREQ__
-# elif defined __GNUC__ && defined __GNUC_MINOR__
-# define __GNUC_PREREQ(maj, min) \
- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-# else
-# define __GNUC_PREREQ(maj, min) 0
-# endif
-#endif
-
-#if __GNUC_PREREQ(4,3) || __has_attribute(cold)
-#ifndef __attribute_cold__
-#define __attribute_cold__ __attribute__ ((cold))
-#endif
-#endif
-#ifndef __attribute_cold__
-#define __attribute_cold__
-#endif
+#include "plasma/plasma_attr.h"
#ifdef __cplusplus
extern "C" {
@@ -64,17 +41,26 @@ enum {
BSOCK_SYSLOG_PERROR_NOSYSLOG = 2
};
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_setlevel (const int level);
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_setlogfd (const int fd);
-void __attribute_cold__
+__attribute_cold__
+__attribute_noinline__
+void
bsock_syslog_openlog (const char * const ident,
const int option, const int facility);
-void __attribute_cold__ __attribute__((format(printf,3,4)))
+__attribute_cold__
+__attribute_noinline__
+__attribute_format__((printf,3,4))
+void
bsock_syslog (const int errnum, const int priority,
const char * const restrict fmt, ...);
diff --git a/bsock/bsock_unix.c b/bsock/bsock_unix.c
index 542d8a2..31b33bc 100644
--- a/bsock/bsock_unix.c
+++ b/bsock/bsock_unix.c
@@ -51,9 +51,10 @@
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_socket_connect (const char * const restrict sockpath)
{
/* connect to unix domain socket */
@@ -81,7 +82,8 @@ bsock_unix_socket_connect (const char * const restrict sockpath)
return -1;
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_socket_bind_listen (const char * const restrict sockpath,
int * const restrict bound)
{
@@ -127,7 +129,8 @@ bsock_unix_socket_bind_listen (const char * const restrict sockpath,
return -1;
}
-static void __attribute__((nonnull (1)))
+__attribute_nonnull_x__((1))
+static void
bsock_unix_recv_ancillary (struct msghdr * const restrict msg,
int * const restrict rfds,
unsigned int * const restrict nrfdsp)
@@ -161,7 +164,9 @@ bsock_unix_recv_ancillary (struct msghdr * const restrict msg,
*nrfdsp = nrfd;
}
-static ssize_t __attribute__((nonnull (4))) __attribute__((noinline))
+__attribute_noinline__
+__attribute_nonnull_x__((4))
+static ssize_t
bsock_unix_recv_fds_msghdr (const int fd,
int * const restrict rfds,
unsigned int * const restrict nrfds,
@@ -170,7 +175,7 @@ bsock_unix_recv_fds_msghdr (const int fd,
/* receive and return file descriptor(s) sent over unix domain socket */
/* 'man cmsg' provides example code */
ssize_t r;
- do { r = recvmsg(fd, msg, MSG_DONTWAIT); } while (-1==r && errno==EINTR);
+ retry_eintr_do_while(r = recvmsg(fd, msg, MSG_DONTWAIT), -1 == r);
if (r < 1) { /* EOF (r=0) or error (r=-1) */
if (0 == r && 0 == errno) errno = EPIPE;
return -1;
@@ -187,7 +192,8 @@ bsock_unix_recv_fds_msghdr (const int fd,
return r;
}
-ssize_t __attribute__((nonnull (4)))
+__attribute_nonnull_x__((4))
+ssize_t
bsock_unix_recv_fds (const int fd,
int * const restrict rfds,
unsigned int * const restrict nrfds,
@@ -209,7 +215,8 @@ bsock_unix_recv_fds (const int fd,
return bsock_unix_recv_fds_msghdr(fd, rfds, nrfds, &msg);
}
-ssize_t __attribute__((nonnull (4,6)))
+__attribute_nonnull_x__((4,6))
+ssize_t
bsock_unix_recv_fds_ex (const int fd,
int * const restrict rfds,
unsigned int * const restrict nrfds,
@@ -232,7 +239,8 @@ bsock_unix_recv_fds_ex (const int fd,
return bsock_unix_recv_fds_msghdr(fd, rfds, nrfds, &msg);
}
-ssize_t __attribute__((nonnull (4)))
+__attribute_nonnull_x__((4))
+ssize_t
bsock_unix_send_fds (const int fd,
const int * const restrict sfds,
unsigned int nsfds,
@@ -268,8 +276,7 @@ bsock_unix_send_fds (const int fd,
cmsg->cmsg_len = msg.msg_controllen = CMSG_LEN(nsfds); /*data*/
}
- do { w = sendmsg(fd, &msg, MSG_DONTWAIT|MSG_NOSIGNAL);
- } while (-1 == w && errno == EINTR);
+ retry_eintr_do_while(w=sendmsg(fd,&msg,MSG_DONTWAIT|MSG_NOSIGNAL), -1 == w);
return w;
/* (caller might choose not to report errno==EPIPE or errno==ECONNRESET) */
}
@@ -277,7 +284,8 @@ bsock_unix_send_fds (const int fd,
#ifdef __linux__
/* obtain peer credentials
* (requires Linux getsockopt SO_PEERCRED or BSD-style getpeereid() support) */
-static inline int __attribute__((nonnull))
+__attribute_nonnull__
+static inline int
getpeereid(const int s,uid_t * const restrict euid,gid_t * const restrict egid)
{
struct ucred { pid_t pid; uid_t uid; gid_t gid; }; /*or define _GNU_SOURCE*/
@@ -294,7 +302,8 @@ getpeereid(const int s,uid_t * const restrict euid,gid_t * const restrict egid)
#ifdef __sun__
/* obtain peer credentials using getpeerucred() (Solaris 10) */
#include
-static inline int __attribute__((nonnull))
+__attribute_nonnull__
+static inline int
getpeereid(const int s,uid_t * const restrict euid,gid_t * const restrict egid)
{
ucred_t *ucred;
@@ -312,7 +321,8 @@ int getpeereid (int, uid_t * __restrict__, gid_t * __restrict__);
#endif
#ifndef __hpux
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_getpeereid (const int s,
uid_t * const restrict euid,
gid_t * const restrict egid)
@@ -320,10 +330,11 @@ bsock_unix_getpeereid (const int s,
return getpeereid(s, euid, egid);
}
#else /* unsupported on HP-UX */
-int __attribute__((nonnull))
-bsock_unix_getpeereid (const int s __attribute__((unused)),
- uid_t * const restrict euid __attribute__((unused)),
- gid_t * const restrict egid __attribute__((unused)))
+__attribute_nonnull__
+int
+bsock_unix_getpeereid (const int s __attribute_unused__,
+ uid_t * const restrict euid __attribute_unused__,
+ gid_t * const restrict egid __attribute_unused__)
{
return -1; /* unsupported on HP-UX */
}
@@ -331,7 +342,8 @@ bsock_unix_getpeereid (const int s __attribute__((unused)),
#if 0 /* sample code */
-ssize_t __attribute__((nonnull))
+__attribute_nonnull__
+ssize_t
bsock_unix_recvmsg (const int fd,
struct iovec * const restrict iov,
const size_t iovlen)
@@ -340,7 +352,8 @@ bsock_unix_recvmsg (const int fd,
return bsock_unix_recv_fds(fd, NULL, NULL, iov, iovlen);
}
-ssize_t __attribute__((nonnull))
+__attribute_nonnull__
+ssize_t
bsock_unix_sendmsg (const int fd,
struct iovec * const restrict iov,
const size_t iovlen)
diff --git a/bsock/bsock_unix.h b/bsock/bsock_unix.h
index ef4e5f3..c50d1ef 100644
--- a/bsock/bsock_unix.h
+++ b/bsock/bsock_unix.h
@@ -29,6 +29,8 @@
#ifndef INCLUDED_BSOCK_UNIX_H
#define INCLUDED_BSOCK_UNIX_H
+#include "plasma/plasma_attr.h"
+
#include
#include
@@ -67,21 +69,25 @@ extern "C" {
#define BSOCK_ANCILLARY_DATA_MAX 10240
#endif
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_socket_connect (const char * const restrict sockpath);
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_socket_bind_listen (const char * const restrict sockpath,
int * const restrict bound);
-ssize_t __attribute__((nonnull (4)))
+__attribute_nonnull_x__((4))
+ssize_t
bsock_unix_recv_fds (const int fd,
int * const restrict rfds,
unsigned int * const restrict nrfds,
struct iovec * const restrict iov,
const size_t iovlen);
-ssize_t __attribute__((nonnull (4,6)))
+__attribute_nonnull_x__((4,6))
+ssize_t
bsock_unix_recv_fds_ex (const int fd,
int * const restrict rfds,
unsigned int * const restrict nrfds,
@@ -90,14 +96,16 @@ bsock_unix_recv_fds_ex (const int fd,
char * const restrict ctrlbuf,
const size_t ctrlbuf_sz);
-ssize_t __attribute__((nonnull (4)))
+__attribute_nonnull_x__((4))
+ssize_t
bsock_unix_send_fds (const int fd,
const int * const restrict sfds,
unsigned int nsfds,
struct iovec * const restrict iov,
const size_t iovlen);
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
bsock_unix_getpeereid (const int s,
uid_t * const restrict euid,
gid_t * const restrict egid);
diff --git a/plasma b/plasma
new file mode 160000
index 0000000..d863a83
--- /dev/null
+++ b/plasma
@@ -0,0 +1 @@
+Subproject commit d863a83ce868d40c88462064c66ba7331f25c0c5
diff --git a/proxyexec/Makefile b/proxyexec/Makefile
index 695729d..cf9613b 100644
--- a/proxyexec/Makefile
+++ b/proxyexec/Makefile
@@ -105,6 +105,9 @@ clean: clean-proxyexec
clean-proxyexec:
$(RM) proxyexec proxyexec.o
-proxyexec.o: $(BSOCK_INCLUDE)/bsock/bsock_daemon.h \
- $(BSOCK_INCLUDE)/bsock/bsock_syslog.h \
- $(BSOCK_INCLUDE)/bsock/bsock_unix.h
+proxyexec.o: $(BSOCK_INCLUDE)/bsock/bsock_daemon.h \
+ $(BSOCK_INCLUDE)/bsock/bsock_syslog.h \
+ $(BSOCK_INCLUDE)/bsock/bsock_unix.h \
+ $(BSOCK_INCLUDE)/plasma/plasma_attr.h \
+ $(BSOCK_INCLUDE)/plasma/plasma_feature.h \
+ $(BSOCK_INCLUDE)/plasma/plasma_stdtypes.h
diff --git a/proxyexec/proxyexec.c b/proxyexec/proxyexec.c
index 4a417ae..a43f4ab 100644
--- a/proxyexec/proxyexec.c
+++ b/proxyexec/proxyexec.c
@@ -35,6 +35,8 @@
* Alternatively, login session limits by user might be employed.
*/
+#include
+
#include
#include
#include
@@ -113,14 +115,15 @@ int dup3(int oldfd, int newfd, int flags);
/* nointr_close() - make effort to avoid leaking open file descriptors */
static int
nointr_close (const int fd)
-{ int r; do { r = close(fd); } while (r != 0 && errno == EINTR); return r; }
+{ int r; retry_eintr_do_while(r = close(fd), r != 0); return r; }
-static int __attribute__((noinline))
+__attribute_noinline__
+static int
retry_poll_fd (const int fd, const short events, const int timeout)
{
struct pollfd pfd = { .fd = fd, .events = events, .revents = 0 };
int n; /*EINTR results in retrying poll with same timeout again and again*/
- do { n = poll(&pfd, 1, timeout); } while (-1 == n && errno == EINTR);
+ retry_eintr_do_while(n = poll(&pfd, 1, timeout), -1 == n);
if (0 == n) errno = ETIME; /* specific for bsock; not generic */
return n;
}
@@ -155,7 +158,9 @@ struct proxyexec_context {
const char *path;
};
-static int __attribute__((nonnull)) __attribute__((pure))
+__attribute_pure__
+__attribute_nonnull__
+static int
proxyexec_env_cmp (const void *x, const void *y)
{
const struct proxyexec_env_st * const restrict a =
@@ -165,7 +170,9 @@ proxyexec_env_cmp (const void *x, const void *y)
return a->sz < b->sz ? -1 : a->sz > b->sz ? 1 : memcmp(a->s, b->s, a->sz);
}
-static inline bool __attribute__((nonnull)) __attribute__((pure))
+__attribute_pure__
+__attribute_nonnull__
+static inline bool
proxyexec_env_allowed (const char * const restrict s, const size_t sz)
{
const struct proxyexec_env_st e = { .s = s, .sz = sz };
@@ -174,7 +181,8 @@ proxyexec_env_allowed (const char * const restrict s, const size_t sz)
sizeof(struct proxyexec_env_st), proxyexec_env_cmp) != NULL;
}
-static bool __attribute__((nonnull))
+__attribute_nonnull__
+static bool
proxyexec_argv_env_parse (char *b, char * const e,
char ** const restrict argv, const uint32_t argc)
{
@@ -224,7 +232,8 @@ proxyexec_ctrlbuf_alloc (void)
}
}
-static ssize_t __attribute__((nonnull))
+__attribute_nonnull__
+static ssize_t
proxyexec_stdfds_recv_dup2 (int fd, struct iovec * const restrict iov,
const size_t iovlen)
{
@@ -250,7 +259,8 @@ proxyexec_stdfds_recv_dup2 (int fd, struct iovec * const restrict iov,
return r;
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
proxyexec_fork_exec (char ** const restrict argv)
{
/* set SIGCHLD handler to default (not ignored, as is done in parent) */
@@ -274,13 +284,15 @@ proxyexec_fork_exec (char ** const restrict argv)
nointr_close(STDIN_FILENO);
nointr_close(STDOUT_FILENO);
nointr_close(STDERR_FILENO);
- while (-1 == waitpid(pid, &status, 0) && errno == EINTR) ;
+ retry_eintr_while(-1 == waitpid(pid, &status, 0));
}
return status;
}
-static int __attribute__((nonnull)) __attribute__((noinline))
+__attribute_noinline__
+__attribute_nonnull__
+static int
proxyexec_child_session (struct proxyexec_context * const restrict cxt)
{
/* Note: leaks memory upon failure, but free() skipped since program exits*/
@@ -397,7 +409,8 @@ proxyexec_child_session (struct proxyexec_context * const restrict cxt)
* client
*/
-static ssize_t __attribute__((nonnull))
+__attribute_nonnull__
+static ssize_t
proxyexec_stdfds_send (const int fd,
struct iovec * const restrict iov, const size_t iovlen)
{
@@ -405,7 +418,8 @@ proxyexec_stdfds_send (const int fd,
return bsock_unix_send_fds(fd, sfds, sizeof(sfds)/sizeof(int), iov, iovlen);
}
-static size_t __attribute__((nonnull))
+__attribute_nonnull__
+static size_t
proxyexec_env_serialize (char * const restrict buf, const size_t sz)
{
/*(future: consider different algorithm if proxyexec_envs[] has many elts)*/
@@ -427,7 +441,8 @@ proxyexec_env_serialize (char * const restrict buf, const size_t sz)
return total;
}
-static bool __attribute__((nonnull))
+__attribute_nonnull__
+static bool
proxyexec_argv_env_send (const int fd, wordexp_t * const restrict cmd,
char * const restrict envbuf, size_t envbufsz)
{
@@ -488,7 +503,8 @@ proxyexec_argv_env_send (const int fd, wordexp_t * const restrict cmd,
return rc;
}
-static int __attribute__((nonnull))
+__attribute_nonnull__
+static int
proxyexec_client (const int argc, char ** const restrict argv)
{
/* Syntax check and perform shell expansion if SSH[2]?_ORIGINAL_COMMAND.
@@ -611,7 +627,8 @@ proxyexec_client (const int argc, char ** const restrict argv)
}
-int __attribute__((nonnull))
+__attribute_nonnull__
+int
main (int argc, char *argv[])
{
int sfd, cfd, dup2fd, log_info = 1, daemon = false, supervised = false;