chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-login: teach sd_pid_get_unit() proper handling of instantiated services
[elogind.git]
/
src
/
journal
/
journal-send.c
diff --git
a/src/journal/journal-send.c
b/src/journal/journal-send.c
index cc3cd8c303135a0a044f908eaaa1bd018b1a1258..d51aec9690bf48e22988efeceb4bcba8022140bb 100644
(file)
--- a/
src/journal/journal-send.c
+++ b/
src/journal/journal-send.c
@@
-53,7
+53,7
@@
retry:
return fd;
}
return fd;
}
-int sd_journal_print(int priority, const char *format, ...) {
+
_public_
int sd_journal_print(int priority, const char *format, ...) {
int r;
va_list ap;
int r;
va_list ap;
@@
-64,7
+64,7
@@
int sd_journal_print(int priority, const char *format, ...) {
return r;
}
return r;
}
-int sd_journal_printv(int priority, const char *format, va_list ap) {
+
_public_
int sd_journal_printv(int priority, const char *format, va_list ap) {
char buffer[8 + LINE_MAX], p[11];
struct iovec iov[2];
char buffer[8 + LINE_MAX], p[11];
struct iovec iov[2];
@@
-88,7
+88,7
@@
int sd_journal_printv(int priority, const char *format, va_list ap) {
return sd_journal_sendv(iov, 2);
}
return sd_journal_sendv(iov, 2);
}
-int sd_journal_send(const char *format, ...) {
+
_public_
int sd_journal_send(const char *format, ...) {
int r, n = 0, i = 0, j;
va_list ap;
struct iovec *iov = NULL;
int r, n = 0, i = 0, j;
va_list ap;
struct iovec *iov = NULL;
@@
-131,7
+131,7
@@
fail:
return r;
}
return r;
}
-int sd_journal_sendv(const struct iovec *iov, int n) {
+
_public_
int sd_journal_sendv(const struct iovec *iov, int n) {
int fd;
struct iovec *w;
uint64_t *l;
int fd;
struct iovec *w;
uint64_t *l;
@@
-148,8
+148,12
@@
int sd_journal_sendv(const struct iovec *iov, int n) {
for (i = 0; i < n; i++) {
char *c, *nl;
for (i = 0; i < n; i++) {
char *c, *nl;
+ if (!iov[i].iov_base ||
+ iov[i].iov_len <= 1)
+ return -EINVAL;
+
c = memchr(iov[i].iov_base, '=', iov[i].iov_len);
c = memchr(iov[i].iov_base, '=', iov[i].iov_len);
- if (!c)
+ if (!c
|| c == iov[i].iov_base
)
return -EINVAL;
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
return -EINVAL;
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
@@
-191,7
+195,7
@@
int sd_journal_sendv(const struct iovec *iov, int n) {
zero(sa);
sa.sun_family = AF_UNIX;
zero(sa);
sa.sun_family = AF_UNIX;
- strncpy(sa.sun_path,
"/run/systemd/journal
", sizeof(sa.sun_path));
+ strncpy(sa.sun_path,
"/run/systemd/journal/socket
", sizeof(sa.sun_path));
zero(mh);
mh.msg_name = &sa;
zero(mh);
mh.msg_name = &sa;
@@
-205,7
+209,7
@@
int sd_journal_sendv(const struct iovec *iov, int n) {
return 0;
}
return 0;
}
-
int sd_journal_stream_fd(const char *tag, int priority, int priority
_prefix) {
+
_public_ int sd_journal_stream_fd(const char *identifier, int priority, int level
_prefix) {
union sockaddr_union sa;
int fd;
char *header;
union sockaddr_union sa;
int fd;
char *header;
@@
-221,7
+225,7
@@
int sd_journal_stream_fd(const char *tag, int priority, int priority_prefix) {
zero(sa);
sa.un.sun_family = AF_UNIX;
zero(sa);
sa.un.sun_family = AF_UNIX;
- strncpy(sa.un.sun_path, "/run/systemd/stdout", sizeof(sa.un.sun_path));
+ strncpy(sa.un.sun_path, "/run/systemd/
journal/
stdout", sizeof(sa.un.sun_path));
r = connect(fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
if (r < 0) {
r = connect(fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
if (r < 0) {
@@
-229,17
+233,26
@@
int sd_journal_stream_fd(const char *tag, int priority, int priority_prefix) {
return -errno;
}
return -errno;
}
- if (!tag)
- tag = "";
+ if (shutdown(fd, SHUT_RD) < 0) {
+ close_nointr_nofail(fd);
+ return -errno;
+ }
+
+ if (!identifier)
+ identifier = "";
- l = strlen(
tag
);
- header = alloca(l + 1 + 2 + 2 + 2);
+ l = strlen(
identifier
);
+ header = alloca(l + 1 + 2 + 2 + 2
+ 2 + 2
);
- memcpy(header,
tag
, l);
+ memcpy(header,
identifier
, l);
header[l++] = '\n';
header[l++] = '0' + priority;
header[l++] = '\n';
header[l++] = '\n';
header[l++] = '0' + priority;
header[l++] = '\n';
- header[l++] = '0' + !!priority_prefix;
+ header[l++] = '0' + !!level_prefix;
+ header[l++] = '\n';
+ header[l++] = '0';
+ header[l++] = '\n';
+ header[l++] = '0';
header[l++] = '\n';
header[l++] = '0';
header[l++] = '\n';
header[l++] = '\n';
header[l++] = '0';
header[l++] = '\n';