{"action":"opened","issue":{"url":"https://api.github.com/repos/shadowsocks/shadowsocks-libev/issues/1928","repository_url":"https://api.github.com/repos/shadowsocks/shadowsocks-libev","labels_url":"https://api.github.com/repos/shadowsocks/shadowsocks-libev/issues/1928/labels{/name}","comments_url":"https://api.github.com/repos/shadowsocks/shadowsocks-libev/issues/1928/comments","events_url":"https://api.github.com/repos/shadowsocks/shadowsocks-libev/issues/1928/events","html_url":"https://github.com/shadowsocks/shadowsocks-libev/issues/1928","id":297344061,"number":1928,"title":"Suggestion: Invoke plugins direct instead of using \"sh\".","user":{"login":"DDoSolitary","id":25856103,"avatar_url":"https://avatars1.githubusercontent.com/u/25856103?v=4","gravatar_id":"","url":"https://api.github.com/users/DDoSolitary","html_url":"https://github.com/DDoSolitary","followers_url":"https://api.github.com/users/DDoSolitary/followers","following_url":"https://api.github.com/users/DDoSolitary/following{/other_user}","gists_url":"https://api.github.com/users/DDoSolitary/gists{/gist_id}","starred_url":"https://api.github.com/users/DDoSolitary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DDoSolitary/subscriptions","organizations_url":"https://api.github.com/users/DDoSolitary/orgs","repos_url":"https://api.github.com/users/DDoSolitary/repos","events_url":"https://api.github.com/users/DDoSolitary/events{/privacy}","received_events_url":"https://api.github.com/users/DDoSolitary/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-15T06:45:28Z","updated_at":"2018-02-15T06:45:28Z","closed_at":null,"author_association":"NONE","body":"Currently the plugins are invoked via `sh` in `start_ss_plugin()`. This is unfriendly to environments that don't have `sh` installed (though such occasions are rare). For example, my project [shadowsocks-libev-win](https://github.com/DDoSolitary/shadowsocks-libev-win) tries to provide standalone Windows executables of this project, but I'm forced to either include `sh.exe` and its dependencies in the released files or applying the following patch.\r\n\r\n``` diff\r\ndiff --git a/src/plugin.c b/src/plugin.c\r\nindex f44041c..3eceabc 100644\r\n--- a/src/plugin.c\r\n+++ b/src/plugin.c\r\n@@ -87,14 +87,6 @@ start_ss_plugin(const char *plugin,\r\n                 const char *local_port,\r\n                 enum plugin_mode mode)\r\n {\r\n-    char *cmd = NULL;\r\n-\r\n-    size_t plugin_len = strlen(plugin);\r\n-    size_t cmd_len    = plugin_len + CMD_RESRV_LEN;\r\n-    cmd = ss_malloc(cmd_len);\r\n-\r\n-    snprintf(cmd, cmd_len, \"exec %s\", plugin);\r\n-\r\n     cork_env_add(env, \"SS_REMOTE_HOST\", remote_host);\r\n     cork_env_add(env, \"SS_REMOTE_PORT\", remote_port);\r\n\r\n@@ -104,7 +96,7 @@ start_ss_plugin(const char *plugin,\r\n     if (plugin_opts != NULL)\r\n         cork_env_add(env, \"SS_PLUGIN_OPTIONS\", plugin_opts);\r\n\r\n-    exec = cork_exec_new_with_params(\"sh\", \"-c\", cmd, NULL);\r\n+    exec = cork_exec_new(plugin);\r\n\r\n     cork_exec_set_env(exec, env);\r\n\r\n@@ -112,8 +104,6 @@ start_ss_plugin(const char *plugin,\r\n\r\n     int err = cork_subprocess_start(sub);\r\n\r\n-    ss_free(cmd);\r\n-\r\n     return err;\r\n }\r\n\r\n```\r\n"}}
{"actor":{"display_login":"DDoSolitary"}}