mirror of
https://github.com/troglobit/finit.git
synced 2026-11-27 20:48:24 +00:00
Improve error messages for failing wordexp()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
41319a8cf8
commit
5e37f94775
1 file changed
+8
-4
+8
-4
@@ -486,8 +486,8 @@ static int service_start(svc_t *svc)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ((rc = wordexp(svc->cmd, &we, 0))) {
|
if ((rc = wordexp(svc->cmd, &we, 0))) {
|
||||||
|
_e("%s: failed wordexp(%s): %d", svc->cmd, svc->cmd, rc);
|
||||||
nomem:
|
nomem:
|
||||||
_e("%s: failed wordexp(): %d", svc->cmd, rc);
|
|
||||||
wordfree(&we);
|
wordfree(&we);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ static int service_start(svc_t *svc)
|
|||||||
for (i = 0; i < MAX_NUM_SVC_ARGS; i++) {
|
for (i = 0; i < MAX_NUM_SVC_ARGS; i++) {
|
||||||
char *arg = svc->args[i];
|
char *arg = svc->args[i];
|
||||||
size_t len = strlen(arg);
|
size_t len = strlen(arg);
|
||||||
char str[len + 2] = {0};
|
char str[len + 2];
|
||||||
char ch = *arg;
|
char ch = *arg;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
@@ -508,11 +508,15 @@ static int service_start(svc_t *svc)
|
|||||||
* XXX: escapes only leading characters ...
|
* XXX: escapes only leading characters ...
|
||||||
*/
|
*/
|
||||||
if (strchr("|<>&:", ch))
|
if (strchr("|<>&:", ch))
|
||||||
str[0] = '\\';
|
sprintf(str, "\\");
|
||||||
|
else
|
||||||
|
str[0] = 0;
|
||||||
strlcat(str, arg, sizeof(str));
|
strlcat(str, arg, sizeof(str));
|
||||||
|
|
||||||
if ((rc = wordexp(str, &we, WRDE_APPEND)))
|
if ((rc = wordexp(str, &we, WRDE_APPEND))) {
|
||||||
|
_e("%s: failed wordexp(%s): %d", svc->cmd, str, rc);
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (we.we_wordc > MAX_NUM_SVC_ARGS) {
|
if (we.we_wordc > MAX_NUM_SVC_ARGS) {
|
||||||
|
|||||||
Reference in new issue
Block a user