reply-password.c revision 490aed584944b684026a3fd01f8d81f2881e38d6
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signalfd.h>
#include <getopt.h>
#include "log.h"
#include "macro.h"
#include "util.h"
union {
struct sockaddr_un un;
} sa;
if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, sizeof(sa_family_t) + 1 + strlen(socket_name)) < 0) {
log_error("Failed to send: %m");
return -1;
}
return 0;
}
log_open();
if (argc != 3) {
log_error("Wrong number of arguments.");
goto finish;
}
packet[0] = '+';
log_error("Failed to read password: %m");
goto finish;
}
packet[0] = '-';
length = 1;
} else {
goto finish;
}
log_error("socket() failed: %m");
goto finish;
}
goto finish;
r = EXIT_SUCCESS;
if (fd >= 0)
return r;
}