From: Kern Sibbald Date: Fri, 8 Aug 2003 14:45:18 +0000 (+0000) Subject: Use bpipe for shell expansion X-Git-Tag: Release-1.32~55 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ee69b43a885958047271953c32ba04e22141c04e;p=bacula%2Fbacula Use bpipe for shell expansion git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@664 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 32472f5bd9..77a2fa55be 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -261,7 +261,7 @@ static void do_director_status(UAContext *ua, char *cmd) msg = _("is waiting on max Job jobs"); break; case JS_WaitPriority: - msg = _("is waiting on for higher priority jobs to finish"); + msg = _("is waiting for higher priority jobs to finish"); break; case JS_WaitMaxJobs: msg = _("is waiting on max total jobs"); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 0ef5a59c29..0692003c97 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -300,113 +300,45 @@ char *encode_mode(mode_t mode, char *buf) int do_shell_expansion(char *name, int name_len) { -/* ****FIXME***** this should work for Win32 too */ -#define UNIX -#ifdef UNIX -#ifndef PATH_MAX -#define PATH_MAX 512 -#endif - - int pid, wpid, stat; - int waitstatus; - char *shellcmd; - int i; - char echout[PATH_MAX + 256]; - int pfd[2]; static char meta[] = "~\\$[]*?`'<>\""; - int found = FALSE; - int len; + bool found = false; + int len, i, stat; + POOLMEM *cmd; + BPIPE *bpipe; + char line[MAXSTRING]; + char *shellcmd; /* Check if any meta characters are present */ len = strlen(meta); for (i = 0; i < len; i++) { if (strchr(name, meta[i])) { - found = TRUE; + found = true; break; } } - stat = 0; if (found) { -#ifdef nt - /* If the filename appears to be a DOS filename, - convert all backward slashes \ to Unix path - separators / and insert a \ infront of spaces. */ - len = strlen(name); - if (len >= 3 && name[1] == ':' && name[2] == '\\') { - for (i=2; i 0) { - echout[--i] = 0; /* set end of string */ - /* look for first line. */ - while (--i >= 0) { - if (echout[i] == '\n') { - echout[i] = 0; /* keep only first one */ - } - } - } - /* wait for child to exit */ - while ((wpid = wait(&waitstatus)) != pid && wpid != -1) - { ; } - strip_trailing_junk(echout); - if (strlen(echout) > 0) { - bstrncpy(name, echout, name_len); - } - stat = 1; - break; - } - close(pfd[0]); /* close pipe */ - close(pfd[1]); -#endif /* nt */ - } - return stat; - -#endif /* UNIX */ - -#if MSC | MSDOS | __WATCOMC__ - - char prefix[100], *env, *getenv(); - - /* Home directory reference? */ - if (*name == '~' && (env=getenv("HOME"))) { - strcpy(prefix, env); /* copy HOME directory name */ - name++; /* skip over ~ in name */ - strcat(prefix, name); - name--; /* get back to beginning */ - strcpy(name, prefix); /* move back into name */ + cmd = get_pool_memory(PM_FNAME); + /* look for shell */ + if ((shellcmd = getenv("SHELL")) == NULL) { + shellcmd = "/bin/sh"; + } + pm_strcpy(&cmd, shellcmd); + pm_strcat(&cmd, " -c \"echo "); + pm_strcat(&cmd, name); + pm_strcat(&cmd, "\""); + Dmsg1(400, "Send: %s\n", cmd); + bpipe = open_bpipe(cmd, 0, "r"); + *line = 0; + fgets(line, sizeof(line), bpipe->rfd); + strip_trailing_junk(line); + stat = close_bpipe(bpipe); + Dmsg2(400, "stat=%d got: %s\n", stat, line); + free_pool_memory(cmd); + if (stat == 0) { + bstrncpy(name, line, name_len); + } } return 1; -#endif - } diff --git a/bacula/src/version.h b/bacula/src/version.h index e1efc7f45b..d7fe9dad08 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ -#define VERSION "1.31b" +#define VERSION "1.32" #define VSTRING "1" -#define BDATE "03 Aug 2003" -#define LSMDATE "03Aug03" +#define BDATE "08 Aug 2003" +#define LSMDATE "08Aug03" /* Debug flags */ #define DEBUG 1