If you like BoxMatrix then please contribute Supportdata, Supportdata2, Firmware and/or Hardware (get in touch).
My metamonk@yahoo.com is not reachable by me since years. Please use hippie2000@webnmail.de instead.

0
U

Property:scgi server (avmcmd)

From BoxMatrix


BoxMatrix >> Shell-Commands >> scgi_server (avmcmd) @ BoxMatrix   -   IRC-Chat   -   Translate: de es fr it nl pl
News Selectors Models Accessories Components Environment Config Commands System Webif Software Develop Lexicon Community Project Media

Startup-Scr Hotplug-Scr BusyBox-Cmds Bash-Cmds AVM-Cmds Chipset-Cmds Linux-Cmds Shared-Libs Kernel-Mods Research

Info
  
Name-Collision - multiple objects in this wiki use the name scgi_server!
scgi_server (avmcmd) Daemon to speed up CGI for the REST-API.
scgi_server (process) Daemon to speed up CGI for the REST-API.

AVM-Command

Goto:   Lua-Land  -  Source  -  Dependencies   -   Model-Matrix   -   Symbols   -   SMW-Browser

Details

scgi_server is a daemon to speed up execution of CGI programs using the SCGI protocol, which is similar to FastCGI.
Both are designed to speed up programs executed by a Webserver by loading the CGI once when the server is started.

This avoids the loading of dependencies, compilation, execution and initialsation overhead per click, since it just happens
once at server startup. HTTP requests just call an already loaded dispatcher function. The CGI behaves like a Webserver.

While other solutions are more flexible scgi_server just supports one port (default Port-8187-tcp), one scripting language (Lua)
and one single script (default api.lua). This script must provide 2 functions to work:

  • cgi_load_callback - called once when the server is started
  • cgi_start_callback - called for each incoming HTTP request

AVM uses SCGI to speed up the new REST-API which consists of a range of Lua-Scripts served via HTTP on Port-8187-tcp.
Currently it is only usable from localhost and IPv4, but it is prepared for usage from LAN and from the Internet. 7530 fw 7.50:

root@fritz1:/var/media/ftp# netstat -tap | grep scgi_server

tcp        0      0 localhost:8187          0.0.0.0:*               LISTEN      925/scgi_server  

The REST-API uses normal HTTP and the request methods GET, POST, PUT and DELETE. The request URL is construted like this:

http://localhost:8187/api/v0/<endpoint>[/<string>[/<string>[/<string>]]]?sid=<sid>[&<arg>=<val>]

The API still is unfinished that's why its version is v0. An <endpoint> is a function block for a specific topic.
In current implementation the request URI can have up to 3 <string> levels.

Access requires a session id which is passed in <sid>, same principle as used for the Webinterface.
Since the API is mainly used from withing Lua-Scripts of the Webinterface the <sid> is just forwarded.

An <endpoint> can either be a builtin of api.lua or an <endpoint>_rest.lua module.
Besides this a selected subset of UI-Modules is accessible as <endpoint>s.

The API has a sophisticated security management. Each <endpoint> can have different access requirements.
Permissions are inherited from the Box-Users management, results appear in the rights ui-module for the current <sid>.

By default an <endpoint> is denied, and whitelisted by a per <endpoint> access mask assigned in security.lua.
This mask may be one or more of App, BoxAdmin, Dial, HomeAuto. NAS, Phone, as known from the Box-Users.

fw 7.39 help:

root@fritz:/var/mod/root# scgi_server -?

usage: scgi_server [options]

options:
  -?                 - print this help
  -d                 - Start as scgi server. (NOTSET)
  -s                 - Stop the scgi server. (NOTSET)
  -p INTEGER         - Set the port (scgi mode only). (8187)
  -m STRING          - Set the main lua script. ("/usr/rest_api/api.lua")
  -a                 - Server allows all HTTP methods. (NOTSET)
  -v INTEGER         - Set lua verbose level (0 ERROR-msg only, 1 += DEBUG-msg, 2+= INFO-msg). (0)
  -c                 - Enable C DEBUG-messages. (NOTSET)

