forked from PsychoticNinja/irssi
/SET dcc_file_create_mode wasn't used. Also print strerror() message if
creation fails. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2949 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
4ed5e9adf6
commit
55c2e7a066
@ -72,9 +72,11 @@ static void dcc_closed(GET_DCC_REC *dcc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dcc_error_file_create(GET_DCC_REC *dcc, const char *fname)
|
static void dcc_error_file_create(GET_DCC_REC *dcc, const char *fname,
|
||||||
|
const char *error)
|
||||||
{
|
{
|
||||||
printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE, fname);
|
printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE,
|
||||||
|
fname, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ FORMAT_REC fecommon_irc_dcc_formats[] = {
|
|||||||
{ "dcc_unknown_type", "{dcc DCC unknown type {hilight $0}}", 1, { 0 } },
|
{ "dcc_unknown_type", "{dcc DCC unknown type {hilight $0}}", 1, { 0 } },
|
||||||
{ "dcc_invalid_ctcp", "{dcc DCC received CTCP {hilight $0} with invalid parameters from {nick $1}}", 4, { 0, 0, 0, 0 } },
|
{ "dcc_invalid_ctcp", "{dcc DCC received CTCP {hilight $0} with invalid parameters from {nick $1}}", 4, { 0, 0, 0, 0 } },
|
||||||
{ "dcc_connect_error", "{dcc DCC can't connect to {hilight $0} port {hilight $1}}", 2, { 0, 1 } },
|
{ "dcc_connect_error", "{dcc DCC can't connect to {hilight $0} port {hilight $1}}", 2, { 0, 1 } },
|
||||||
{ "dcc_cant_create", "{dcc DCC can't create file {dccfile $0}}", 1, { 0 } },
|
{ "dcc_cant_create", "{dcc DCC can't create file {dccfile $0}: $1}", 2, { 0, 0 } },
|
||||||
{ "dcc_rejected", "{dcc DCC $0 was rejected by {nick $1} [{hilight $2}]}", 3, { 0, 0, 0 } },
|
{ "dcc_rejected", "{dcc DCC $0 was rejected by {nick $1} [{hilight $2}]}", 3, { 0, 0, 0 } },
|
||||||
{ "dcc_request_send", "{dcc DCC $0 request sent to {nick $1}: $2", 3, { 0, 0, 0 } },
|
{ "dcc_request_send", "{dcc DCC $0 request sent to {nick $1}: $2", 3, { 0, 0, 0 } },
|
||||||
{ "dcc_close", "{dcc DCC $0 close for {nick $1} [{hilight $2}]}", 3, { 0, 0, 0 } },
|
{ "dcc_close", "{dcc DCC $0 close for {nick $1} [{hilight $2}]}", 3, { 0, 0, 0 } },
|
||||||
|
@ -176,7 +176,7 @@ static void sig_dccget_connected(GET_DCC_REC *dcc)
|
|||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
char *fname, *tempfname;
|
char *fname, *tempfname;
|
||||||
int ret, temphandle, old_umask;
|
int ret, ret_errno, temphandle, old_umask;
|
||||||
|
|
||||||
if (net_geterror(dcc->handle) != 0) {
|
if (net_geterror(dcc->handle) != 0) {
|
||||||
/* error connecting */
|
/* error connecting */
|
||||||
@ -211,14 +211,18 @@ static void sig_dccget_connected(GET_DCC_REC *dcc)
|
|||||||
if download_path is in some global temp directory */
|
if download_path is in some global temp directory */
|
||||||
tempfname = g_strconcat(dcc->file, ".XXXXXX", NULL);
|
tempfname = g_strconcat(dcc->file, ".XXXXXX", NULL);
|
||||||
|
|
||||||
old_umask = umask(066);
|
old_umask = umask(0077);
|
||||||
temphandle = mkstemp(tempfname);
|
temphandle = mkstemp(tempfname);
|
||||||
umask(old_umask);
|
umask(old_umask);
|
||||||
|
|
||||||
if (temphandle == -1)
|
if (temphandle == -1)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
else {
|
else
|
||||||
|
ret = fchmod(temphandle, dcc_file_create_mode);
|
||||||
|
|
||||||
|
if (ret != -1) {
|
||||||
ret = link(tempfname, dcc->file);
|
ret = link(tempfname, dcc->file);
|
||||||
|
|
||||||
if (ret == -1 && errno == EPERM) {
|
if (ret == -1 && errno == EPERM) {
|
||||||
/* hard links aren't supported - some people
|
/* hard links aren't supported - some people
|
||||||
want to download stuff to FAT/NTFS/etc
|
want to download stuff to FAT/NTFS/etc
|
||||||
@ -229,17 +233,17 @@ static void sig_dccget_connected(GET_DCC_REC *dcc)
|
|||||||
|
|
||||||
/* if ret = 0, we're the file owner now */
|
/* if ret = 0, we're the file owner now */
|
||||||
dcc->fhandle = ret == -1 ? -1 :
|
dcc->fhandle = ret == -1 ? -1 :
|
||||||
open(dcc->file, O_WRONLY | O_TRUNC,
|
open(dcc->file, O_WRONLY | O_TRUNC);
|
||||||
dcc_file_create_mode);
|
|
||||||
|
|
||||||
/* close/remove the temp file */
|
/* close/remove the temp file */
|
||||||
|
ret_errno = errno;
|
||||||
close(temphandle);
|
close(temphandle);
|
||||||
unlink(tempfname);
|
unlink(tempfname);
|
||||||
g_free(tempfname);
|
g_free(tempfname);
|
||||||
|
|
||||||
if (dcc->fhandle == -1) {
|
if (dcc->fhandle == -1) {
|
||||||
signal_emit("dcc error file create", 2,
|
signal_emit("dcc error file create", 3,
|
||||||
dcc, dcc->file);
|
dcc, dcc->file, g_strerror(ret_errno));
|
||||||
dcc_destroy(DCC(dcc));
|
dcc_destroy(DCC(dcc));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user