Compare commits

..

15 Commits

Author SHA1 Message Date
tomasz.sowa 3d7ece15f8 changed version to 0.7.2 2021-02-18 21:07:05 +01:00
tomasz.sowa 541597f355 fixed: in TimeZone::SetTzDst() was used operator && instead of || 2021-02-17 18:36:50 +01:00
tomasz.sowa 5fe843d76b set -std=c++20 in Makefile 2021-02-17 18:07:05 +01:00
tomasz.sowa 3191369ece added 'using PT::FileLog::init' to FileLog to suppress clang warning:
warning: 'Winix::FileLog::init' hides overloaded virtual function [-Woverloaded-virtual]
2021-02-17 18:06:00 +01:00
tomasz.sowa a4de11d69c fixed: Image did not use 'savelog' when creating logs
before commit 4832c7db4b the logs were lost, but after 4832c7db4b
the logs were printed when winix shuts down

in 4832c7db4b at the end of BaseThread::StartRoutine()
has been added a call to save_log()
2021-02-17 16:17:36 +01:00
tomasz.sowa 4832c7db4b fixed: clang address sanitizer reports that there is an use after free bug at the end when winix shuts down:
==3859==ERROR: AddressSanitizer: heap-use-after-free on address 0x61b0000053e0 at pc 0x000800697160 bp 0x7fffffffcfb0 sp 0x7fffffffcfa8
READ of size 8 at 0x61b0000053e0 thread T0
    #0 0x80069715f in PT::MemBuffer<wchar_t, 256ul, 4096ul>::empty() const /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:675:9
    #1 0x80069700d in PT::TextStreamBase<wchar_t, 256ul, 4096ul>::empty() const /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/textstream/textstream.h:161:16
    #2 0x8009af0e3 in PT::FileLog::save_log(PT::TextStreamBase<wchar_t, 256ul, 4096ul>*) /usr/home/tomek/roboczy/prog/pikotools/log/filelog.cpp:105:14
    #3 0x8009b3f8a in PT::Log::save_log() /usr/home/tomek/roboczy/prog/pikotools/log/log.cpp:461:13
    #4 0x8009b3d72 in PT::Log::save_log_and_clear() /usr/home/tomek/roboczy/prog/pikotools/log/log.cpp:448:2
    #5 0x8009b0627 in PT::Log::~Log() /usr/home/tomek/roboczy/prog/pikotools/log/log.cpp:62:2
    #6 0x8007288e7 in Winix::Log::~Log() /usr/home/tomek/roboczy/prog/winix/winixd/core/log.cpp:56:1
    #7 0x8007eac96 in Winix::WinixBase::~WinixBase() /usr/home/tomek/roboczy/prog/winix/winixd/core/winixbase.cpp:51:1
    #8 0x8007eb097 in Winix::WinixModel::~WinixModel() /usr/home/tomek/roboczy/prog/winix/winixd/core/winixmodel.cpp:52:1
    #9 0x80069e552 in Winix::BaseThread::~BaseThread() /usr/home/tomek/roboczy/prog/winix/winixd/core/basethread.cpp:54:1
    #10 0x2f8132 in Winix::Job::~Job() /usr/home/tomek/roboczy/prog/web.ttmath.org/../winix/winixd/core/job.h:54:7
    #11 0x2e0c8a in Winix::System::~System() /usr/home/tomek/roboczy/prog/web.ttmath.org/../winix/winixd/core/system.h:67:7
    #12 0x2df017 in Winix::App::~App() /usr/home/tomek/roboczy/prog/web.ttmath.org/../winix/winixd/core/app.h:70:7
    #13 0x800cc9f50 in __cxa_finalize /hddraidzfs/usr/src/lib/libc/stdlib/atexit.c:238:5
    #14 0x800c5ef10 in exit /hddraidzfs/usr/src/lib/libc/stdlib/exit.c:74:2
    #15 0x25c935 in _start /hddraidzfs/usr/src/lib/csu/amd64/crt1.c:76:2

0x61b0000053e0 is located 1632 bytes inside of 1656-byte region [0x61b000004d80,0x61b0000053f8)
freed by thread T0 here:
    #0 0x2dc07d in operator delete(void*) /hddraidzfs/usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:160:3
    #1 0x8007c3b2c in Winix::ThreadManager::StopAll() /usr/home/tomek/roboczy/prog/winix/winixd/core/threadmanager.cpp:189:3
    #2 0x800647474 in Winix::App::WaitForThreads() /usr/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:2122:24
    #3 0x800647311 in Winix::App::Close() /usr/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:340:2
    #4 0x2dec7c in main /usr/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:224:6
    #5 0x25c92e in _start /hddraidzfs/usr/src/lib/csu/amd64/crt1.c:76:7
    #6 0x80033efff  (<unknown module>)

