237 ctx->data[ctx->datasize] = '\0'; /* terminate last string */ |
237 ctx->data[ctx->datasize] = '\0'; /* terminate last string */ |
238 |
238 |
239 const char **args = unpackcmdargsnul(ctx); |
239 const char **args = unpackcmdargsnul(ctx); |
240 if (!args[0] || !args[1] || !args[2]) |
240 if (!args[0] || !args[1] || !args[2]) |
241 abortmsg("missing type or command or cwd in system request"); |
241 abortmsg("missing type or command or cwd in system request"); |
242 debugmsg("run '%s' at '%s'", args[1], args[2]); |
242 if (strcmp(args[0], "system") == 0) { |
243 int32_t r = runshellcmd(args[1], args + 3, args[2]); |
243 debugmsg("run '%s' at '%s'", args[1], args[2]); |
244 free(args); |
244 int32_t r = runshellcmd(args[1], args + 3, args[2]); |
245 |
245 free(args); |
246 uint32_t r_n = htonl(r); |
246 |
247 memcpy(ctx->data, &r_n, sizeof(r_n)); |
247 uint32_t r_n = htonl(r); |
248 ctx->datasize = sizeof(r_n); |
248 memcpy(ctx->data, &r_n, sizeof(r_n)); |
249 writeblock(hgc); |
249 ctx->datasize = sizeof(r_n); |
|
250 writeblock(hgc); |
|
251 } else { |
|
252 abortmsg("unknown type in system request: %s", args[0]); |
|
253 } |
250 } |
254 } |
251 |
255 |
252 /* Read response of command execution until receiving 'r'-esult */ |
256 /* Read response of command execution until receiving 'r'-esult */ |
253 static void handleresponse(hgclient_t *hgc) |
257 static void handleresponse(hgclient_t *hgc) |
254 { |
258 { |