summaryrefslogtreecommitdiffstats
path: root/src/core.c
Commit message (Collapse)AuthorAgeFilesLines
* src: add last client command context and use it for image creationOpenGnSys Support Team2024-10-311-1/+1
| | | | | | | Add last client command context that is used in the request to client. This allows to remove the stub image entry in the database in case that the image creation fails.
* src: add safe_strtoull for safe string to number conversionAlejandro Sirgo Rica2024-10-251-1/+8
| | | | | | | | | Add safe_strtoull to validate the execution of strtoull. Definining the base of the number is required becase partition codes are base 16 but they lack the 0x prefix. Replace uses of atoi and strtoull/strtoul and log the conversion errors.
* rest: remove scheduler codeOpenGnSys Support Team2024-09-171-29/+1
| | | | Put ogserver into diet, remove this feature, including pending command queue.
* rest: add cmd to shell/outputOpenGnSys Support Team2024-06-211-0/+1
| | | | | Add "cmd" field to json that provides the original command string, so it is provided with the output and the return code.
* rest: add retcode to shell/outputOpenGnSys Support Team2024-06-211-1/+1
| | | | Add retcode field to specify return code of shell invocation.
* core: remove useless log when ogClient connects to serverOpenGnSys Support Team2023-11-231-9/+1
| | | | | | | | | | The following log message is display for each ogClient that is connected to the ogServer: Sent refresh to: 192.168.2.200 this tells the ogClient to send his current partition table when the connection between ogServer <-> ogClient starts. This is not very useful, remove it.
* core: restrict rest API to 127.0.0.1OpenGnSys Support Team2023-11-141-2/+8
| | | | | Until there is TLS support for this, frontend and ogserver needs to be in the same box by now.
* core: log payload if sequences do not matchJose M. Guisado2023-07-031-3/+5
| | | | | | | | We need to inspect the received payload if any error is raised related to the X-Sequence header. Not just when a malformed X-Sequence header is detected. Fixes: d2c19ef13d7 ("core: add X-Sequence header support")
* core: add X-Sequence header supportv1.2.2Jose M. Guisado2023-06-131-0/+15
| | | | | | | | | | | | | | | Add non-standard HTTP header "X-Sequence" to the header section of requests (og_send_request) sent to a connected client. Define a starting sequence number when creating a new instance of struct og_client inside og_server_accept_cb. This sequence number is incremented by one for each outgoing request from ogServer. This sequence number is checked when receiving a response from a connected client, if they do not match the connection is dropped. Use sequence 0 for out-of-band commands (reboot, poweroff, stop). Any client response with header "X-Sequence: 0" bypasses sequence check.
* #1043 check for WoL pending confirmation logic only for clientOpenGnSys Support Team2022-01-211-4/+4
| | | | REST API request does not need to perform a list lookup on the wol list.
* #915 release existing client on reconnectionsOpenGnSys Support Team2022-01-211-4/+15
| | | | | Trasient network problems might result in duplicated clients, drop client object if it already exists before creating a new one.
* #915 remove temporary file to store shell outputOpenGnSys Support Team2022-01-181-0/+1
| | | | | Remove legacy behaviour, store it in the client object instead of a temporary file.
* #1067 fix use-after-free in deliver pending commandOpenGnSys Support Team2021-12-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not release the json object twice, once from og_send_request() and again og_cmd_free(). Valgrind reports: ==11885== Invalid read of size 8 ==11885== at 0x117B9A: json_decref (jansson.h:128) ==11885== by 0x117B9A: og_cmd_free (rest.c:2409) ==11885== by 0x113465: og_agent_deliver_pending_cmd (core.c:211) ==11885== by 0x113465: og_agent_read_cb (core.c:256) ==11885== by 0x4E41D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x4E453DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x110C2D: ev_loop (ev.h:835) ==11885== by 0x110C2D: main (main.c:104) ==11885== Address 0x8e7e988 is 8 bytes inside a block of size 72 free'd ==11885== at 0x4C32D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11885== by 0x117437: json_decref (jansson.h:129) ==11885== by 0x117437: og_send_request (rest.c:330) ==11885== by 0x113454: og_agent_deliver_pending_cmd (core.c:208) ==11885== by 0x113454: og_agent_read_cb (core.c:256) ==11885== by 0x4E41D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x4E453DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x110C2D: ev_loop (ev.h:835) ==11885== by 0x110C2D: main (main.c:104) ==11885== Block was alloc'd at ==11885== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11885== by 0x526461A: json_object (in /usr/lib/x86_64-linux-gnu/libjansson.so.4.11.0) ==11885== by 0x116A07: og_cmd_legacy_image_restore (rest.c:2627) ==11885== by 0x116A07: og_cmd_legacy (rest.c:2757) ==11885== by 0x116A07: og_queue_task_command (rest.c:2848) ==11885== by 0x118284: og_dbi_queue_command (rest.c:3109) ==11885== by 0x118284: og_schedule_run (rest.c:3190) ==11885== by 0x1147B9: og_agent_timer_cb (schedule.c:445) ==11885== by 0x4E41D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x4E453DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==11885== by 0x110C2D: ev_loop (ev.h:835) ==11885== by 0x110C2D: main (main.c:104)
* #1043 fix timeout refreshOpenGnSys Support Team2021-11-231-12/+10
| | | | | as described by man(3) ev, to make it work with ev_timer_again() otherwise timer might not ever expire.
* #1064 revisit error handling from ogClientOpenGnSys Support Team2021-11-121-3/+0
| | | | | | | | | | | | | | | | | | | | 200 => successful command, run next pending command 202 => successful command in progress, do not run next pending command 403 => server sent a malformed HTTP header, should not ever happen, close connection (server is buggy?). 500 => client fails to run command, report error and run next pending command 503 => client is busy, report error and do not run next pending command Anything else, should not ever happen (client is buggy?), close connection with client. On error, when processing response from ogClient, do not close the connection, instead annotate in the database that command was not successful and run next pending command. *Only* if client replies status code 500 set last_cmd to UNSPEC so its state is not BSY as reported by og_client_status function and pending cmds can be sent.
* #1061 add timeout to pending scheduled commandsJose M. Guisado2021-09-061-0/+11
| | | | | | | | | | | Pending schedule commands can deny ogLive boot of clients due to filling of pending cmd queue with commands such as "Iniciar Sesión". For example: Using RemotePC to serve clients that do not boot into ogLive will fill up the pending command queue with "Iniciar Sesión". Introduce a safety timeout for pending (scheduled) commands to avoid this situation.
* ogServer is AGPLv3+OpenGnSys Support Team2021-05-041-2/+3
| | | | Update license header in files.
* #915 only API REST is supportedOpenGnSys Support Team2021-05-041-6/+3
| | | | Socket hidra API has been removed, all connections use a REST API.
* #580 remove old keepalive codeOpenGnSys Support Team2021-05-041-23/+2
| | | | Needed by the old socket Hydra that does not exist anymore
* #1043 add WOL_SENT stateOpenGnSys Support Team2021-04-291-0/+6
| | | | | WOL_SENT tells that WakeOnLan was sent to computer, after 60 seconds, if computer does not boot, this state is released.
* #980 Broken TCP connection times out after 120 seconds through keepaliveOpenGnSys Support Team2021-04-221-0/+12
| | | | | Enable TCP keepalive to detect if the ogClient is gone (hard reset). If no reply after 120 seconds, then release the connection to the client.
* #1021 remove LOG_DEBUG syslogOpenGnSys Support Team2021-02-041-20/+0
| | | | | | | Some distros enable *.* in syslog.conf to add all logging information to /var/log/syslog. The existing LOG_DEBUG syslog() entries that ogserver generates fill up the log files very quickly. Remove most of the LOG_DEBUG syslog() calls.
* #998 disable incremental image APIOpenGnSys Support Team2020-08-141-17/+0
| | | | This API is not supported by ogClient yet and it uses the obsolete socket hydra API.
* #971 rename sources folder to srcOpenGnSys Support Team2020-06-261-0/+433
Use the same folder as in ogClient.