scgi_server

REST-API:

Lua-Land

The REST-API consists of a range of Lua-Scripts located in /usr/rest_api. AVM calls it Lua-Land.
The main script which is loaded by the server is api.lua. The remaining scripts are loaded by dependency.

This is a subset of the Lua-Scripts section, filtered for files in /usr/rest_api:

Daily updated index of all lua scripts found scanning Firmware-Probes . Last update: 2024-03-16 07:08 GMT.
The label (static) in the Script column shows there are other objects in this wiki using this name.
The Mod column shows the amount of models using the respective script. Click the column header to sort by this number.

Source

The names of source files compiled into an executable often help to understand function blocks (and show gaps in the docs).
fw 7.39 source files:

$ strings /usr/bin/scgi_server | grep -e '\.c$' -e '\.cpp$'

ar7/ctlmgr/src/luacgi/scgi_server.c
ar7/ctlmgr/src/luacgi/scgi_server_base.c
ar7/ctlmgr/src/luacgi/scgi_server_utils.c
ar7/ctlmgr/src/luacgi/escape_lua.c
ar7/ctlmgr/src/luacgi/lua_json.c  

Dependencies

Daily updated index of all dependencies of this command. Last update: 2024-03-28 07:36 GMT.
A * in the Mod column marks info from Supportdata-Probes, which will always stay incomplete.

Relation Typ Object Mod Firmware Info Origin
Started by serv scgi_server.service 45 7.39 - 7.90 supervisor service for scgi_server. AVM
Runs as proc scgi_server (process) 9* 7.39 - 7.80 Daemon to speed up CGI for the REST-API. AVM
Serving port Port-8187-tcp 9* 7.39 - 7.80 Box REST-API provided by scgi_server. AVM
Depends on lib ld.so 11 7.39 - 7.90 Dynamic linker / loader Linux
Depends on lib libar7cfg.so 45 7.39 - 7.90 TFFS-Configuration API to ar7.cfg and many more. AVM
Depends on lib libavmauth.so 45 7.39 - 7.90 Fritzbox authentification helpers AVM
Depends on lib libavmcipher.so 45 7.39 - 7.90 AES / DES / Rijndael encryption / decryption. AVM
Depends on lib libavmcrypto.so 45 7.39 - 7.90 JWE encryption / decryption / key generator AVM
Depends on lib libavmcsock.so 45 7.39 - 7.90 Networking, I/O and helper functions AVM
Depends on lib libavmfbconf.so 45 7.39 - 7.80 API to hardcoded fbconf.cfg AVM
Depends on lib libavmfbstate.so 45 7.39 - 7.90 IPC fritzbox state notification AVM
Depends on lib libavmhmac.so 45 7.39 - 7.90 HMAC / SHA / MD5 hashing. AVM
Depends on lib libavmluautils.so 45 7.39 - 7.90 Utility Lua-Library AVM
Depends on lib libavmrrdstate.so 3 7.90 API wrapping rrdinfo AVM
Depends on lib libavmwdt.so 3 7.90 AVM-Watchdogs management API. Renamed libwdt.so AVM
Depends on lib libboxenv.so 3 7.90 API to the rc.conf enhanced Config-Environment AVM
Depends on lib libboxlib.so 45 7.39 - 7.90 Box status, logging and statistics functions AVM
Depends on lib libc.so 45 7.39 - 7.90 Standard C library Linux
Depends on lib libcm.so 45 7.39 - 7.90 ctlmgr / cm_logic messaging API Linux
Depends on lib libcore.so 3 7.90 Collects the MAC addresses of the device it's running on AVM
Depends on lib libcrypto.so 45 7.39 - 7.90 OpenSSL general crypto and X.509 library Linux
Depends on lib libdl.so 39 7.39 - 7.90 Dynamic linking library Linux
Depends on lib libdputil.so 45 7.39 - 7.90 DataPipe / packet utilities AVM
Depends on lib libewnwjson.so 45 7.39 - 7.90 JSON helper functions AVM
Depends on lib libewnwlinux.so 45 7.39 - 7.90 Linux networking functions AVM
Depends on lib libewnwnet.so 45 7.39 - 7.90 Internet helper functions AVM
Depends on lib libfbconf.so 3 7.90 TODO AVM
Depends on lib libjuisclient.so 45 7.39 - 7.90 Update-Search - second generation - JUIS AVM
Depends on lib liblocalize.so 3 7.90 TODO AVM
Depends on lib liblua.so 45 7.39 - 7.90 Lua 5.1.4 interpreter library Linux
Depends on lib libm.so 39 7.39 - 7.90 C math library Linux
Depends on lib libmonitorapi.so 3 7.90 TODO AVM
Depends on lib liboauth2.so 45 7.39 - 7.90 OAuth v2.0 authentificator Linux
Depends on lib libpthread.so 39 7.39 - 7.90 POSIX threading library Linux
Depends on lib librt.so 39 7.39 - 7.90 POSIX realtime extensions library Linux
Depends on lib libslab_c++.so 3 7.90 TODO AVM
Depends on lib libsvctl.so 45 7.39 - 7.90 supervisor notification library AVM
Depends on lib libtiinterpreter.so 45 7.39 - 7.90 Preprocessor for SSI-Files by TI. AVM
Depends on lib libwdt.so 45 7.39 - 7.80 AVM-Watchdogs management API AVM
Depends on lib libwebkpiclient.so 45 7.39 - 7.90 KPI sensor for system parts which use HTTP / HTTPS AVM
Depends on lib libwebsrv.so 45 7.39 - 7.90 HTTP / HTTPS webserver and tools. AVM
Depends on lib libyajl.so 45 7.39 - 7.90 Event-driven JSON parser Linux
Depends on lib libz.so 45 7.39 - 7.90 Zlib compressor / decompressor Linux
43 dependencies for this command

