소스 검색

swupdate_class: let reading password for key from file

Add SWUPDATE_PASSWORD_FILE variable to allow reading
the passphrase from a file. Ensure that .sig is the second file
in the cpio archive.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Stefano Babic 9 년 전
부모
커밋
4de0c0ee98
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      classes/swupdate.bbclass

+ 8 - 4
classes/swupdate.bbclass

@@ -101,6 +101,9 @@ python do_swuimage () {
     fetch = bb.fetch2.Fetch([], d)
     list_for_cpio = ["sw-description"]
 
+    if d.getVar('SWUPDATE_SIGNING', True) == '1':
+        list_for_cpio.append('sw-description.sig')
+
     for url in fetch.urls:
         local = fetch.localpath(url)
         filename = os.path.basename(local)
@@ -110,9 +113,6 @@ python do_swuimage () {
 
     deploydir = d.getVar('DEPLOY_DIR_IMAGE', True)
 
-    if d.getVar('SWUPDATE_SIGNING', True) == '1':
-        list_for_cpio.append('sw-description.sig')
-
     for image in images:
         imagename = image + '-' + d.getVar('MACHINE', True)
         fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split()
@@ -135,8 +135,12 @@ python do_swuimage () {
             bb.fatal("SWUPDATE_PRIVATE_KEY isn't set")
         if not os.path.exists(privkey):
             bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey))
-        signcmd = "openssl dgst -sha256 -sign '%s' -out '%s' '%s'" % (
+        passout = d.getVar('SWUPDATE_PASSWORD_FILE', True)
+        if passout:
+            passout = "-passin file:'%s' " % (passout)
+        signcmd = "openssl dgst -sha256 -sign '%s' %s -out '%s' '%s'" % (
             privkey,
+            passout,
             os.path.join(s, 'sw-description.sig'),
             os.path.join(s, 'sw-description'))
         if os.system(signcmd) != 0: