summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-23 01:58:49 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-23 03:26:24 +0100
commitee451d766a64117a41ec36dd71e61683c9d9b83c (patch)
tree12a05ec521818b9ed02b0d15811d82e2d6fc9f5d /src/shared
parent40205d706e1210763ff4c98a317556375bd04bcd (diff)
systemd-run: support -t mode when combined with -M
For that, ask machined for a container PTY and use that.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c24
-rw-r--r--src/shared/util.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 06b6077843..6695a85a1c 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -7433,3 +7433,27 @@ int sethostname_idempotent(const char *s) {
return 1;
}
+
+int ptsname_malloc(int fd, char **ret) {
+ size_t l = 100;
+
+ for (;;) {
+ char *c;
+
+ c = new(char, l);
+ if (!c)
+ return -ENOMEM;
+
+ if (ptsname_r(fd, c, l) == 0) {
+ *ret = c;
+ return 0;
+ }
+ if (errno != ERANGE) {
+ free(c);
+ return -errno;
+ }
+
+ free(c);
+ l *= 2;
+ }
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 1804b8c3a2..d3e78e43ca 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -1052,3 +1052,5 @@ int sethostname_idempotent(const char *s);
(e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len))
#define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW)
+
+int ptsname_malloc(int fd, char **ret);