X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1680112364; x=1680198764; bh=SGY7bFl+PGxGjmtOjIKGyB16vr8ZpPMi9lV oHpNo5rM=; b=Km/tMN4U8zQxKSeh4oWlwWogYp69ERsRuPyVBLkVorjOE9FkcNB rhOmta+TQA/C3ztxh6XVbWAKjZeIHA6mmah2x5GW4+xJGkw/c+pt4IN1HGZyG50+ POqCZz4sdgmKM2bJH2CIAFEr4LFvC2lccAj5mWts2A8GC0+PnbyqFWQDsd1Vfb4a LJ11O46pOlg6spT06g0b8hVB3VZ7TtJokqUt1MwGrlpkyKTzK1AsfQvmPkDdxRn/ cJutXlZihzuJB7SC1YTddREDAP3SUDj5fvW043avR5e5zEv6hlaVqqlKcKZ6Cpgd 9YTA54TbJfzWS0rl5xaTuGhU0iyEa0/E+xQ== X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1680112364; x= 1680198764; bh=SGY7bFl+PGxGjmtOjIKGyB16vr8ZpPMi9lVoHpNo5rM=; b=L 0334V4Ai99BNwc9Tg/eVfCrfMDkpyShPfmilqn4WHUdhi1KcCq9PrFELsepR1XZH YxBhaGJ+euz7X7Dcv/RIbmDpycf4NgjUXFehf/IYvcr8lyGRo/Dk4OJIy9RCzVti gqTL5JXfomPKMJOmtoeTXhqnwF5NfnGIZMx3NqiMNetSwRMBoEX9CqJ2MVq5j6/b CqUAIdizYzuJ2arhT0hfCbzt5NPpXBFpbz9G2tHhy0Y8vhOc//aZSG4bgge7XoFv 6J8K/kbSWKBHKX8zbIY3PqF5JcdBcqmOB1TAstAozfjh/ooPff6SylOZRRgxUxz5 jym7lv44Y0qp/I8L+VtTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehiedguddulecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ekredttdefjeenucfhrhhomhepifhirhhvihhnucfjvghrrhcuoehghhgvrhhrlhdvsehf rghsthhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhepveefudetgffgleetgfeuie ejleeugefhheelieekffevgeffueeuieffffehtdevnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepghhhvghrrhhlvdesfhgrshhtmhgrihhlrd gtohhm X-ME-Proxy: Feedback-ID: iee494631:Fastmail Subject: Re: [geda-user] Changing gschem backup file permissions To: geda-user AT delorie DOT com References: <4772851a-fca0-4370-d6bb-ef854127e604 AT fastmail DOT com> From: "Girvin Herr (gherrl2 AT fastmail DOT com) [via geda-user AT delorie DOT com]" Message-ID: <220e2113-ca15-9f9b-107b-b9609d3cc2ef@fastmail.com> Date: Wed, 29 Mar 2023 10:52:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 3/27/23 6:13 PM, Roland Lutz wrote: > On Mon, 27 Mar 2023, Girvin Herr (gherrl2 AT fastmail DOT com) [via > geda-user AT delorie DOT com] wrote: >> That is what I was afraid of. I was hoping it could be done in a >> configuration file somewhere. Thanks for the info, though. > > Well ... if you don't want do re-build gEDA/gaf from source, you could > always binary-patch the library. > > Go to the directory (e.g., /usr/local) where you installed gEDA/gaf. > Make a backup copy of your libgeda library: > > $ cp -i lib/libgeda.so.47.0.0 lib/libgeda.so.47.0.0.backup > > Look at the disassembled library to find the relevant code location: > > $ objdump -d lib/libgeda.so.47.0.0 | less > > You can use "/f_save" to search for the function name and "n" to > skip over the procedure linkage table entry (we are not interested in > that) until you get to the actual function.  This should look > something like this: > > 0000000000023a20 : >    23a20:       41 57                   push   %r15 >    23a22:       41 56                   push   %r14 >    23a24:       41 55                   push   %r13 > (and so on) > > Now, look for the AND instruction ("/and") that clears the write > bits in the permissions (ug-wx o-x = 0446 = 0x126). There are two AND > instructions in f_save; in my case, the relevant one is the second > one. It should look something like this: > >    23e44:       31 ff                   xor    %edi,%edi >    23e46:       e8 15 1a ff ff          callq  15860 >    23e4b:       48 8b 7c 24 10          mov    0x10(%rsp),%rdi >    23e50:       89 c6                   mov    %eax,%esi >    23e52:       89 44 24 1c             mov    %eax,0x1c(%rsp) >    23e56:       f7 d6                   not    %esi >    23e58:       81 e6 26 01 00 00       and    $0x126,%esi >    23e5e:       e8 1d f2 fe ff          callq  13080 > > The previous umask is stored in %esi, inverted, masked with 0x126, and > passed to chmod.  We want to change the permission mask, so it is the > address of the AND instruction we are interested in (0x23e58 in my > case, but yours will be different), as well as the exact machine text > (81 e6 26 01 00 00 in my case). > > Copy that information, close the disassembly ("q") and run Python.  > Open the shared library, seek to the position you determined and see > if you get the bytes you saw in the disassembly (make sure to enter > the extra newline after the third line of code to tell Python the > block is over): > > $ python3 >>>> with open('lib/libgeda.so.47.0.0', 'rb') as f: > ...     f.seek(0x23e58)  # <-- replace with your value > ...     f.read(6) > ... 147032 > b'\x81\xe6&\x01\x00\x00' > > Looks good!  The ampersand is ASCII 0x26, so it's displayed as a > visual character, but it is the correct value.  Now replace the mask > with the one we want (ugo-x = 0666 = 0x1b6), otherwise using the exact > same bytes as seen in your disassembly: > >>>> with open('lib/libgeda.so.47.0.0', 'r+b') as f: > ...     f.seek(0x23e58)  # <-- replace with your value > ...     f.write(b'\x81\xe6\xb6\x01\x00\x00')  # <-- this too > ... 147032 > 6 >>>> ^D > > (For Python 2, you need to omit the "b" before the byte string.) > > You're done!  Now verify that you did indeed change the correct > instruction.  You should see exactly one changed byte (from 26 to b6): > > $ diff <(objdump -d lib/libgeda.so.47.0.0.backup) <(objdump -d > lib/libgeda.so.47.0.0) > 2c2 > < lib/libgeda.so.47.0.0.backup:     file format elf64-x86-64 > --- >> lib/libgeda.so.47.0.0:     file format elf64-x86-64 > 19164c19164 > <    23e58:     81 e6 26 01 00 00       and    $0x126,%esi > --- >>    23e58:     81 e6 b6 01 00 00 and    $0x1b6,%esi > > If this is what you see, the binary patch has succeeded, and you > should have the file permissions you want the next time you run > gschem.  If you see changes different than that (or no changes at > all), DELETE the botched library and restore it from the backup. > > Hope that helps! > > Roland > Roland, Thanks for the info. I may take a look at it, but I prefer to use the unchanged package from gEDA. I have been giving my problem some thought and I think it will be better to create a script to change all 4xx file permissions to 6xx. That should catch all of the files that are giving me problems, including any non-gschem files, or even files located in a directory other than the one I invoke gschem from. It sounds better to me. Thanks again. Girvin