In a custom module, is there a way to allow all permissions for files/directories?











up vote
1
down vote

favorite












I've written a custom selinux module that looks something like this:



require {
type my_app_t;
type my_app_file_t;
class file { getattr lock open read write execute execute_no_trans ioctl append setattr };
class dir { write search getattr };
}

allow my_app_t my_app_file_t:file { append setattr write getattr execute read open execute_no_trans lock ioctl};
allow my_app_t my_app_file_t:dir { write search getattr};


This mostly works OK, but I'm tired of adding new perms every time a new deny shows up in audit.log. Is there any way to just allow all permissions for files/directories with a given context? For instance:



require {
type my_app_t;
type my_app_file_t;
class file { * };
class dir { * };
}

allow my_app_t my_app_file_t:file { * };
allow my_app_t my_app_file_t:dir { * };









share|improve this question


























    up vote
    1
    down vote

    favorite












    I've written a custom selinux module that looks something like this:



    require {
    type my_app_t;
    type my_app_file_t;
    class file { getattr lock open read write execute execute_no_trans ioctl append setattr };
    class dir { write search getattr };
    }

    allow my_app_t my_app_file_t:file { append setattr write getattr execute read open execute_no_trans lock ioctl};
    allow my_app_t my_app_file_t:dir { write search getattr};


    This mostly works OK, but I'm tired of adding new perms every time a new deny shows up in audit.log. Is there any way to just allow all permissions for files/directories with a given context? For instance:



    require {
    type my_app_t;
    type my_app_file_t;
    class file { * };
    class dir { * };
    }

    allow my_app_t my_app_file_t:file { * };
    allow my_app_t my_app_file_t:dir { * };









    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I've written a custom selinux module that looks something like this:



      require {
      type my_app_t;
      type my_app_file_t;
      class file { getattr lock open read write execute execute_no_trans ioctl append setattr };
      class dir { write search getattr };
      }

      allow my_app_t my_app_file_t:file { append setattr write getattr execute read open execute_no_trans lock ioctl};
      allow my_app_t my_app_file_t:dir { write search getattr};


      This mostly works OK, but I'm tired of adding new perms every time a new deny shows up in audit.log. Is there any way to just allow all permissions for files/directories with a given context? For instance:



      require {
      type my_app_t;
      type my_app_file_t;
      class file { * };
      class dir { * };
      }

      allow my_app_t my_app_file_t:file { * };
      allow my_app_t my_app_file_t:dir { * };









      share|improve this question













      I've written a custom selinux module that looks something like this:



      require {
      type my_app_t;
      type my_app_file_t;
      class file { getattr lock open read write execute execute_no_trans ioctl append setattr };
      class dir { write search getattr };
      }

      allow my_app_t my_app_file_t:file { append setattr write getattr execute read open execute_no_trans lock ioctl};
      allow my_app_t my_app_file_t:dir { write search getattr};


      This mostly works OK, but I'm tired of adding new perms every time a new deny shows up in audit.log. Is there any way to just allow all permissions for files/directories with a given context? For instance:



      require {
      type my_app_t;
      type my_app_file_t;
      class file { * };
      class dir { * };
      }

      allow my_app_t my_app_file_t:file { * };
      allow my_app_t my_app_file_t:dir { * };






      selinux






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 5 at 20:02









      jayhendren

      5,31721444




      5,31721444






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          You should consider using reference policy macros. Using reference policy macros, you can then use manage_files_pattern macro to allow all access, for example:



          manage_files_pattern(my_app_t, my_app_file_t, my_app_file_t)


          There are also macros for other commonly used patterns, located at /policy/support in the reference policy source.



          If my_app_t is defined by a reference policy module, there likely already exists an interface, which you can use to allow access. Interfaces are documented in reference policy API documentation (provided by selinux-policy-doc package) and are also available online (however a bit outdated).



          The easiest way to build a reference policy module is by using the makefile in SELinux policy development package (selinux-policy-devel or similar) of your distribution, for example: make -f /usr/share/selinux/devel/Makefile my_app.pp.






          share|improve this answer























          • Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
            – jayhendren
            yesterday











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486229%2fin-a-custom-module-is-there-a-way-to-allow-all-permissions-for-files-directorie%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          You should consider using reference policy macros. Using reference policy macros, you can then use manage_files_pattern macro to allow all access, for example:



          manage_files_pattern(my_app_t, my_app_file_t, my_app_file_t)


          There are also macros for other commonly used patterns, located at /policy/support in the reference policy source.



          If my_app_t is defined by a reference policy module, there likely already exists an interface, which you can use to allow access. Interfaces are documented in reference policy API documentation (provided by selinux-policy-doc package) and are also available online (however a bit outdated).



          The easiest way to build a reference policy module is by using the makefile in SELinux policy development package (selinux-policy-devel or similar) of your distribution, for example: make -f /usr/share/selinux/devel/Makefile my_app.pp.






          share|improve this answer























          • Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
            – jayhendren
            yesterday















          up vote
          1
          down vote













          You should consider using reference policy macros. Using reference policy macros, you can then use manage_files_pattern macro to allow all access, for example:



          manage_files_pattern(my_app_t, my_app_file_t, my_app_file_t)


          There are also macros for other commonly used patterns, located at /policy/support in the reference policy source.



          If my_app_t is defined by a reference policy module, there likely already exists an interface, which you can use to allow access. Interfaces are documented in reference policy API documentation (provided by selinux-policy-doc package) and are also available online (however a bit outdated).



          The easiest way to build a reference policy module is by using the makefile in SELinux policy development package (selinux-policy-devel or similar) of your distribution, for example: make -f /usr/share/selinux/devel/Makefile my_app.pp.






          share|improve this answer























          • Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
            – jayhendren
            yesterday













          up vote
          1
          down vote










          up vote
          1
          down vote









          You should consider using reference policy macros. Using reference policy macros, you can then use manage_files_pattern macro to allow all access, for example:



          manage_files_pattern(my_app_t, my_app_file_t, my_app_file_t)


          There are also macros for other commonly used patterns, located at /policy/support in the reference policy source.



          If my_app_t is defined by a reference policy module, there likely already exists an interface, which you can use to allow access. Interfaces are documented in reference policy API documentation (provided by selinux-policy-doc package) and are also available online (however a bit outdated).



          The easiest way to build a reference policy module is by using the makefile in SELinux policy development package (selinux-policy-devel or similar) of your distribution, for example: make -f /usr/share/selinux/devel/Makefile my_app.pp.






          share|improve this answer














          You should consider using reference policy macros. Using reference policy macros, you can then use manage_files_pattern macro to allow all access, for example:



          manage_files_pattern(my_app_t, my_app_file_t, my_app_file_t)


          There are also macros for other commonly used patterns, located at /policy/support in the reference policy source.



          If my_app_t is defined by a reference policy module, there likely already exists an interface, which you can use to allow access. Interfaces are documented in reference policy API documentation (provided by selinux-policy-doc package) and are also available online (however a bit outdated).



          The easiest way to build a reference policy module is by using the makefile in SELinux policy development package (selinux-policy-devel or similar) of your distribution, for example: make -f /usr/share/selinux/devel/Makefile my_app.pp.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 15 hours ago

























          answered 2 days ago









          sebasth

          8,00331846




          8,00331846












          • Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
            – jayhendren
            yesterday


















          • Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
            – jayhendren
            yesterday
















          Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
          – jayhendren
          yesterday




          Thanks. I didn't know the manage_files_pattern macro existed. In my particular case, my_app_t and my_app_file_t are actually defined in my module, I just didn't include them in my question because it didn't seem relevant.
          – jayhendren
          yesterday


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486229%2fin-a-custom-module-is-there-a-way-to-allow-all-permissions-for-files-directorie%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          サソリ

          広島県道265号伴広島線

          Accessing regular linux commands in Huawei's Dopra Linux