Skip to content
Snippets Groups Projects
Unverified Commit 742c217f authored by Recolic Keghart's avatar Recolic Keghart
Browse files

working

parent b3b705e4
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
filename="$1"
gpg_pubkey_id="$2" # leave empty to use default receipt.
[[ "$filename" = '' ]] && echo "Usage: $0 <filename> [gpg_pubkey_id]" && exit 1
echo '>>> Please type keyring_name and password in the following format:
keyring1:password1
......@@ -13,5 +15,10 @@ login:12345678
>>> When you are done, use Ctrl-D to end.'
gpg --encrypt -o "$filename" -a -r "$gpg_pubkey_id"
exit $?
if [[ "$gpg_pubkey_id" = '' ]]; then
gpg --encrypt -o "$filename" -a
exit $?
else
gpg --encrypt -o "$filename" -a -r "$gpg_pubkey_id"
exit $?
fi
#!/bin/bash
# This script should be run after gnome being started.
_my_path="$0"
secret_file="$1"
[[ "$secret_file" = '' ]] && echo "Usage: $0 <secret_file>" && exit 1
function where_is_him () {
SOURCE="$1"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo -n "$DIR"
}
function where_am_i () {
where_is_him "$_my_path"
}
cd `where_am_i` &&
gpg --decrypt "$secret_file" | bin/unlock_keyrings --secret-file - # --quiet
exit $?
......@@ -3,17 +3,17 @@
#include <rlib/stream.hpp>
#include "keyring_op.hpp"
rlib::logger rlog(std::cerr);
int main(int argc, char **argv) {
rlib::opt_parser args(argc, argv);
rlib::logger rlog(std::cout);
if(args.getBoolArg("-h", "--help")) {
rlog.info("Usage: {} [-h/--help] [-q/--quiet] --secret-file <filename> # use `-` as stdin.");
return 0;
}
if(args.getBoolArg("-q", "--quiet")) {
rlog = rlib::logger(rlib::null_stream);
rlog.set_log_level(rlib::log_level_t::FATAL);
}
auto secret_file_name = args.getValueArg("--secret-file");
......@@ -43,7 +43,7 @@ int main(int argc, char **argv) {
auto res = do_unlock(keyring_and_pswd.at(0), keyring_and_pswd.at(1));
auto msg = keyringResultToString(res);
if(res == GNOME_KEYRING_RESULT_OK)
rlog.verbose("line {}: {}.", line_num, msg);
rlog.info("line {}: {}.", line_num, msg);
else {
rlog.error("line {}: {}.", line_num, msg);
no_error = false;
......
#!/bin/bash
# This script should be run after gnome being started.
_my_path="$0"
secret_file="$1"
[[ "$secret_file" = '' ]] && echo "Usage: $0 <secret_file>" && exit 1
function where_is_him () {
SOURCE="$1"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo -n "$DIR"
}
function where_am_i () {
where_is_him "$_my_path"
}
cd `where_am_i` &&
gpg --decrypt "$secret_file" | bin/unlock_keyrings --secret-file - --quiet
exit $?
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment