diff --git a/src/command.c b/src/command.c index d2a68fb..6aa6e12 100644 --- a/src/command.c +++ b/src/command.c @@ -44,24 +44,6 @@ static LIST_HEAD(task_pending); static void run_task(struct task *t); -/* For execute command */ -static bool login_test(const char *username, const char *password) -{ - struct spwd *sp; - - if (!username || *username == 0) - return false; - - sp = getspnam(username); - if (!sp || !sp->sp_pwdp[1]) - return false; - - if (!password) - password = ""; - - return !strcmp(crypt(password, sp->sp_pwdp), sp->sp_pwdp); -} - static const char *cmd_lookup(const char *cmd) { struct stat s; @@ -342,15 +324,14 @@ static void add_task(struct rtty *rtty, const char *token, uid_t uid, const char void run_command(struct rtty *rtty, const char *data) { const char *username = data; - const char *password = username + strlen(username) + 1; - const char *cmd = password + strlen(password) + 1; + const char *cmd = username + strlen(username) + 1; const char *token = cmd + strlen(cmd) + 1; struct passwd *pw; int err = 0; data = token + strlen(token) + 1; - if (!username[0] || !login_test(username, password)) { + if (!username[0]) { err = RTTY_CMD_ERR_PERMIT; goto ERR; } diff --git a/tools/sendcmd.sh b/tools/sendcmd.sh index 28cbf10..68abfdd 100755 --- a/tools/sendcmd.sh +++ b/tools/sendcmd.sh @@ -6,7 +6,6 @@ port=5913 # Your linux device's username and password username="test" -password="test" # Default wait 30s. # If you don't care about the results, you can set it to 0, that is, don't wait @@ -17,7 +16,7 @@ cmd="echo" params='["Hello, Rtty"]' -resp=$(curl "http://$host:$port/cmd/$devid?wait=$wait" -d "{\"cmd\":\"$cmd\", \"params\": $params, \"username\": \"$username\", \"password\": \"$password\"}" 2>/dev/null) +resp=$(curl "http://$host:$port/cmd/$devid?wait=$wait" -d "{\"cmd\":\"$cmd\", \"params\": $params, \"username\": \"$username\"}" 2>/dev/null) [ "$wait" = "0" ] && exit 0