X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Freply-password.c;h=a935d0f08401fe9794f0870083270b5ebdd273e3;hb=68fb08920b2162b48cf0fa8dd98b021327b42896;hp=236fdcc94cc585d930bdcca757b6035240d20a15;hpb=490aed584944b684026a3fd01f8d81f2881e38d6;p=elogind.git diff --git a/src/reply-password.c b/src/reply-password.c index 236fdcc94..a935d0f08 100644 --- a/src/reply-password.c +++ b/src/reply-password.c @@ -6,16 +6,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + 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 - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -31,6 +31,7 @@ #include #include #include +#include #include "log.h" #include "macro.h" @@ -48,9 +49,9 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s zero(sa); sa.un.sun_family = AF_UNIX; - strncpy(sa.un.sun_path+1, socket_name, sizeof(sa.un.sun_path)-1); + strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path)); - if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, sizeof(sa_family_t) + 1 + strlen(socket_name)) < 0) { + 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 -1; } @@ -63,7 +64,7 @@ int main(int argc, char *argv[]) { char packet[LINE_MAX]; size_t length; - log_set_target(LOG_TARGET_SYSLOG_OR_KMSG); + log_set_target(LOG_TARGET_AUTO); log_parse_environment(); log_open(); @@ -81,7 +82,7 @@ int main(int argc, char *argv[]) { } truncate_nl(packet+1); - length = strlen(packet+1) + 1; + length = 1 + strlen(packet+1) + 1; } else if (streq(argv[1], "0")) { packet[0] = '-'; length = 1;