From f1d0fab3acc99d329deb0338fc51921e32fbe6f4 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Mon, 5 Oct 2009 18:22:03 -0700 Subject: opkg: Don't prompt for user input from stdin if it's not a tty. Also fixes a minor memory leak while we're at it, as the code was strdup'ing the malloc'd string read from stdin without ever freeing the original. Signed-off-by: Chris Larson --- recipes/opkg/opkg.inc | 5 ++-- recipes/opkg/opkg/isatty.patch | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 recipes/opkg/opkg/isatty.patch (limited to 'recipes/opkg') diff --git a/recipes/opkg/opkg.inc b/recipes/opkg/opkg.inc index c146c75b79..aa91955c3a 100644 --- a/recipes/opkg/opkg.inc +++ b/recipes/opkg/opkg.inc @@ -4,13 +4,14 @@ SECTION = "base" LICENSE = "GPL" DEPENDS = "curl gpgme" PV = "0.1.6+svnr${SRCREV}" -INC_PR = "r15" +INC_PR = "r16" FILESPATHPKG =. "opkg:" SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \ file://opkg_unarchive.patch;patch=1;maxrev=201 \ - file://opkg-intercept-cleanup.patch;patch=1" + file://opkg-intercept-cleanup.patch;patch=1 \ + file://isatty.patch;patch=1" SRC_URI += "file://configure" diff --git a/recipes/opkg/opkg/isatty.patch b/recipes/opkg/opkg/isatty.patch new file mode 100644 index 0000000000..c935f153d1 --- /dev/null +++ b/recipes/opkg/opkg/isatty.patch @@ -0,0 +1,64 @@ +Copyright (c) 2009 MontaVista Software, Inc. All rights reserved. + +Don't prompt for user input from stdin if it's not a tty. Fixes a minor +memory leak while we're at it, as the code was strdup'ing the malloc'd string +read from stdin without ever freeing the original. +--- + libopkg/libopkg.c | 13 ++++++++----- + libopkg/opkg_install.c | 3 +++ + libopkg/user.c | 10 +++++++--- + 3 files changed, 18 insertions(+), 8 deletions(-) + +--- trunk.orig/libopkg/libopkg.c ++++ trunk/libopkg/libopkg.c +@@ -71,11 +71,14 @@ int default_opkg_status_callback(char *n + char* default_opkg_response_callback(char *question) + { + char *response = NULL; +- printf("%s",question); +- fflush(stdout); +- do { +- response = (char *)file_read_line_alloc(stdin); +- } while (response == NULL); ++ if (isatty(fileno(stdin))) ++ { ++ printf("%s",question); ++ fflush(stdout); ++ do { ++ response = (char *)file_read_line_alloc(stdin); ++ } while (response == NULL); ++ } + return response; + } + +--- trunk.orig/libopkg/user.c ++++ trunk/libopkg/user.c +@@ -44,9 +44,13 @@ char *get_user_response(const char *form + len = vsnprintf(question,question_len,format,ap); + va_end(ap); + } while (len > question_len); +- response = strdup(opkg_cb_response(question)); +- str_chomp(response); +- str_tolower(response); ++ ++ response = opkg_cb_response(question); ++ if (response) ++ { ++ str_chomp(response); ++ str_tolower(response); ++ } + + return response; + } +--- trunk.orig/libopkg/opkg_install.c ++++ trunk/libopkg/opkg_install.c +@@ -1613,6 +1613,9 @@ static int user_prefers_old_conffile(con + " D : show the differences between the versions (if diff is installed)\n" + " The default action is to keep your current version.\n" + " *** %s (Y/I/N/O/D) [default=N] ? ", file_name, short_file_name); ++ if (!response) ++ return 1; ++ + if (strcmp(response, "y") == 0 + || strcmp(response, "i") == 0 + || strcmp(response, "yes") == 0) { -- cgit v1.2.3