Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove copy-to-tmp option #1510

Merged
merged 5 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions doc/sphinx_source/modules/mod/transfer.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Last revised: January 1, 2002
Last revised: November 29, 2023

.. _transfer:

Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions doc/sphinx_source/using/tcl-commands.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. highlight:: text

Eggdrop Tcl Commands
Last revised: January 24, 2021
Last revised: January 6, 2024

====================
Eggdrop Tcl Commands
Expand Down Expand Up @@ -2011,8 +2011,7 @@ dccsend <filename> <ircnick>
| 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
Expand Down
6 changes: 0 additions & 6 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/dccutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) &&
Expand Down
1 change: 1 addition & 0 deletions src/mod/filesys.mod/filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define MODULE_NAME "share"
#define MAKING_SHARE

#include <errno.h>
#include "src/mod/module.h"

#include <netinet/in.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.";
Expand Down
7 changes: 0 additions & 7 deletions src/mod/transfer.mod/help/set/transfer.help
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/mod/transfer.mod/help/transfer.help
Original file line number Diff line number Diff line change
Expand Up @@ -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 <variable>'%b for more info)
30 changes: 14 additions & 16 deletions src/mod/transfer.mod/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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", &copy_to_tmp, 0},
{"quiet-reject", &quiet_reject, 0},
{"cidr-support", &cidr_support, 0},
{"remove-pass", &remove_pass, 0},
Expand Down
6 changes: 4 additions & 2 deletions src/users.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "modules.h"
#include "tandem.h"

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>

Expand Down Expand Up @@ -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;
Expand Down