- para_sigaction(SIGCHLD, SIG_IGN);
- para_sigaction(SIGINT, SIG_DFL);
- para_sigaction(SIGTERM, SIG_DFL);
- para_sigaction(SIGHUP, SIG_DFL);
+ int ret, i, argc;
+ char *p, *end, **argv;
+ const struct lls_command *lcmd = NULL;
+ unsigned perms;
+ struct lls_parse_result *lpr;
+ char *errctx;
+
+ if (iov->iov_base == NULL || iov->iov_len == 0)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ p = iov->iov_base;
+ p[iov->iov_len - 1] = '\0'; /* just to be sure */
+
+ ret = lls(lls_lookup_subcmd(p, server_cmd_suite, &errctx));
+ if (ret < 0) {
+ send_errctx(cc, errctx);
+ return ret;
+ }
+ perms = server_command_perms[ret];
+ if ((perms & cc->u->perms) != perms)
+ return -E_PERM;
+ lcmd = lls_cmd(ret, server_cmd_suite);
+ end = iov->iov_base + iov->iov_len;
+ for (i = 0; p < end; i++)
+ p += strlen(p) + 1;
+ argc = i;
+ argv = para_malloc((argc + 1) * sizeof(char *));
+ for (i = 0, p = iov->iov_base; p < end; i++) {
+ argv[i] = para_strdup(p);
+ p += strlen(p) + 1;
+ }
+ argv[argc] = NULL;
+ PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", lls_command_name(lcmd),
+ cc->u->name, peername);
+ ret = lls(lls_parse(argc, argv, lcmd, &lpr, &errctx));
+ if (ret >= 0) {
+ const struct server_cmd_user_data *ud = lls_user_data(lcmd);
+ ret = ud->handler(cc, lpr);
+ lls_free_parse_result(lpr, lcmd);
+ } else
+ send_errctx(cc, errctx);
+ free_argv(argv);
+ mutex_lock(mmd_mutex);
+ mmd->num_commands++;
+ if (ret >= 0 && (perms & AFS_WRITE))
+ mmd->events++;
+ mutex_unlock(mmd_mutex);
+ return ret;