summaryrefslogtreecommitdiffstats
path: root/src/client.c
Commit message (Collapse)AuthorAgeFilesLines
* refresh: update client login status from "status" field valueAlejandro Sirgo Rica10 days1-1/+5
| | | | | | Update the session status based on the value of the "status" field in the refresh response, the possible values are: LINUXS, LINUX, WINS, WIN.
* client: improve error reporting for image creation reponsev1.2.5-25OpenGnSys Support Team2024-11-071-3/+6
| | | | provide a bit more information in the logs to identify the error
* client: use image id in last command contextOpenGnSys Support Team2024-11-071-3/+3
| | | | instead of using image id that client reports
* client: no need to update repository id after creating imageOpenGnSys Support Team2024-11-071-31/+3
| | | | | this repository id is already added to the database when the image creation is requested, remove this code to update it again when the client replies
* client: remove image stub entry image creation registration failsOpenGnSys Support Team2024-10-311-0/+2
| | | | | if client succeeds to create the image but server fails to register this image, then remove the image stub in the database.
* src: add last client command context and use it for image creationOpenGnSys Support Team2024-10-311-25/+12
| | | | | | | 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.
* client: add helper function to reset last client command informationOpenGnSys Support Team2024-10-311-4/+8
| | | | just a preparation, no functional changes are intended.
* src: place last client command information in structOpenGnSys Support Team2024-10-311-11/+11
| | | | just a preparation, no functional changes are intended.
* src: add safe_strtoull for safe string to number conversionAlejandro Sirgo Rica2024-10-251-3/+19
| | | | | | | | | 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.
* src: remove placeholder image in failed image/createv1.2.5-21Alejandro Sirgo Rica2024-10-041-0/+44
| | | | Delete image data after a failed image creation.
* rest: remove unused probeOpenGnSys Support Team2024-09-301-37/+0
| | | | unused since 87be2ce08
* client: move image list to cache data to consolidate itOpenGnSys Support Team2024-09-251-17/+19
| | | | | Move list of images in the cache to cache_data. Add new functions to initialize cache data (image list) and release it.
* src: add used_size and free_size to partition dataAlejandro Sirgo Rica2024-09-251-21/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend database table ordenadores_particiones to add new "used_size" and "free_size" fields. FIELD TYPE | tamano | bigint | | uso | tinyint | | used_size | bigint | | free_size | bigint | "tamano" is the field storing the total size of the partition. "uso" is a field storing the integer percentage of use, it is preserved for backwards compatibility with scritps that access the database. "used_size" and "free_size" contain the used and free partition size in bytes. Old response from ogClient for /cache/delete, /cache/fetch and /image/restore: { 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } New response: { 'cache': { 'used_size': 4520232322423, 'free_size': 48273465287452945, 'images': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] } } Parse the new "free_size" and "used_size" fields of each partition data in the response payload of /refresh Parse "free_size" and "used_size" fields of the cache data in the reponse payload of /image/restore, /cache/delete and /cache/fetch Replace "used_size" field of GET /client/setup with the value of the new database field "used_size"
* client: log error on refreshOpenGnSys Support Team2024-09-231-0/+2
| | | | Report failure when trying to refresh client information.
* client: remove redundant refresh validationOpenGnSys Support Team2024-09-231-24/+7
| | | | json parser already validates attributes must be set on.
* ogAdmServer: replace old actualizaConfiguracionOpenGnSys Support Team2024-09-231-17/+285
| | | | | | | | | | | | Reimplement the legacy funcion actualizaConfiguracion with og_update_client_config in src/client.c if disk does not exist, add it, otherwise update disk contents. if partition size, code, filesystem or os is different, reset image id, otherwise update partition usage only. delete partitions that are gone at the end.
* rest: remove scheduler codeOpenGnSys Support Team2024-09-171-35/+0
| | | | Put ogserver into diet, remove this feature, including pending command queue.
* rest: add GET /efiAlejandro Sirgo Rica2024-09-111-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add GET /efi request to obtain information about the client's boot entries. Field inside the /refresh payload 'efi': { 'entries': [ { "order": 0, "name": "Boot0000", "active": false, "description": "grub" }, { "order": 1, "name": "Boot0001", "active": true, "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller" } ] } If the client is not a EFI system it won't add the 'efi' field. If an entry is not in the boot order it won't have the 'order' field. GET /efi resquest payload structure: { 'clients': ['10.141.10.21', '10.141.10.22'] } GET /efi response's structure: { 'clients': [ { 'ip': '10.141.10.21', 'entries': [ { "order": 0, "name": "Boot0000", "active": false, "description": "grub" }, { "order": 1, "name": "Boot0001", "active": true, "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller" } ] }, { 'ip': '10.141.10.22', 'entries': [] } ] } The client with ip 10.141.10.22 is a BIOS system. If an entry does not appear in the boot order it won't have the 'order' field.
* rest: allow repository to have more than one IP addressOpenGnSys Support Team2024-08-211-4/+9
| | | | | | | | | | Repository can have more than one single IP address. * Add alias field to database to represent the extra IPs that are attached to the repository, update schema and add version 9. * Use og_dbi_get_repository_ip() to infer the repository IP address. * Add helper functions (src/repo.c) to build a list of repositories and update rest API to use it.
* rest: add cache/fetchv1.2.5-17Alejandro Sirgo Rica2024-08-091-0/+3
| | | | | | | | | | | | | | | | | | | Add POST cache/fetch request to request download of images in the client's cache. Resquest payload structure: { 'clients': ['10.141.10.21', '10.141.10.22'] 'image': 'windows.img' 'type': 'TIPTORRENT' 'repository': '12.141.10.2' } The clients listed in the 'clients' field will receive a cache/fetch POST request with the payload received by the server without the 'clients' field. The clients respond with the contents of their cache so the server can update the database.
* client: split revision query when updating image informationv1.2.5-16OpenGnSys Support Team2024-07-191-3/+23
| | | | a simple cleanup to help diagnose problems, not behaviour change expected.
* client: fortify check for mandatory cmd json field in shell/outputOpenGnSys Support Team2024-07-151-2/+2
| | | | | | | | Revisit 6cbe69e89e71 ("rest: add cmd to shell/output") to reject response with no 'cmd' field, otherwise strdup() crashes when dealing with NULL string. Set retcode to zero, otherwise this value remains uninitialized if no retcode json field is provided by the client.
* rest: add checksum to GET /imagesOpenGnSys Support Team2024-07-051-4/+9
| | | | | Add a new checksum attribute to GET /images, extend database to add a new checksum field to images table.
* rest: add timestamp to shell/outputOpenGnSys Support Team2024-06-211-0/+1
| | | | Provide a timestamp that tells when the command output from client was received.
* rest: add cmd to shell/outputOpenGnSys Support Team2024-06-211-2/+8
| | | | | 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-2/+9
| | | | Add retcode field to specify return code of shell invocation.
* client: update cache after image/restorev1.2.5-11Alejandro Sirgo Rica2024-05-301-0/+2
| | | | | | | | | | | | | | | | | | | | Update the database with the new cache contents sent by the client after an image/restore operation. Resquest response structure: { ... 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'} ] ... } Parse the contents of the 'cache' field to update the data of the client's cache in the database. This is one of the required changes the make cache/list coherent and prevent cache desync between the server and clients.
* rest: add cache/deleteAlejandro Sirgo Rica2024-05-301-0/+56
| | | | | | | | | | | | | | | | | | | Add POST cache/delete request to request deletion of images in the client's cache. Resquest payload structure: { 'clients': ['10.141.10.21', '10.141.10.22'] 'images': ['windows.img', 'linux.img'] } The clients listed in the 'clients' field will receive a cache/delete POST request with the 'clients' field removed and only containing 'images' from the payload received by the server. Each client will try to delete as many images as available in their cache from the list of files in 'images'. The clients will give response with the contents of the cache so the server can update the database.
* client: store image cache data in databaseAlejandro Sirgo Rica2024-05-301-7/+60
| | | | | | | | | | | | | | | | | | | | | | Parse the 'cache' field of the refresh payload sent by the clients. Cache field structure in the payload: { ... 'cache': [ {'name': 'windows.img', 'size': 2432370213, checksum: '5d4dcc677bc19f40a647d0002f4ade90'}, {'name': 'linux.img', 'size': 243234534213, checksum: '3eb22f888f88a55ad954f55644e1192e'}, ] ... } Store that data in the 'cache' table of the database so it can be obtained later on. The table contains the following fields: - clientid: the numeric identifier of the client. - imagename: name of the image in cache. - size: size in bytes of the image in cache. - checksum: checksum of the image in cache.
* src: replace old function to update image informationOpenGnSys Support Team2024-05-291-7/+91
| | | | replace old legacy code, no functional changes are intended.
* client: parse permissions and lastupdate in /image/create response from clientv1.2.5-5OpenGnSys Support Team2023-12-121-5/+11
| | | | | | Use permissions and last update from client. update src/schema.c to add a new database version.
* client: stub to parse size field in /image/create response from clientOpenGnSys Support Team2023-12-121-3/+6
| | | | | Still incomplete, src/schema.c needs to be update to add a new field to the 'imagenes' table in the database.
* client: harden og_resp_refreshJose M. Guisado2023-06-071-1/+5
| | | | | | | | | | | | | Harden refresh response logic. Check for necessary JSON fields inside the payload. Check if serial_number is null before calling strlen, prevent ogServer from a malformed refresh response with missing serial_number. Refresh uses legacy function actualizaConfiguracion that takes a long string with the computers configuration (serialno, partitions, disks, link speed and status). Check for an empty string before executing any legacy code inside actualizaConfiguracion.
* client: increase software inventory buffer sizeJose M. Guisado2023-04-201-1/+1
| | | | | | | | | | | | Large software inventory is truncated because it does not fit into the existing buffer. Software inventory response payload consists of a string with each component delimited by '\n'. Large software inventories can consist of more than 8192 bytes. Avoid truncating any large software inventory by increasing the buffer size where this string is stored.
* Log ogClient sessions in ogagent.logv1.2.1Javier Sánchez Parra2022-11-021-4/+41
| | | | | Otherwise, administrators can not read the logging history from WebConsole.
* #915 Fix conditional jump depending on uninitialised valueJavier Sánchez Parra2022-05-181-1/+1
| | | | | | | | | | | | | | | | | | Valgrind says: ==9452== 1 errors in context 1 of 38: ==9452== Conditional jump or move depends on uninitialised value(s) ==9452== at 0x11BD1E: og_resp_refresh (client.c:383) ==9452== by 0x11CF2A: og_agent_state_process_response (client.c:822) ==9452== by 0x112FCE: og_agent_read_cb (core.c:254) ==9452== by 0x4E41D72: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==9452== by 0x4E453DD: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0) ==9452== by 0x1107CD: ev_loop (ev.h:835) ==9452== by 0x1107CD: main (main.c:108) ==9452== Uninitialised value was created by a stack allocation ==9452== at 0x11BB02: og_resp_refresh (client.c:348) Fixes: f03425e ("#915 Add support for link speed in the refresh response")
* #915 Add last_cmd to GET /clients APIJavier Sánchez Parra2022-05-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "last_cmd" json object contains information of the last command executed by the correspondent client. For now, it only includes "result" string property, which stores "success" if the last command finished correctly or "failure" on the contrary. To populate "result" property, this commit also adds "last_cmd_result" enum attribute to og_client struct. Client response processing fills this attribute according to its success. Clients in WOL_SENT state always have last_cmd->result = "unknown". Request: GET /clients Response: 200 OK { "clients": [ { "addr": "10.141.10.102", "state": "WOL_SENT", "last_cmd": { "result": "unknown" } }, { "addr": "10.141.10.101", "state": "OPG", "speed": 1000, "last_cmd": { "result": "success" } }, { "addr": "10.141.10.100", "state": "OPG", "speed": 1000, "last_cmd": { "result": "failure" } } ] }
* #915 Add support for link speed in the refresh responseJavier Sánchez Parra2022-05-091-0/+6
| | | | | | | | Add ogServer support for parsing and storing the link speed from ogClient's refresh response. Probe response already has client's link speed, but this API is deprecated.
* #915 remove temporary file to store shell outputOpenGnSys Support Team2022-01-181-12/+2
| | | | | Remove legacy behaviour, store it in the client object instead of a temporary file.
* #915 remove shim code to update database after image restore commandOpenGnSys Support Team2021-12-221-21/+26
| | | | Make direct call to dbi API to update database instead.
* #1065 split og_status_session_toggleJose M. Guisado2021-12-031-9/+22
| | | | | | | | | | | Handles non usual situations like a client sending more than one event of same type. When toggling, receiving two events of the same type is the same as receiving two different ones (eg. start, then stop). Split into _session_start and _session_stop in order to check valid client status.
* #1065 Add support for client eventsJose M. Guisado2021-12-011-1/+72
| | | | | | | | ogServer supports events from clients in an agent mode (linux/windows). Client sends event information (eg. user login/logout) via a 103 Early Hints http response message.
* #1065 client: add support for ogclient win stateJose M. Guisado2021-11-171-2/+6
| | | | | | | | | ogClient can be run in windows mode, enabling connection with ogServer when running on a Windows machine. Don't expect the same payload in windows mode as a in live or virtual. Client in windows mode does not send partition setup information, only the status/state. (same case for linux mode)
* #1065 client: add support for ogclient linux stateJose M. Guisado2021-11-171-0/+8
| | | | | | | | | | ogClient can be run in linux mode, intended for exposing some ogServer commands when running in a linux distribution. When connecting with a client in linux mode, do not expect a full partition setup response. Just expect a 'status', and then accept the connection without updating any partition information in the database.
* #1064 revisit error handling from ogClientOpenGnSys Support Team2021-11-121-11/+73
| | | | | | | | | | | | | | | | | | | | 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.
* #1037 Add disk typeJavier Sánchez Parra2021-05-261-2/+2
| | | | | | | Add ogServer support for parsing and storing in the DB disk type data from ogClient refresh response. See also commits with #1037 in ogClient and WebConsole repo.
* #980 ignore unknown attributesOpenGnSys Support Team2021-05-041-14/+0
| | | | If ogClient sends an unknown attribute, ignore it.
* #995 Add link speed parsing to client probe responseJose M. Guisado2021-05-041-0/+6
| | | | | | If a probe response contains speedinformation, parse and store it inside the client struct. Speed is interpreted as an unsigned integer representing Mbit/s.
* ogServer is AGPLv3+OpenGnSys Support Team2021-05-041-2/+3
| | | | Update license header in files.
* #980 memleak in json ogclient pathOpenGnSys Support Team2021-02-231-0/+1
|