libore update
This commit is contained in:
parent
183beb72b1
commit
996a101f50
@ -397,7 +397,6 @@ int main(int argc, char *argv[])
|
|||||||
log_print(LOG_INFO, "alix-usvd started (pid: %d)", getpid());
|
log_print(LOG_INFO, "alix-usvd started (pid: %d)", getpid());
|
||||||
|
|
||||||
const char *socket_path = config_get_string("global", "socket", DEFAULT_SOCKET);
|
const char *socket_path = config_get_string("global", "socket", DEFAULT_SOCKET);
|
||||||
unlink(socket_path);
|
|
||||||
int sockfd = unix_listen(socket_path);
|
int sockfd = unix_listen(socket_path);
|
||||||
if (sockfd < 0)
|
if (sockfd < 0)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -18,10 +18,12 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
@ -92,6 +94,12 @@ int log_init(const char *logfile)
|
|||||||
fprintf(stderr, "log_init(): can not open logfile");
|
fprintf(stderr, "log_init(): can not open logfile");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fcntl(fileno(log_fd), F_SETFD, FD_CLOEXEC) < 0) {
|
||||||
|
fprintf(stderr, "log_init(): fcntl(FD_CLOEXEC)");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
* Free Software Foundation, Inc., *
|
* Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
@ -33,11 +35,21 @@ int unix_listen(const char *filename)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fcntl(sockfd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||||
|
log_print(LOG_WARN, "unix_listen(): fcntl(FD_CLOEXEC)");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
strncpy(addr.sun_path, filename, sizeof(addr.sun_path));
|
strncpy(addr.sun_path, filename, sizeof(addr.sun_path));
|
||||||
int len = sizeof(addr.sun_family) + strlen(addr.sun_path);
|
int len = sizeof(addr.sun_family) + strlen(addr.sun_path);
|
||||||
|
|
||||||
|
if (unlink(addr.sun_path) == -1) {
|
||||||
|
log_print(LOG_ERROR, "unix_listen: unlink()");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
mode_t old_umask = umask(0077);
|
mode_t old_umask = umask(0077);
|
||||||
int ret = bind(sockfd, (struct sockaddr *) &addr, len);
|
int ret = bind(sockfd, (struct sockaddr *) &addr, len);
|
||||||
umask(old_umask);
|
umask(old_umask);
|
||||||
|
Loading…
Reference in New Issue
Block a user