17 Commits

Author SHA1 Message Date
1ef74e79c3 bump version 2025-11-21 14:05:32 +01:00
6e4d9dfc0f add more tests 2025-11-21 14:01:55 +01:00
314dafa164 fix substring allocation 2025-11-21 14:01:46 +01:00
96b966892c ovector should not be freed because it points into match_data 2025-11-21 12:56:24 +01:00
27a7582d91 fix berkeley db key deletion 2025-11-21 12:38:05 +01:00
e206eef2b8 fix yaml 2025-11-21 12:35:01 +01:00
eb273460c8 add more tests 2025-11-21 12:32:11 +01:00
69cf79fa47 fix packages 2025-11-21 12:23:27 +01:00
26e4fef653 add lip deps 2025-11-21 12:21:58 +01:00
6fbf283df3 fix yaml 2025-11-21 12:20:39 +01:00
6b7a5dedd5 separate test pipeline 2025-11-21 12:17:30 +01:00
a6e08c86c0 build release on tag only 2025-11-21 12:17:20 +01:00
8ea077ba56 use gdbm 2025-11-21 11:59:28 +01:00
be42776399 db-static as well 2025-11-21 11:56:33 +01:00
81792189fb try pcre2-static 2025-11-21 11:52:47 +01:00
7632c617bc make release static 2025-11-21 11:48:53 +01:00
603d702117 fix array allocation and deletion 2025-11-21 11:46:25 +01:00
11 changed files with 32 additions and 84 deletions

View File

@@ -44,17 +44,9 @@ steps:
# check modified key
- build/dbtool -d test.db -s -k test | grep modified
# use splitting with regex
- echo today:100 | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
- printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
# check if it works
- build/dbtool -d test.db -s -k today | grep 100
# use splitting with regex reverse
- echo today:cold | build/dbtool -d test.db -R -i -f -t '^([^:]*):([^:]*)'
# check if it works
- build/dbtool -d test.db -s -k cold | grep today
# check encryption
- build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar
- build/dbtool -d test.db -s -k borg -p -P foobar | grep sevenofnine
- cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100
build-gdbm:
@@ -98,14 +90,7 @@ steps:
# check modified key
- build/dbtool -d test.db -s -k test | grep modified
# use splitting with regex
- echo today:100 | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
- printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
# check if it works
- build/dbtool -d test.db -s -k today | grep 100
# use splitting with regex reverse
- echo today:cold | build/dbtool -d test.db -R -i -f -t '^([^:]*):([^:]*)'
# check if it works
- build/dbtool -d test.db -s -k cold | grep today
# check encryption
- build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar
- build/dbtool -d test.db -s -k borg -p -P foobar | grep sevenofnine
- cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100

View File

@@ -50,5 +50,5 @@ fi
for file in "$@"; do
https --ignore-stdin --check-status -A bearer -a "$DEPLOY_TOKEN" -f POST \
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/$ID/assets" \
"name=${file}" "attachment@${file}"
"name=${file}-${version}" "attachment@${file}"
done

View File

