dstr_destroy(&dd);
}
+/* --- @a_format@ --- *
+ *
+ * Arguments: @dstr *d@ = where to leave the formatted message
+ * @const char *fmt@ = pointer to format string
+ *
+ * Returns: ---
+ *
+ * Use: Writes a tokenized message into a string, for later
+ * presentation.
+ */
+
+void a_format(dstr *d, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ a_vformat(d, fmt, ap);
+ va_end(ap);
+}
+
/* --- @a_write@, @a_vwrite@ --- *
*
* Arguments: @admin *a@ = admin connection to write to
add->peer.tag = 0;
add->peer.t_ka = 0;
add->peer.tops = tun_default;
- add->peer.kxf = 0;
+ add->peer.f = 0;
/* --- Parse options --- */
}
})
OPTTIME("-keepalive", t, { add->peer.t_ka = t; })
- OPT("-cork", { add->peer.kxf |= KXF_CORK; })
+ OPT("-cork", { add->peer.f |= KXF_CORK; })
OPTARG("-key", arg, {
if (add->peer.tag)
xfree(add->peer.tag);
add->peer.tag = xstrdup(arg);
})
+ OPT("-mobile", { add->peer.f |= PSF_MOBILE; })
});
/* --- Make sure someone's not got there already --- */
* Arguments: @const char *name@ = socket name to create
* @uid_t u@ = user to own the socket
* @gid_t g@ = group to own the socket
+ * @mode_t m@ = permissions to set on the socket
*
* Returns: ---
*
* Use: Creates the admin listening socket.
*/
-void a_init(const char *name, uid_t u, gid_t g)
+void a_init(const char *name, uid_t u, gid_t g, mode_t m)
{
int fd;
int n = 5;
close(fd);
goto again;
}
- chmod(sun.sun_path, 0600);
if (chown(sun.sun_path, u, g)) {
- T( trace(T_ADMIN,
- "admin: failed to give away socket: %s",
- strerror(errno)); )
+ die(EXIT_FAILURE, "failed to set socket owner: %s",
+ strerror(errno));
+ }
+ if (chmod(sun.sun_path, m)) {
+ die(EXIT_FAILURE, "failed to set socket permissions: %s",
+ strerror(errno));
}
umask(omask);
fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);