summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--src/libsystemd-bus/sd-memfd.c2
-rw-r--r--src/libsystemd-bus/test-bus-memfd.c47
3 files changed, 43 insertions, 8 deletions
diff --git a/TODO b/TODO
index 4f5af140f0..8d4b937a5a 100644
--- a/TODO
+++ b/TODO
@@ -29,6 +29,8 @@ Fedora 19:
Features:
+* maybe add "journalctl -k" as shortcut for "-b _TRANSPORT=kernel"
+
* Introduce a way how we can kill the main process of a service with KillSignal, but all processes with SIGKILL later on
https://bugzilla.redhat.com/show_bug.cgi?id=952634
diff --git a/src/libsystemd-bus/sd-memfd.c b/src/libsystemd-bus/sd-memfd.c
index 51b111e8b5..98a8e0893a 100644
--- a/src/libsystemd-bus/sd-memfd.c
+++ b/src/libsystemd-bus/sd-memfd.c
@@ -106,7 +106,7 @@ int sd_memfd_get_file(sd_memfd *m, FILE **f) {
if (!f)
return -EINVAL;
- if (!m->fd) {
+ if (!m->f) {
m->f = fdopen(m->fd, "r+");
if (!m->f)
return -errno;
diff --git a/src/libsystemd-bus/test-bus-memfd.c b/src/libsystemd-bus/test-bus-memfd.c
index 4c5ae21a8c..4b22ea9a68 100644
--- a/src/libsystemd-bus/test-bus-memfd.c
+++ b/src/libsystemd-bus/test-bus-memfd.c
@@ -32,6 +32,7 @@ int main(int argc, char *argv[]) {
char *s;
uint64_t sz;
int r, fd;
+ FILE *f;
log_set_max_level(LOG_DEBUG);
@@ -43,18 +44,31 @@ int main(int argc, char *argv[]) {
assert_se(r >= 0);
strcpy(s, "hallo");
- assert_se(munmap(s, 6) == 0);
+
+ r = sd_memfd_set_sealed(m, 1);
+ assert_se(r == -EPERM);
assert_se(write(sd_memfd_get_fd(m), "he", 2) == 2);
+ assert_se(write(sd_memfd_get_fd(m), "HE", 2) == 2);
- r = sd_memfd_get_sealed(m);
- assert_se(r == 0);
+ log_error("lseek = %llu", (unsigned long long) lseek(sd_memfd_get_fd(m), 0, SEEK_CUR));
- r = sd_memfd_set_sealed(m, 1);
- assert_se(r >= 0);
+ log_info("<%s>", s);
+
+ access("HUHU", F_OK);
+
+ assert_se(sd_memfd_get_file(m, &f) >= 0);
+ fputc('L', f);
+ fflush(f);
+
+ access("HAHA", F_OK);
+
+ log_info("<%s>", s);
+
+ assert_se(munmap(s, 6) == 0);
r = sd_memfd_get_sealed(m);
- assert_se(r == 1);
+ assert_se(r == 0);
r = sd_memfd_get_size(m, &sz);
assert_se(r >= 0);
@@ -63,6 +77,12 @@ int main(int argc, char *argv[]) {
r = sd_memfd_set_size(m, 6);
assert_se(r >= 0);
+ r = sd_memfd_set_sealed(m, 1);
+ assert_se(r >= 0);
+
+ r = sd_memfd_get_sealed(m);
+ assert_se(r == 1);
+
fd = sd_memfd_dup_fd(m);
assert_se(fd >= 0);
@@ -78,8 +98,21 @@ int main(int argc, char *argv[]) {
r = sd_memfd_map(m, 0, 6, (void**) &s);
assert_se(r >= 0);
- assert_se(streq(s, "hello"));
+ r = sd_memfd_set_sealed(m, 1);
+ assert_se(r == -EALREADY);
+
+ r = sd_memfd_set_sealed(m, 0);
+ assert_se(r == -EPERM);
+
+ log_info("<%s>", s);
+
+ assert_se(streq(s, "heLlo"));
assert_se(munmap(s, 6) == 0);
+ r = sd_memfd_set_sealed(m, 0);
+ assert_se(r >= 0);
+
+ sd_memfd_free(m);
+
return 0;
}