• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Add a new file as part of a commit and have System Patches set the +x flag on it?

Scheduled Pinned Locked Moved Plus 23.01 Development Snapshots (Retired)
8 Posts 3 Posters 772 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    luckman212 LAYER 8
    last edited by luckman212 Oct 4, 2022, 3:09 PM Oct 3, 2022, 9:49 PM

    I have a patch for wireguard and part of it involves fetching a brand new file that needs to be executable. In my git tree I have marked it as such, and even run

    $ git update-index --chmod=+x path/to/file
    

    still, upon fetching the patch, even though it's "successful" the file permissions are 644. So my patch fails to actually do what it's supposed to do until the user manually runs chmod +x /path/to/file.

    Am I doing this wrong? Is there a way to ensure the file permissions are preserved during the patch operation?

    the patch in question is here luckman212/wgfix

    1 Reply Last reply Reply Quote 0
    • L
      luckman212 LAYER 8
      last edited by Oct 4, 2022, 1:40 PM

      Even when downloading the patch manually, I can see the patch instructs the system to mark the file executable, so System Patches is either ignoring this or something else is going on... ?

      cdcc9338-a6a6-4794-9eb3-041bf8a01137-CleanShot 2022-10-04 at 09.36.01.png

      L 1 Reply Last reply Oct 4, 2022, 1:53 PM Reply Quote 0
      • L
        luckman212 LAYER 8 @luckman212
        last edited by luckman212 Oct 4, 2022, 3:11 PM Oct 4, 2022, 1:53 PM

        I think the problem may be that the FreeBSD patch(1) comand simply ignores the file mode bits. I looked at the source and it looks like this is the section that does most of the work, but I don't see any reason that would omit the mode-setting, unless the patch command itself was responsible.

        I posted a question on the FreeBSD forum.

        1 Reply Last reply Reply Quote 0
        • J
          jimp Rebel Alliance Developer Netgate
          last edited by Oct 5, 2022, 2:57 PM

          The patch command has behaved that way for as long as I can remember. When testing diffs that add files we usually have to fix the permissions by hand after if they have to be executable.

          It could be a missing feature in patch or it could be for security reasons -- forcing people to make something executable is a safety belt against accidentally importing a malicious script via patch.

          Still would be nice to have a command line option to optionally obey the file permissions specified in a diff.

          Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

          Need help fast? Netgate Global Support!

          Do not Chat/PM for help!

          L 1 Reply Last reply Oct 5, 2022, 5:18 PM Reply Quote 0
          • L
            luckman212 LAYER 8 @jimp
            last edited by Oct 5, 2022, 5:18 PM

            @jimp Ever considered adding one more field to System Patches called "Post processing command" where we could, for example type in chmod +x /etc/wgfix.sh and have it execute that after successfully applying the patch?

            If you're too busy I am happy to try to put that together as a PR.

            J 1 Reply Last reply Oct 7, 2022, 1:33 PM Reply Quote 0
            • J
              jimp Rebel Alliance Developer Netgate
              last edited by Oct 7, 2022, 12:05 PM

              Might not be a bad idea but I am hesitant to add yet another way to run shell commands to the system. Have to think on that one a bit.

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • J
                JeGr LAYER 8 Moderator @luckman212
                last edited by Oct 7, 2022, 1:33 PM

                @luckman212 Wouldn't that work by throwing the new file into the filer package? There you can add it with 0755 as mask so you get the correct x-bit?

                Don't forget to upvote 👍 those who kindly offered their time and brainpower to help you!

                If you're interested, I'm available to discuss details of German-speaking paid support (for companies) if needed.

                L 1 Reply Last reply Oct 7, 2022, 2:27 PM Reply Quote 0
                • L
                  luckman212 LAYER 8 @JeGr
                  last edited by Oct 7, 2022, 2:27 PM

                  @jegr Maybe, but I didn't want the patch to also need to depend on having Filer installed, which most people don't (including myself...) That would require manually downloading the script and pasting it into Filer, setting the right bits, then installing System Patches, fetching the patch... lots of steps and more room for error.

                  1 Reply Last reply Reply Quote 0
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                    This community forum collects and processes your personal information.
                    consent.not_received