Ok On Fri, 4 Feb 2022, 21:19 Claudio Jeker, <cje...@diehard.n-r-g.com> wrote:
> On illumos sun is defined by some header so better not use sun as a > variable name. Rename variable to sa_un to reduce hacks in -portable. > > -- > :wq Claudio > > Index: bgpctl/bgpctl.c > =================================================================== > RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v > retrieving revision 1.273 > diff -u -p -r1.273 bgpctl.c > --- bgpctl/bgpctl.c 9 Aug 2021 08:24:36 -0000 1.273 > +++ bgpctl/bgpctl.c 4 Feb 2022 11:10:31 -0000 > @@ -78,7 +78,7 @@ usage(void) > int > main(int argc, char *argv[]) > { > - struct sockaddr_un sun; > + struct sockaddr_un sa_un; > int fd, n, done, ch, verbose = 0; > struct imsg imsg; > struct network_config net; > @@ -160,12 +160,12 @@ main(int argc, char *argv[]) > if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) > err(1, "control_init: socket"); > > - bzero(&sun, sizeof(sun)); > - sun.sun_family = AF_UNIX; > - if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= > - sizeof(sun.sun_path)) > + bzero(&sa_un, sizeof(sa_un)); > + sa_un.sun_family = AF_UNIX; > + if (strlcpy(sa_un.sun_path, sockname, sizeof(sa_un.sun_path)) >= > + sizeof(sa_un.sun_path)) > errx(1, "socket name too long"); > - if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) > + if (connect(fd, (struct sockaddr *)&sa_un, sizeof(sa_un)) == -1) > err(1, "connect: %s", sockname); > > if (pledge("stdio", NULL) == -1) > Index: bgpd/control.c > =================================================================== > RCS file: /cvs/src/usr.sbin/bgpd/control.c,v > retrieving revision 1.105 > diff -u -p -r1.105 control.c > --- bgpd/control.c 27 Apr 2021 15:34:18 -0000 1.105 > +++ bgpd/control.c 4 Feb 2022 11:07:25 -0000 > @@ -42,19 +42,19 @@ ssize_t imsg_read_nofd(struct imsgbuf > int > control_check(char *path) > { > - struct sockaddr_un sun; > + struct sockaddr_un sa_un; > int fd; > > - bzero(&sun, sizeof(sun)); > - sun.sun_family = AF_UNIX; > - strlcpy(sun.sun_path, path, sizeof(sun.sun_path)); > + bzero(&sa_un, sizeof(sa_un)); > + sa_un.sun_family = AF_UNIX; > + strlcpy(sa_un.sun_path, path, sizeof(sa_un.sun_path)); > > if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1) { > log_warn("%s: socket", __func__); > return (-1); > } > > - if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == 0) { > + if (connect(fd, (struct sockaddr *)&sa_un, sizeof(sa_un)) == 0) { > log_warnx("control socket %s already in use", path); > close(fd); > return (-1); > @@ -68,7 +68,7 @@ control_check(char *path) > int > control_init(int restricted, char *path) > { > - struct sockaddr_un sun; > + struct sockaddr_un sa_un; > int fd; > mode_t old_umask, mode; > > @@ -78,10 +78,10 @@ control_init(int restricted, char *path) > return (-1); > } > > - bzero(&sun, sizeof(sun)); > - sun.sun_family = AF_UNIX; > - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= > - sizeof(sun.sun_path)) { > + bzero(&sa_un, sizeof(sa_un)); > + sa_un.sun_family = AF_UNIX; > + if (strlcpy(sa_un.sun_path, path, sizeof(sa_un.sun_path)) >= > + sizeof(sa_un.sun_path)) { > log_warn("control_init: socket name too long"); > close(fd); > return (-1); > @@ -102,7 +102,7 @@ control_init(int restricted, char *path) > mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; > } > > - if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { > + if (bind(fd, (struct sockaddr *)&sa_un, sizeof(sa_un)) == -1) { > log_warn("control_init: bind: %s", path); > close(fd); > umask(old_umask); > @@ -159,12 +159,12 @@ control_accept(int listenfd, int restric > { > int connfd; > socklen_t len; > - struct sockaddr_un sun; > + struct sockaddr_un sa_un; > struct ctl_conn *ctl_conn; > > - len = sizeof(sun); > + len = sizeof(sa_un); > if ((connfd = accept4(listenfd, > - (struct sockaddr *)&sun, &len, > + (struct sockaddr *)&sa_un, &len, > SOCK_NONBLOCK | SOCK_CLOEXEC)) == -1) { > if (errno == ENFILE || errno == EMFILE) { > pauseaccept = getmonotime(); > >