mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 02:43:13 +02:00
- loadmodule now reports proper errors when the actual file can't be found, instead of blaming
it on the temp file, reported in #3015. (aquanight backport)
This commit is contained in:
@@ -1355,3 +1355,5 @@
|
||||
- Fixed set::allowed-nickchars causing a segfault for some unknown charsets, reported
|
||||
by avb (#0003069).
|
||||
- Cutoff webtv whois at MAXTARGETS (#0003004).
|
||||
- loadmodule now reports proper errors when the actual file can't be found, instead of blaming
|
||||
it on the temp file, reported in #3015.
|
||||
|
||||
+13
-2
@@ -331,14 +331,25 @@ char *Module_Create(char *path_)
|
||||
strcpy(path, "./");
|
||||
strcat(path, path_);
|
||||
}
|
||||
|
||||
if (!file_exists(path))
|
||||
{
|
||||
snprintf(errorbuf, sizeof(errorbuf), "Cannot open module file: %s", strerror(errno));
|
||||
return errorbuf;
|
||||
}
|
||||
#ifdef __OpenBSD__
|
||||
/* For OpenBSD, do not do a hardlinkink attempt first because it checks inode
|
||||
* numbers to see if a certain module is already loaded. -- Syzop
|
||||
*/
|
||||
unreal_copyfileex(path, tmppath, 0);
|
||||
ret = unreal_copyfileex(path, tmppath, 0);
|
||||
#else
|
||||
unreal_copyfileex(path, tmppath, 1);
|
||||
ret = unreal_copyfileex(path, tmppath, 1);
|
||||
#endif
|
||||
if (!ret)
|
||||
{
|
||||
snprintf(errorbuf, sizeof(errorbuf), "Failed to copy module file.");
|
||||
return errorbuf;
|
||||
}
|
||||
if ((Mod = irc_dlopen(tmppath, RTLD_NOW)))
|
||||
{
|
||||
/* We have engaged the borg cube. Scan for lifesigns. */
|
||||
|
||||
+15
-1
@@ -1675,6 +1675,17 @@ void *MyMallocEx(size_t size)
|
||||
return (p);
|
||||
}
|
||||
|
||||
int file_exists(char* file)
|
||||
{
|
||||
FILE *fd;
|
||||
fd = fopen(file, "r");
|
||||
if (!fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns a unique filename in the specified directory
|
||||
* using the specified suffix. The returned value will
|
||||
* be of the form <dir>/<random-hex>.<suffix>
|
||||
@@ -1766,7 +1777,10 @@ int unreal_copyfile(char *src, char *dest)
|
||||
#endif
|
||||
|
||||
if (srcfd < 0)
|
||||
{
|
||||
config_error("Unable to open file '%s': %s", src, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
destfd = open(dest, O_WRONLY|O_CREAT, DEFAULT_PERMISSIONS);
|
||||
@@ -1814,7 +1828,7 @@ int unreal_copyfileex(char *src, char *dest, int tryhardlink)
|
||||
#ifndef _WIN32
|
||||
/* Try a hardlink first... */
|
||||
if (tryhardlink && !link(src, dest))
|
||||
return 0; /* success */
|
||||
return 1; /* success */
|
||||
#endif
|
||||
return unreal_copyfile(src, dest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user