@@ -6,26 +6,24 @@ labels:
steps:
compile:
when:
event: [tag,manual]
event: [tag]
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base words-en gdb perl pcre2-static pcre2-dev gdbm gdbm-dev pkgconfig meson ninja git
- apk add --no-cache bash build-base words-en gdb perl pcre2-static pcre2-dev gdbm gdbm-dev pkgconfig meson ninja
- meson setup --reconfigure --prefer-static -Dcpp_link_args="-static" --buildtype=release build
- ninja -C build
- meson dist -C build --formats xztar,gztar,zip
- file build/dbtool
- mv build/dbtool dbtool-linux-amd64-$CI_COMMIT_TAG
- mv build/meson-dist/* .
- mv build/dbtool dbtool-linux-amd64
release:
image: alpine:latest
when:
event: [tag,manual]
event: [tag]
environment:
DEPLOY_TOKEN:
from_secret: DEPLOY_TOKEN
commands:
- apk update
- apk add --no-cache bash httpie jq git
- .woodpecker/release.sh dbtool-*
- .woodpecker/release.sh dbtool-linux-amd64

View File

@@ -1,19 +0,0 @@
#!/bin/bash
yq '.steps.test-gdbm.commands' < .woodpecker/build.yaml \
| grep -- - | grep -v apk | sed 's/^\- //' \
| while read COMMAND; do
echo "$COMMAND" | bash -e > debug.log 2>&1
if test $? -ne 0; then
echo "fail - $COMMAND"
if test -s debug.log; then
cat debug.log
else
echo exit 1
fi
else
echo "ok - $COMMAND"
fi
done
rm -f debug.log

View File

@@ -1,22 +0,0 @@
#
# convenience wrapper around meson and ninja. Forgive me, I'm old :
.PHONY: all static install test clean debug
all:
meson setup --reconfigure build
ninja -C build
install: all
sudo ninja -C install
clean:
rm -rf build dbtool*core* dbtool.1 test.db clean
test:
@.woodpecker/test.sh
debug: all
rm -f test.db
build/dbtool -d test.db -i -k borg -v sevenofnine -p -P foobar
build/dbtool -d test.db -s -k borg -p -P foobar

View File

@@ -1,7 +1,7 @@
[![status-badge](https://ci.codeberg.org/api/badges/15585/status.svg)](https://ci.codeberg.org/repos/15585)
[![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://codeberg.org/scip/dbtool/blob/master/LICENSE)
# README for dbtool 1.9.2 (21/11/2025)
# README for dbtool 1.9.1 (21/11/2025)
dbtool can be used to store and retrieve data in a key/value
format in a hash database. Perl compatible regular expressions
@@ -17,7 +17,7 @@ data and speed.
You need either the GNU gdbm library or the Berkeley database
system. You can find gdbm at:
http://www.gnu.org/software/gdbm/gdbm.html
And the berkeley library at: https://libdb.org/.
And the berkeley library at: http://www.sleepycat.com.
You will also need `meson` and `ninja`: https://mesonbuild.com/.

View File

@@ -56,8 +56,11 @@ void cipher::init(const string& phrase) {
dig.initDigest();
dig.putDigest( (unsigned char *)phrase.c_str(), phrase.length() );
__key = dig.stringDigest(); // this is a 32 byte long string, as Rijndael:: expects
memcpy(key, __key, 32);
/* convert the key to unsigned char[] */
for(int i=0; i<32; i++) {
key[i] = __key[i];
}
}

View File

@@ -61,6 +61,7 @@ class cipher {
Rijndael rijn;
MD5Digest dig;
unsigned char key[32];
string blah;
const char* error(int num);
public:

View File

@@ -67,8 +67,8 @@ int main(int argc, char *argv[]) {
case 'i':
/* insert */
if(config.key == "") {
cerr << pkg << ": key required\n";
exit(1);
cerr << pkg << ": key required\n";
exit(1);
}
engine.insert();
break;
@@ -82,32 +82,32 @@ int main(int argc, char *argv[]) {
case 's':
/* select */
if(config.key == "") {
cerr << pkg << ": key required\n";
exit(1);
cerr << pkg << ": key required\n";
exit(1);
}
engine.select();
break;
case 'S':
/* regexp select */
if(config.key == "") {
cerr << pkg << ": key (regexp) required\n";
exit(1);
cerr << pkg << ": key (regexp) required\n";
exit(1);
}
engine.regexp();
break;
case 'r':
/* remove */
if(config.key == "") {
cerr << pkg << ": key required\n";
exit(1);
cerr << pkg << ": key required\n";
exit(1);
}
engine.remove();
break;
case 'u':
/* update */
if(config.key == "") {
cerr << pkg << ": key required\n";
exit(1);
cerr << pkg << ": key required\n";
exit(1);
}
engine.update();
break;
@@ -125,6 +125,7 @@ int main(int argc, char *argv[]) {
}
string readpass() {
char *envpass;
envpass = getenv(PW_VARNAME);
@@ -145,3 +146,5 @@ string readpass() {
return password;
}
}

View File

@@ -334,7 +334,6 @@ void Engine::regexp() {
char *part = (char *)malloc(substring_length+1);
part = strncpy(part, (char *)substring_start, substring_length);
part[substring_length] = '\0';
subs[i-1] = part;
free(part);

View File

@@ -2,7 +2,7 @@ project(
'dbtool',
'cpp',
license: 'GPL',
version: '1.9.3',
version: '1.9.2',
meson_version: '>=1.3',
default_options: [
'warning_level=2',