Model-Matrix

Daily updated index of the presence, path and size of this command for each model. Last update: 2024-03-28 06:03 GMT.
Showing all models using this command. Click any column header (click-wait-click) to sort the list by the respective data.
The (main/scrpn/boot/arm/prx/atom) label in the Model column shows which CPU is meant for models with multiple Linux instances.
Note that this list is merged from Firmware-Probes of all known AVM firmware for a model, including Recovery.exe and Labor-Files.

Model Firmware Path Size
FRITZ!Box 4020 7.39 /usr/bin 49.6k
FRITZ!Box 4040 7.39 - 7.57 /usr/bin 41.5k - 49.6k
FRITZ!Box 4060 7.39 - 7.57 /usr/bin 41.5k - 49.6k
FRITZ!Box 5530 Fiber (main) 7.39 - 7.80 /usr/bin 49.0k - 53.1k
FRITZ!Box 5590 Fiber (arm) 7.39 - 7.80 /usr/bin 41.5k - 49.6k
FRITZ!Box 6430 Cable (arm) 7.57 /usr/bin 49.7k
FRITZ!Box 6490 Cable (arm) 7.39 - 7.57 /usr/bin 41.4k - 49.7k
FRITZ!Box 6490 Cable (atom) 7.39 - 7.51 /usr/bin 41.4k - 49.4k
FRITZ!Box 6590 Cable (arm) 7.39 - 7.57 /usr/bin 41.4k - 49.7k
FRITZ!Box 6590 Cable (atom) 7.39 - 7.51 /usr/bin 41.4k - 49.4k
FRITZ!Box 6591 Cable (arm) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6591 Cable (atom) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6660 Cable (arm) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6660 Cable (atom) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6690 Cable (arm) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6690 Cable (atom) 7.39 - 7.57 /usr/bin 49.6k - 65.6k
FRITZ!Box 6820 LTE v1 7.39 - 7.51 /usr/bin 49.6k - 53.2k
FRITZ!Box 6820 LTE v2 7.39 - 7.51 /usr/bin 49.6k - 53.2k
FRITZ!Box 6820 LTE v3 7.39 - 7.57 /usr/bin 53.1k - 53.2k
FRITZ!Box 6840 LTE 7.39 /usr/bin 49.6k
FRITZ!Box 6850 LTE 7.39 - 7.58 /usr/bin 41.5k - 49.6k
FRITZ!Box 6850 5G 7.39 - 7.51 /usr/bin 41.5k - 49.6k
FRITZ!Box 6890 LTE 7.39 - 7.51 /usr/bin 49.0k - 57.4k
FRITZ!Box 6890 LTE v1 7.39 - 7.51 /usr/bin 49.0k - 57.4k
FRITZ!Box 6890 LTE v2 7.39 - 7.51 /usr/bin 49.0k - 57.4k
FRITZ!Box 7272 7.39 /usr/bin 49.6k
FRITZ!Box 7430 7.39 /usr/bin 49.6k
FRITZ!Box 7490 (main) 7.39 - 7.57 /usr/bin 49.6k - 53.1k
FRITZ!Box 7510 7.39 - 7.57 /usr/bin 41.5k
FRITZ!Box 7520 7.39 - 7.51 /usr/bin 41.5k - 49.6k
FRITZ!Box 7520 v2 (arm) 7.39 - 7.57 /usr/bin 41.5k - 49.6k
FRITZ!Box 7530 7.39 - 7.56 /usr/bin 41.5k - 49.6k
FRITZ!Box 7530 AX 7.39 - 7.90 /usr/bin 41.6k - 49.7k
FRITZ!Box 7560 7.39 /usr/bin 49.6k
FRITZ!Box 7583 7.50 - 7.57 /usr/bin 49.0k
FRITZ!Box 7590 7.39 - 7.90 /usr/bin 49.0k - 57.4k
FRITZ!Box 7590 AX 7.39 - 7.90 /usr/bin 49.0k - 57.4k
FRITZ!Repeater 600 7.39 /usr/bin 49.6k
FRITZ!Repeater 1200 7.39 /usr/bin 49.6k
FRITZ!WLAN Repeater 1750E 7.39 /usr/bin 49.6k
FRITZ!Repeater 2400 7.39 /usr/bin 49.5k - 49.6k
FRITZ!Repeater 3000 7.39 /usr/bin 49.6k
FRITZ!Repeater 3000 AX 7.39 /usr/bin 49.6k
FRITZ!Powerline 1260E 7.39 /usr/bin 49.6k
44 models use this command

Symbols

Daily updated index of all symbols of this command. Last update: 2024-03-28 07:36 GMT.

Firmware Symbol
7.39 - 7.90 GetSessionId
7.39 - 7.90 IsAccessWithoutSidApi
7.39 - 7.90 OutputHTTPHeader
7.39 - 7.90 SetSessionId
7.39 escape_init
7.39 - 7.58 fork_server_start
7.39 - 7.90 is_logged_in
7.39 - 7.90 is_loginbutton_needed
7.39 - 7.90 login
7.39 - 7.90 login_from_addr
7.39 - 7.90 main
7.39 - 7.90 scgi_request_alloc
7.39 - 7.90 scgi_request_free
7.39 - 7.90 scgi_server_exit_lua_stack
7.39 - 7.90 scgi_server_init_lua_stack
7.39 - 7.90 scgi_server_load
7.39 - 7.90 scgi_server_load_request_vars
7.39 scgi_server_show_error
7.39 - 7.90 scgi_server_start
7.39 - 7.90 scgi_supportdata
7.39 - 7.90 set_no_sidrenew
21 symbols for this command

SMW-Browser

Information is currently being retrieved from the backend.