unrar: rewrite getpass() so password will not be echoed
This commit is contained in:
parent
08c7415f52
commit
c0823dfbf4
@ -3,6 +3,6 @@ TERMUX_PKG_DESCRIPTION="Tool for extracting files from .rar archives"
|
|||||||
TERMUX_PKG_VERSION=5.5.8
|
TERMUX_PKG_VERSION=5.5.8
|
||||||
TERMUX_PKG_SRCURL=http://www.rarlab.com/rar/unrarsrc-${TERMUX_PKG_VERSION}.tar.gz
|
TERMUX_PKG_SRCURL=http://www.rarlab.com/rar/unrarsrc-${TERMUX_PKG_VERSION}.tar.gz
|
||||||
TERMUX_PKG_SHA256=9b66e4353a9944bc140eb2a919ff99482dd548f858f5e296d809e8f7cdb2fcf4
|
TERMUX_PKG_SHA256=9b66e4353a9944bc140eb2a919ff99482dd548f858f5e296d809e8f7cdb2fcf4
|
||||||
TERMUX_PKG_DEPENDS="libandroid-support"
|
TERMUX_PKG_DEPENDS="libandroid-support,readline"
|
||||||
TERMUX_PKG_FOLDERNAME=unrar
|
TERMUX_PKG_FOLDERNAME=unrar
|
||||||
TERMUX_PKG_BUILD_IN_SRC=yes
|
TERMUX_PKG_BUILD_IN_SRC=yes
|
||||||
|
47
packages/unrar/getpass.patch
Normal file
47
packages/unrar/getpass.patch
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
diff -uNr unrar.mod/consio.cpp unrar.mod2/consio.cpp
|
||||||
|
--- unrar.mod/consio.cpp 2017-08-11 16:56:22.000000000 +0300
|
||||||
|
+++ unrar.mod2/consio.cpp 2017-09-14 20:34:17.247733000 +0300
|
||||||
|
@@ -1,6 +1,10 @@
|
||||||
|
#include "rar.hpp"
|
||||||
|
#include "log.cpp"
|
||||||
|
|
||||||
|
+// For getpass()
|
||||||
|
+#include <termios.h>
|
||||||
|
+#include <readline/readline.h>
|
||||||
|
+
|
||||||
|
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
|
||||||
|
static RAR_CHARSET RedirectCharset=RCH_DEFAULT;
|
||||||
|
|
||||||
|
@@ -57,6 +61,32 @@
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SILENT
|
||||||
|
+#ifdef __ANDROID__
|
||||||
|
+char* getpass(const char *prompt) {
|
||||||
|
+ struct termios term_old, term_new;
|
||||||
|
+ int nread;
|
||||||
|
+
|
||||||
|
+ /* Turn echoing off and fail if we can't. */
|
||||||
|
+ if (tcgetattr (0, &term_old) != 0) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ term_new = term_old;
|
||||||
|
+ term_new.c_lflag &= ~ECHO;
|
||||||
|
+
|
||||||
|
+ if (tcsetattr (0, TCSAFLUSH, &term_new) != 0) {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Read the password. */
|
||||||
|
+ char *password = readline(prompt);
|
||||||
|
+
|
||||||
|
+ /* Restore terminal. */
|
||||||
|
+ (void) tcsetattr (0, TCSAFLUSH, &term_old);
|
||||||
|
+
|
||||||
|
+ return password;
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
static void cvt_wprintf(FILE *dest,const wchar *fmt,va_list arglist)
|
||||||
|
{
|
||||||
|
// This buffer is for format string only, not for entire output,
|
@ -1,7 +1,7 @@
|
|||||||
diff -uNr unrar/makefile unrar.mod/makefile
|
diff -uNr unrar/makefile unrar.mod/makefile
|
||||||
--- unrar/makefile 2017-06-13 14:04:49.000000000 +0300
|
--- unrar/makefile 2017-06-13 14:04:49.000000000 +0300
|
||||||
+++ unrar.mod/makefile 2017-09-14 20:19:46.976412521 +0300
|
+++ unrar.mod/makefile 2017-09-14 20:40:07.511902817 +0300
|
||||||
@@ -2,14 +2,14 @@
|
@@ -2,14 +2,15 @@
|
||||||
# Makefile for UNIX - unrar
|
# Makefile for UNIX - unrar
|
||||||
|
|
||||||
# Linux using GCC
|
# Linux using GCC
|
||||||
@ -20,6 +20,7 @@ diff -uNr unrar/makefile unrar.mod/makefile
|
|||||||
+AR?=ar
|
+AR?=ar
|
||||||
+LDFLAGS?=-pthread
|
+LDFLAGS?=-pthread
|
||||||
+DESTDIR=$(PREFIX)
|
+DESTDIR=$(PREFIX)
|
||||||
|
+LIBS=-lreadline
|
||||||
|
|
||||||
# Linux using LCC
|
# Linux using LCC
|
||||||
#CXX=lcc
|
#CXX=lcc
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
diff -u -r ../unrar/consio.cpp ./consio.cpp
|
|
||||||
--- ../unrar/consio.cpp 2013-12-01 09:10:14.000000000 +0100
|
|
||||||
+++ ./consio.cpp 2014-02-13 00:27:45.000000000 +0100
|
|
||||||
@@ -144,6 +144,20 @@
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SILENT
|
|
||||||
+#ifdef __ANDROID__
|
|
||||||
+static char* getpass(const char* prompt) {
|
|
||||||
+ static char chars[128];
|
|
||||||
+ int len = 0;
|
|
||||||
+ while (true) {
|
|
||||||
+ char c = fgetc(stdin);
|
|
||||||
+ if (c == '\r' || c == '\n' || c == 0) break;
|
|
||||||
+ chars[len++] = c;
|
|
||||||
+ if (len == sizeof(chars)-1) break;
|
|
||||||
+ }
|
|
||||||
+ chars[len] = 0;
|
|
||||||
+ return chars;
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
static void GetPasswordText(wchar *Str,uint MaxLength)
|
|
||||||
{
|
|
||||||
if (MaxLength==0)
|
|
Loading…
Reference in New Issue
Block a user