update: more debug messages for send functions

This commit is contained in:
ngn 2024-08-09 02:25:52 +03:00
parent d75b8b9c1b
commit 544df2a4ab
5 changed files with 25 additions and 682 deletions

View File

@ -1,654 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-09 02:22+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/error.c:19
msgid "no error"
msgstr "hata yok"
#: src/error.c:20
#, fuzzy
msgid "URL contains an invalid character"
msgstr "URL contains an invalid char"
#: src/error.c:21
msgid "URL does not have a valid protocol field"
msgstr "URL does not have a valid protocol field"
#: src/error.c:22
msgid "URL is too large"
msgstr "URL is too large"
#: src/error.c:23
msgid "URL hostname is too large"
msgstr "URL hostname is too large"
#: src/error.c:24
msgid "URL path is too large"
msgstr "URL path is too large"
#: src/error.c:25
msgid "URL does not have a valid hostname"
msgstr "URL does not have a valid hostname"
#: src/error.c:26
#, fuzzy
msgid "URL does not have a valid port number"
msgstr "URL does not have a valid hostname"
#: src/error.c:27
msgid "URL does not have a valid path"
msgstr "URL does not have a valid path"
#: src/error.c:28
#, fuzzy
msgid "hostname does not contain a valid port number"
msgstr "URL does not contain a hostname with a valid port number"
#: src/error.c:29
#, fuzzy
msgid "hostname is not valid"
msgstr "URL hostname is too large"
#: src/error.c:30
msgid "URL protocol port number is unknown"
msgstr "URL protocol port number is unknown"
#: src/error.c:31
msgid "URL is incomplete"
msgstr "URL tamamlanmamış"
#: src/error.c:32
msgid "pool does not support the specified protocol"
msgstr "pool does not support the specified protocol"
#: src/error.c:33
msgid "unsupported MPTP version"
msgstr ""
#: src/error.c:34
msgid "invalid MPTP request/response code"
msgstr ""
#: src/error.c:35
msgid "invalid MPTP URL"
msgstr ""
#: src/error.c:36
msgid "failed to resolve hostname for MPTP connection"
msgstr ""
#: src/error.c:37
msgid "failed to create a MPTP socket"
msgstr ""
#: src/error.c:38
msgid "failed to connect to the MPTP host"
msgstr ""
#: src/error.c:39
#, c-format
msgid "failed receive MPTP data from host: %s"
msgstr ""
#: src/error.c:40
msgid "failed send MPTP data to host"
msgstr ""
#: src/error.c:41
#, fuzzy
msgid "MPTP data size is invalid"
msgstr "URL path is too large"
#: src/error.c:42
#, fuzzy
msgid "MPTP host size is invalid"
msgstr "URL path is too large"
#: src/error.c:43
msgid "failed to set MPTP socket options"
msgstr ""
#: src/error.c:44
msgid "MPTP connection timed out"
msgstr ""
#: src/error.c:45
#, c-format
msgid "failed to bind MPTP socket: %s"
msgstr ""
#: src/error.c:46
msgid "required argument is a NULL pointer or 0"
msgstr ""
#: src/error.c:47
msgid "not a MPTP request"
msgstr ""
#: src/error.c:48
msgid "not a MPTP response"
msgstr ""
#: src/error.c:49 src/error.c:50
msgid "MPTP request last flag is not set"
msgstr ""
#: src/error.c:51
msgid "host port not specified"
msgstr ""
#: src/error.c:52
msgid "pool info is badly formatted or is not complete"
msgstr ""
#: src/error.c:53
msgid "failed to write block from archive"
msgstr ""
#: src/error.c:54
msgid "failed to read block from archive"
msgstr ""
#: src/error.c:55
msgid "failed to open archive"
msgstr ""
#: src/error.c:56
msgid "failed to write archive header"
msgstr ""
#: src/error.c:57
msgid "failed to finish writing the archive entry"
msgstr ""
#: src/error.c:58
msgid "failed to create new archive reader/writer"
msgstr ""
#: src/error.c:59
msgid "failed to resolve full path for archive file"
msgstr ""
#: src/error.c:60
msgid "failed to read the next header of the archive"
msgstr ""
#: src/error.c:61
msgid "failed to obtain current working directory"
msgstr ""
#: src/error.c:62
msgid "failed to open extracted pool list directory"
msgstr ""
#: src/error.c:63
msgid "failed to read access the pool list file"
msgstr ""
#: src/error.c:64
msgid "failed to read access the pool info file"
msgstr ""
#: src/error.c:65
msgid "failed to parse package data"
msgstr ""
#: src/error.c:66
#, fuzzy
msgid "package name is invalid"
msgstr "URL hostname is too large"
#: src/error.c:67
msgid "data path is not set with in the ctx"
msgstr ""
#: src/error.c:68
msgid "temp path is not set with in the ctx"
msgstr ""
#: src/error.c:69
msgid "root path is not set with in the ctx"
msgstr ""
#: src/error.c:70
#, c-format
msgid "failed to set the ctx temp director to %s: %s"
msgstr ""
#: src/error.c:71
#, c-format
msgid "failed to set the ctx root directory to %s: %s"
msgstr ""
#: src/error.c:72
#, c-format
msgid "failed to set the ctx data directory to %s: %s"
msgstr ""
#: src/error.c:73
msgid "pool did not respond ping with pong"
msgstr ""
#: src/error.c:74
msgid "package file and directory paths are empty"
msgstr ""
#: src/error.c:75
msgid "failed to to open target file for sending"
msgstr ""
#: src/error.c:76
msgid "failed to to delete target file for receiving"
msgstr ""
#: src/error.c:77
msgid "failed to to open target file for receiving"
msgstr ""
#: src/error.c:78
msgid "got a bad response code for receiving the target file"
msgstr ""
#: src/error.c:79
msgid "failed to write to the target file for receiving"
msgstr ""
#: src/error.c:80
#, fuzzy
msgid "package not found"
msgstr "URL hostname is too large"
#: src/error.c:81
msgid "failed to access to the database file/directory"
msgstr ""
#: src/error.c:82
msgid "failed to open SQLite database"
msgstr ""
#: src/error.c:83
msgid "failed to create table in SQLite database"
msgstr ""
#: src/error.c:84
msgid "failed to prepare statement for SQLite database"
msgstr ""
#: src/error.c:85
msgid "failed to insert to the table in SQLite database"
msgstr ""
#: src/error.c:86
msgid "failed to select from the table in SQLite database"
msgstr ""
#: src/error.c:87
msgid "failed to delete from the table in SQLite database"
msgstr ""
#: src/error.c:88
msgid "failed to find entry in SQLite database"
msgstr ""
#: src/error.c:89
msgid "failed to init GPG for package verification"
msgstr ""
#: src/error.c:90
msgid "failed to import signature to GPG for package verification"
msgstr ""
#: src/error.c:91
msgid "failed to import archive to GPG for package verification"
msgstr ""
#: src/error.c:92
msgid "package signature verification failed with zero matches"
msgstr ""
#: src/error.c:93
msgid "package signature verification failed with zero results"
msgstr ""
#: src/error.c:94
msgid "pool file and directory paths are empty"
msgstr ""
#: src/error.c:95
msgid "pool is not avaliable for connection"
msgstr ""
#: src/error.c:96
msgid "pool URL is empty or invalid"
msgstr ""
#: src/error.c:97
msgid "pool directory path is not accessible"
msgstr ""
#: src/error.c:98
msgid "pool directory sub-paths are not accessible"
msgstr ""
#: src/error.c:99
msgid "package file list not found in the database"
msgstr ""
#: src/error.c:100
msgid "failed to open package file list in the database"
msgstr ""
#: src/error.c:101
msgid "failed to access package file list database directory"
msgstr ""
#: src/error.c:102
msgid "failed to remove package file list from the database"
msgstr ""
#: src/error.c:103
msgid "failed to write to the file list in the database"
msgstr ""
#: src/error.c:104
msgid "package keep list not found in the database"
msgstr ""
#: src/error.c:105
msgid "failed to open package keep list in the database"
msgstr ""
#: src/error.c:106
msgid "failed to access package keep list database directory"
msgstr ""
#: src/error.c:107
msgid "failed to remove package keep list from the database"
msgstr ""
#: src/error.c:108
#, c-format
msgid "failed to find %s (dependency of %s)"
msgstr ""
#: src/error.c:109
#, c-format
msgid "failed to download %s for installation: %s"
msgstr ""
#: src/error.c:110
#, fuzzy
msgid "package is not downloaded"
msgstr "URL hostname is too large"
#: src/error.c:111 src/error.c:112
msgid "failed to remove downloaded package"
msgstr ""
#: src/error.c:113
msgid "failed to open the destination file"
msgstr ""
#: src/error.c:114
msgid "failed to open the source file"
msgstr ""
#: src/error.c:115 src/error.c:116
msgid "failed to write to the destination file"
msgstr ""
#: src/error.c:117
msgid "package does not have associated pool"
msgstr ""
#: src/error.c:118
msgid "failed to create specified temp directory"
msgstr ""
#: src/error.c:119
msgid "package archive does not contain required files"
msgstr ""
#: src/error.c:120
msgid "package data does not match with target package"
msgstr ""
#: src/error.c:121
#, c-format
msgid "failed to update changes file for package: %s"
msgstr ""
#: src/error.c:122
msgid "failed to access package hashes file"
msgstr ""
#: src/error.c:123
msgid "failed to remove package changes file from the database"
msgstr ""
#: src/error.c:124
msgid "failed to stat target file for sending"
msgstr ""
#: src/error.c:125
msgid "failed to format target file size for sending"
msgstr ""
#: src/error.c:126
msgid "failed to read target file size for sending"
msgstr ""
#: src/error.c:127
msgid "failed to parse target file size for receiving"
msgstr ""
#: src/error.c:128
msgid "target file is not fully received"
msgstr ""
#: src/error.c:129
msgid "failed to stat for target extract archive"
msgstr ""
#: src/error.c:130
#, c-format
msgid "failed to add package file (%s) to the database: %s"
msgstr ""
#: src/error.c:131
#, c-format
msgid "failed to extract package files: %s"
msgstr ""
#: src/error.c:132
#, c-format
msgid "failed to add package to the database: %s"
msgstr ""
#: src/error.c:133
#, fuzzy
msgid "package is already installed"
msgstr "URL hostname is too large"
#: src/error.c:134
#, fuzzy
msgid "package is not installed"
msgstr "URL hostname is too large"
#: src/error.c:135
#, c-format
msgid "failed to remove package file (%s): %s"
msgstr ""
#: src/error.c:136
#, c-format
msgid "failed to remove package from the database: %s"
msgstr ""
#: src/error.c:137
#, c-format
msgid "failed to remove package files from the database: %s"
msgstr ""
#: src/error.c:138
#, c-format
msgid "failed to remove changes file for package: %s"
msgstr ""
#: src/error.c:139
msgid "failed to get current directory for running install"
msgstr ""
#: src/error.c:140
msgid "failed change directory to root for running install"
msgstr ""
#: src/error.c:141
msgid "failed run install spawn command"
msgstr ""
#: src/error.c:143
msgid "failed to change directory to old directory after running install"
msgstr ""
#: src/error.c:144
msgid "install script returned a bad status code"
msgstr ""
#: src/error.c:145
#, c-format
msgid "failed to run the package install script: %s"
msgstr ""
#: src/error.c:146
#, c-format
msgid "failed to save the package install script: %s"
msgstr ""
#: src/error.c:147
#, c-format
msgid "removing package breaks %s"
msgstr ""
#: src/error.c:148
#, fuzzy
msgid "package is already up-to-date"
msgstr "URL hostname is too large"
#: src/error.c:149
msgid "failed to open file for hashing"
msgstr ""
#: src/error.c:150
msgid "failed create digest for hashing"
msgstr ""
#: src/error.c:151
#, c-format
msgid "failed to get hash of %s: %s"
msgstr ""
#: src/error.c:152
#, c-format
msgid "file hash does not match for %s"
msgstr ""
#: src/error.c:153
#, fuzzy
msgid "pool info is not loaded"
msgstr "URL hostname is too large"
#: src/error.c:154
msgid "pool list is empty"
msgstr ""
#: src/error.c:155
msgid "package changes file not found in the database"
msgstr ""
#: src/error.c:156
msgid "failed to change mod of the changes file"
msgstr ""
#: src/error.c:157
msgid "failed to create install script save directory"
msgstr ""
#: src/error.c:158
msgid "directory does not have write permissions"
msgstr ""
#: src/error.c:159
msgid "specified path is not a directory"
msgstr ""
#: src/error.c:160
msgid "failed to create the specified directory"
msgstr ""
#: src/error.c:161
msgid "specified list extraction directory is not accessible"
msgstr ""
#: src/error.c:162
#, c-format
msgid "file does not exist: %s"
msgstr ""
#: src/error.c:163
#, c-format
msgid "file is a symbolic link: %s"
msgstr ""
#: src/error.c:164
msgid "failed to set the package archive"
msgstr ""
#: src/error.c:165
#, c-format
msgid "failed change directory: %s"
msgstr ""
#: src/error.c:166
msgid "failed to change directory to root during extraction"
msgstr ""
#: src/error.c:167
msgid "failed to change directory back from root during extraction"
msgstr ""
#: src/error.c:168
#, c-format
msgid "failed to accept the MPTP connection: %s"
msgstr ""
#: src/error.c:169
#, c-format
msgid "failed to listen the MPTP socket: %s"
msgstr ""
#: src/error.c:170
#, c-format
msgid "pool name (%s) doesn't match with: %s"
msgstr ""
#: src/error.c:171
#, c-format
msgid "unknown key in the configuration: %s"
msgstr ""

