reply-password.c revision 4cfa2c999dea269ddc646bfeba6c7f1021a73843
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d710d36375bacbf9cfb8903107bedf2c0aada84eMichal Schmidt This file is part of systemd.
fff87a35d9e26c0d4ea41273a963c0eb20e18da4Zbigniew Jędrzejewski-Szmek Copyright 2010 Lennart Poettering
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt systemd is free software; you can redistribute it and/or modify it
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt under the terms of the GNU General Public License as published by
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt the Free Software Foundation; either version 2 of the License, or
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt (at your option) any later version.
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt systemd is distributed in the hope that it will be useful, but
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt WITHOUT ANY WARRANTY; without even the implied warranty of
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt General Public License for more details.
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt You should have received a copy of the GNU General Public License
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt along with systemd; If not, see <http://www.gnu.org/licenses/>.
41a5ef639b248aa3d10609d9af5d0043b909d93cHarald Hoyerstatic int send_on_socket(int fd, const char *socket_name, const void *packet, size_t size) {
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt if (!fgets(packet+1, sizeof(packet)-1, stdin)) {
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt log_error("Invalid first argument %s", argv[1]);
b5da077ddf01546c4a85688624d6957766d6c00cMichal Schmidt if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0)) < 0) {