diff --git a/Changes b/Changes index 13e5de12f..4808d4139 100644 --- a/Changes +++ b/Changes @@ -2794,4 +2794,8 @@ seen. gmtime warning still there - Fixed invalid nameserver info when chrooted (nameserver was always localhost). - Fixed a remote include bug involving cached files. Thanks to chatsphere.net for helping to track this down! - +- Modified 404 numeric a bit (#0001515). +- Fixed 'no server notice on /restart or /die', reported by Lx (#0001062). This was caused + by a bug in flush_connections(&me), hopefully there won't be any side effects. +- Fixed file owner problems when IRC_UID/IRC_GID is used (eg: when running chrooted). +- Fixed crashbug if we were unable to write a remote include file to disk. diff --git a/src/modules/m_message.c b/src/modules/m_message.c index 952debed5..10b983c0f 100644 --- a/src/modules/m_message.c +++ b/src/modules/m_message.c @@ -418,7 +418,7 @@ DLLFUNC int m_message(aClient *cptr, aClient *sptr, int parc, char *parv[], int { if (!notice) sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), - me.name, parv[0], parv[0], + me.name, parv[0], chptr->chname, err_cantsend[6], p2); continue; } @@ -430,7 +430,7 @@ DLLFUNC int m_message(aClient *cptr, aClient *sptr, int parc, char *parv[], int { if (!notice) sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), - me.name, parv[0], parv[0], + me.name, parv[0], chptr->chname, err_cantsend[6], p2); continue; } @@ -487,7 +487,7 @@ DLLFUNC int m_message(aClient *cptr, aClient *sptr, int parc, char *parv[], int { if (!notice || (cansend == 8)) /* privmsg or 'cannot send notice'... */ sendto_one(sptr, err_str(ERR_CANNOTSENDTOCHAN), - me.name, parv[0], parv[0], + me.name, parv[0], chptr->chname, err_cantsend[cansend - 1], p2); } continue; diff --git a/src/send.c b/src/send.c index 54e1b809c..148dd8a6d 100644 --- a/src/send.c +++ b/src/send.c @@ -120,8 +120,8 @@ void flush_connections(aClient* cptr) { for (i = LastSlot; i >= 0; i--) if ((acptr = local[i]) && !(acptr->flags & FLAGS_BLOCKED) - && DBufLength(&cptr->sendQ) > 0) - send_queued(cptr); + && DBufLength(&acptr->sendQ) > 0) + send_queued(acptr); } else if (cptr->fd >= 0 && !(cptr->flags & FLAGS_BLOCKED) && DBufLength(&cptr->sendQ) > 0) diff --git a/src/support.c b/src/support.c index 426eadd31..e0238ba49 100644 --- a/src/support.c +++ b/src/support.c @@ -1770,6 +1770,10 @@ int unreal_copyfile(char *src, char *dest) close(srcfd); close(destfd); +#if defined(IRC_UID) && defined(IRC_GID) + if (!loop.ircd_booted) + chown(dest, IRC_UID, IRC_GID); +#endif return 1; fail: close(srcfd); diff --git a/src/url.c b/src/url.c index f0f5200cd..4d09cebfb 100644 --- a/src/url.c +++ b/src/url.c @@ -145,6 +145,14 @@ char *download_file(char *url, char **error) if (curl) { FILE *fd = fopen(tmp, "wb"); + if (!fd) + { + snprintf(errorbuf, CURL_ERROR_SIZE, "Cannot write to %s: %s", tmp, strerror(ERRNO)); + if (file) + free(file); + *error = errorbuf; + return NULL; + } curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fd); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, do_download); @@ -156,6 +164,10 @@ char *download_file(char *url, char **error) curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuf); res = curl_easy_perform(curl); fclose(fd); +#if defined(IRC_UID) && defined(IRC_GID) + if (!loop.ircd_booted) + chown(tmp, IRC_UID, IRC_GID); +#endif } if (file) free(file); @@ -195,14 +207,24 @@ void url_init(void) */ void download_file_async(char *url, time_t cachetime, vFP callback) { + static char errorbuf[CURL_ERROR_SIZE]; CURL *curl = curl_easy_init(); if (curl) { - char *file = url_getfilename(url); + char *file = url_getfilename(url); char *filename = unreal_getfilename(file); - char *tmp = unreal_mktemp("tmp", filename ? filename : "download.conf"); + char *tmp = unreal_mktemp("tmp", filename ? filename : "download.conf"); FileHandle *handle = malloc(sizeof(FileHandle)); handle->fd = fopen(tmp, "wb"); + if (!handle->fd) + { + snprintf(errorbuf, sizeof(errorbuf), "Cannot create '%s': %s", tmp, strerror(ERRNO)); + callback(url, NULL, errorbuf, 0); + if (file) + MyFree(file); + MyFree(handle); + return; + } handle->callback = callback; handle->cachetime = cachetime; strcpy(handle->filename, tmp); @@ -280,6 +302,10 @@ void url_do_transfers_async(void) curl_easy_getinfo(msg->easy_handle, CURLINFO_EFFECTIVE_URL, &url); curl_easy_getinfo(msg->easy_handle, CURLINFO_FILETIME, &last_mod); fclose(handle->fd); +#if defined(IRC_UID) && defined(IRC_GID) + if (!loop.ircd_booted) + chown(handle->filename, IRC_UID, IRC_GID); +#endif if (msg->data.result == CURLE_OK) { if (code == 304 || (last_mod != -1 && last_mod < handle->cachetime))