Skip to content

Commit d463e7e

Browse files
author
Janez Justin
committed
FIX no passphrase gpg keys causing badsign
1 parent 9a8530e commit d463e7e

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
deb/requirements/
2+
deb/code.zip
3+
4+
rpm/code.zip
5+
6+
rpm/__pycache__
7+
rpm/boto3*
8+
rpm/botocore*
9+
rpm/concurrent*
10+
rpm/docutils*
11+
rpm/dateutil*
12+
rpm/six*
13+
rpm/futures*
14+
rpm/pyrpm*
15+
rpm/tests*
16+
rpm/jmespath*
17+
rpm/python_gnupg*
18+
rpm/python_dateutil*
19+
20+
rpm/code.zip
21+
22+
rpm/six.py
23+
rpm/gnupg.py
24+
rpm/gnupg.pyc

rpm/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ package: ## creates zip of code
1313
zip -r code.zip $(ZIPPED_DIRS)
1414

1515
clean: ## cleans up the repository
16-
/bin/rm -rf code.zip
16+
/bin/rm -rf code.zip __pycache__ boto3* botocore* concurrent* docutils* dateutil* six* futures* pyrpm* tests* jmespath* python_gnupg* python_dateutil* six.py gnupg.py gnupg.pyc
17+
1718

1819
test: ## runs the tests
1920
python3.6 s3rpm_test.py

rpm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ aws lambda create-function \
9393
--function-name <name the function> \
9494
--zip-file fileb://code.zip \
9595
--role <role's arn> \ # arn from role with S3 read/write access
96-
--handler s3rpm.handler \
96+
--handler s3rpm.lambda_handler \
9797
--runtime python3.6 \
9898
# Replace '<...>' with environmental variables
9999
--environment Variables='{PUBLIC=<bool>, GPG_KEY=<file>, GPG_PASS=<password>, BUCKET_NAME=<bucket name>, REPO_DIR=<dir>}'

rpm/s3rpm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ def sign_md_file(repo, s3_repo_dir):
184184
print("Key import returned: ")
185185
print(str(sec.results))
186186
with open(repo.repodir + 'repodata/repomd.xml', 'rb') as stream:
187-
signed = gpg.sign_file(stream, passphrase=os.environ['GPG_PASS'], clearsign=True, detach=True, binary=False)
187+
# If gpgkey has no password set, leaving GPG_PASS empty caues badsign,
188+
# that is why we are not calling passphrase in gpg.sign_file
189+
if os.environ['GPG_PASS'] == '':
190+
signed = gpg.sign_file(stream, clearsign=True, detach=True, binary=False)
191+
else:
192+
signed = gpg.sign_file(stream, passphrase=os.environ['GPG_PASS'], clearsign=True, detach=True, binary=False)
188193

189194
s3 = boto3.resource('s3')
190195
sign_obj = s3.Object(bucket_name=os.environ['BUCKET_NAME'], key=s3_repo_dir + "/repodata/repomd.xml.asc")

0 commit comments

Comments
 (0)