diff --git a/doc/sphinx_source/modules/mod/transfer.rst b/doc/sphinx_source/modules/mod/transfer.rst index d914c64c6..1d804c229 100644 --- a/doc/sphinx_source/modules/mod/transfer.rst +++ b/doc/sphinx_source/modules/mod/transfer.rst @@ -1,4 +1,4 @@ -Last revised: January 1, 2002 +Last revised: November 29, 2023 .. _transfer: @@ -27,13 +27,6 @@ There are also some variables you can set in your config file: but admits that may be too small. 1024 is standard these days. Set this to 0 to use turbo-dcc (recommended). - set copy-to-tmp 1 - Enable this setting if you want to copy files to a temporary location - before sending or receiving them. This might be useful for file - stability, but if your directories are NFS mounted, it's a pain. - Setting this to 1 is not advised for big files or if you're low on - disk space. - set xfer-timeout 30 Set here the time (in seconds) to wait before an inactive transfer times out. diff --git a/doc/sphinx_source/using/tcl-commands.rst b/doc/sphinx_source/using/tcl-commands.rst index 9d0f53df1..34a318b53 100644 --- a/doc/sphinx_source/using/tcl-commands.rst +++ b/doc/sphinx_source/using/tcl-commands.rst @@ -1,7 +1,7 @@ .. highlight:: text Eggdrop Tcl Commands -Last revised: January 24, 2021 +Last revised: January 6, 2024 ==================== Eggdrop Tcl Commands @@ -2011,8 +2011,7 @@ dccsend | 4 | the file was queued for later transfer, which means that person has | | | too many file transfers going right now | +-------+---------------------------------------------------------------------+ - | 5 | copy-to-tmp is enabled and the file already exists in the temp | - | | directory | + | 5 | the file could not be opened or temporary file could not be created | +-------+---------------------------------------------------------------------+ Module: transfer diff --git a/eggdrop.conf b/eggdrop.conf index 1b8de6651..fedb6d919 100755 --- a/eggdrop.conf +++ b/eggdrop.conf @@ -1445,12 +1445,6 @@ set max-dloads 3 # 0 is turbo-dcc (recommended). set dcc-block 0 -# Enable this setting if you want to copy files to a temporary location before -# sending or receiving them. This might be useful for file stability, but if -# your directories are NFS mounted, it's a pain. Setting this to 1 is not -# advised for big files or if you're low on disk space. -set copy-to-tmp 1 - # Set here the time (in seconds) to wait before an inactive transfer times out. set xfer-timeout 30 diff --git a/src/dccutil.c b/src/dccutil.c index b3a80e2cb..ece4d895d 100644 --- a/src/dccutil.c +++ b/src/dccutil.c @@ -33,7 +33,7 @@ #include "tandem.h" extern struct dcc_t *dcc; -extern int dcc_total, dcc_flood_thr, backgrd, copy_to_tmp, max_socks; +extern int dcc_total, dcc_flood_thr, backgrd, max_socks; extern char botnetnick[], version[]; extern time_t now; extern sock_list *socklist; @@ -318,7 +318,7 @@ void killtransfer(int n) fclose(dcc[n].u.xfer->f); dcc[n].u.xfer->f = NULL; } - if (dcc[n].u.xfer->filename && copy_to_tmp) { + if (dcc[n].u.xfer->filename) { for (i = 0; i < dcc_total; i++) { if ((i != n) && (dcc[i].type->flags & DCT_FILETRAN) && (dcc[i].u.xfer->filename) && diff --git a/src/mod/filesys.mod/filesys.c b/src/mod/filesys.mod/filesys.c index 5b40ffebd..f5ef33533 100644 --- a/src/mod/filesys.mod/filesys.c +++ b/src/mod/filesys.mod/filesys.c @@ -791,6 +791,7 @@ static void filesys_dcc_send_hostresolved(int i) /* Put uploads in a temp file first */ dcc[i].u.xfer->f = tmpfile(); if (dcc[i].u.xfer->f == NULL) { + debug1("filesys: filesys_dcc_send_hostresolved(): tmpfile(): error: %s", strerror(errno)); dprintf(DP_HELP, "NOTICE %s :Can't create file `%s' (temp dir error)\n", dcc[i].nick, dcc[i].u.xfer->origname); diff --git a/src/mod/share.mod/share.c b/src/mod/share.mod/share.c index 40452536a..9e7bc519a 100644 --- a/src/mod/share.mod/share.c +++ b/src/mod/share.mod/share.c @@ -24,6 +24,7 @@ #define MODULE_NAME "share" #define MAKING_SHARE +#include #include "src/mod/module.h" #include @@ -1242,12 +1243,10 @@ static void share_ufsend(int idx, char *par) putlog(LOG_MISC, "*", "NO MORE DCC CONNECTIONS -- can't grab userfile"); dprintf(idx, "s e I can't open a DCC to you; I'm full.\n"); zapfbot(idx); - } else if (copy_to_tmp && !(f = tmpfile())) { + } else if (!(f = tmpfile())) { + debug1("share: share_ufsend(): tmpfile(): error: %s", strerror(errno)); putlog(LOG_MISC, "*", "CAN'T WRITE TEMPORARY USERFILE DOWNLOAD FILE!"); zapfbot(idx); - } else if (!copy_to_tmp && !(f = fopen(s, "wb"))) { - putlog(LOG_MISC, "*", "CAN'T WRITE USERFILE DOWNLOAD FILE!"); - zapfbot(idx); } else { /* Ignore longip and use botaddr, arg kept for backward compat for pre 1.8.3 */ newsplit(&par); @@ -2353,7 +2352,7 @@ char *share_start(Function *global_funcs) global = global_funcs; - module_register(MODULE_NAME, share_table, 2, 4); + module_register(MODULE_NAME, share_table, 2, 5); if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) { module_undepend(MODULE_NAME); return "This module requires Eggdrop 1.8.0 or later."; diff --git a/src/mod/transfer.mod/help/set/transfer.help b/src/mod/transfer.mod/help/set/transfer.help index 1a5b01505..959b4d448 100644 --- a/src/mod/transfer.mod/help/set/transfer.help +++ b/src/mod/transfer.mod/help/set/transfer.help @@ -16,13 +16,6 @@ mode, the bot will dump transfers as fast as possible, only stopping to count acks after it's finished. This can dramatically improve the speed of file transfers, and is recommended. -%{help=set copy-to-tmp}%{+n} -### %bset copy-to-tmp%b <0/1> - Enable this setting if you want to copy files to a temporary location - before sending or receiving them. This might be useful for file - stability, but if your directories are NFS mounted, it's a pain. - Setting this to 1 is not advised for big files or if you're low on - disk space. %{help=set xfer-timeout}%{+n} ### %bset xfer-timeout%b <#> This is the number of seconds to wait before a dcc send or get is diff --git a/src/mod/transfer.mod/help/transfer.help b/src/mod/transfer.mod/help/transfer.help index bc64802ac..2af240cf3 100644 --- a/src/mod/transfer.mod/help/transfer.help +++ b/src/mod/transfer.mod/help/transfer.help @@ -4,6 +4,6 @@ support for userfile sharing. Config file variables for configuring the transfer module: - %bxfer-timeout copy-to-tmp dcc-block%b - %bmax-dloads sharefail-unlink%b + %bxfer-timeout dcc-block max-dloads%b + %bsharefail-unlink%b (Use %b'.help set '%b for more info) diff --git a/src/mod/transfer.mod/transfer.c b/src/mod/transfer.mod/transfer.c index 1c7c39342..0171b6fbc 100644 --- a/src/mod/transfer.mod/transfer.c +++ b/src/mod/transfer.mod/transfer.c @@ -291,7 +291,7 @@ static void eof_dcc_send(int idx) + strlen(dcc[idx].u.xfer->origname) + 1); sprintf(nfn, "%s%s", dcc[idx].u.xfer->dir, dcc[idx].u.xfer->origname); - if (copy_to_tmp && (l = fcopyfile(dcc[idx].u.xfer->f, nfn))) { + if ((l = fcopyfile(dcc[idx].u.xfer->f, nfn))) { putlog(LOG_MISC | LOG_FILES, "*", TRANSFER_FAILED_MOVE, nfn); } /* Only close now in case it was a tmpfile, as it's deleted upon close */ @@ -302,8 +302,8 @@ static void eof_dcc_send(int idx) u = get_user_by_host(s); hand = u ? u->handle : "*"; - /* Add to file database if not tmpfile or if copyfile succeeded */ - if (!copy_to_tmp || !l) { + /* Add to file database if copyfile succeeded */ + if (!l) { module_entry *fs = module_find("filesys", 0, 0); if (fs != NULL) { @@ -961,8 +961,10 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, zz = -1; f = fopen(filename, "r"); - if (!f) + if (!f) { + debug2("transfer: raw_dcc_resend_send(): fopen(%s): error: %s", filename, strerror(errno)); return DCCSEND_BADFN; + } fseeko(f, 0, SEEK_END); dccfilesize = ftello(f); fclose(f); @@ -988,19 +990,15 @@ static int raw_dcc_resend_send(char *filename, char *nick, char *from, else nfn++; - if (copy_to_tmp) { - f = tmpfile(); - if (!f) - return DCCSEND_BADFN; - if (copyfilef(filename, f)) { - fclose(f); - return DCCSEND_FCOPY; - } - } else - f = fopen(filename, "r"); - - if (!f) + f = tmpfile(); + if (!f) { + debug1("transfer: raw_dcc_resend_send(): tmpfile(): error: %s", strerror(errno)); return DCCSEND_BADFN; + } + if (copyfilef(filename, f)) { + fclose(f); + return DCCSEND_FCOPY; + } if ((i = new_dcc(&DCC_GET_PENDING, sizeof(struct xfer_info))) == -1) { fclose(f); diff --git a/src/modules.c b/src/modules.c index 29045cd1c..932794df8 100644 --- a/src/modules.c +++ b/src/modules.c @@ -82,9 +82,11 @@ extern int parties, noshare, dcc_total, egg_numver, userfile_perm, ignore_time, must_be_owner, raw_log, max_dcc, make_userfile, default_flags, require_p, share_greet, use_invites, use_exempts, password_timeout, force_expire, protect_readonly, reserved_port_min, reserved_port_max, - copy_to_tmp, quiet_reject; + quiet_reject; extern volatile sig_atomic_t do_restart; +int copy_to_tmp = 1; /* TODO: remove from module API for eggdrop 2.0 */ + #ifdef IPV6 extern int pref_af; #endif diff --git a/src/tcl.c b/src/tcl.c index bbd12fcbc..6557645d5 100644 --- a/src/tcl.c +++ b/src/tcl.c @@ -86,7 +86,6 @@ int remote_boots = 2; int allow_dk_cmds = 1; int must_be_owner = 1; int quiet_reject = 1; -int copy_to_tmp = 1; int max_socks = 100; int quick_logs = 0; int par_telnet_flood = 1; @@ -498,7 +497,6 @@ static tcl_ints def_tcl_ints[] = { {"force-expire", &force_expire, 0}, {"dupwait-timeout", &dupwait_timeout, 0}, {"userfile-perm", &userfile_perm, 0}, - {"copy-to-tmp", ©_to_tmp, 0}, {"quiet-reject", &quiet_reject, 0}, {"cidr-support", &cidr_support, 0}, {"remove-pass", &remove_pass, 0}, diff --git a/src/users.c b/src/users.c index e99f6f9c2..2e8f5ff5c 100644 --- a/src/users.c +++ b/src/users.c @@ -35,6 +35,7 @@ #include "modules.h" #include "tandem.h" +#include #include #include @@ -698,9 +699,10 @@ int readuserfile(char *file, struct userrec **ret) global_invites = NULL; } lasthand[0] = 0; - f = fopen(file, "r"); - if (f == NULL) + if (!(f = fopen(file, "r"))) { + debug2("users: fopen(%s): %s", file, strerror(errno)); return 0; + } noshare = noxtra = 1; /* read opening comment */ s = buf;