Quick help needed - finding userinfo.db path for a given UID based on, well, UID
LindaFerum opened this issue · comments
So I'm prototyping something that uses Cloak and of course I need the long since requested feature of "regularly reset user quotas"
I've been trying out various bolt db tools with some bash glue and getting promising results but I still can't sort out how to go from "user's UID" (which I of course know) to a particular path in the userinfo.db (as seen in say boltbrowser database viewer etc.)
for very small number of users one could configure pairs in such a way that their value would serve as indirect identifier (setting up expiry to a particular long value that would also identify user, etc. and then leverage that) but that strikes me as very dirty hackage and I would like to have a cleaner solution
Please pardon for shameless tag @notsure2 @cbeuw but my crops are dying (technically not germinating unless I can sort this one out ;-) )
gently tagging @HirbodBehnam in the hope they may have some insight into this
Okay, I see, the buckets are the UIDs but the base64 encoding is throwing most command line tools off (boltbrowser somehow manages to represent them conveniently but that doesn't help me do anything useful with CLI)
Okay I sorted it out myself, so leaving a breadcrumb of recipe for posterity and anyone else trying to hack together things with cloak.
One can use base64 --decode to pass "CLI readable UID" to a bolt database command line tool.
Simple test bash oneliner so future generations of cloak users have it easier than I did ;-) :
sudo bash -c "echo "test" ; echo "" ; varbuck=$(printf "JatJTpCUBipHu3+qiJ0xBA==" | base64 --decode) ; echo "" ; echo "$varbuck" ; echo "" ; /home/boss/go/bin/bbolt keys /etc/cloak/userinfo.db "$varbuck""
From here on, manipulating the userinfo.db using command line tools (and thus cron) becomes much more plausible