|
|
c88ac0 |
From 2bae8ecf04ec2ba6bb9f0af5b80485dd0edb427d Mon Sep 17 00:00:00 2001
|
|
|
c88ac0 |
From: Florian Weimer <fweimer@redhat.com>
|
|
|
c88ac0 |
Date: Mon, 17 Nov 2014 12:48:25 +0100
|
|
|
c88ac0 |
Subject: [PATCH 3/4] fio.c: Unconditionally require wordexp support
|
|
|
c88ac0 |
|
|
|
c88ac0 |
---
|
|
|
c88ac0 |
fio.c | 67 +++++--------------------------------------------------------------
|
|
|
c88ac0 |
1 file changed, 5 insertions(+), 62 deletions(-)
|
|
|
c88ac0 |
|
|
|
c88ac0 |
diff --git a/fio.c b/fio.c
|
|
|
c88ac0 |
index 65e8f10..1529236 100644
|
|
|
c88ac0 |
--- a/fio.c
|
|
|
c88ac0 |
+++ b/fio.c
|
|
|
c88ac0 |
@@ -43,12 +43,15 @@ static char sccsid[] = "@(#)fio.c 2.76 (gritter) 9/16/09";
|
|
|
c88ac0 |
#endif /* not lint */
|
|
|
c88ac0 |
|
|
|
c88ac0 |
#include "rcv.h"
|
|
|
c88ac0 |
+
|
|
|
c88ac0 |
+#ifndef HAVE_WORDEXP
|
|
|
c88ac0 |
+#error wordexp support is required
|
|
|
c88ac0 |
+#endif
|
|
|
c88ac0 |
+
|
|
|
c88ac0 |
#include <sys/stat.h>
|
|
|
c88ac0 |
#include <sys/file.h>
|
|
|
c88ac0 |
#include <sys/wait.h>
|
|
|
c88ac0 |
-#ifdef HAVE_WORDEXP
|
|
|
c88ac0 |
#include <wordexp.h>
|
|
|
c88ac0 |
-#endif /* HAVE_WORDEXP */
|
|
|
c88ac0 |
#include <unistd.h>
|
|
|
c88ac0 |
|
|
|
c88ac0 |
#if defined (USE_NSS)
|
|
|
c88ac0 |
@@ -481,7 +484,6 @@ next:
|
|
|
c88ac0 |
static char *
|
|
|
c88ac0 |
globname(char *name)
|
|
|
c88ac0 |
{
|
|
|
c88ac0 |
-#ifdef HAVE_WORDEXP
|
|
|
c88ac0 |
wordexp_t we;
|
|
|
c88ac0 |
char *cp;
|
|
|
c88ac0 |
sigset_t nset;
|
|
|
c88ac0 |
@@ -527,65 +529,6 @@ globname(char *name)
|
|
|
c88ac0 |
}
|
|
|
c88ac0 |
wordfree(&we);
|
|
|
c88ac0 |
return cp;
|
|
|
c88ac0 |
-#else /* !HAVE_WORDEXP */
|
|
|
c88ac0 |
- char xname[PATHSIZE];
|
|
|
c88ac0 |
- char cmdbuf[PATHSIZE]; /* also used for file names */
|
|
|
c88ac0 |
- int pid, l;
|
|
|
c88ac0 |
- char *cp, *shell;
|
|
|
c88ac0 |
- int pivec[2];
|
|
|
c88ac0 |
- extern int wait_status;
|
|
|
c88ac0 |
- struct stat sbuf;
|
|
|
c88ac0 |
-
|
|
|
c88ac0 |
- if (pipe(pivec) < 0) {
|
|
|
c88ac0 |
- perror("pipe");
|
|
|
c88ac0 |
- return name;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- snprintf(cmdbuf, sizeof cmdbuf, "echo %s", name);
|
|
|
c88ac0 |
- if ((shell = value("SHELL")) == NULL)
|
|
|
c88ac0 |
- shell = SHELL;
|
|
|
c88ac0 |
- pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NULL);
|
|
|
c88ac0 |
- if (pid < 0) {
|
|
|
c88ac0 |
- close(pivec[0]);
|
|
|
c88ac0 |
- close(pivec[1]);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- close(pivec[1]);
|
|
|
c88ac0 |
-again:
|
|
|
c88ac0 |
- l = read(pivec[0], xname, sizeof xname);
|
|
|
c88ac0 |
- if (l < 0) {
|
|
|
c88ac0 |
- if (errno == EINTR)
|
|
|
c88ac0 |
- goto again;
|
|
|
c88ac0 |
- perror("read");
|
|
|
c88ac0 |
- close(pivec[0]);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- close(pivec[0]);
|
|
|
c88ac0 |
- if (wait_child(pid) < 0 && WTERMSIG(wait_status) != SIGPIPE) {
|
|
|
c88ac0 |
- fprintf(stderr, catgets(catd, CATSET, 81,
|
|
|
c88ac0 |
- "\"%s\": Expansion failed.\n"), name);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- if (l == 0) {
|
|
|
c88ac0 |
- fprintf(stderr, catgets(catd, CATSET, 82,
|
|
|
c88ac0 |
- "\"%s\": No match.\n"), name);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- if (l == sizeof xname) {
|
|
|
c88ac0 |
- fprintf(stderr, catgets(catd, CATSET, 83,
|
|
|
c88ac0 |
- "\"%s\": Expansion buffer overflow.\n"), name);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- xname[l] = 0;
|
|
|
c88ac0 |
- for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
|
|
|
c88ac0 |
- ;
|
|
|
c88ac0 |
- cp[1] = '\0';
|
|
|
c88ac0 |
- if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) {
|
|
|
c88ac0 |
- fprintf(stderr, catgets(catd, CATSET, 84,
|
|
|
c88ac0 |
- "\"%s\": Ambiguous.\n"), name);
|
|
|
c88ac0 |
- return NULL;
|
|
|
c88ac0 |
- }
|
|
|
c88ac0 |
- return savestr(xname);
|
|
|
c88ac0 |
-#endif /* !HAVE_WORDEXP */
|
|
|
c88ac0 |
}
|
|
|
c88ac0 |
|
|
|
c88ac0 |
/*
|
|
|
c88ac0 |
--
|
|
|
c88ac0 |
1.9.3
|
|
|
c88ac0 |
|