2008-12-11 03:48:25 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-11 03:48:25 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2012-01-12 03:24:08 +01:00
|
|
|
* Copyright (c) 2008-2012, Tomasz Sowa
|
2008-12-11 03:48:25 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "log.h"
|
2009-11-13 21:40:11 +01:00
|
|
|
#include "plugin.h"
|
2009-12-30 21:46:12 +01:00
|
|
|
#include "misc.h"
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
#include "crypt.h"
|
2008-12-11 03:48:25 +01:00
|
|
|
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
Config::Config()
|
|
|
|
{
|
|
|
|
errors_to_stdout = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
//!! czy tu w ogole mozemy uzywac log << ?
|
|
|
|
//!! przeciez jeszcze nie zostal przetworzony plik konfiguracyjny
|
|
|
|
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
void Config::ShowError()
|
|
|
|
{
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
switch( parser.status )
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2012-05-01 00:53:54 +02:00
|
|
|
case PT::SpaceParser::no_space:
|
2011-09-26 07:40:26 +02:00
|
|
|
log << log2 << "Config: space not set" << logend;
|
|
|
|
break;
|
|
|
|
|
2012-05-01 00:53:54 +02:00
|
|
|
case PT::SpaceParser::ok:
|
2008-12-30 02:05:03 +01:00
|
|
|
log << log2 << "Config: syntax ok" << logend;
|
2008-12-11 03:48:25 +01:00
|
|
|
break;
|
|
|
|
|
2012-05-01 00:53:54 +02:00
|
|
|
case PT::SpaceParser::cant_open_file:
|
2008-12-11 03:48:25 +01:00
|
|
|
if( errors_to_stdout )
|
2010-08-10 18:12:50 +02:00
|
|
|
std::cout << "Config: cant open a config file: " << config_file << std::endl;
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
log << log1 << "Config: cant open a config file: " << config_file << logend;
|
2008-12-11 03:48:25 +01:00
|
|
|
break;
|
|
|
|
|
2012-05-01 00:53:54 +02:00
|
|
|
case PT::SpaceParser::syntax_error:
|
2008-12-11 03:48:25 +01:00
|
|
|
if( errors_to_stdout )
|
2010-08-10 18:12:50 +02:00
|
|
|
std::cout << "Config: syntax error, line: " << parser.line << std::endl;
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
log << log1 << "Config: syntax error, line: " << parser.line << logend;
|
2008-12-11 03:48:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
|
|
|
errors_to_stdout = errors_to_stdout_;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
if( config_file.empty() )
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
log << log2 << "Config: name of the config file is empty" << logend;
|
2008-12-11 03:48:25 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
log << log2 << "Config: reading a config file" << logend;
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
parser.SplitSingle(true);
|
2010-11-21 01:19:17 +01:00
|
|
|
parser.UTF8(true); // config is always read in UTF-8
|
2011-09-26 07:40:26 +02:00
|
|
|
parser.SetSpace(space);
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2012-05-01 00:53:54 +02:00
|
|
|
PT::SpaceParser::Status status = parser.Parse(config_file);
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2012-05-01 00:53:54 +02:00
|
|
|
if( status == PT::SpaceParser::ok )
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2010-08-10 18:12:50 +02:00
|
|
|
AssignValues(stdout_is_closed);
|
|
|
|
SetAdditionalVariables();
|
2008-12-11 03:48:25 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowError();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void Config::AssignValues(bool stdout_is_closed)
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2012-06-27 01:19:19 +02:00
|
|
|
demonize = Bool(L"demonize", true);
|
|
|
|
|
|
|
|
user = AText(L"user");
|
|
|
|
group = AText(L"group");
|
|
|
|
additional_groups = Bool(L"additional_groups", true);
|
|
|
|
|
|
|
|
log_file = AText(L"log_file");
|
|
|
|
log_notify_file = AText(L"log_notify_file");
|
|
|
|
log_delimiter = Text(L"log_delimiter", L"---------------------------------------------------------------------------------");
|
|
|
|
fcgi_socket = AText(L"fcgi_socket");
|
|
|
|
fcgi_socket_chmod = Int(L"fcgi_socket_chmod", 0770);
|
|
|
|
fcgi_socket_user = AText(L"fcgi_socket_user");
|
|
|
|
fcgi_socket_group = AText(L"fcgi_socket_group");
|
|
|
|
log_level = Int(L"log_level", 1);
|
|
|
|
log_request = Int(L"log_request", 1);
|
|
|
|
log_save_each_line = Bool(L"log_save_each_line", false);
|
2012-09-06 19:50:14 +02:00
|
|
|
log_time_zone_id = Size(L"log_time_zone_id", 34);
|
2012-06-27 01:19:19 +02:00
|
|
|
log_stdout = Bool(L"log_stdout", false);
|
|
|
|
log_db_query = Bool(L"log_db_query", false);
|
|
|
|
log_plugin_call = Bool(L"log_plugin_call", false);
|
|
|
|
log_post_value_size = Size(L"log_post_value_size", 80);
|
|
|
|
|
|
|
|
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
|
|
|
|
|
|
|
|
upload_dir = Text(L"upload_dir");
|
|
|
|
common_dir = Text(L"common_dir");
|
2011-06-24 22:53:21 +02:00
|
|
|
NoLastSlash(upload_dir);
|
|
|
|
NoLastSlash(common_dir);
|
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
upload_dirs_chmod = Int(L"upload_dirs_chmod", 0750);
|
|
|
|
upload_files_chmod = Int(L"upload_files_chmod", 0640);
|
2011-06-15 01:45:42 +02:00
|
|
|
ListText(L"static_dirs", static_dirs);
|
2012-06-27 01:19:19 +02:00
|
|
|
dont_use_static_dirs = Bool(L"dont_use_static_dirs", false);
|
|
|
|
create_thumb = Bool(L"create_thumb", true);
|
|
|
|
thumb_mode = Int(L"thumb_mode", 2);
|
|
|
|
thumb_cx = Size(L"thumb_cx", 150);
|
|
|
|
thumb_cy = Size(L"thumb_cy", 150);
|
|
|
|
thumb_quality = Int(L"thumb_quality", 92);
|
|
|
|
image_resize = Bool(L"image_resize", true);
|
|
|
|
image_mode = Int(L"image_mode", 6);
|
|
|
|
image_cx = Size(L"image_cx", 1000);
|
|
|
|
image_cy = Size(L"image_cy", 800);
|
|
|
|
image_quality = Int(L"image_quality", 92);
|
|
|
|
convert_cmd = Text(L"convert_cmd", L"/usr/local/bin/convert");
|
|
|
|
|
|
|
|
templates_dir = Text(L"templates_dir");
|
|
|
|
templates_dir_default = Text(L"templates_dir_default");
|
|
|
|
txt_templates_dir = Text(L"txt_templates_dir");
|
2010-12-02 02:02:02 +01:00
|
|
|
txt_templates_dir_default = Text(L"txt_templates_dir_default");
|
2012-06-27 01:19:19 +02:00
|
|
|
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
|
|
|
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
|
|
|
templates_index = Text(L"templates_index", L"index.html");
|
2010-11-21 01:19:17 +01:00
|
|
|
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
http_session_id_name = AText(L"http_session_id_name");
|
|
|
|
db_database = AText(L"db_database");
|
|
|
|
db_user = AText(L"db_user");
|
|
|
|
db_pass = AText(L"db_pass");
|
|
|
|
item_url_empty = Text(L"item_url_empty");
|
2010-11-21 01:19:17 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
url_proto = Text(L"url_proto", L"http://");
|
|
|
|
url_ssl_proto = Text(L"url_ssl_proto", L"https://");
|
2011-08-18 01:09:47 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
use_ssl = Bool(L"use_ssl", false);
|
|
|
|
use_ssl_static = Bool(L"use_ssl_static", false);
|
|
|
|
use_ssl_common = Bool(L"use_ssl_common", false);
|
2011-08-18 01:09:47 +02:00
|
|
|
use_ssl_only_for_logged_users = Bool(L"use_ssl_only_for_logged_users", true);
|
2012-06-27 01:19:19 +02:00
|
|
|
use_ssl_redirect_code = Int(L"use_ssl_redirect_code", 303);
|
2011-08-18 01:09:47 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
base_url = Text(L"base_url");
|
|
|
|
base_url_static = Text(L"base_url_static");
|
|
|
|
base_url_common = Text(L"base_url_common");
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
base_url_redirect = Bool(L"base_url_redirect", false);
|
|
|
|
base_url_redirect_code = Int(L"base_url_redirect_code", 301);
|
2012-04-22 15:30:07 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
NoLastSlash(base_url);
|
|
|
|
NoLastSlash(base_url_static);
|
|
|
|
NoLastSlash(base_url_common);
|
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
priv_no_user = Text(L"priv_no_user", L"-- no user --");
|
|
|
|
priv_no_group = Text(L"priv_no_group", L"-- no group --");
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
session_max_idle = Int(L"session_max_idle", 10800); // 3h
|
2010-11-21 01:19:17 +01:00
|
|
|
session_remember_max_idle = Int(L"session_remember_max_idle", 16070400); // 3 months
|
2012-06-27 01:19:19 +02:00
|
|
|
session_file = AText(L"session_file");
|
|
|
|
session_max = Size(L"session_max", 1000000);
|
2009-11-21 00:09:52 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
compression = Bool(L"compression", true);
|
2011-04-02 02:10:16 +02:00
|
|
|
compression_page_min_size = Size(L"compression_page_min_size", 512);
|
2012-06-27 01:19:19 +02:00
|
|
|
compression_encoding = Int(L"compression_encoding", 20);
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
html_filter = Bool(L"html_filter", true);
|
|
|
|
html_filter_trim_white = Bool(L"html_filter_trim_white", true);
|
|
|
|
html_filter_break_word = Int(L"html_filter_break_word", 60);
|
|
|
|
html_filter_wrap_line = Int(L"html_filter_wrap_line", 110);
|
|
|
|
html_filter_tabs = Size(L"html_filter_tabs", 2);
|
2011-04-16 10:42:22 +02:00
|
|
|
html_filter_orphans = Bool(L"html_filter_orphans", true);
|
2011-09-26 07:40:26 +02:00
|
|
|
html_filter_orphans_mode_str = Text(L"html_filter_orphans_mode_str", L"nbsp");
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
locale_dir = Text(L"locale_dir");
|
|
|
|
locale_dir_default = Text(L"locale_dir_default");
|
|
|
|
locale_max_id = Size(L"locale_max_id", 100);
|
|
|
|
locale_default_id = Size(L"locale_default_id", 0);
|
2011-02-24 18:06:12 +01:00
|
|
|
ListText(L"locale_files", locale_files);
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
title_separator = Text(L"title_separator", L" / ");
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
http_header_send_file = Text(L"http_header_send_file", L"X-LIGHTTPD-send-file");
|
|
|
|
debug_info = Bool(L"debug_info", false);
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
editors_html_safe_mode = Bool(L"editors_html_safe_mode", true);
|
2010-11-21 01:19:17 +01:00
|
|
|
editors_html_safe_mode_skip_root = Bool(L"editors_html_safe_mode_skip_root", true);
|
2010-08-14 19:56:07 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
plugins_dir = Text(L"plugins_dir", L"/usr/local/winix/plugins");
|
2010-08-18 00:32:47 +02:00
|
|
|
NoLastSlash(plugins_dir);
|
2011-02-24 18:06:12 +01:00
|
|
|
ListText(L"plugins", plugin_file);
|
2010-10-24 01:12:47 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
utf8 = Bool(L"utf8", true);
|
|
|
|
symlinks_follow_max = Size(L"symlinks_follow_max", 20);
|
2011-01-05 22:24:11 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
ticket_form_prefix = Text(L"ticket_form_prefix", L"ticketparam");
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
pass_min_size = Size(L"pass_min_size", 5);
|
|
|
|
pass_type = Int(L"pass_type", 12);
|
|
|
|
pass_hash_use_salt = Bool(L"pass_hash_use_salt", false);
|
|
|
|
pass_hash_salt = Text(L"pass_hash_salt");
|
|
|
|
pass_use_rsa = Bool(L"pass_use_rsa", false);
|
|
|
|
pass_rsa_private_key = Text(L"pass_rsa_private_key");
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
opensll_path = Text(L"opensll_path", L"/usr/bin/openssl");
|
2011-07-15 04:09:02 +02:00
|
|
|
|
|
|
|
pattern_cacher_when_delete = Size(L"pattern_cacher_when_delete", 130);
|
|
|
|
pattern_cacher_how_many_delete = Size(L"pattern_cacher_how_many_delete", 30);
|
2011-12-17 22:59:22 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
content_type_header = Int(L"content_type_header", 0);
|
2012-01-25 00:03:36 +01:00
|
|
|
umask = Int(L"umask", 0222);
|
2012-02-17 06:19:24 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
ezc_max_elements = Size(L"ezc_max_elements", 50000);
|
|
|
|
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
|
2012-02-17 06:19:24 +01:00
|
|
|
|
2012-03-09 23:56:54 +01:00
|
|
|
account_need_email_verification = Bool(L"account_need_email_verification", true);
|
|
|
|
reset_password_code_expiration_time = Long(L"reset_password_code_expiration_time", 86400);
|
2012-05-30 21:04:18 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
time_zone_default_id = Size(L"time_zone_default_id", 34);
|
|
|
|
time_zone_max_id = Size(L"time_zone_max_id", 130);
|
2012-05-30 21:04:18 +02:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
etc_dir = Text(L"etc_dir", L"");
|
|
|
|
time_zones_file = Text(L"time_zones_file", L"time_zones.conf");
|
2012-06-23 01:34:33 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2010-07-21 19:24:16 +02:00
|
|
|
|
2011-02-24 18:06:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void Config::SetAdditionalVariables()
|
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
if( html_filter_orphans_mode_str == L"160" )
|
2010-08-12 21:10:12 +02:00
|
|
|
html_filter_orphans_mode = HTMLFilter::orphan_160space;
|
|
|
|
else
|
|
|
|
html_filter_orphans_mode = HTMLFilter::orphan_nbsp;
|
2011-02-24 18:06:12 +01:00
|
|
|
|
2011-06-15 01:45:42 +02:00
|
|
|
for(size_t i=0 ; i<static_dirs.size() ; ++i)
|
|
|
|
NoLastSlash(static_dirs[i]);
|
|
|
|
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
CheckPasswd();
|
2011-12-17 22:59:22 +01:00
|
|
|
|
|
|
|
if( content_type_header < 0 || content_type_header > 2 )
|
|
|
|
content_type_header = 0;
|
2010-01-07 15:45:00 +01:00
|
|
|
|
2012-06-27 01:19:19 +02:00
|
|
|
if( locale_default_id > locale_max_id )
|
|
|
|
locale_default_id = locale_max_id;
|
2012-06-30 20:37:52 +02:00
|
|
|
|
|
|
|
if( locale_files.empty() )
|
|
|
|
locale_files.push_back(L"en");
|
2012-06-27 01:19:19 +02:00
|
|
|
}
|
2011-02-24 18:06:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-07 15:45:00 +01:00
|
|
|
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
void Config::CheckPasswd()
|
|
|
|
{
|
|
|
|
switch(pass_type)
|
|
|
|
{
|
2011-06-24 22:53:21 +02:00
|
|
|
case WINIX_CRYPT_HASH_NONE:
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
case WINIX_CRYPT_HASH_MD4:
|
|
|
|
case WINIX_CRYPT_HASH_MD5:
|
|
|
|
case WINIX_CRYPT_HASH_SHA1:
|
|
|
|
case WINIX_CRYPT_HASH_SHA224:
|
|
|
|
case WINIX_CRYPT_HASH_SHA256:
|
|
|
|
case WINIX_CRYPT_HASH_SHA384:
|
|
|
|
case WINIX_CRYPT_HASH_SHA512:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
pass_type = WINIX_CRYPT_HASH_SHA256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
|
|
|
|
|
2011-09-17 00:46:42 +02:00
|
|
|
std::wstring & Config::Text(const wchar_t * name)
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Text(name);
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2011-09-17 00:46:42 +02:00
|
|
|
std::wstring & Config::Text(const wchar_t * name, const wchar_t * def)
|
2010-01-07 15:45:00 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Text(name, def);
|
2010-01-07 15:45:00 +01:00
|
|
|
}
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2011-09-17 00:46:42 +02:00
|
|
|
std::wstring & Config::Text(const std::wstring & name, const wchar_t * def)
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Text(name, def);
|
2008-12-11 03:48:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-17 00:46:42 +02:00
|
|
|
std::string & Config::AText(const wchar_t * name)
|
2010-11-21 01:19:17 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.AText(name);
|
2010-11-21 01:19:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-26 07:40:26 +02:00
|
|
|
std::string & Config::AText(const wchar_t * name, const char * def)
|
2010-11-21 01:19:17 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.AText(name, def);
|
2010-11-21 01:19:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-26 07:40:26 +02:00
|
|
|
std::string & Config::AText(const std::wstring & name, const char * def)
|
2010-11-21 01:19:17 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.AText(name, def);
|
2010-11-21 01:19:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Config::Int(const wchar_t * name)
|
2010-01-07 15:45:00 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Int(name);
|
2010-01-07 15:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
int Config::Int(const wchar_t * name, int def)
|
2010-01-07 15:45:00 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Int(name, def);
|
2010-01-07 15:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
int Config::Int(const std::wstring & name, int def)
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Int(name, def);
|
2008-12-11 03:48:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-09 23:56:54 +01:00
|
|
|
long Config::Long(const wchar_t * name)
|
|
|
|
{
|
|
|
|
return space.Long(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
long Config::Long(const wchar_t * name, long def)
|
|
|
|
{
|
|
|
|
return space.Long(name, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
long Config::Long(const std::wstring & name, long def)
|
|
|
|
{
|
|
|
|
return space.Long(name, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
size_t Config::Size(const wchar_t * name)
|
2010-08-12 21:10:12 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Size(name);
|
2010-08-12 21:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
size_t Config::Size(const wchar_t * name, size_t def)
|
2010-08-12 21:10:12 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Size(name, def);
|
2010-08-12 21:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
size_t Config::Size(const std::wstring & name, size_t def)
|
2010-08-12 21:10:12 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Size(name, def);
|
2010-08-12 21:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool Config::Bool(const wchar_t * name)
|
2010-01-07 15:45:00 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Bool(name);
|
2010-01-07 15:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool Config::Bool(const wchar_t * name, bool def)
|
2010-01-07 15:45:00 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Bool(name, def);
|
2010-01-07 15:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool Config::Bool(const std::wstring & name, bool def)
|
2008-12-11 03:48:25 +01:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.Bool(name, def);
|
2008-12-11 03:48:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-09-26 07:40:26 +02:00
|
|
|
bool Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
2010-07-21 19:24:16 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.ListText(name, list);
|
2010-07-21 19:24:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-26 07:40:26 +02:00
|
|
|
bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
2010-07-21 19:24:16 +02:00
|
|
|
{
|
2011-09-26 07:40:26 +02:00
|
|
|
return space.ListText(name, list);
|
2010-07-21 19:24:16 +02:00
|
|
|
}
|
|
|
|
|
2008-12-11 03:48:25 +01:00
|
|
|
|
2011-09-26 07:40:26 +02:00
|
|
|
void Config::Print(std::wostream & out)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2011-11-25 05:51:55 +01:00
|
|
|
space.Serialize(out);
|
2009-12-30 21:46:12 +01:00
|
|
|
}
|
2008-12-11 03:48:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|