]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/configparser.cpp
Treat an empty bool/duration/int/uint config field as undefined.
[user/henk/code/inspircd.git] / src / configparser.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 linuxdaemon <linuxdaemon.irc@gmail.com>
5  *   Copyright (C) 2013-2014, 2016-2020 Sadie Powell <sadie@witchery.services>
6  *   Copyright (C) 2013 ChrisTX <xpipe@hotmail.de>
7  *   Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
8  *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
9  *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
10  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
11  *
12  * This file is part of InspIRCd.  InspIRCd is free software: you can
13  * redistribute it and/or modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation, version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24
25
26 #include "inspircd.h"
27 #include <fstream>
28 #include "configparser.h"
29
30 enum ParseFlags
31 {
32         // Legacy config parsing should be used.
33         FLAG_USE_COMPAT = 1,
34
35         // Executable includes are disabled.
36         FLAG_NO_EXEC = 2,
37
38         // All includes are disabled.
39         FLAG_NO_INC = 4,
40
41         // &env.FOO; is disabled.
42         FLAG_NO_ENV = 8
43 };
44
45 // Represents the position within a config file.
46 struct FilePosition
47 {
48         // The name of the file which is being read.
49         std::string name;
50
51         // The line of the file that this position points to.
52         unsigned int line;
53
54         // The column of the file that this position points to.
55         unsigned int column;
56
57         FilePosition(const std::string& Name)
58                 : name(Name)
59                 , line(1)
60                 , column(1)
61         {
62         }
63
64         /** Returns a string that represents this file position. */
65         std::string str()
66         {
67                 return name + ":" + ConvToStr(line) + ":" + ConvToStr(column);
68         }
69 };
70
71 // RAII wrapper for FILE* which closes the file when it goes out of scope.
72 class FileWrapper
73 {
74  private:
75         // Whether this file handle should be closed with pclose.
76         bool close_with_pclose;
77
78         // The file handle which is being wrapped.
79         FILE* const file;
80
81  public:
82         FileWrapper(FILE* File, bool CloseWithPClose = false)
83                 : close_with_pclose(CloseWithPClose)
84                 , file(File)
85         {
86         }
87
88         // Operator which determines whether the file is open.
89         operator bool() { return (file != NULL); }
90
91         // Operator which retrieves the underlying FILE pointer.
92         operator FILE*() { return file; }
93
94         ~FileWrapper()
95         {
96                 if (!file)
97                         return;
98
99                 if (close_with_pclose)
100                         pclose(file);
101                 else
102                         fclose(file);
103         }
104 };
105
106
107 struct Parser
108 {
109         ParseStack& stack;
110         int flags;
111         FILE* const file;
112         FilePosition current;
113         FilePosition last_tag;
114         reference<ConfigTag> tag;
115         int ungot;
116         std::string mandatory_tag;
117
118         Parser(ParseStack& me, int myflags, FILE* conf, const std::string& name, const std::string& mandatorytag)
119                 : stack(me), flags(myflags), file(conf), current(name), last_tag(name), ungot(-1), mandatory_tag(mandatorytag)
120         { }
121
122         int next(bool eof_ok = false)
123         {
124                 if (ungot != -1)
125                 {
126                         int ch = ungot;
127                         ungot = -1;
128                         return ch;
129                 }
130                 int ch = fgetc(file);
131                 if (ch == EOF && !eof_ok)
132                 {
133                         throw CoreException("Unexpected end-of-file");
134                 }
135                 else if (ch == '\n')
136                 {
137                         current.line++;
138                         current.column = 0;
139                 }
140                 else
141                 {
142                         current.column++;
143                 }
144                 return ch;
145         }
146
147         void unget(int ch)
148         {
149                 if (ungot != -1)
150                         throw CoreException("INTERNAL ERROR: cannot unget twice");
151                 ungot = ch;
152         }
153
154         void comment()
155         {
156                 while (1)
157                 {
158                         int ch = next();
159                         if (ch == '\n')
160                                 return;
161                 }
162         }
163
164         bool wordchar(char ch)
165         {
166                 return isalnum(ch)
167                         || ch == '-'
168                         || ch == '.'
169                         || ch == '_';
170         }
171
172         void nextword(std::string& rv)
173         {
174                 int ch = next();
175                 while (isspace(ch))
176                         ch = next();
177                 while (wordchar(ch))
178                 {
179                         rv.push_back(ch);
180                         ch = next();
181                 }
182                 unget(ch);
183         }
184
185         bool kv(ConfigItems* items)
186         {
187                 std::string key;
188                 nextword(key);
189                 int ch = next();
190                 if (ch == '>' && key.empty())
191                 {
192                         return false;
193                 }
194                 else if (ch == '#' && key.empty())
195                 {
196                         comment();
197                         return true;
198                 }
199                 else if (ch != '=')
200                 {
201                         throw CoreException("Invalid character " + std::string(1, ch) + " in key (" + key + ")");
202                 }
203
204                 std::string value;
205                 ch = next();
206                 if (ch != '"')
207                 {
208                         throw CoreException("Invalid character in value of <" + tag->tag + ":" + key + ">");
209                 }
210                 while (1)
211                 {
212                         ch = next();
213                         if (ch == '&' && !(flags & FLAG_USE_COMPAT))
214                         {
215                                 std::string varname;
216                                 while (1)
217                                 {
218                                         ch = next();
219                                         if (wordchar(ch) || (varname.empty() && ch == '#'))
220                                                 varname.push_back(ch);
221                                         else if (ch == ';')
222                                                 break;
223                                         else
224                                         {
225                                                 stack.errstr << "Invalid XML entity name in value of <" + tag->tag + ":" + key + ">\n"
226                                                         << "To include an ampersand or quote, use &amp; or &quot;\n";
227                                                 throw CoreException("Parse error");
228                                         }
229                                 }
230                                 if (varname.empty())
231                                         throw CoreException("Empty XML entity reference");
232                                 else if (varname[0] == '#' && (varname.size() == 1 || (varname.size() == 2 && varname[1] == 'x')))
233                                         throw CoreException("Empty numeric character reference");
234                                 else if (varname[0] == '#')
235                                 {
236                                         const char* cvarname = varname.c_str();
237                                         char* endptr;
238                                         unsigned long lvalue;
239                                         if (cvarname[1] == 'x')
240                                                 lvalue = strtoul(cvarname + 2, &endptr, 16);
241                                         else
242                                                 lvalue = strtoul(cvarname + 1, &endptr, 10);
243                                         if (*endptr != '\0' || lvalue > 255)
244                                                 throw CoreException("Invalid numeric character reference '&" + varname + ";'");
245                                         value.push_back(static_cast<char>(lvalue));
246                                 }
247                                 else if (varname.compare(0, 4, "env.") == 0)
248                                 {
249                                         if (flags & FLAG_NO_ENV)
250                                                 throw CoreException("XML environment entity reference in file included with noenv=\"yes\"");
251
252                                         const char* envstr = getenv(varname.c_str() + 4);
253                                         if (!envstr)
254                                                 throw CoreException("Undefined XML environment entity reference '&" + varname + ";'");
255
256                                         value.append(envstr);
257                                 }
258                                 else
259                                 {
260                                         insp::flat_map<std::string, std::string>::iterator var = stack.vars.find(varname);
261                                         if (var == stack.vars.end())
262                                                 throw CoreException("Undefined XML entity reference '&" + varname + ";'");
263                                         value.append(var->second);
264                                 }
265                         }
266                         else if (ch == '\\' && (flags & FLAG_USE_COMPAT))
267                         {
268                                 int esc = next();
269                                 if (esc == 'n')
270                                         value.push_back('\n');
271                                 else if (isalpha(esc))
272                                         throw CoreException("Unknown escape character \\" + std::string(1, esc));
273                                 else
274                                         value.push_back(esc);
275                         }
276                         else if (ch == '"')
277                                 break;
278                         else if (ch != '\r')
279                                 value.push_back(ch);
280                 }
281
282                 if (items->find(key) != items->end())
283                         throw CoreException("Duplicate key '" + key + "' found");
284
285                 (*items)[key] = value;
286                 return true;
287         }
288
289         void dotag()
290         {
291                 last_tag = current;
292                 std::string name;
293                 nextword(name);
294
295                 int spc = next();
296                 if (spc == '>')
297                         unget(spc);
298                 else if (!isspace(spc))
299                         throw CoreException("Invalid character in tag name");
300
301                 if (name.empty())
302                         throw CoreException("Empty tag name");
303
304                 ConfigItems* items;
305                 tag = ConfigTag::create(name, current.name, current.line, items);
306
307                 while (kv(items))
308                 {
309                         // Do nothing here (silences a GCC warning).
310                 }
311
312                 if (name == mandatory_tag)
313                 {
314                         // Found the mandatory tag
315                         mandatory_tag.clear();
316                 }
317
318                 if (stdalgo::string::equalsci(name, "include"))
319                 {
320                         stack.DoInclude(tag, flags);
321                 }
322                 else if (stdalgo::string::equalsci(name, "files"))
323                 {
324                         for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
325                         {
326                                 stack.DoReadFile(i->first, i->second, flags, false);
327                         }
328                 }
329                 else if (stdalgo::string::equalsci(name, "execfiles"))
330                 {
331                         for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
332                         {
333                                 stack.DoReadFile(i->first, i->second, flags, true);
334                         }
335                 }
336                 else if (stdalgo::string::equalsci(name, "define"))
337                 {
338                         if (flags & FLAG_USE_COMPAT)
339                                 throw CoreException("<define> tags may only be used in XML-style config (add <config format=\"xml\">)");
340                         std::string varname = tag->getString("name");
341                         std::string value = tag->getString("value");
342                         if (varname.empty())
343                                 throw CoreException("Variable definition must include variable name");
344                         stack.vars[varname] = value;
345                 }
346                 else if (stdalgo::string::equalsci(name, "config"))
347                 {
348                         std::string format = tag->getString("format");
349                         if (stdalgo::string::equalsci(format, "xml"))
350                                 flags &= ~FLAG_USE_COMPAT;
351                         else if (stdalgo::string::equalsci(format, "compat"))
352                                 flags |= FLAG_USE_COMPAT;
353                         else if (!format.empty())
354                                 throw CoreException("Unknown configuration format " + format);
355                 }
356                 else
357                 {
358                         stack.output.insert(std::make_pair(name, tag));
359                 }
360                 // this is not a leak; reference<> takes care of the delete
361                 tag = NULL;
362         }
363
364         bool outer_parse()
365         {
366                 try
367                 {
368                         while (1)
369                         {
370                                 int ch = next(true);
371                                 switch (ch)
372                                 {
373                                         case EOF:
374                                                 // this is the one place where an EOF is not an error
375                                                 if (!mandatory_tag.empty())
376                                                         throw CoreException("Mandatory tag \"" + mandatory_tag + "\" not found");
377                                                 return true;
378                                         case '#':
379                                                 comment();
380                                                 break;
381                                         case '<':
382                                                 dotag();
383                                                 break;
384                                         case ' ':
385                                         case '\r':
386                                         case '\t':
387                                         case '\n':
388                                                 break;
389                                         case 0xFE:
390                                         case 0xFF:
391                                                 stack.errstr << "Do not save your files as UTF-16 or UTF-32, use UTF-8!\n";
392                                                 /*@fallthrough@*/
393                                         default:
394                                                 throw CoreException("Syntax error - start of tag expected");
395                                 }
396                         }
397                 }
398                 catch (CoreException& err)
399                 {
400                         stack.errstr << err.GetReason() << " at " << current.str();
401                         if (tag)
402                                 stack.errstr << " (inside tag " << tag->tag << " at line " << tag->src_line << ")\n";
403                         else
404                                 stack.errstr << " (last tag was on line " << last_tag.line << ")\n";
405                 }
406                 return false;
407         }
408 };
409
410 void ParseStack::DoInclude(ConfigTag* tag, int flags)
411 {
412         if (flags & FLAG_NO_INC)
413                 throw CoreException("Invalid <include> tag in file included with noinclude=\"yes\"");
414
415         std::string mandatorytag;
416         tag->readString("mandatorytag", mandatorytag);
417
418         std::string name;
419         if (tag->readString("file", name))
420         {
421                 if (tag->getBool("noinclude", false))
422                         flags |= FLAG_NO_INC;
423                 if (tag->getBool("noexec", false))
424                         flags |= FLAG_NO_EXEC;
425                 if (tag->getBool("noenv", false))
426                         flags |= FLAG_NO_ENV;
427
428                 if (!ParseFile(ServerInstance->Config->Paths.PrependConfig(name), flags, mandatorytag))
429                         throw CoreException("Included");
430         }
431         else if (tag->readString("directory", name))
432         {
433                 if (tag->getBool("noinclude", false))
434                         flags |= FLAG_NO_INC;
435                 if (tag->getBool("noexec", false))
436                         flags |= FLAG_NO_EXEC;
437                 if (tag->getBool("noenv", false))
438                         flags |= FLAG_NO_ENV;
439
440                 const std::string includedir = ServerInstance->Config->Paths.PrependConfig(name);
441                 std::vector<std::string> files;
442                 if (!FileSystem::GetFileList(includedir, files, "*.conf"))
443                         throw CoreException("Unable to read directory for include: " + includedir);
444
445                 std::sort(files.begin(), files.end());
446                 for (std::vector<std::string>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
447                 {
448                         const std::string path = includedir + '/' + *iter;
449                         if (!ParseFile(path, flags, mandatorytag))
450                                 throw CoreException("Included");
451                 }
452         }
453         else if (tag->readString("executable", name))
454         {
455                 if (flags & FLAG_NO_EXEC)
456                         throw CoreException("Invalid <include:executable> tag in file included with noexec=\"yes\"");
457                 if (tag->getBool("noinclude", false))
458                         flags |= FLAG_NO_INC;
459                 if (tag->getBool("noexec", true))
460                         flags |= FLAG_NO_EXEC;
461                 if (tag->getBool("noenv", true))
462                         flags |= FLAG_NO_ENV;
463
464                 if (!ParseFile(name, flags, mandatorytag, true))
465                         throw CoreException("Included");
466         }
467 }
468
469 void ParseStack::DoReadFile(const std::string& key, const std::string& name, int flags, bool exec)
470 {
471         if (flags & FLAG_NO_INC)
472                 throw CoreException("Invalid <files> tag in file included with noinclude=\"yes\"");
473         if (exec && (flags & FLAG_NO_EXEC))
474                 throw CoreException("Invalid <execfiles> tag in file included with noexec=\"yes\"");
475
476         std::string path = ServerInstance->Config->Paths.PrependConfig(name);
477         FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(path.c_str(), "r"), exec);
478         if (!file)
479                 throw CoreException("Could not read \"" + path + "\" for \"" + key + "\" file");
480
481         file_cache& cache = FilesOutput[key];
482         cache.clear();
483
484         char linebuf[5120];
485         while (fgets(linebuf, sizeof(linebuf), file))
486         {
487                 size_t len = strlen(linebuf);
488                 if (len)
489                 {
490                         if (linebuf[len-1] == '\n')
491                                 len--;
492                         cache.push_back(std::string(linebuf, len));
493                 }
494         }
495 }
496
497 bool ParseStack::ParseFile(const std::string& path, int flags, const std::string& mandatory_tag, bool isexec)
498 {
499         ServerInstance->Logs->Log("CONFIG", LOG_DEBUG, "Reading (isexec=%d) %s", isexec, path.c_str());
500         if (stdalgo::isin(reading, path))
501                 throw CoreException((isexec ? "Executable " : "File ") + path + " is included recursively (looped inclusion)");
502
503         /* It's not already included, add it to the list of files we've loaded */
504
505         FileWrapper file((isexec ? popen(path.c_str(), "r") : fopen(path.c_str(), "r")), isexec);
506         if (!file)
507                 throw CoreException("Could not read \"" + path + "\" for include");
508
509         reading.push_back(path);
510         Parser p(*this, flags, file, path, mandatory_tag);
511         bool ok = p.outer_parse();
512         reading.pop_back();
513         return ok;
514 }
515
516 bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf)
517 {
518         for(ConfigItems::iterator j = items.begin(); j != items.end(); ++j)
519         {
520                 if(j->first != key)
521                         continue;
522                 value = j->second;
523                 if (!allow_lf && (value.find('\n') != std::string::npos))
524                 {
525                         ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + getTagLocation() +
526                                 " contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces.");
527                         for (std::string::iterator n = value.begin(); n != value.end(); n++)
528                                 if (*n == '\n')
529                                         *n = ' ';
530                 }
531                 return true;
532         }
533         return false;
534 }
535
536 std::string ConfigTag::getString(const std::string& key, const std::string& def, const TR1NS::function<bool(const std::string&)>& validator)
537 {
538         std::string res;
539         if (!readString(key, res))
540                 return def;
541
542         if (!validator(res))
543         {
544                 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: The value of <%s:%s> is not valid; value set to %s.",
545                         tag.c_str(), key.c_str(), def.c_str());
546                 return def;
547         }
548         return res;
549 }
550
551 std::string ConfigTag::getString(const std::string& key, const std::string& def, size_t minlen, size_t maxlen)
552 {
553         std::string res;
554         if (!readString(key, res))
555                 return def;
556
557         if (res.length() < minlen || res.length() > maxlen)
558         {
559                 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: The length of <%s:%s> is not between %ld and %ld; value set to %s.",
560                         tag.c_str(), key.c_str(), minlen, maxlen, def.c_str());
561                 return def;
562         }
563         return res;
564 }
565
566 namespace
567 {
568         /** Check for an invalid magnitude specifier. If one is found a warning is logged and the
569          * value is corrected (set to \p def).
570          * @param tag The tag name; used in the warning message.
571          * @param key The key name; used in the warning message.
572          * @param val The full value set in the config as a string.
573          * @param num The value to verify and modify if needed.
574          * @param def The default value, \p res will be set to this if \p tail does not contain a.
575          *            valid magnitude specifier.
576          * @param tail The location in the config value at which the magnifier is located.
577          */
578         template <typename Numeric>
579         void CheckMagnitude(const std::string& tag, const std::string& key, const std::string& val, Numeric& num, Numeric def, const char* tail)
580         {
581                 // If this is NULL then no magnitude specifier was given.
582                 if (!*tail)
583                         return;
584
585                 switch (toupper(*tail))
586                 {
587                         case 'K':
588                                 num *= 1024;
589                                 return;
590
591                         case 'M':
592                                 num *= 1024 * 1024;
593                                 return;
594
595                         case 'G':
596                                 num *= 1024 * 1024 * 1024;
597                                 return;
598                 }
599
600                 const std::string message = "WARNING: <" + tag + ":" + key + "> value of " + val + " contains an invalid magnitude specifier '"
601                         + tail + "'; value set to " + ConvToStr(def) + ".";
602                 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, message);
603                 num = def;
604         }
605
606         /** Check for an out of range value. If the value falls outside the boundaries a warning is
607          * logged and the value is corrected (set to \p def).
608          * @param tag The tag name; used in the warning message.
609          * @param key The key name; used in the warning message.
610          * @param num The value to verify and modify if needed.
611          * @param def The default value, \p res will be set to this if (min <= res <= max) doesn't hold true.
612          * @param min Minimum accepted value for \p res.
613          * @param max Maximum accepted value for \p res.
614          */
615         template <typename Numeric>
616         void CheckRange(const std::string& tag, const std::string& key, Numeric& num, Numeric def, Numeric min, Numeric max)
617         {
618                 if (num >= min && num <= max)
619                         return;
620
621                 const std::string message = "WARNING: <" + tag + ":" + key + "> value of " + ConvToStr(num) + " is not between "
622                         + ConvToStr(min) + " and " + ConvToStr(max) + "; value set to " + ConvToStr(def) + ".";
623                 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, message);
624                 num = def;
625         }
626 }
627
628 long ConfigTag::getInt(const std::string &key, long def, long min, long max)
629 {
630         std::string result;
631         if(!readString(key, result) || result.empty())
632                 return def;
633
634         const char* res_cstr = result.c_str();
635         char* res_tail = NULL;
636         long res = strtol(res_cstr, &res_tail, 0);
637         if (res_tail == res_cstr)
638                 return def;
639
640         CheckMagnitude(tag, key, result, res, def, res_tail);
641         CheckRange(tag, key, res, def, min, max);
642         return res;
643 }
644
645 unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max)
646 {
647         std::string result;
648         if (!readString(key, result) || result.empty())
649                 return def;
650
651         const char* res_cstr = result.c_str();
652         char* res_tail = NULL;
653         unsigned long res = strtoul(res_cstr, &res_tail, 0);
654         if (res_tail == res_cstr)
655                 return def;
656
657         CheckMagnitude(tag, key, result, res, def, res_tail);
658         CheckRange(tag, key, res, def, min, max);
659         return res;
660 }
661
662 unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max)
663 {
664         std::string duration;
665         if (!readString(key, duration) || duration.empty())
666                 return def;
667
668         unsigned long ret;
669         if (!InspIRCd::Duration(duration, ret))
670         {
671                 ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + getTagLocation() +
672                         " is not a duration; value set to " + ConvToStr(def) + ".");
673                 return def;
674         }
675
676         CheckRange(tag, key, ret, def, min, max);
677         return ret;
678 }
679
680 double ConfigTag::getFloat(const std::string& key, double def, double min, double max)
681 {
682         std::string result;
683         if (!readString(key, result))
684                 return def;
685
686         double res = strtod(result.c_str(), NULL);
687         CheckRange(tag, key, res, def, min, max);
688         return res;
689 }
690
691 bool ConfigTag::getBool(const std::string &key, bool def)
692 {
693         std::string result;
694         if(!readString(key, result) || result.empty())
695                 return def;
696
697         if (stdalgo::string::equalsci(result, "yes") || stdalgo::string::equalsci(result, "true") || stdalgo::string::equalsci(result, "on") || result == "1")
698                 return true;
699
700         if (stdalgo::string::equalsci(result, "no") || stdalgo::string::equalsci(result, "false") || stdalgo::string::equalsci(result, "off") || result == "0")
701                 return false;
702
703         ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + getTagLocation() +
704                 " is not valid, ignoring");
705         return def;
706 }
707
708 std::string ConfigTag::getTagLocation()
709 {
710         return src_name + ":" + ConvToStr(src_line);
711 }
712
713 ConfigTag* ConfigTag::create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items)
714 {
715         ConfigTag* rv = new ConfigTag(Tag, file, line);
716         Items = &rv->items;
717         return rv;
718 }
719
720 ConfigTag::ConfigTag(const std::string& Tag, const std::string& file, int line)
721         : tag(Tag), src_name(file), src_line(line)
722 {
723 }
724
725 OperInfo::OperInfo(const std::string& Name)
726         : name(Name)
727 {
728 }
729
730 std::string OperInfo::getConfig(const std::string& key)
731 {
732         std::string rv;
733         if (type_block)
734                 type_block->readString(key, rv);
735         if (oper_block)
736                 oper_block->readString(key, rv);
737         return rv;
738 }