View File

@ -147,7 +147,8 @@ void __lm_ctx_serve_thread(void *_arg) {
} }
// send package archive and the signature file // send package archive and the signature file
lm_mptp_sendfile(arg->sock, pkg->archive, NULL, NULL); if(!lm_mptp_sendfile(arg->sock, pkg->archive, NULL, NULL))
goto end; // if we fail to send the archive no need to send the signature
lm_mptp_sendfile(arg->sock, pkg->signature, NULL, NULL); lm_mptp_sendfile(arg->sock, pkg->signature, NULL, NULL);
break; break;
} }

View File

@ -9,10 +9,7 @@
#include <unistd.h> #include <unistd.h>
bool lm_mptp_init(lm_mptp_t *packet, bool is_request, uint8_t code, bool is_last) { bool lm_mptp_init(lm_mptp_t *packet, bool is_request, uint8_t code, bool is_last) {
packet->header.flags = 0; bzero(&packet->header, sizeof(packet->header));
packet->header.data_size = 0;
packet->header.host_size = 0;
bzero(packet->data, MPTP_DATA_MAX); bzero(packet->data, MPTP_DATA_MAX);
bzero(packet->host, MPTP_HOST_MAX); bzero(packet->host, MPTP_HOST_MAX);

View File

@ -112,7 +112,7 @@ bool lm_mptp_server_send(int sock, lm_mptp_t *packet) {
} }
char buffer[sizeof(packet->header) + packet->header.host_size + packet->header.data_size]; char buffer[sizeof(packet->header) + packet->header.host_size + packet->header.data_size];
ssize_t total = sizeof(buffer), used = 0; ssize_t total = sizeof(buffer), used = 0, buflen = total;
packet->header.flags = htons(packet->header.flags); packet->header.flags = htons(packet->header.flags);
@ -120,13 +120,13 @@ bool lm_mptp_server_send(int sock, lm_mptp_t *packet) {
copy_to_buffer(buffer, packet->host, packet->header.host_size, &total, &used); copy_to_buffer(buffer, packet->host, packet->header.host_size, &total, &used);
copy_to_buffer(buffer, packet->data, packet->header.data_size, &total, &used); copy_to_buffer(buffer, packet->data, packet->header.data_size, &total, &used);
pdebug(__func__, "printing the packet dump"); if (send(sock, buffer, buflen, 0) < 0) {
pdebug_binary(buffer, sizeof(buffer));
if (send(sock, buffer, sizeof(buffer), 0) < 0) {
lm_error_set(LM_ERR_MPTPSendFail); lm_error_set(LM_ERR_MPTPSendFail);
return false; return false;
} }
pdebug(__func__, "printing the packet dump (%lu bytes)", buflen);
pdebug_binary(buffer, buflen);
return true; return true;
} }

