Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 2bae8ecf04ec2ba6bb9f0af5b80485dd0edb427d Mon Sep 17 00:00:00 2001 |
| 2 | From: Florian Weimer <fweimer@redhat.com> |
| 3 | Date: Mon, 17 Nov 2014 12:48:25 +0100 |
| 4 | Subject: [PATCH 3/4] fio.c: Unconditionally require wordexp support |
| 5 | |
| 6 | This patch is taken from |
| 7 | ftp://ftp.debian.org/debian/pool/main/h/heirloom-mailx/heirloom-mailx_12.5-5.debian.tar.xz |
| 8 | |
| 9 | Upstream-Status: Inappropriate [upstream is dead] |
| 10 | --- |
| 11 | fio.c | 67 +++++-------------------------------------------------------------- |
| 12 | 1 file changed, 5 insertions(+), 62 deletions(-) |
| 13 | |
| 14 | diff --git a/fio.c b/fio.c |
| 15 | index 65e8f10..1529236 100644 |
| 16 | --- a/fio.c |
| 17 | +++ b/fio.c |
| 18 | @@ -43,12 +43,15 @@ static char sccsid[] = "@(#)fio.c 2.76 (gritter) 9/16/09"; |
| 19 | #endif /* not lint */ |
| 20 | |
| 21 | #include "rcv.h" |
| 22 | + |
| 23 | +#ifndef HAVE_WORDEXP |
| 24 | +#error wordexp support is required |
| 25 | +#endif |
| 26 | + |
| 27 | #include <sys/stat.h> |
| 28 | #include <sys/file.h> |
| 29 | #include <sys/wait.h> |
| 30 | -#ifdef HAVE_WORDEXP |
| 31 | #include <wordexp.h> |
| 32 | -#endif /* HAVE_WORDEXP */ |
| 33 | #include <unistd.h> |
| 34 | |
| 35 | #if defined (USE_NSS) |
| 36 | @@ -481,7 +484,6 @@ next: |
| 37 | static char * |
| 38 | globname(char *name) |
| 39 | { |
| 40 | -#ifdef HAVE_WORDEXP |
| 41 | wordexp_t we; |
| 42 | char *cp; |
| 43 | sigset_t nset; |
| 44 | @@ -527,65 +529,6 @@ globname(char *name) |
| 45 | } |
| 46 | wordfree(&we); |
| 47 | return cp; |
| 48 | -#else /* !HAVE_WORDEXP */ |
| 49 | - char xname[PATHSIZE]; |
| 50 | - char cmdbuf[PATHSIZE]; /* also used for file names */ |
| 51 | - int pid, l; |
| 52 | - char *cp, *shell; |
| 53 | - int pivec[2]; |
| 54 | - extern int wait_status; |
| 55 | - struct stat sbuf; |
| 56 | - |
| 57 | - if (pipe(pivec) < 0) { |
| 58 | - perror("pipe"); |
| 59 | - return name; |
| 60 | - } |
| 61 | - snprintf(cmdbuf, sizeof cmdbuf, "echo %s", name); |
| 62 | - if ((shell = value("SHELL")) == NULL) |
| 63 | - shell = SHELL; |
| 64 | - pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NULL); |
| 65 | - if (pid < 0) { |
| 66 | - close(pivec[0]); |
| 67 | - close(pivec[1]); |
| 68 | - return NULL; |
| 69 | - } |
| 70 | - close(pivec[1]); |
| 71 | -again: |
| 72 | - l = read(pivec[0], xname, sizeof xname); |
| 73 | - if (l < 0) { |
| 74 | - if (errno == EINTR) |
| 75 | - goto again; |
| 76 | - perror("read"); |
| 77 | - close(pivec[0]); |
| 78 | - return NULL; |
| 79 | - } |
| 80 | - close(pivec[0]); |
| 81 | - if (wait_child(pid) < 0 && WTERMSIG(wait_status) != SIGPIPE) { |
| 82 | - fprintf(stderr, catgets(catd, CATSET, 81, |
| 83 | - "\"%s\": Expansion failed.\n"), name); |
| 84 | - return NULL; |
| 85 | - } |
| 86 | - if (l == 0) { |
| 87 | - fprintf(stderr, catgets(catd, CATSET, 82, |
| 88 | - "\"%s\": No match.\n"), name); |
| 89 | - return NULL; |
| 90 | - } |
| 91 | - if (l == sizeof xname) { |
| 92 | - fprintf(stderr, catgets(catd, CATSET, 83, |
| 93 | - "\"%s\": Expansion buffer overflow.\n"), name); |
| 94 | - return NULL; |
| 95 | - } |
| 96 | - xname[l] = 0; |
| 97 | - for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--) |
| 98 | - ; |
| 99 | - cp[1] = '\0'; |
| 100 | - if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) { |
| 101 | - fprintf(stderr, catgets(catd, CATSET, 84, |
| 102 | - "\"%s\": Ambiguous.\n"), name); |
| 103 | - return NULL; |
| 104 | - } |
| 105 | - return savestr(xname); |
| 106 | -#endif /* !HAVE_WORDEXP */ |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | -- |
| 111 | 1.9.3 |
| 112 | |
| 113 | |