Thomas Jarosch [Mon, 10 Jan 2022 15:26:00 +0000]
Merge branch 'daemon-ext'
Philipp Gesang [Fri, 7 Jan 2022 10:07:19 +0000]
add handling of stdio descriptors
This completes the daemonization API by adding a function that
reassigns the stdio descriptors to /dev/null to prevent the
process from being tied IO wise to the terminal it was started
on.
A ``daemonize_full()`` helper combines all the daemonization
steps into a single call.
Philipp Gesang [Mon, 10 Jan 2022 14:27:12 +0000]
don't leak iconv context on OOM
Philipp Gesang [Wed, 5 Jan 2022 15:38:15 +0000]
add session handling
The ``daemonize()`` API does not establish a new session so
processes that use it end up being controlled by the tty of the
process they were launched under, which too often happens to be
some system console.
Thomas Jarosch [Mon, 29 Nov 2021 13:37:02 +0000]
Merge branch 'html_entities_iso'
Philipp Gesang [Mon, 29 Nov 2021 13:25:01 +0000]
fix typo
Philipp Gesang [Mon, 29 Nov 2021 13:24:10 +0000]
add latin-1 wrapper for html_entities
Still a bit underwhelming as we can't express the encoding
difference in the type system.
Philipp Gesang [Tue, 16 Nov 2021 09:45:28 +0000]
account for deletion marker in /proc/pid/exe
The kernel appends a `` (deleted)`` suffix to the executable path
if the original binary has been unlinked since the process was
started. The ``pid_of()`` API needs to account for this when
matching process names.
Thomas Jarosch [Sat, 23 May 2020 10:33:35 +0000]
Fix 'occurred' typo
Philipp Gesang [Mon, 3 Feb 2020 14:40:37 +0000]
remove unused constants
These have been provided by glibc for ages and are no longer
needed.
Philipp Gesang [Mon, 3 Feb 2020 14:35:38 +0000]
replace obsolete call to ftime(3)
ftime() and timeb.h have been deprecated since POSIX 2008 and
will be removed in future versions of glibc [0]. Replace them
with (probably faster) calls to clock_gettime(2).
[0] https://sourceware.org/ml/libc-announce/2020/msg00001.html
Philipp Gesang [Thu, 25 Apr 2019 13:58:55 +0000]
drop reference to obsolete symbol from unit test
The revert
commit
49ee03b8f8540d2f09ebd416d2f3e09350300573 (origin/master, origin/HEAD)
Author: Christian Herdtweck <christian.herdtweck@intra2net.com>
Date: Thu Apr 18 17:35:21 2019 +0200
Revert "Add another convenience function allowing i18n_noops("foo")+"bar""
failed to revert one use of i18n_noops() from the unit tests
which breaks the build. Fix it by removing the call.
Christian Herdtweck [Thu, 18 Apr 2019 15:35:21 +0000]
Revert "Add another convenience function allowing i18n_noops("foo")+"bar""
Such string-return aliases for i18n functions encourage creation of texts
using concatenation (+). However, such strings might not be translateable
in the future (e.g. into languages with very different word order).
To encourage using i18n_get_string() which is a translation-friendly way
to dynamically assemble strings, we remove this
This reverts commit
0562a0f617437d45d9e344da14980598d7c6c93d.
Thomas Jarosch [Fri, 5 Apr 2019 14:30:01 +0000]
Release libi2ncommon 2.11
No increase in SOVERSION needed as far as I can tell.
Thomas Jarosch [Fri, 5 Apr 2019 14:23:44 +0000]
Merge branch 'timefunc-new'
Philipp Gesang [Fri, 5 Apr 2019 09:48:44 +0000]
document some more timefunc member functions
Philipp Gesang [Fri, 5 Apr 2019 07:08:07 +0000]
add constructor tests for all Time::Clock ids and variants
Go through the supported combinations of clock modes in the
constructor tests.
Philipp Gesang [Fri, 5 Apr 2019 06:51:25 +0000]
stop leaking TZ between unit tests
So apparently boost/unit_test does not restore the original
environment for each test. Do that ourselves then for the TZ
variable which is needed for certain tests.
Also enable UTC in more helpers that leave it unspecified in
formatting. Till now those were relying on the UTC set in a
previous test. Ew!
Philipp Gesang [Thu, 4 Apr 2019 15:23:08 +0000]
document timefunc api
Philipp Gesang [Thu, 4 Apr 2019 15:06:25 +0000]
document clockid_t helper
Philipp Gesang [Thu, 4 Apr 2019 14:35:47 +0000]
remove bogus clock variant check
Spotted by Tom: There are no variants to CLOCK_BOOTTIME so
this would fall back on the default monotonic clock.
Philipp Gesang [Thu, 4 Apr 2019 14:26:09 +0000]
handle strftime() more defensively
Null terminating the result is not necessary under the assumption
that the function works as advertised since we start out with a
zeroed buffer. Thus drop the calculation based on its return
value and null terminate the final byte instead -- after all if
the function should be borked we have no idea where the
terminator should go.
Also error out if it returns zero since the ISO time format cannot
result in the empty string.
Thomas Jarosch [Wed, 27 Mar 2019 15:49:44 +0000]
Fix output unit for Time::operator<<
It's seconds instead of milliseconds.
Thomas Jarosch [Wed, 27 Mar 2019 09:38:41 +0000]
Fix compile warning
timefunc.cpp: In function ‘boost::optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > format_min_sec_msec(const timespec&)’:
timefunc.cpp:1000: warning: '0' flag ignored with precision and ‘%d’ gnu_printf format
Also fix small typos.
Philipp Gesang [Mon, 5 Feb 2018 13:49:28 +0000]
add more struct timespec/Time formatters
Add formatters for durations:
* format_sec_msec: ``1s 337ms'', and
* format_min_sec_msec: ``1m3.370s'' (following time(1)).
Also only use string option types when there is actually an error
path under our control (e. g. with snprintf(3)). (NB the
omnipresent to_string() does not propagate formatting errors
upward so the wrappers we have for it return a plain string.)
Philipp Gesang [Thu, 1 Feb 2018 09:50:02 +0000]
take precautions for 32bit time_t/long
Direct handling of time_t or conversions to it from other
representations will cause failures on 32 bit systems. Introduce
an exception ``conversion_error'' to communicate these conditions
from constructors.
Philipp Gesang [Wed, 31 Jan 2018 13:32:59 +0000]
use separate directives for time formatting and scanning
Glibc 2.17 has trouble with length modifiers in format directives
which prevents us from using the same strings both ways. This is
fixed in later versions (by 2.25 definitely, maybe earlier) but
for the time being we have to use different format strings
depending on the action.
Philipp Gesang [Tue, 30 Jan 2018 16:00:07 +0000]
implement division by scalar for Time and container ops
Add division by integer plus related operations over containers.
As per C++ convention the division functions themselves will not
attempt to handle the case when zero is passed as the divisor.
The functions operating on containers will simply return a zero-
initialized Time object if the argument container is empty.
Philipp Gesang [Tue, 30 Jan 2018 14:52:25 +0000]
allow creating Time objects from formatted timestamps
Read ISO-8601 formatted strings to construct timestamps from.
The format strings already defined for formatting timestamps are
reused. Since years can be negative but the sign handling in
glibc is flawed with the %Y specifier, we need to handle negative
year numbers manually.
Philipp Gesang [Tue, 30 Jan 2018 09:24:03 +0000]
extend Time class with string formatters
Add convenience member functions for the existing formatters.
Note that the make_*() group of functions all use
``localtime_r()`` internally so unit tests must be guarded by an
explicit time zone change to UTC.
Philipp Gesang [Tue, 9 Jan 2018 10:52:53 +0000]
add ISO-8601 formatters to timefunc
Adds format_iso8601() to create conforming timestamps from
broken-down time. Includes overload wrappers for time_t and
struct timespec.
Philipp Gesang [Mon, 29 Jan 2018 13:02:18 +0000]
implement basic operations over class Time
This adds members and overloads for
* addition, subtraction / difference, multiplication by
time_t,
* comparison, less-than / greater-than, equality,
* trivial formatting (needed in boost unittest)
operations involving *class Time* objects.
Philipp Gesang [Mon, 29 Jan 2018 10:06:13 +0000]
implement a basic time/clock datastructure
Add a class ``Time'' to the timefunc part of the library. The
goal is to provide a generalist handle around struct timespec to
supersede the current ones that had been built on now deprecated
APIs (e. g. ``timeb.h'').
Philipp Gesang [Tue, 27 Nov 2018 15:30:41 +0000]
stop leaking FILE* objects when hashing
In hash_file(), the input FILE* needs freeing when no error
occurred. Do this as soon as it is not needed anymore.
Philipp Gesang [Tue, 27 Nov 2018 15:14:20 +0000]
make crypto code compile with openssl 1.1.x
From EVP_DigestInit(3):
EVP_MD_CTX_create() and EVP_MD_CTX_destroy() were renamed
to EVP_MD_CTX_new() and EVP_MD_CTX_free() in OpenSSL 1.1.
Philipp Gesang [Tue, 27 Nov 2018 15:06:22 +0000]
drop unused includes from userfunc
Ironically, despite the duplicate include the userfunc routines
never even check errno at all.
Thomas Jarosch [Tue, 2 Oct 2018 12:16:08 +0000]
Merge branch 'redirect-urlauth'
Thomas Jarosch [Fri, 28 Sep 2018 12:43:45 +0000]
Remove default hash algorithm from the new hash functions
Rationale: SHA1 is outdated, we would need to switch
to something like SHA256 nowadays. If the algorithm
is given explicitly, we can grep for the identifier.
When we do the migration from the libgcrypt-intranator API,
it's better to explicitly adapt the call sites.
Túlio Cavalcanti [Tue, 18 Sep 2018 13:12:10 +0000]
RedirectHash class created in restricted_html file
class used to find all redirect urls in a html text and add a query
parameter "urlauth" with a hash as value to them.
Tulio Cavalcanti [Mon, 17 Sep 2018 12:47:26 +0000]
Hashing functions based upon openssl created
The following functions were implemented:
string hash_data(string data, algorithm algo=SHA1); // output: hex encoded hash
string hash_data_raw(string data, algorithm algo=SHA1); // output: raw binary hash
string hash_file(string filename, algorithm algo=SHA1); // hash data in 64kb blocks
Unit test also included.
Thomas Jarosch [Tue, 4 Sep 2018 15:39:05 +0000]
Add openssl-devel to build requirements
Thomas Jarosch [Wed, 15 Aug 2018 15:14:58 +0000]
Revert "restore join_string() symbols in library"
We bump the SOVERSION of the library, so no compat functions needed anymore.
This reverts commit
f3b61bd6816546a39a072a5b8be56d78cf775683.
Thomas Jarosch [Wed, 15 Aug 2018 14:54:30 +0000]
Bump soversion to 7 since the pipestream interface changed
Thomas Jarosch [Tue, 14 Aug 2018 15:24:14 +0000]
Merge branch 'pipeexec'
Thanks Philipp!
Philipp Gesang [Tue, 26 Jun 2018 07:38:56 +0000]
add support for guarding pipestream with NO_NEW_PRIVS
Add an option to the pipestream and related APIs to drop the
right to obtain further privileges before exec()ing the binary
(off by default). This may be used as an additional measure to
guard invocations of untrusted binaries or trusted ones that
operate on untrusted inputs.
Target audience: arnied scheduler, everywhere file(1) or
imagemagick tools are called.
Defects: it will be tricky to properly unit test this.
[0] https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
Philipp Gesang [Tue, 14 Aug 2018 13:38:50 +0000]
do not indent boost unittest structurals
As per request. Does not contain functional changes.
Philipp Gesang [Mon, 13 Aug 2018 15:25:58 +0000]
pass pipestream flags as bitset
Avoid cluttering the API with long lists of booleans by using
symbolic names instead.
Philipp Gesang [Tue, 17 Apr 2018 09:32:20 +0000]
add option to forward environment to pipestream
Add an argument to all execve-based pipestream APIs to control
whether *environ* should be passed through to the executed
command. Till now this used to depend on whether path lookup was
requested which is rather undesirable.
Unit tests included.
Philipp Gesang [Mon, 12 Feb 2018 14:32:36 +0000]
skip unit tests for handling child errors in pipestream with ancient boost
Philipp Gesang [Mon, 12 Feb 2018 10:52:23 +0000]
distinguish child errors from failing to exec
Use the old pipe/cloexec trick to separate errors from the spawned
program from such that occur before execv[p]e(). Only errors on
the far side of exec() may be handled by the user.
Philipp Gesang [Mon, 12 Feb 2018 09:48:07 +0000]
protect pipe fd with O_CLOEXEC
On the parent, prevent other exec()s than the one in our child
from carrying over the fd. The pipe wrapper may be long lived
for this to become a problem.
Philipp Gesang [Mon, 12 Feb 2018 08:19:53 +0000]
block signals before fork()ing the pipestream child
Block all signals until we are ready to handle them again.
In particular, this saves us checking for close(2) being
interrupted.
Philipp Gesang [Thu, 4 Jan 2018 16:35:48 +0000]
redirect unused fds to /dev/null in pipestream
Closing an fd like stdout and stderr will cause EBADF on access
which may not be handled in a child process. Thus redirect them
to /dev/null if the user requests that their output be ignored.
Philipp Gesang [Wed, 3 Jan 2018 17:08:44 +0000]
allow path lookup for pipestream
Add a flag ``path'' which, if set, causes the specified program
to be executed with execvpe(); also, the environment is passed
on so in this case (to propagate $PATH) so it is up to the caller
to sanitize envp beforehand.
Philipp Gesang [Thu, 4 Jan 2018 08:17:10 +0000]
add printing helper to pipestream status specification
Philipp Gesang [Wed, 3 Jan 2018 16:16:43 +0000]
handle pipe termination separately depending on whether a shell is present
Keep the child's pid around and wait() for it to perish in the
dtor of inpipestream. Return the error from closing the pipe or
terminating the process in the shell-free version. The mechanism
for retrieving the status does not allow to distinguish between
the two, so always prefer the latter.
Philipp Gesang [Wed, 3 Jan 2018 13:50:50 +0000]
add pipestream unit tests for execution failure
Note that on the Intranator as of 6.4.13, the argument
--catch_system_errors=no must be passed to the unit test
executable on account of ancient Boost being oversensitive to
child process termination.
Philipp Gesang [Tue, 2 Jan 2018 16:55:28 +0000]
allow selecting stdout and stderr with inpipestream
Only handle the user-requested fd in the forked command and
discard the other.
Philipp Gesang [Tue, 2 Jan 2018 16:12:47 +0000]
bump release version 2.9 -> 2.10
Philipp Gesang [Tue, 2 Jan 2018 16:10:13 +0000]
add pipestream ctor overload for vectors of string
Add definitions that make passing a vector<string> equivalent to
passing a char**, i. e. take the execve() path.
Philipp Gesang [Tue, 2 Jan 2018 15:13:30 +0000]
add unit test series for pipestream
Setup skeleton unit test file with some simple functionality
tests and include it in a normal run. There haven't been any
pipestream tests so far.
Philipp Gesang [Fri, 9 Feb 2018 13:21:41 +0000]
add shell-free pipestream
Overload the pipestream ctor with a variant that avoids shelling
out with *popen(3)* that is chosen by passing an argument list
in lieu of a command.
Juliana Rodrigueiro [Wed, 8 Aug 2018 12:40:24 +0000]
Implement percent url encoder and decoder
Juliana Rodrigueiro [Wed, 8 Aug 2018 12:13:39 +0000]
Add basic restricted_html structure
Philipp Gesang [Mon, 29 Jan 2018 08:03:38 +0000]
use glibc syscall wrapper for clock_gettime
These are available on any non-ancient system by now so it’s safe
to drop them.
Thomas Jarosch [Wed, 8 Aug 2018 09:31:39 +0000]
Merge branch 'scopetracker-nothrow'
The nothrow() modification of SourceLocation has been dropped
since std::string might throw std::bad_alloc.
Fixing this would require more work for little gain.
Christian Herdtweck [Mon, 6 Aug 2018 10:43:33 +0000]
Wrap Scopetracker constructor/destructor in big try-catch
Christian Herdtweck [Mon, 6 Aug 2018 10:43:07 +0000]
Return NULL thread local storage instead of raising exception
Thomas Jarosch [Thu, 2 Aug 2018 13:39:44 +0000]
Merge branch 'stringfunc-join_string'
Philipp Gesang [Thu, 19 Jul 2018 14:01:30 +0000]
restore join_string() symbols in library
To keep the library it backward compatible, instantiate versions
of join_string() for STL containers.
Old symbols (x86):
0003a040 g DF .text
00000083 Base _ZN3I2n11join_stringERKSt4listISsSaISsEERKSs
00039fb0 g DF .text
00000084 Base _ZN3I2n11join_stringERKSt6vectorISsSaISsEERKSs
New symbols:
000aa0fd g DF .text
00000041 Base _ZN3I2n11join_stringERKSt4listISsSaISsEERKSs
000b084d w DF .text
0000017d Base _ZN3I2n11join_stringISt20_List_const_iteratorISsEEESsT_S3_RKSs
000b09ca w DF .text
0000017d Base _ZN3I2n11join_stringIN9__gnu_cxx17__normal_iteratorIPKSsSt6vectorISsSaISsEEEEEESsT_S9_RS3_
000aa13e g DF .text
00000041 Base _ZN3I2n11join_stringERKSt6vectorISsSaISsEERKSs
000afbce w DF .text
00000074 Base _ZN3I2n11join_stringISt6vectorISsSaISsEEEESsRKT_RKSs
000a9f62 g DF .text
0000019b Base _ZN3I2n11join_stringEPKPKcRKSs
000afb5a w DF .text
00000074 Base _ZN3I2n11join_stringISt4listISsSaISsEEEESsRKT_RKSs
Philipp Gesang [Thu, 19 Jul 2018 13:32:51 +0000]
add unit tests for join_string() overloads
Philipp Gesang [Thu, 19 Jul 2018 10:54:06 +0000]
implement iterator based join_string()
For more idiomatic C++, add a version of join_string () that
accepts a pair of iterators and templatize it, to supersede the
existing boilerplate variants. Good riddance.
Philipp Gesang [Thu, 19 Jul 2018 09:02:53 +0000]
overload join_string() for std::set
Philipp Gesang [Fri, 9 Feb 2018 13:19:36 +0000]
add char** overloads for join_string
Add overloads to joing NULL-terminated arrays with
join_string().
Philipp Gesang [Tue, 24 Apr 2018 11:23:12 +0000]
change permissions before fsync()
Reorder the calls so that the metadata changes performed by
fchmod() are committed to disk (journal) the same way as the
data.
Gerd von Egidy [Tue, 27 Jun 2017 15:06:27 +0000]
Adapt Requires.private and Libs.private to make pkg-config output all neccessary libs for a static build
Gerd von Egidy [Tue, 27 Jun 2017 11:00:53 +0000]
build static library versions of libi2ncommon too
Gerd von Egidy [Tue, 27 Jun 2017 09:05:00 +0000]
BOOST_MESSAGE got replaced by BOOST_TEST_MESSAGE in newer versions of boost
Thomas Jarosch [Thu, 8 Jun 2017 09:22:14 +0000]
base64 encoder/decoder: Add parameter to control linefeed handling
openssl is very strict about if the input data of the decoder
contains linefeeds or not.
Therefore make it a parameter and default
to "one line" base64 output/input.
Add unit test cases.
Thomas Jarosch [Fri, 19 May 2017 13:31:23 +0000]
Add new base64_encode() / base64_decode() functions
Based upon openssl. If an error occurs, an exception
is thrown and memory cleanup is still done.
Thomas Jarosch [Thu, 23 Mar 2017 11:25:13 +0000]
Increase version to 2.9
Carefully checked that it should be ABI compatible to 2.8.
Thomas Jarosch [Thu, 23 Mar 2017 10:42:35 +0000]
Declare internal function rounding_upwards() to have local linkage only
Thomas Jarosch [Thu, 23 Mar 2017 10:37:35 +0000]
Rename get_dir_size() to get_dir_count()
Christian Herdtweck [Wed, 15 Feb 2017 14:41:07 +0000]
Create unittest for i18n_noop[s]
Christian Herdtweck [Wed, 15 Feb 2017 14:40:50 +0000]
Add another convenience function allowing i18n_noops("foo")+"bar"
Thomas Jarosch [Thu, 23 Mar 2017 09:23:01 +0000]
Merge branch 'scopetracker-shorter-types'
Christian Herdtweck [Wed, 25 Jan 2017 08:39:48 +0000]
Run shorten_stl_types (and a bit more) only if needed in scope tracker
Christian Herdtweck [Tue, 24 Jan 2017 09:54:42 +0000]
Use new shorten_stl_types in scope tracker
Christian Herdtweck [Tue, 24 Jan 2017 09:54:17 +0000]
Create unit tests for new shorten_stl_types
Christian Herdtweck [Tue, 24 Jan 2017 09:54:08 +0000]
Create string-function shorten_stl_types
Christian Herdtweck [Thu, 16 Mar 2017 13:13:24 +0000]
Create get_dir_size to avoid unnecessary name copying if only size needed
Thomas Jarosch [Wed, 22 Mar 2017 10:11:44 +0000]
Merge branch 'remove-html-comments'
Thomas Jarosch [Wed, 22 Mar 2017 10:10:47 +0000]
Change find_html_comments() API to return the results
Christian Herdtweck [Fri, 17 Feb 2017 17:09:40 +0000]
Create vector-result-version of split_string with unit test
[Note from Tom during review:
Can still be optimized later on when the API is in place]
Christian Herdtweck [Wed, 8 Feb 2017 15:22:51 +0000]
Add unittests for new find/replace_html_comments
Christian Herdtweck [Wed, 8 Feb 2017 15:22:34 +0000]
Create functions find/remove_html_comments
Similar functions existed in two places in UI but these were not able to
deal with nested comments.
Christian Herdtweck [Thu, 15 Dec 2016 12:38:13 +0000]
Added function format_date which is format_full_time without time
Christian Herdtweck [Wed, 25 Jan 2017 08:58:19 +0000]
Clean up log file created in unit tests
Christian Herdtweck [Wed, 25 Jan 2017 08:58:08 +0000]
Ensure filefunc unit test works with all working dirs
The __FILE__ macro contains an absolute path.
Christian Herdtweck [Wed, 8 Feb 2017 12:22:09 +0000]
Fix comment