summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-26 19:18:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-02-26 19:18:26 +0000
commit9ce18436e94c2cdebeba90eba30b3c3e1ca311ed (patch)
tree1e4ae4080759edadfde9ae232f7c465e326a230c
parenta6e0557f91998c30469030f08464cc8cb6c11fd6 (diff)
Revert configure so that we can uh, actually compile.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9037 e03df62e-2008-0410-955e-edbf42e46eb7
-rwxr-xr-xconfigure209
-rw-r--r--include/configreader.h16
-rw-r--r--src/configreader.cpp51
-rw-r--r--src/modules.cpp4
4 files changed, 136 insertions, 144 deletions
diff --git a/configure b/configure
index 4622d9703..4adedf04e 100755
--- a/configure
+++ b/configure
@@ -154,7 +154,6 @@ GetOptions (
'update' => sub { update(); },
'svnupdate' => sub { svnupdate(); },
'clean' => sub { clean(); },
- 'update-root' => sub { update_root() },
'list-extras' => sub { list_extras; exit 0; }, # This, --enable-extras, and --disable-extras are for non-interactive managing.
'enable-extras=s@' => \@opt_enableextras, # ^
'disable-extras=s@' => \@opt_disableextras, # ^
@@ -210,7 +209,6 @@ our $interactive = !$non_interactive;
chomp(our $topdir = getcwd());
our $this = resolve_directory($topdir); # PWD, Regardless.
our @modlist = (); # Declare for Module List..
-
our %config = (); # Initiate Configuration Hash..
$config{ME} = resolve_directory($topdir); # Present Working Directory
@@ -409,42 +407,6 @@ sub clean
our ($has_epoll, $has_ports, $has_kqueue) = (0, 0, 0);
-sub update_root
-{
- eval {
- chomp($topdir = getcwd());
- $this = resolve_directory($topdir); # PWD, Regardless.
- getmodules();
- # Does the cache file exist?
- if (!getcache()) {
- # No, No it doesn't.. *BASH*
- print "You have not run ./configure before. Please do this before trying to run the update script.\n";
- exit 0;
- } else {
- print "Updating root files...\n";
- getosflags();
- if (defined($opt_disable_debug) && $opt_disable_debug == 1)
- {
- print "Disabling debug information (-g).\n";
- $config{OPTIMISATI} = "";
- getosflags();
- }
- $has_epoll = $config{HAS_EPOLL};
- $has_ports = $config{HAS_PORTS};
- $has_kqueue = $config{HAS_KQUEUE};
- write_root_files();
- makecache();
- print "Complete.\n";
- exit 0;
- }
- };
- if ($@)
- {
- print "Configure update failed: $@\n";
- }
- exit 1;
-}
-
sub update
{
eval {
@@ -1149,91 +1111,6 @@ sub getosflags {
my ($mliflags, $mfrules, $mobjs, $mfcount) = ("", "", "", 0);
-sub write_root_files {
- # Create a Modules List..
- my $modules = "";
- foreach my $i (@modlist)
- {
- $modules .= "m_".$i.".so ";
- }
- chomp($modules); # Remove Redundant whitespace..
-
- opendir(DIRHANDLE, "src/modules");
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^m_(.+?)$/) {
- if (defined(opendir(MDIRHANDLE, "src/modules/$name"))) {
- closedir(MDIRHANDLE);
- $modules .= "$name.so ";
- $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name.so\n";
- }
- }
- }
- closedir(DIRHANDLE);
-
- # Write all .in files.
- my $exe = "inspircd";
-
- # Do this once here, and cache it in the .*.inc files,
- # rather than attempting to read src/version.sh from
- # compiled code -- we might not have the source to hand.
- # Fix for bug#177 by Brain.
-
- chomp(my $version = `sh ./src/version.sh`);
- chomp(my $revision = getrevision());
- $version = "$version(r$revision)";
-
- # We can actually parse any file starting with . and ending with .inc,
- # but right now we only parse .inspircd.inc to form './inspircd'
-
- opendir(DIRHANDLE, $this);
-
- foreach my $name (sort readdir(DIRHANDLE)) {
- if ($name =~ /^\.(.+)\.inc$/) {
- my $file = $1;
-
- # Bug #353, omit this on non-darwin
- next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
-
- # All .name.inc files need parsing!
- my $tmp = "";
- open(FILEHANDLE, ".$file.inc") or die ("Can't open .$file.inc");
- while (<FILEHANDLE>) {
- $tmp .= $_;
- }
- close(FILEHANDLE);
-
- print "Writing \e[1;32m$file\e[0m ...\n";
- $tmp =~ s/\@CC\@/$config{CC}/ if defined $config{CC};
- $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/ if defined $config{MAKEPROG};
- $tmp =~ s/\@FLAGS\@/$config{FLAGS}/ if defined $config{FLAGS};
- $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/ if defined $config{DEVELOPER};
- $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/ if defined $config{LDLIBS};
- $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/ if defined $config{BASE_DIR};
- $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/ if defined $config{CONFIG_DIR};
- $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/ if defined $config{MODULE_DIR};
- $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/ if defined $config{BINARY_DIR};
- $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/ if defined $config{LIBRARY_DIR};
- $tmp =~ s/\@MODULES\@/$modules/ if defined $modules;
- $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/ if defined $config{STARTSCRIPT};
- $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/ if defined $config{DESTINATION};
- $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/ if defined $config{EXTRA_DIR};
- $tmp =~ s/\@EXECUTABLE\@/$exe/ if defined $exe;
- $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/ if defined $config{MAKEORDER};
- $tmp =~ s/\@VERSION\@/$version/ if defined $version;
- $tmp =~ s/\@INSTALL_LIST\@/$install_list/ if defined $install_list;
- $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/ if defined $uninstall_list;
-
- open(FILEHANDLE, ">$file");
- print FILEHANDLE $tmp;
- }
- }
- closedir(DIRHANDLE);
-
- # Make inspircd executable!
- chmod 0744, 'inspircd';
-
-}
-
sub writefiles {
my($writeheader) = @_;
my $se = "";
@@ -1342,12 +1219,95 @@ EOF
close(FILEHANDLE);
}
- write_root_files();
+
+ # Create a Modules List..
+ my $modules = "";
+ foreach my $i (@modlist)
+ {
+ $modules .= "m_".$i.".so ";
+ }
+ chomp($modules); # Remove Redundant whitespace..
+
+ opendir(DIRHANDLE, "src/modules");
+ foreach my $name (sort readdir(DIRHANDLE)) {
+ if ($name =~ /^m_(.+?)$/) {
+ if (defined(opendir(MDIRHANDLE, "src/modules/$name"))) {
+ closedir(MDIRHANDLE);
+ $modules .= "$name.so ";
+ $uninstall_list = $uninstall_list . " -rm \$(MODULES)/$name.so\n";
+ }
+ }
+ }
+ closedir(DIRHANDLE);
+
+
+ # Write all .in files.
+ my $tmp = "";
+ my $file = "";
+ my $exe = "inspircd";
+
+ # Do this once here, and cache it in the .*.inc files,
+ # rather than attempting to read src/version.sh from
+ # compiled code -- we might not have the source to hand.
+ # Fix for bug#177 by Brain.
+
+ chomp($version = `sh ./src/version.sh`);
+ chomp(my $revision = getrevision());
+ $version = "$version(r$revision)";
+
+ # We can actually parse any file starting with . and ending with .inc,
+ # but right now we only parse .inspircd.inc to form './inspircd'
print "Writing \e[1;32mMakefiles\e[0m\n";
write_dynamic_modules_makefile();
write_dynamic_makefile();
+ opendir(DIRHANDLE, $this);
+
+ foreach my $name (sort readdir(DIRHANDLE)) {
+ if ($name =~ /^\.(.+)\.inc$/) {
+ $file = $1;
+
+ # Bug #353, omit this on non-darwin
+ next if (($config{OSNAME} !~ /darwin/) && ($file eq "org.inspircd.plist"));
+
+ # All .name.inc files need parsing!
+ $tmp = "";
+ open(FILEHANDLE, ".$file.inc") or die ("Can't open .$file.inc");
+ while (<FILEHANDLE>) {
+ $tmp .= $_;
+ }
+ close(FILEHANDLE);
+
+ print "Writing \e[1;32m$file\e[0m ...\n";
+ $tmp =~ s/\@CC\@/$config{CC}/ if defined $config{CC};
+ $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/ if defined $config{MAKEPROG};
+ $tmp =~ s/\@FLAGS\@/$config{FLAGS}/ if defined $config{FLAGS};
+ $tmp =~ s/\@DEVELOPER\@/$config{DEVELOPER}/ if defined $config{DEVELOPER};
+ $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/ if defined $config{LDLIBS};
+ $tmp =~ s/\@BASE_DIR\@/$config{BASE_DIR}/ if defined $config{BASE_DIR};
+ $tmp =~ s/\@CONFIG_DIR\@/$config{CONFIG_DIR}/ if defined $config{CONFIG_DIR};
+ $tmp =~ s/\@MODULE_DIR\@/$config{MODULE_DIR}/ if defined $config{MODULE_DIR};
+ $tmp =~ s/\@BINARY_DIR\@/$config{BINARY_DIR}/ if defined $config{BINARY_DIR};
+ $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/ if defined $config{LIBRARY_DIR};
+ $tmp =~ s/\@MODULES\@/$modules/ if defined $modules;
+ $tmp =~ s/\@STARTSCRIPT\@/$config{STARTSCRIPT}/ if defined $config{STARTSCRIPT};
+ $tmp =~ s/\@DESTINATION\@/$config{DESTINATION}/ if defined $config{DESTINATION};
+ $tmp =~ s/\@EXTRA_DIR\@/$config{EXTRA_DIR}/ if defined $config{EXTRA_DIR};
+ $tmp =~ s/\@EXECUTABLE\@/$exe/ if defined $exe;
+ $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/ if defined $config{MAKEORDER};
+ $tmp =~ s/\@VERSION\@/$version/ if defined $version;
+ $tmp =~ s/\@INSTALL_LIST\@/$install_list/ if defined $install_list;
+ $tmp =~ s/\@UNINSTALL_LIST\@/$uninstall_list/ if defined $uninstall_list;
+
+ open(FILEHANDLE, ">$file");
+ print FILEHANDLE $tmp;
+ }
+ }
+ closedir(DIRHANDLE);
+
+ # Make inspircd executable!
+ chmod 0744, 'inspircd';
}
sub write_dynamic_modules_makefile {
@@ -1634,7 +1594,6 @@ sub write_dynamic_makefile
my $all = "all: ";
my $all_libsonly = "";
-
my $libraryext = "";
my $othercrap = "";
my $RPATH = "";
diff --git a/include/configreader.h b/include/configreader.h
index 3d889f943..d7789b9ed 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -231,10 +231,6 @@ class CoreExport ServerConfig : public Extensible
* and setting error if an error has occured.
*/
bool ParseLine(ConfigDataHash &target, std::string &line, long &linenumber, std::ostringstream &errorstream);
-
- /** Process an include directive
- */
- bool DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
/** Check that there is only one of each configuration item
*/
@@ -242,6 +238,14 @@ class CoreExport ServerConfig : public Extensible
public:
+ /** Process an include executable directive
+ */
+ bool DoPipe(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
+
+ /** Process an include file directive
+ */
+ bool DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
+
User* RehashUser;
std::string RehashParameter;
@@ -679,12 +683,12 @@ class CoreExport ServerConfig : public Extensible
/** Load 'filename' into 'target', with the new config parser everything is parsed into
* tag/key/value at load-time rather than at read-value time.
*/
- bool LoadConf(ConfigDataHash &target, const char* filename, std::ostringstream &errorstream);
+ bool LoadConf(ConfigDataHash &target, FILE* &conf, const char* filename, std::ostringstream &errorstream);
/** Load 'filename' into 'target', with the new config parser everything is parsed into
* tag/key/value at load-time rather than at read-value time.
*/
- bool LoadConf(ConfigDataHash &target, const std::string &filename, std::ostringstream &errorstream);
+ bool LoadConf(ConfigDataHash &target, FILE* &conf, const std::string &filename, std::ostringstream &errorstream);
/* Both these return true if the value existed or false otherwise */
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 11c74f88c..7a7934f16 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -950,7 +950,7 @@ void ServerConfig::Read(bool bail, User* user)
/* Make a copy here so if it fails then we can carry on running with an unaffected config */
newconfig.clear();
- if (this->LoadConf(newconfig, ServerInstance->ConfigFileName, errstr))
+ if (this->DoInclude(newconfig, ServerInstance->ConfigFileName, errstr))
{
/* If we succeeded, set the ircd config to the new one */
ServerInstance->Threads->Mutex(true);
@@ -1266,9 +1266,8 @@ void ServerConfig::Read(bool bail, User* user)
}
-bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::ostringstream &errorstream)
+bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const char* filename, std::ostringstream &errorstream)
{
- std::ifstream conf(filename);
std::string line;
char ch;
long linenumber;
@@ -1289,9 +1288,6 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
return false;
}
- /* Fix the chmod of the file to restrict it to the current user and group */
- chmod(filename,0600);
-
for (unsigned int t = 0; t < include_stack.size(); t++)
{
if (std::string(filename) == include_stack[t])
@@ -1305,7 +1301,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
include_stack.push_back(filename);
/* Start reading characters... */
- while (conf.get(ch))
+ while ((ch = fgetc(conf)))
{
/*
@@ -1364,7 +1360,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
{
line += ch;
char real_character;
- if (conf.get(real_character))
+ if ((real_character = fgetc(conf)))
{
if (real_character == 'n')
real_character = '\n';
@@ -1470,9 +1466,9 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
}
-bool ServerConfig::LoadConf(ConfigDataHash &target, const std::string &filename, std::ostringstream &errorstream)
+bool ServerConfig::LoadConf(ConfigDataHash &target, FILE* &conf, const std::string &filename, std::ostringstream &errorstream)
{
- return this->LoadConf(target, filename.c_str(), errorstream);
+ return this->LoadConf(target, conf, filename.c_str(), errorstream);
}
bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &linenumber, std::ostringstream &errorstream)
@@ -1577,6 +1573,12 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &li
if (!this->DoInclude(target, current_value, errorstream))
return false;
}
+ else if ((tagname == "include") && (current_key == "executable"))
+ {
+ /* Pipe an executable and use its stdout as config data */
+ if (!this->DoPipe(target, current_value, errorstream))
+ return false;
+ }
current_key.clear();
current_value.clear();
@@ -1599,6 +1601,22 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long &li
return true;
}
+bool ServerConfig::DoPipe(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream)
+{
+ FILE* conf = popen(file.c_str(), "r");
+ bool ret = false;
+
+ if (conf)
+ {
+ ret = LoadConf(target, conf, file.c_str(), errorstream);
+ pclose(conf);
+ }
+ else
+ errorstream << "Couldn't execute: " << file << std::endl;
+
+ return ret;
+}
+
bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream)
{
std::string confpath;
@@ -1625,7 +1643,18 @@ bool ServerConfig::DoInclude(ConfigDataHash &target, const std::string &file, st
}
}
- return LoadConf(target, newfile, errorstream);
+ FILE* conf = fopen(newfile.c_str(), "r");
+ bool ret = false;
+
+ if (conf)
+ {
+ ret = LoadConf(target, conf, newfile, errorstream);
+ fclose(conf);
+ }
+ else
+ errorstream << "Couldn't open config file: " << file << std::endl;
+
+ return ret;
}
bool ServerConfig::ConfValue(ConfigDataHash &target, const char* tag, const char* var, int index, char* result, int length, bool allow_linefeeds)
diff --git a/src/modules.cpp b/src/modules.cpp
index 6271213fd..8fd1e84de 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -823,8 +823,8 @@ ConfigReader::ConfigReader(InspIRCd* Instance, const std::string &filename) : Se
this->data = new ConfigDataHash;
this->privatehash = true;
this->errorlog = new std::ostringstream(std::stringstream::in | std::stringstream::out);
- /*** XXX: Can return a 'not ready yet!' code! */
- this->readerror = ServerInstance->Config->LoadConf(*this->data, filename, *this->errorlog);
+ /*** XXX: This might block! */
+ this->readerror = ServerInstance->Config->DoInclude(*this->data, filename, *this->errorlog);
if (!this->readerror)
this->error = CONF_FILE_NOT_FOUND;
}