previously allocated by thread T0 here:
    #0 0x2db81d in operator new(unsigned long) /hddraidzfs/usr/src/contrib/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
    #1 0x8007c17c3 in Winix::ThreadManager::Add(Winix::BaseThread*, wchar_t const*) /usr/home/tomek/roboczy/prog/winix/winixd/core/threadmanager.cpp:77:26
    #2 0x8007b0b81 in Winix::System::Init() /usr/home/tomek/roboczy/prog/winix/winixd/core/system.cpp:170:17
    #3 0x8006468d4 in Winix::App::Init() /usr/home/tomek/roboczy/prog/winix/winixd/core/app.cpp:295:9
    #4 0x2deb7e in main /usr/home/tomek/roboczy/prog/winix/winixd/main/main.cpp:206:11
    #5 0x25c92e in _start /hddraidzfs/usr/src/lib/csu/amd64/crt1.c:76:7
    #6 0x80033efff  (<unknown module>)

in ThreadManager::StopAll() there is item.thread_item_data pointer which was freed (the pointer was pointing to an object with a log_buffer)
but internal Log buffer from item.object was pointing to that object and when thread_tab.clear() was called then the d-ctor was called
and then save_log_and_clear() method was called and tried to use the freed object.
2021-02-17 15:58:05 +01:00
tomasz.sowa be83d62f96 changed html in index templates: [include "index_head_functions_add.html"] -> [include "index_head_adder.html"] 2021-02-16 20:10:29 +01:00
tomasz.sowa 3fd2ef1da4 renamed: html/index_head_functions_add.html -> html/index_head_adder.html 2021-02-16 20:01:38 +01:00
tomasz.sowa d861384889 Merge pull request 'uikit' (#3) from uikit into master
Reviewed-on: #3
2021-02-16 19:52:36 +01:00
tomasz.sowa cfd8e88e57 changed markup in fun_thread.html, removed item_options.html (was not used by winix)
WIP: #2
2021-02-16 19:44:57 +01:00
tomasz.sowa 8169cb5a7e added uikit markup for uname winix function
WIP: #2
2021-02-16 19:28:42 +01:00
tomasz.sowa 8c85cd7346 added uikit markup for stat winix function
WIP: #2
2021-02-16 19:25:36 +01:00
tomasz.sowa 4e202833b2 added uikit markup for rmuser winix function
WIP: #2
2021-02-16 19:21:53 +01:00
tomasz.sowa 4a163bd170 added uikit markup for pw winix function
WIP: #2
2021-02-16 19:12:15 +01:00
tomasz.sowa a2b19547a3 fixed: in Functions::CheckSpecialFile() after parsing new mount points
the cur->mount pointer was pointing at the old mount object
(which may no longer exists)
2021-02-16 17:23:36 +01:00
22 changed files with 68 additions and 78 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ endif
# CXX = g++-4.8
ifndef CXXFLAGS
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++17 -I/usr/local/include -I/usr/include/postgresql -DEZC_HAS_SPECIAL_STREAM
CXXFLAGS = -Wall -O0 -g -fPIC -pthread -std=c++20 -I/usr/local/include -I/usr/include/postgresql -DEZC_HAS_SPECIAL_STREAM
endif
ifndef AR
+1
View File
@@ -254,6 +254,7 @@ void * BaseThread::StartRoutine(void * this_object)
}
}
base->save_log();
pthread_exit(0);
return 0;
}
+5 -1
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018, Tomasz Sowa
* Copyright (c) 2018-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,10 @@ public:
void set_synchro(Synchro * synchro);
// using PT::FileLog::init to suppress clang warning:
// warning: 'Winix::FileLog::init' hides overloaded virtual function [-Woverloaded-virtual]
using PT::FileLog::init;
void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line, size_t log_time_zone_id);
void set_time_zones(TimeZones * time_zones);
+2
View File
@@ -581,6 +581,8 @@ void Image::CreateImage()
<< ", 'convert' process returned: " << res << logend;
}
}
log << logsave;
}
+6 -1
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2009-2018, Tomasz Sowa
* Copyright (c) 2009-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -222,6 +222,11 @@ void Mounts::ReadMounts(const std::wstring & mounts)
mount_parser.Parse(mounts, mount_tab);
CalcCurMount();
// IMPROVE ME
// cur->mount is pointing to the empty mount (it is set in functions.cpp in CheckSpecialFile method)
// may would be better to call WINIX_FSTAB_CHANGED after the cur->mount is set?
// some plugins are using 'cur' object
plugin->Call((Session*)0, WINIX_FSTAB_CHANGED);
}
+4
View File
@@ -186,6 +186,10 @@ void ThreadManager::StopAll()
item.object->WaitForThread();
log << log4 << "TM: thread " << id << " terminated" << logend;
// the thread is stopped and we can set the thread log buffer pointing to
// the main log buffer (from the main thread)
item.object->set_log_buffer(log.GetLogBuffer());
delete item.thread_item_data;
id += 1;
}
+1 -1
View File
@@ -259,7 +259,7 @@ bool TimeZone::SetTzDst(PT::Space & year)
int year_int = Toi(year.name);
if( year_int < 1970 && year_int > 10000 )
if( year_int < 1970 || year_int > 10000 )
return false;
dst.has_dst = year.Bool(L"has_dst", false);
+1 -1
View File
@@ -42,7 +42,7 @@ namespace Winix
#define WINIX_VER_MAJOR 0
#define WINIX_VER_MINOR 7
#define WINIX_VER_REVISION 1
#define WINIX_VER_REVISION 2
+8 -1
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018, Tomasz Sowa
* Copyright (c) 2018-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -90,6 +90,13 @@ void WinixBase::set_dependency(WinixBase * winix_base)
void WinixBase::save_log()
{
log << logsave;
}
}
+3 -1
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018, Tomasz Sowa
* Copyright (c) 2018-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,8 @@ public:
void set_dependency(WinixBase * winix_base);
void save_log();
protected:
+2
View File
@@ -168,7 +168,9 @@ Error Functions::CheckSpecialFile(const Item & item)
{
log << log3 << "Functions: reloading mount points" << logend;
cur->mount = system->mounts.GetEmptyMount();
system->mounts.ReadMounts(item.content);
cur->mount = system->mounts.pmount;
templates->ReadNewIndexTemplates();
templates->ReadNewChangeTemplates();
+3 -3
View File
@@ -1,9 +1,9 @@
<div class="winix">
<h1>Pw</h1>
<h1>{pw_header}</h1>
[if user_tab]
<table class="tablec">
<table class="uk-table uk-table-divider uk-table-small uk-table-responsive">
<tr>
<th>{pw_table_no}</th>
<th>{pw_table_login}</th>
@@ -14,7 +14,7 @@
</tr>
[for user_tab]
<tr class="[if index "odd"]roweven[else]rowodd[end]">
<tr>
<td>[user_tab_index]</td>
<td>[user_tab_name]</td>
<td>[if user_tab_is_super_user]{pw_table_yes}[end]</td>
+15 -11
View File
@@ -4,18 +4,20 @@
[if user_logged]
<form id="additem" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]rmuser">
<fieldset>
<legend>{rmuser_legend}</legend>
<form class="uk-form-stacked" method="post" action="[doc_base_url][dir][if item_is][item_url]/[end]rmuser">
[if user_super_user]
<p class="withnext">{rmuser_selectuser}:</p>
<select name="userid">
[for user_tab]
<option value="[user_tab_id]">[user_tab_name]</option>
[end]
</select>
<div class="uk-margin">
<label class="uk-form-label" for="winix_select_user_id">{rmuser_selectuser}</label>
<div class="uk-form-controls">
<select class="uk-select uk-width-1-2@s" id="winix_select_user_id" name="userid">
[for user_tab]
<option value="[user_tab_id]">[user_tab_name]</option>
[end]
</select>
</div>
</div>
[else]
<p>{rmuser_removecurrent}</p>
@@ -26,8 +28,10 @@
<input type="hidden" name="postredirect" value="[winix_function_param_value "postredirect"]">
[end]
<input type="submit" value="{rmuser_submit}">
</fieldset>
<div class="uk-margin">
<input class="uk-button uk-button-primary" type="submit" value="{rmuser_submit}">
</div>
</form>
[end]
+1 -1
View File
@@ -2,7 +2,7 @@
<h1 class="simple">{stat_header}</h1>
<table class="withoutborder">
<table class="uk-table uk-table-small uk-table-divider uk-width-1-2@m">
<tr><th>{stat_item_type}:</th> <td>
[if stat_item_type_is_file]{stat_item_type_file}[end]
+2 -2
View File
@@ -6,7 +6,7 @@
[end]
[if not [thread_mount_arg_is "sort_desc"]]
<div class="winix_threadbox">
<div class="uk-margin">
[if item_can_write]<a class="uk-button uk-button-default uk-button-small" href="[item_link]/emacs" rel="nofollow">{edit}</a>[end]
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item_subject]</h2>[end]
[if thread_mount_arg_is "info"][include "item_info.html"][end]
@@ -36,7 +36,7 @@
[if thread_mount_arg_is "sort_desc"]
<div class="winix_threadbox">
<div class="uk-margin">
[if item_can_write]<a class="uk-button uk-button-default uk-button-small" href="[item_link]/emacs" rel="nofollow">{edit}</a>[end]
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item_subject]</h2>[end]
[if thread_mount_arg_is "info"][include "item_info.html"][end]
+5 -4
View File
@@ -6,11 +6,12 @@
[if sys_plugin_tab]
{uname_available_plugins}:
<ul>
<h2>{uname_available_plugins}</h2>
<ul class="uk-list">
[for sys_plugin_tab]
<li>[if sys_plugin_tab_has_name][sys_plugin_tab_name][else]&lt;{uname_plugin_unknown}&gt;[end]</li>
<li>[if sys_plugin_tab_has_name][sys_plugin_tab_name][else]&lt;{uname_plugin_unknown}&gt;[end]</li>
[end]
</ul>
+1 -1
View File
@@ -4,7 +4,7 @@
<html lang="{winix_html_lang_attr}">
<head>
[include "index_head_functions_add.html"]
[include "index_head_adder.html"]
<title>[doc_title]</title>
</head>
+1 -1
View File
@@ -4,7 +4,7 @@
<html lang="{winix_html_lang_attr}">
<head>
[include "index_head_functions_add.html"]
[include "index_head_adder.html"]
<title>[doc_title]</title>
</head>
@@ -1,6 +1,3 @@
[# rename me to index_head_adder.html]
[def winix_has_uikit "true"]
[def winix_has_jquery "false"]
-39
View File
@@ -1,39 +0,0 @@
[if not [winix_function_param_is "fullscreen"]]
[if dir_can_write item_can_write]
<div class="winix_itemoptions_a">
[if dir_can_write]
<h2>{add_page}</h2>
<ul>
<li><a href="[doc_base_url][dir]emacs">{admin_emacs_add}</a></li>
[if user_can_use_html]
<li><a href="[doc_base_url][dir]ckeditor">{admin_ckeditor_add}</a></li>
<li><a href="[doc_base_url][dir]nicedit">{admin_nicedit_add}</a></li>
<li><a href="[doc_base_url][dir]tinymce">{admin_tinymce_add}</a></li>
[end]
</ul>
[end]
[if item_is item_can_write]
<h2>{edit_page}</h2>
<ul>
<li><a href="[doc_base_url][dir][item_url]/emacs">{admin_emacs_edit}</a></li>
[if user_can_use_html]
<li><a href="[doc_base_url][dir][item_url]/ckeditor">{admin_ckeditor_edit}</a></li>
<li><a href="[doc_base_url][dir][item_url]/nicedit">{admin_nicedit_edit}</a></li>
<li><a href="[doc_base_url][dir][item_url]/tinymce">{admin_tinymce_edit}</a></li>
[end]
</ul>
[end]
<h2>{admin_options}:</h2>
<ul>
<li><a href="[doc_base_url][dir]ls">{admin_ls}</a></li>
[if dir_can_write]<li><a href="[doc_base_url][dir]mkdir">{admin_mkdir}</a></li>[end]
[if dir_can_write]<li><a href="[doc_base_url][dir]upload">{admin_upload}</a></li>[end]
[if not item_is]<li><a href="[doc_base_url][dir]sort">{admin_sort}</a></li>[end]
[if any item_is item_can_remove]<li><a href="[doc_base_url][dir][item_url]/rm">{admin_rm}</a></li>[end]
</ul>
</div>
[end]
[end]
+3 -3
View File
@@ -258,7 +258,8 @@ pw_table_is_active = Is active
pw_table_is_suspended = Is suspended
pw_table_is_banned = Is banned
pw_table_yes = yes
pw_table_no = no
# !! is it used anymore?
pw_password_changed = Your password has been changed
@@ -288,8 +289,7 @@ rm_content_use_r_option = Content of a directory can be removed only with 'r' pa
rmuser_header = Remove user
rmuser_legend = Remove user form
rmuser_selectuser = Select a user
rmuser_selectuser = Choose a user to delete
rmuser_submit = Remove
rmuser_removecurrent = Are you really want to remove your account from our service?
+3 -3
View File
@@ -280,7 +280,8 @@ pw_table_is_active = Aktywny
pw_table_is_suspended = Wstrzymany
pw_table_is_banned = Zbanowany
pw_table_yes = tak
pw_table_no = nie
# !! is it used anymore?
pw_password_changed = Twoje hasło zostało zmienione
@@ -309,8 +310,7 @@ rm_cannot_remove_root_dir = Nie możesz usunąć głównego katalogu
rm_content_use_r_option = Zawartość katalogu może zostać usunięta tylko z użyciem parametru 'r'
rmuser_header = Usuń użytkownika
rmuser_legend = Formularz usunięcia użytkownika
rmuser_selectuser = Wybierz użytkownika
rmuser_selectuser = Wybierz użytkownika do usunięcia
rmuser_submit = Usuń
rmuser_removecurrent = Naprawdę chcesz usunąć swoje konto z naszego serwisu?