summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2015-09-02 11:14:41 +0200
committerDavid Herrmann <dh.herrmann@googlemail.com>2015-09-02 11:14:41 +0200
commitd18ec0491ed7c502080c03fa5fe93c8b6ac3d6ea (patch)
tree3613b205544d081eaa76656c117034754531ce73 /src/basic/terminal-util.c
parentf22572452b55f78ec9cddfdb0229c1d93dd9ce67 (diff)
parent751090cc8ae09787402d60b7080d479b3afe3b13 (diff)
Merge pull request #1112 from poettering/sd-bus-container-fixes
machined and sd-bus container fixes
Diffstat (limited to 'src/basic/terminal-util.c')
-rw-r--r--src/basic/terminal-util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index cf55263bbf..c5ef5ab0d1 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1074,3 +1074,22 @@ int get_ctty(pid_t pid, dev_t *_devnr, char **r) {
return 0;
}
+
+int ptsname_namespace(int pty, char **ret) {
+ int no = -1, r;
+
+ /* Like ptsname(), but doesn't assume that the path is
+ * accessible in the local namespace. */
+
+ r = ioctl(pty, TIOCGPTN, &no);
+ if (r < 0)
+ return -errno;
+
+ if (no < 0)
+ return -EIO;
+
+ if (asprintf(ret, "/dev/pts/%i", no) < 0)
+ return -ENOMEM;
+
+ return 0;
+}