[PATCH] remove '\n' from end of callout return
remove possible newline at end of callout output, for easier matching with ID=
This commit is contained in:
parent
5a3ee97760
commit
2052464275
11
namedev.c
11
namedev.c
|
@ -264,7 +264,7 @@ static int exec_callout(struct config_device *dev, char *value, int len)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int value_set = 0;
|
int value_set = 0;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char *arg;
|
char *pos;
|
||||||
char *args[CALLOUT_MAXARG];
|
char *args[CALLOUT_MAXARG];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -286,9 +286,9 @@ static int exec_callout(struct config_device *dev, char *value, int len)
|
||||||
dup(fds[1]); /* dup write side of pipe to STDOUT */
|
dup(fds[1]); /* dup write side of pipe to STDOUT */
|
||||||
if (strchr(dev->exec_program, ' ')) {
|
if (strchr(dev->exec_program, ' ')) {
|
||||||
/* callout with arguments */
|
/* callout with arguments */
|
||||||
arg = dev->exec_program;
|
pos = dev->exec_program;
|
||||||
for (i=0; i < CALLOUT_MAXARG-1; i++) {
|
for (i=0; i < CALLOUT_MAXARG-1; i++) {
|
||||||
args[i] = strsep(&arg, " ");
|
args[i] = strsep(&pos, " ");
|
||||||
if (args[i] == NULL)
|
if (args[i] == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -324,9 +324,12 @@ static int exec_callout(struct config_device *dev, char *value, int len)
|
||||||
} else {
|
} else {
|
||||||
value_set = 1;
|
value_set = 1;
|
||||||
strncpy(value, buffer, len);
|
strncpy(value, buffer, len);
|
||||||
|
pos = value + strlen(value)-1;
|
||||||
|
if (pos[0] == '\n')
|
||||||
|
pos[0] = '\0';
|
||||||
|
dbg("callout returned '%s'", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg("callout returned '%s'", value);
|
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
res = wait(&status);
|
res = wait(&status);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
|
|
Loading…
Reference in New Issue