static krb5_socket_t make_signal_socket (krb5_context context) { #ifndef NO_UNIX_SOCKETS struct sockaddr_un addr; const char *fn; krb5_socket_t fd; fn = kadm5_log_signal_socket(context); fd = socket (AF_UNIX, SOCK_DGRAM, 0); if (fd < 0) krb5_err (context, 1, errno, "socket AF_UNIX"); memset (&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strlcpy (addr.sun_path, fn, sizeof(addr.sun_path)); unlink (addr.sun_path); if (bind (fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) krb5_err (context, 1, errno, "bind %s", addr.sun_path); return fd; #else struct addrinfo *ai = NULL; krb5_socket_t fd; kadm5_log_signal_socket_info(context, 1, &ai); fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (rk_IS_BAD_SOCKET(fd)) krb5_err (context, 1, rk_SOCK_ERRNO, "socket AF=%d", ai->ai_family); if (rk_IS_SOCKET_ERROR( bind (fd, ai->ai_addr, ai->ai_addrlen) )) krb5_err (context, 1, rk_SOCK_ERRNO, "bind"); return fd; #endif }
static void set_socket_name(krb5_context context, struct sockaddr_un *un) { const char *fn = kadm5_log_signal_socket(context); memset(un, 0, sizeof(*un)); un->sun_family = AF_UNIX; strlcpy (un->sun_path, fn, sizeof(un->sun_path)); }