initctl: improve error message for unprivileged users

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-03-12 13:26:16 +01:00
1 parent 9f06a2db99
commit 1edc4356a6
1 file changed
+4 -8
+4 -8
View File
@@ -21,6 +21,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <err.h>
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
@@ -38,17 +39,12 @@ int client_connect(void)
sd = socket(AF_UNIX, SOCK_STREAM, 0); sd = socket(AF_UNIX, SOCK_STREAM, 0);
if (-1 == sd) if (-1 == sd)
goto error; err(1, "Failed creating UNIX domain socket");
if (connect(sd, (struct sockaddr*)&sun, sizeof(sun)) == -1) { if (connect(sd, (struct sockaddr*)&sun, sizeof(sun)) == -1)
close(sd); err(1, "Failed connecting to finit");
goto error;
}
return sd; return sd;
error:
perror("Failed connecting to finit");
return -1;
} }
int client_disconnect(void) int client_disconnect(void)