From bed92e102b85a5502c4f6f84f912fae16c6d9bb3 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 12 Feb 1999 00:52:30 +0000 Subject: When executing a command as part of a dial/login/hangup script, expand words in the same way as !bg does. --- usr.sbin/ppp/chat.c | 15 +++++++++------ usr.sbin/ppp/ppp.8 | 7 ++++++- usr.sbin/ppp/ppp.8.m4 | 7 ++++++- 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index 6fda79e..ad56a01 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.52 1998/10/27 22:53:25 brian Exp $ + * $Id: chat.c,v 1.53 1999/01/28 01:56:31 brian Exp $ */ #include @@ -65,6 +65,7 @@ #include "ipcp.h" #include "filter.h" #include "cbcp.h" +#include "command.h" #include "datalink.h" #ifndef NORADIUS #include "radius.h" @@ -724,11 +725,13 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) { pid_t pid; int fids[2]; - char *vector[MAXARGS], *startout, *endout; - int stat, nb; + char *argv[MAXARGS], *vector[MAXARGS], *startout, *endout; + int stat, nb, argc; log_Printf(LogCHAT, "Exec: %s\n", command); - MakeArgs(command, vector, VECSIZE(vector)); + argc = MakeArgs(command, vector, VECSIZE(vector)); + command_Expand(argv, argc, (char const *const *)vector, + physical->dl->bundle, 0); if (pipe(fids) < 0) { log_Printf(LogCHAT, "Unable to create pipe in ExecStr: %s\n", @@ -749,8 +752,8 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) else fcntl(3, F_SETFD, 1); /* Set close-on-exec flag */ setuid(geteuid()); - execvp(vector[0], vector); - fprintf(stderr, "execvp failed: %s: %s\n", vector[0], strerror(errno)); + execvp(argv[0], argv); + fprintf(stderr, "execvp: %s: %s\n", argv[0], strerror(errno)); exit(127); } else { char *name = strdup(vector[0]); diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 437f168..7558438 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.145 1999/02/11 10:14:08 brian Exp $ +.\" $Id: ppp.8,v 1.146 1999/02/11 16:34:15 brian Exp $ .Dd 20 September 1995 .nr XX \w'\fC00' .Os FreeBSD @@ -3262,6 +3262,11 @@ This, of course means that it is possible to execute an entirely external command rather than using the internal one. See .Xr chat 8 for a good alternative. +.Pp +The external command that is executed is subjected to the same special +word expansions as the +.Dq !bg +command. .It set enddisc Op label|IP|MAC|magic|psn value This command sets our local endpoint discriminator. If set prior to LCP negotiation, diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 437f168..7558438 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.145 1999/02/11 10:14:08 brian Exp $ +.\" $Id: ppp.8,v 1.146 1999/02/11 16:34:15 brian Exp $ .Dd 20 September 1995 .nr XX \w'\fC00' .Os FreeBSD @@ -3262,6 +3262,11 @@ This, of course means that it is possible to execute an entirely external command rather than using the internal one. See .Xr chat 8 for a good alternative. +.Pp +The external command that is executed is subjected to the same special +word expansions as the +.Dq !bg +command. .It set enddisc Op label|IP|MAC|magic|psn value This command sets our local endpoint discriminator. If set prior to LCP negotiation, -- cgit v1.1