View File

@ -27,15 +27,13 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
if(NULL == file){ if(NULL == file){
pdebug(__func__, "failed to open file: %s", path); pdebug(__func__, "failed to open file: %s", path);
lm_error_set(LM_ERR_SendOpenFail); lm_error_set(LM_ERR_SendOpenFail);
lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); goto end_1;
goto end;
} }
if(fstat(fileno(file), &st)<0){ if(fstat(fileno(file), &st)<0){
pdebug(__func__, "failed to stat file: %s", path); pdebug(__func__, "failed to stat file: %s", path);
lm_error_set(LM_ERR_SendStatFail); lm_error_set(LM_ERR_SendStatFail);
lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); goto end_1;
goto end;
} }
total = st.st_size; total = st.st_size;
@ -44,32 +42,31 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
if((size = snprintf(packet.data, MPTP_DATA_MAX, "%lu", st.st_size)) <= 0){ if((size = snprintf(packet.data, MPTP_DATA_MAX, "%lu", st.st_size)) <= 0){
pdebug(__func__, "snprintf for stat size failed: %s", path); pdebug(__func__, "snprintf for stat size failed: %s", path);
lm_error_set(LM_ERR_SendSnprintfFail); lm_error_set(LM_ERR_SendSnprintfFail);
lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); goto end_1;
goto end;
} }
packet.header.data_size = size; packet.header.data_size = size;
lm_mptp_server_send(sock, &packet); lm_mptp_server_send(sock, &packet);
if(NULL != callback) if(NULL != callback && !callback(path, current, total, data))
if(!callback(path, current, total, data)) goto end_1;
goto end;
// clear the packet // clear the packet
lm_mptp_init(&packet, false, MPTP_S2C_COOL, false); lm_mptp_init(&packet, false, MPTP_S2C_COOL, false);
while ((read = fread(packet.data, 1, MPTP_DATA_MAX, file)) > 0) { while ((read = fread(packet.data, 1, MPTP_DATA_MAX, file)) > 0) {
packet.header.data_size = read; packet.header.data_size = read;
pdebug(__func__, "sending the %lu/%lu of %s", current+read, total, path);
if(!lm_mptp_server_send(sock, &packet)){ if(!lm_mptp_server_send(sock, &packet)){
pdebug(__func__, "failed to send packet for %s (left at %lu/%lu): %s", path, current, total, lm_strerror()); pdebug(__func__, "failed to send packet for %s (left at %lu/%lu): %s", path, current, total, lm_strerror());
goto end; goto end_2;
} }
current += read; current += read;
if(NULL != callback) if(NULL != callback && !callback(path, current, st.st_size, data))
if(!callback(path, current, st.st_size, data)) goto end_1;
goto end;
lm_mptp_init(&packet, false, MPTP_S2C_COOL, false); lm_mptp_init(&packet, false, MPTP_S2C_COOL, false);
} }
@ -77,19 +74,21 @@ bool lm_mptp_sendfile(int sock, char *path, lm_mptp_transfer_callback_t callback
if(current != total){ if(current != total){
pdebug(__func__, "failed read the entire file (left at %lu/%lu): %s", current, total, path); pdebug(__func__, "failed read the entire file (left at %lu/%lu): %s", current, total, path);
lm_error_set(LM_ERR_SendReadFail); lm_error_set(LM_ERR_SendReadFail);
lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true); goto end_1;
goto end;
} }
pdebug(__func__, "completed sending %s, sending last packet", path); pdebug(__func__, "completed sending %s, sending last packet", path);
lm_mptp_init(&packet, false, MPTP_S2C_COOL, true); lm_mptp_init(&packet, false, MPTP_S2C_COOL, true);
lm_mptp_server_send(sock, &packet);
ret = true; ret = true;
goto end_2;
end: end_1:
lm_mptp_init(&packet, false, MPTP_S2C_BRUH, true);
lm_mptp_server_send(sock, &packet);
end_2:
if(NULL != file) if(NULL != file)
fclose(file); fclose(file);
lm_mptp_server_send(sock, &packet);
return ret; return ret;
} }