From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id A5C501381F3 for ; Sat, 22 Dec 2012 20:18:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 55E4021C014; Sat, 22 Dec 2012 20:17:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C44A121C014 for ; Sat, 22 Dec 2012 20:17:58 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ACA0D33D937 for ; Sat, 22 Dec 2012 20:17:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 4A14DE543C for ; Sat, 22 Dec 2012 20:17:56 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1356207467.d2e3a668071b95273c8a7d7f21370a2417b1b748.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: scripts/ X-VCS-Repository: proj/elfix X-VCS-Files: scripts/migrate-pax X-VCS-Directories: scripts/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: d2e3a668071b95273c8a7d7f21370a2417b1b748 X-VCS-Branch: master Date: Sat, 22 Dec 2012 20:17:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: cdbe194b-2e41-4af5-b87e-95ecaadb10d1 X-Archives-Hash: 11a9b2e9d2a39b89a69ff11a9c2c3812 commit: d2e3a668071b95273c8a7d7f21370a2417b1b748 Author: Anthony G. Basile gentoo org> AuthorDate: Sat Dec 22 20:17:47 2012 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Dec 22 20:17:47 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=d2e3a668 scripts/migrate-pax: add delete XATTR_PAX on all system ELF objects --- scripts/migrate-pax | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/migrate-pax b/scripts/migrate-pax index e30c306..d5bc03a 100755 --- a/scripts/migrate-pax +++ b/scripts/migrate-pax @@ -48,6 +48,7 @@ def run_usage(): print('') print('Usage : migrate -v print out all system ELF objects') print(' : migrate -m [-v] migrate flags on all system ELF objects') + print(' : migrate -d [-v] delete XATTR_PAX on all system ELF objects') print(' : migrate [-h] print out this help') print(' : -v be verbose when migrating') print('') @@ -55,15 +56,15 @@ def run_usage(): def main(): try: - opts, args = getopt.getopt(sys.argv[1:], 'mv') + opts, args = getopt.getopt(sys.argv[1:], 'vmdh') except getopt.GetoptError as err: print(str(err)) # will print something like 'option -a not recognized' run_usage() sys.exit(1) - verbose = False do_migration = False + do_deleteall = False do_usage = False opt_count = 0 @@ -75,6 +76,9 @@ def main(): elif o == '-m': do_migration = True opt_count += 1 + elif o == '-d': + do_deleteall = True + opt_cout += 1 elif o == '-h': do_usage = True opt_count += 1 @@ -83,14 +87,27 @@ def main(): print('Please file a bug') sys.exit(1) - if opt_count == 0 or do_usage: + if do_usage: run_usage() sys.exit(0) + if opt_count == 0 or opt_count > 2 or ( do_migration and do_deleteall): + run_usage() + sys.exit(1) + + # Are we root? uid = os.getuid() if uid != 0 and do_migration: print('RUN AS ROOT: cannot migrate flags') - sys.exit(0) + sys.exit(1) + + # Do we have XATTR_PAX support? + if do_migration or do_deleteall: + try: + from pax import deletextpax + except ImportError: + print('ERROR: Python module pax.so was compiled without XATTR_PAX support, cannot migrate or delete XATTR_PAX') + sys.exit(1) object_needed = get_object_needed() @@ -99,6 +116,7 @@ def main(): for elf in object_needed: try: + flags = pax.getflags(elf)[0] if flags: if verbose: print("%s %s" % (flags, elf)) @@ -106,11 +124,14 @@ def main(): none.append(elf) if verbose: print("NONE: %s" % elf) + if do_migration: - flags = pax.getflags(elf)[0] flags = re.sub('-','',flags) pax.setstrflags(elf, flags) + if do_deleteall: + pax.deletextpax(elf) + # We should never get here, because you can # always getflags() via pax.so since you can # read PT_PAX even from a busy text file, and