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 763 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.
    • luckman212L
      luckman212 LAYER 8
      last edited by luckman212

      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
      • luckman212L
        luckman212 LAYER 8
        last edited by

        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

        luckman212L 1 Reply Last reply Reply Quote 0
        • luckman212L
          luckman212 LAYER 8 @luckman212
          last edited by luckman212

          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
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            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!

            luckman212L 1 Reply Last reply Reply Quote 0
            • luckman212L
              luckman212 LAYER 8 @jimp
              last edited by

              @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.

              JeGrJ 1 Reply Last reply Reply Quote 0
              • jimpJ
                jimp Rebel Alliance Developer Netgate
                last edited by

                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
                • JeGrJ
                  JeGr LAYER 8 Moderator @luckman212
                  last edited by

                  @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.

                  luckman212L 1 Reply Last reply Reply Quote 0
                  • luckman212L
                    luckman212 LAYER 8 @JeGr
                    last edited by

                    @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
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.