2 * Sub-authentication Client
4 * (c) 2017 Martin Mares <mj@ucw.cz>
12 #include <sys/socket.h>
18 static char *socket_path = INSTALL_RUN_DIR "/subauthd.socket";
20 static const struct opt_section options = {
22 OPT_HELP("A client to the sub-authentication daemon."),
23 OPT_HELP("Usage: subauth [options]"),
31 int main(int argc UNUSED, char **argv)
33 opt_parse(&options, argv+1);
35 int sk = socket(PF_UNIX, SOCK_SEQPACKET, 0);
37 die("socket(PF_UNIX, SOCK_SEQPACKET): %m");
39 struct sockaddr_un sun;
40 sun.sun_family = AF_UNIX;
41 if (strlen(socket_path) >= sizeof(sun.sun_path))
42 die("Socket path too long");
43 strcpy(sun.sun_path, socket_path);
45 if (connect(sk, (struct sockaddr *) &sun, sizeof(sun)) < 0)
46 die("Cannot connect to %s: %m", socket_path);
49 if (send(sk, msg, sizeof(msg), 0) < 0)
50 die("Send failed: %m");