cURL em shell vs. knockd

0

Eu quero usar o curl para controlar os recursos de uma IPcam. Isso funciona bem em um shell (/ bin / sh), mas falha quando chamado de knockd. Estou tentando isso em um QNAP NAS (Busybox Linux).

O script que estou usando é:

#!/bin/sh
cd /share/Marc/.scripts
curl -v --upload-file /share/CACHEDEV1_DATA/Marc/.scripts/on.txt --user admin:xxxxx --digest http://192.168.178.28/PSIA/Custom/SelfExt/Event/triggers/VMD-1

Produz a seguinte saída (canalizada para um arquivo para depuração):

<!DOCTYPE html>
<html><head><title>Document Error: Unauthorized</title></head>
<body><h2>Access Error: 401 -- Unauthorized</h2>
<p>Authentication Error: Access Denied! Authorization required.</p>
</body>
</html>

Ao chamar o curl de um shell, recebo:

* About to connect() to 192.168.178.28 port 80 (#0)
*   Trying 192.168.178.28...   
[...]
connected
* Connected to 192.168.178.28 (192.168.178.28) port 80 (#0)
* Server auth using Digest with user 'admin'
> PUT /PSIA/Custom/SelfExt/Event/triggers/VMD-1 HTTP/1.1
> User-Agent: curl/7.21.0 (arm-openwrt-linux-gnu) libcurl/7.21.0 OpenSSL/1.0.0s zlib/1.2.7 libidn/1.9
> Host: 192.168.178.28
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
> 
< HTTP/1.1 401 Unauthorized
< Date: Tue, 17 Nov 2015 07:03:21 GMT
< Server: App-webs/
< Content-Length: 218
< Content-Type: text/html
< Connection: keep-alive
< Keep-Alive: timeout=60, max=99
< WWW-Authenticate: Digest realm="TV-IP320PI",nonce="ZjY1MWVmNThiNzY0YmVmOTEwMzFiY2E0YmZhNzQwNzZmMjBjMzNmNmU0OGQ0ZjczMzZiMzZkNGMxOWZlM2QxNTo6MTQ0MTQ3OTU6VFYtSVAzMjBQSQ=="
< 
* Ignoring the response-body
{ [data not shown]
[...]
Connection #0 to host 192.168.178.28 left intact
* Issue another request to this URL: 'http://192.168.178.28/PSIA/Custom/SelfExt/Event/triggers/VMD-1'
* Re-using existing connection! (#0) with host 192.168.178.28
* Connected to 192.168.178.28 (192.168.178.28) port 80 (#0)
* Server auth using Digest with user 'admin'
> PUT /PSIA/Custom/SelfExt/Event/triggers/VMD-1 HTTP/1.1
> Authorization: Digest username="admin", realm="TV-IP320PI", nonce="ZjY1MWVmNThiNzY0YmVmOTEwMzFiY2E0YmZhNzQwNzZmMjBjMzNmNmU0OGQ0ZjczMzZiMzZkNGMxOWZlM2QxNTo6MTQ0MTQ3OTU6VFYtSVAzMjBQSQ==", uri="/PSIA/Custom/SelfExt/Event/triggers/VMD-1", response="1e4ca05ee7ac23230232de3a611bb7b3"
> User-Agent: curl/7.21.0 (arm-openwrt-linux-gnu) libcurl/7.21.0 OpenSSL/1.0.0s zlib/1.2.7 libidn/1.9
> Host: 192.168.178.28
> Accept: */*
> Content-Length: 470
> Expect: 100-continue
> 
[...]
< HTTP/1.1 200 OK
< Date: Tue, 17 Nov 2015 07:03:22 GMT
< Server: App-webs/
< Connection: close
< Content-Length: 242
< Content-Type: application/xml
< 
{ [data not shown]
[...]
Closing connection #0

De alguma forma, o curl parece parar prematuramente quando chamado de knockd. O knockd.conf é:

[EnableOutdoors]
        sequence    = x,y
        seq_timeout = 5
        command     = /share/CACHEDEV1_DATA/Marc/.scripts/enableOutdoors.sh
        tcpflags    = syn

Por que a onda está se comportando de maneira diferente? Eu também tentei incluir todas as exportações como definidas no shell no script enableOutdoors.sh , mas isso não ajudou.

    
por Marc 17.11.2015 / 07:14

1 resposta

0

Por motivos desconhecidos para mim, houve duas instâncias de ondulação no NAS. (Talvez um introduzido por uma atualização do sistema operacional?) De alguma forma, a exportação da variável de ambiente não funcionou. Chamar explicitamente o "direito" curl no script resolveu o problema.

# /sbin/curl -V 
curl 7.21.0 (arm-openwrt-linux-gnu) libcurl/7.21.0 OpenSSL/1.0.0s zlib/1.2.7 libidn/1.9
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz 

# /share/CACHEDEV1_DATA/.qpkg/Entware/bin/curl -V
curl 7.43.0 (arm-openwrt-linux-gnueabi) libcurl/7.43.0 OpenSSL/1.0.2d zlib/1.2.8
Protocols: file ftp ftps http https imap imaps pop3 pop3s rtsp smtp smtps tftp 
Features: IPv6 Largefile SSL libz 
    
por 28.11.2015 / 06:51