summaryrefslogtreecommitdiff
path: root/src/cli_new.c
diff options
context:
space:
mode:
authorMichael Larson <mike@vyatta.com>2010-11-24 23:11:39 -0800
committerMichael Larson <mike@vyatta.com>2010-11-24 23:11:39 -0800
commit792d6aa0dd0ecfd45c9b5ab57c6c0cb71a9b8da6 (patch)
tree3bf70dc29cbcc43ffbc8ec95a028a1a25ead188b /src/cli_new.c
parentcc525741b011f70a9841b9f0f6341dfc2d52819b (diff)
downloadvyatta-cfg-792d6aa0dd0ecfd45c9b5ab57c6c0cb71a9b8da6.tar.gz
vyatta-cfg-792d6aa0dd0ecfd45c9b5ab57c6c0cb71a9b8da6.zip
implementation of err location support for commit process. commit failures will now look different (via cli):
vyatta@vyatta# commit [ service nat ] NAT configuration error: rule type not specified/valid [ system domain-search domain ] System configuration error. Both 'domain-name' and 'domain-search' are specified, but only one of these mutually exclusive parameters is allowed. [ load-balancing wan ] WARNING: A valid WAN load-balance configuration requires an interface with a nexthop Commit failed Location of error will now be supplied on each failure, with the option to override the script node location.
Diffstat (limited to 'src/cli_new.c')
-rw-r--r--src/cli_new.c61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/cli_new.c b/src/cli_new.c
index 1ac99a1..065d62c 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -2535,49 +2535,46 @@ old_system_out(const char *command)
}
int
-system_out(const char *cmd, const char **outbuf)
-{
- // fprintf(out_stream,"system out\n");
- if (outbuf == NULL) {
- return old_system_out(cmd);
- }
-
- if (cmd == NULL) {
- return -1;
- }
-
- int cp[2]; // Child to parent pipe
-
- if( pipe(cp) < 0) {
- return -1;
- }
-
- pid_t pid = fork();
- if (pid == 0) {
- //child
- close(1); // Close current stdout./
- dup2( cp[1],1); // Make stdout go to write end of pipe.
- dup2( cp[1],2); // Make stderr go to write end of pipe.
- close(0); // Close current stdin.
- close( cp[0]);
-
- int ret = 0;
- if (execl("/bin/sh","sh","-c",cmd,NULL) == -1) {
+system_out(const char *cmd, const char **outbuf)
+{
+ // fprintf(out_stream,"system out\n");
+ if (outbuf == NULL) {
+ return old_system_out(cmd);
+ }
+ if (cmd == NULL) {
+ return -1;
+ }
+
+ int cp[2]; // Child to parent pipe
+ if( pipe(cp) < 0) { return -1;
+ }
+
+ pid_t pid = fork();
+ if (pid == 0) {
+ //child
+ close(1); // Close current stdout./
+ dup2(cp[1],1); // Make stdout go to write end of pipe.
+ dup2(cp[1],2); // Make stderr go to write end of pipe.
+ close(0); // Close current stdin.
+ close(cp[0]);
+ close(cp[1]);
+ int ret = 0;
+ if (execl("/bin/sh","sh","-c",cmd,NULL) == -1) {
ret = errno;
}
- close( cp[1]);
+ close(cp[1]);
exit(ret);
}
else {
- //parent
+ //parent
char buf[1025];
memset(buf,'\0',1025);
close(cp[1]);
- if (read(cp[0], &buf, 1024) > 0) {
+ while (read(cp[0], &buf, 1024) > 0) {
strcat((char*)*outbuf,buf);
}
- //now wait on child to kick the bucket
+ //now wait on child to kick the bucket
int status;
wait(&status);
close(cp[0]);