reply-password.c revision 7e8185ef942de5acecfa4cda03d7d7711ddda992
/*-*- 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 Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser 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 <stddef.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, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
log_error("Failed to send: %m");
return -errno;
}
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;
}
if (fd < 0) {
log_error("socket() failed: %m");
goto finish;
}
goto finish;
r = EXIT_SUCCESS;
safe_close(fd);
return r;
}