mosh: Link against libutil for openpty and forkpty
This commit is contained in:
parent
a904f85549
commit
21accda0a9
@ -1,7 +1,7 @@
|
|||||||
TERMUX_PKG_HOMEPAGE=http://mosh.mit.edu/
|
TERMUX_PKG_HOMEPAGE=http://mosh.mit.edu/
|
||||||
TERMUX_PKG_DESCRIPTION="Mobile shell that supports roaming and intelligent local echo"
|
TERMUX_PKG_DESCRIPTION="Mobile shell that supports roaming and intelligent local echo"
|
||||||
TERMUX_PKG_VERSION=1.2.5.20160402
|
TERMUX_PKG_VERSION=1.2.5.20160402
|
||||||
TERMUX_PKG_BUILD_REVISION=1
|
TERMUX_PKG_BUILD_REVISION=2
|
||||||
TERMUX_PKG_SRCURL=http://mosh.mit.edu/mosh-${TERMUX_PKG_VERSION}.tar.gz
|
TERMUX_PKG_SRCURL=http://mosh.mit.edu/mosh-${TERMUX_PKG_VERSION}.tar.gz
|
||||||
_COMMIT=f30738e3256e90850e945c08624fce90b1ba78a1
|
_COMMIT=f30738e3256e90850e945c08624fce90b1ba78a1
|
||||||
TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/archive/${_COMMIT}.zip
|
TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/archive/${_COMMIT}.zip
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--- ../mosh/src/frontend/Makefile.am 2016-04-08 10:26:08.000000000 +1000
|
diff -u -r ../mosh-f30738e3256e90850e945c08624fce90b1ba78a1/src/frontend/Makefile.am ./src/frontend/Makefile.am
|
||||||
+++ ./src/frontend/Makefile.am 2016-04-29 00:42:03.147468293 +1000
|
--- ../mosh-f30738e3256e90850e945c08624fce90b1ba78a1/src/frontend/Makefile.am 2016-04-07 20:26:08.000000000 -0400
|
||||||
@@ -11,9 +11,14 @@
|
+++ ./src/frontend/Makefile.am 2016-05-02 01:20:09.868867123 -0400
|
||||||
|
@@ -11,9 +11,15 @@
|
||||||
bin_PROGRAMS += mosh-client
|
bin_PROGRAMS += mosh-client
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -14,4 +15,5 @@
|
|||||||
|
|
||||||
mosh_client_SOURCES = mosh-client.cc stmclient.cc stmclient.h terminaloverlay.cc terminaloverlay.h
|
mosh_client_SOURCES = mosh-client.cc stmclient.cc stmclient.h terminaloverlay.cc terminaloverlay.h
|
||||||
mosh_server_SOURCES = mosh-server.cc
|
mosh_server_SOURCES = mosh-server.cc
|
||||||
+mosh_cfront_SOURCES = mosh.cc pty.cc shittypty.h
|
+mosh_cfront_SOURCES = mosh.cc
|
||||||
|
+mosh_cfront_LDADD = -lutil
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
--- ../mosh/src/frontend/mosh.cc 2016-04-29 00:42:24.837700203 +1000
|
--- ../mosh/src/frontend/mosh.cc 2016-04-29 00:42:24.837700203 +1000
|
||||||
+++ ./src/frontend/mosh.cc 2016-04-29 00:40:13.346294286 +1000
|
+++ ./src/frontend/mosh.cc 2016-04-29 00:40:13.346294286 +1000
|
||||||
@@ -0,0 +1,521 @@
|
@@ -0,0 +1,519 @@
|
||||||
+// Mosh: the mobile shell
|
+// Mosh: the mobile shell
|
||||||
+// Copyright 2012 Keith Winstein
|
+// Copyright 2012 Keith Winstein
|
||||||
+//
|
+//
|
||||||
@ -47,8 +47,6 @@
|
|||||||
+#include <libutil.h>
|
+#include <libutil.h>
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
+#include "shittypty.h"
|
|
||||||
+
|
|
||||||
+#if !HAVE_GETLINE
|
+#if !HAVE_GETLINE
|
||||||
+ssize_t getline( char ** restrict linep,
|
+ssize_t getline( char ** restrict linep,
|
||||||
+ size_t * restrict linecapp,
|
+ size_t * restrict linecapp,
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
--- ../mosh/src/frontend/pty.cc 2016-04-29 00:42:37.207832463 +1000
|
|
||||||
+++ ./src/frontend/pty.cc 2016-04-29 00:40:31.306486322 +1000
|
|
||||||
@@ -0,0 +1,147 @@
|
|
||||||
+/*
|
|
||||||
+ Mosh: the mobile shell
|
|
||||||
+ Copyright 2012 Keith Winstein
|
|
||||||
+
|
|
||||||
+ This program is free software: you can redistribute it and/or modify
|
|
||||||
+ it under the terms of the GNU General Public License as published by
|
|
||||||
+ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
+ (at your option) any later version.
|
|
||||||
+
|
|
||||||
+ This program is distributed in the hope that it will be useful,
|
|
||||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ GNU General Public License for more details.
|
|
||||||
+
|
|
||||||
+ You should have received a copy of the GNU General Public License
|
|
||||||
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+*/
|
|
||||||
+
|
|
||||||
+#include "config.h"
|
|
||||||
+
|
|
||||||
+#include <sys/types.h>
|
|
||||||
+#include <sys/stat.h>
|
|
||||||
+#include <sys/ioctl.h>
|
|
||||||
+#include <fcntl.h>
|
|
||||||
+#include <termios.h>
|
|
||||||
+#include <unistd.h>
|
|
||||||
+#include <stdlib.h>
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <string.h>
|
|
||||||
+#include <pty.h>
|
|
||||||
+
|
|
||||||
+#ifndef HAVE_OPENPTY
|
|
||||||
+/* from dropbear 0.53.1 sshpty.c, original license: "can be used freely for any purpose." */
|
|
||||||
+int my_openpty (int *amaster, int *aslave, char *name, const struct termios *termp,
|
|
||||||
+ const struct winsize *winp)
|
|
||||||
+{
|
|
||||||
+ int master, slave;
|
|
||||||
+ char *name_slave;
|
|
||||||
+
|
|
||||||
+ master = open("/dev/ptmx", O_RDWR);
|
|
||||||
+ if (master == -1) {
|
|
||||||
+// TRACE(("Fail to open master"))
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (grantpt(master))
|
|
||||||
+ goto fail;
|
|
||||||
+
|
|
||||||
+ if (unlockpt(master))
|
|
||||||
+ goto fail;
|
|
||||||
+
|
|
||||||
+ name_slave = ptsname(master);
|
|
||||||
+// TRACE(("openpty: slave name %s", name_slave))
|
|
||||||
+ slave = open(name_slave, O_RDWR | O_NOCTTY);
|
|
||||||
+ if (slave == -1)
|
|
||||||
+ {
|
|
||||||
+ goto fail;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(termp)
|
|
||||||
+ tcsetattr(slave, TCSAFLUSH, termp);
|
|
||||||
+ if (winp)
|
|
||||||
+ ioctl (slave, TIOCSWINSZ, winp);
|
|
||||||
+
|
|
||||||
+ *amaster = master;
|
|
||||||
+ *aslave = slave;
|
|
||||||
+ if (name != NULL)
|
|
||||||
+ strcpy(name, name_slave);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+ fail:
|
|
||||||
+ close (master);
|
|
||||||
+ return -1;
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#ifndef HAVE_LOGIN_TTY
|
|
||||||
+/* from glibc 2.14, login/login_tty.c, under the BSD license */
|
|
||||||
+int login_tty(int fd)
|
|
||||||
+{
|
|
||||||
+ (void) setsid();
|
|
||||||
+#ifdef TIOCSCTTY
|
|
||||||
+ if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1)
|
|
||||||
+ return (-1);
|
|
||||||
+#else
|
|
||||||
+ {
|
|
||||||
+ /* This might work. */
|
|
||||||
+ char *fdname = ttyname (fd);
|
|
||||||
+ int newfd;
|
|
||||||
+ if (fdname)
|
|
||||||
+ {
|
|
||||||
+ if (fd != 0)
|
|
||||||
+ (void) close (0);
|
|
||||||
+ if (fd != 1)
|
|
||||||
+ (void) close (1);
|
|
||||||
+ if (fd != 2)
|
|
||||||
+ (void) close (2);
|
|
||||||
+ newfd = open (fdname, O_RDWR);
|
|
||||||
+ (void) close (newfd);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+ while (dup2(fd, 0) == -1 && errno == EBUSY)
|
|
||||||
+ ;
|
|
||||||
+ while (dup2(fd, 1) == -1 && errno == EBUSY)
|
|
||||||
+ ;
|
|
||||||
+ while (dup2(fd, 2) == -1 && errno == EBUSY)
|
|
||||||
+ ;
|
|
||||||
+ if (fd > 2)
|
|
||||||
+ (void) close(fd);
|
|
||||||
+ return (0);
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+int my_forkpty (int *amaster, char *name, const struct termios *termp, const struct winsize *winp) {
|
|
||||||
+#ifdef HAVE_FORKPTY
|
|
||||||
+//return forkpty(amaster, name, termp, winp);
|
|
||||||
+#else
|
|
||||||
+/* from glibc 2.14, login/forkpty.c, under the LGPL 2.1 (or later) license */
|
|
||||||
+ int master, slave, pid;
|
|
||||||
+
|
|
||||||
+ if (openpty (&master, &slave, name, termp, winp) == -1)
|
|
||||||
+ return -1;
|
|
||||||
+
|
|
||||||
+ switch (pid = fork ())
|
|
||||||
+ {
|
|
||||||
+ case -1:
|
|
||||||
+ close (master);
|
|
||||||
+ close (slave);
|
|
||||||
+ return -1;
|
|
||||||
+ case 0:
|
|
||||||
+ /* Child. */
|
|
||||||
+ close (master);
|
|
||||||
+ if (login_tty (slave))
|
|
||||||
+ _exit (1);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+ default:
|
|
||||||
+ /* Parent. */
|
|
||||||
+ *amaster = master;
|
|
||||||
+ close (slave);
|
|
||||||
+
|
|
||||||
+ return pid;
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+}
|
|
@ -1,38 +0,0 @@
|
|||||||
--- ../mosh/src/frontend/shittypty.h 2016-04-29 00:42:50.787977659 +1000
|
|
||||||
+++ ./src/frontend/shittypty.h 2016-04-29 00:40:48.256667557 +1000
|
|
||||||
@@ -0,0 +1,35 @@
|
|
||||||
+/*
|
|
||||||
+ Mosh: the mobile shell
|
|
||||||
+ Copyright 2012 Keith Winstein
|
|
||||||
+
|
|
||||||
+ This program is free software: you can redistribute it and/or modify
|
|
||||||
+ it under the terms of the GNU General Public License as published by
|
|
||||||
+ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
+ (at your option) any later version.
|
|
||||||
+
|
|
||||||
+ This program is distributed in the hope that it will be useful,
|
|
||||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ GNU General Public License for more details.
|
|
||||||
+
|
|
||||||
+ You should have received a copy of the GNU General Public License
|
|
||||||
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+*/
|
|
||||||
+
|
|
||||||
+#ifndef PTY_HPP
|
|
||||||
+#define PTY_HPP
|
|
||||||
+
|
|
||||||
+#include "config.h"
|
|
||||||
+
|
|
||||||
+#ifndef HAVE_FORKPTY
|
|
||||||
+#define forkpty my_forkpty
|
|
||||||
+int my_forkpty (int *amaster, char *name, const struct termios *termp, const struct winsize *winp);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#ifndef HAVE_OPENPTY
|
|
||||||
+#define openpty my_openpty
|
|
||||||
+int my_openpty (int *amaster, int *aslave, char *name, const struct termios *termp,
|
|
||||||
+ const struct winsize *winp);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#endif
|
|
Loading…
Reference in New Issue
Block a user