From 906855ecf7f8b9ad93c9217221d5a80a467f2841 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 22 May 2020 11:40:54 -0400 Subject: [PATCH] Fix cpio generation It needed to be relative path, and also fix use of bytes fed into cpio. --- confluent_server/bin/osimage | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/confluent_server/bin/osimage b/confluent_server/bin/osimage index a9a7f969..75f13469 100644 --- a/confluent_server/bin/osimage +++ b/confluent_server/bin/osimage @@ -86,23 +86,28 @@ def initialize(cmdset): for x in bytearray(os.urandom(22)): tmpname += fnamechars[x >> 2] topack = [] - for currd, _, files in os.walk('/var/lib/confluent/public/site/tls'): + opath = os.getcwd() + os.chdir('/var/lib/confluent/public/site') + for currd, _, files in os.walk('tls'): for fname in files: topack.append(os.path.join(currd, fname)) - for currd, _, files in os.walk('/var/lib/confluent/public/site/ssh'): + for currd, _, files in os.walk('ssh'): for fname in files: topack.append(os.path.join(currd, fname)) with open(tmpname, 'wb') as initramfs: packit = subprocess.Popen(['cpio', '-H', 'newc', '-o'], stdout=initramfs, stdin=subprocess.PIPE) for packfile in topack: + if not isinstance(packfile, bytes): + packfile = packfile.encode('utf8') packit.stdin.write(packfile) - packit.stdin.write('\n') + packit.stdin.write(b'\n') packit.stdin.close() res = packit.wait() if res: sys.stderr.write('Error occurred while packing site initramfs') sys.exit(1) + os.chdir(opath) os.rename(tmpname, '/var/lib/confluent/public/site/initramfs.cpio') def osimport(imagefile):