Browse Source

rename sockaddr_un variables from 'sun' to the more common 'sa'.

This avoids a namespace conflict with Solaris build environments.
discussed with deraadt@ and kettenis@
OPENBSD_5_7
bcook 9 years ago
parent
commit
2b0bc47767
2 changed files with 17 additions and 17 deletions
  1. +10
    -10
      src/usr.sbin/ntpd/control.c
  2. +7
    -7
      src/usr.sbin/ntpd/ntpd.c

+ 10
- 10
src/usr.sbin/ntpd/control.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.2 2013/11/13 20:44:39 benno Exp $ */
/* $OpenBSD: control.c,v 1.3 2015/01/04 01:24:43 bcook Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -36,7 +36,7 @@
int int
control_init(char *path) control_init(char *path)
{ {
struct sockaddr_un sun;
struct sockaddr_un sa;
int fd; int fd;
mode_t old_umask; mode_t old_umask;
@ -45,10 +45,10 @@ control_init(char *path)
return (-1); 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, sizeof(sa));
sa.sun_family = AF_UNIX;
if (strlcpy(sa.sun_path, path, sizeof(sa.sun_path)) >=
sizeof(sa.sun_path))
errx(1, "ctl socket name too long"); errx(1, "ctl socket name too long");
if (unlink(path) == -1) if (unlink(path) == -1)
@ -59,7 +59,7 @@ control_init(char *path)
} }
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
log_warn("control_init: bind: %s", path); log_warn("control_init: bind: %s", path);
close(fd); close(fd);
umask(old_umask); umask(old_umask);
@ -108,12 +108,12 @@ control_accept(int listenfd)
{ {
int connfd; int connfd;
socklen_t len; socklen_t len;
struct sockaddr_un sun;
struct sockaddr_un sa;
struct ctl_conn *ctl_conn; struct ctl_conn *ctl_conn;
len = sizeof(sun);
len = sizeof(sa);
if ((connfd = accept(listenfd, if ((connfd = accept(listenfd,
(struct sockaddr *)&sun, &len)) == -1) {
(struct sockaddr *)&sa, &len)) == -1) {
if (errno != EWOULDBLOCK && errno != EINTR) if (errno != EWOULDBLOCK && errno != EINTR)
log_warn("control_accept: accept"); log_warn("control_accept: accept");
return (0); return (0);


+ 7
- 7
src/usr.sbin/ntpd/ntpd.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.80 2015/01/04 01:11:24 bcook Exp $ */
/* $OpenBSD: ntpd.c,v 1.81 2015/01/04 01:24:43 bcook Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -527,7 +527,7 @@ writefreq(double d)
void void
ctl_main(int argc, char *argv[]) ctl_main(int argc, char *argv[])
{ {
struct sockaddr_un sun;
struct sockaddr_un sa;
struct imsg imsg; struct imsg imsg;
struct imsgbuf *ibuf_ctl; struct imsgbuf *ibuf_ctl;
int fd, n, done, ch, action; int fd, n, done, ch, action;
@ -580,12 +580,12 @@ ctl_main(int argc, char *argv[])
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
err(1, "ntpctl: socket"); err(1, "ntpctl: 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, sizeof(sa));
sa.sun_family = AF_UNIX;
if (strlcpy(sa.sun_path, sockname, sizeof(sa.sun_path)) >=
sizeof(sa.sun_path))
errx(1, "ctl socket name too long"); errx(1, "ctl socket name too long");
if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1)
if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1)
err(1, "connect: %s", sockname); err(1, "connect: %s", sockname);
if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL)


Loading…
Cancel
Save