Skip to content

Commit 10f5ac6

Browse files
committed
feat(makefile): use just one credentials file and review permissions
1 parent aba37b4 commit 10f5ac6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
barracuda_file = barracudavpn_5.1.4_amd64.deb
2-
key_directory = ~/.keys
3-
key_path = $(key_directory)/barracuda-vpn-key_rsa
4-
user_file_encrypted = vpn.user
5-
pwd_file_encrypted = vpn.pwd
2+
key_directory = ~/.barracuda-vpn
3+
key_path = $(key_directory)/key_rsa
4+
credentials_path = $(key_directory)/credentials
65
zhell_path = ~/.zshrc
76

87
.PHONY: install # = Install the barracuda-vpn
98
install:
109
sudo dpkg -i $(barracuda_file)
10+
./vpn-configure
1111

12-
.PHONY: credentials # = Create key and encrypted files for credentials using the key
12+
.PHONY: credentials # = Create the credentials file using a new key
1313
credentials:
1414
@ if [ "$(user)" = "" ] || [ "$(pwd)" = "" ]; then \
1515
echo "Missing parameters! Use 'make test user=value pwd=value'"; \
1616
exit 1; \
1717
fi
1818
mkdir -p $(key_directory)
1919
openssl genrsa -out $(key_path) 2048
20-
echo "$(user)" | openssl rsautl -inkey $(key_path) -encrypt > $(user_file_encrypted)
21-
echo "$(pwd)" | openssl rsautl -inkey $(key_path) -encrypt > $(pwd_file_encrypted)
20+
echo "$(user)::$(pwd)" | openssl rsautl -inkey $(key_path) -encrypt > $(credentials_path)
2221
sudo chown root:root $(key_path)
23-
sudo chmod 600 $(key_path)
22+
sudo chmod 400 $(key_path)
23+
sudo chmod 400 $(credentials_path)
24+
25+
.PHONY: show-credentials # = Decrypt and show the content of the credentials file
26+
show-credentials:
27+
sudo openssl rsautl -inkey $(key_path) -decrypt < $(credentials_path)
2428

2529
.PHONY: test # = Connect to the vpn and close the connection
2630
test:
27-
./vpn-open $(key_path)
31+
./vpn-open $(key_path) $(credentials_path)
2832
./vpn-close
2933

3034
.PHONY: clean # = Remove the encrypted files for credentials and the key
3135
clean:
32-
sudo rm $(user_file_encrypted) || true
33-
sudo rm $(pwd_file_encrypted) || true
36+
sudo rm $(credentials_path) || true
3437
sudo rm $(key_path) || true
3538
rmdir --ignore-fail-on-non-empty $(key_directory)
3639

0 commit comments

Comments
 (0)