SELinux not allowing oddjobd-mkhomedir to create user home directory on a non-standard location












9















We are using SSSD to authenticate users on CentOS servers. oddjobd-mkhomedir works perfectly fine when the default home directory is /home, but on a particular server, we had to change default home directory to /data, which is on a SAN mount.



Now, every time a user tries to log in, they are dropped into a bash shell with the following message.



Creating home directory for first.last.

Could not chdir to home directory /data/X.Y.local/first.last: No such file or directory

-bash-4.1$


I see the following AVC denial message for every attempt:



type=AVC msg=audit(1492004159.114:1428): avc:  denied  { create } for  pid=2832 
comm="mkhomedir" name="x.y.local"
scontext=system_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023
tcontext=system_u:object_r:default_t:s0 tclass=dir


Have made sure to change the context for /data.



 drwxr-xr-x. root root system_u:object_r:home_root_t:s0 data


If /data has the same context as /home, why is SELinux restricting oddjobd to create /data/X.Y.local/first.last ?



# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted


[UPDATE]



Not sure if this is the correct way to solve this, but after adding the following three entries user's are now able to log in and get to their home directories. For new user's directories are getting created based on the context's defined below.



semanage fcontext -a -t home_root_t /data
semanage fcontext -a -t user_home_dir_t /data/x.y.local
semanage fcontext -a -t user_home_t "/data/x.y.local(/.*)?"


Is this the correct way to get around this problem?










share|improve this question

























  • Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

    – 0xSheepdog
    Jul 26 '17 at 12:38
















9















We are using SSSD to authenticate users on CentOS servers. oddjobd-mkhomedir works perfectly fine when the default home directory is /home, but on a particular server, we had to change default home directory to /data, which is on a SAN mount.



Now, every time a user tries to log in, they are dropped into a bash shell with the following message.



Creating home directory for first.last.

Could not chdir to home directory /data/X.Y.local/first.last: No such file or directory

-bash-4.1$


I see the following AVC denial message for every attempt:



type=AVC msg=audit(1492004159.114:1428): avc:  denied  { create } for  pid=2832 
comm="mkhomedir" name="x.y.local"
scontext=system_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023
tcontext=system_u:object_r:default_t:s0 tclass=dir


Have made sure to change the context for /data.



 drwxr-xr-x. root root system_u:object_r:home_root_t:s0 data


If /data has the same context as /home, why is SELinux restricting oddjobd to create /data/X.Y.local/first.last ?



# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted


[UPDATE]



Not sure if this is the correct way to solve this, but after adding the following three entries user's are now able to log in and get to their home directories. For new user's directories are getting created based on the context's defined below.



semanage fcontext -a -t home_root_t /data
semanage fcontext -a -t user_home_dir_t /data/x.y.local
semanage fcontext -a -t user_home_t "/data/x.y.local(/.*)?"


Is this the correct way to get around this problem?










share|improve this question

























  • Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

    – 0xSheepdog
    Jul 26 '17 at 12:38














9












9








9


3






We are using SSSD to authenticate users on CentOS servers. oddjobd-mkhomedir works perfectly fine when the default home directory is /home, but on a particular server, we had to change default home directory to /data, which is on a SAN mount.



Now, every time a user tries to log in, they are dropped into a bash shell with the following message.



Creating home directory for first.last.

Could not chdir to home directory /data/X.Y.local/first.last: No such file or directory

-bash-4.1$


I see the following AVC denial message for every attempt:



type=AVC msg=audit(1492004159.114:1428): avc:  denied  { create } for  pid=2832 
comm="mkhomedir" name="x.y.local"
scontext=system_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023
tcontext=system_u:object_r:default_t:s0 tclass=dir


Have made sure to change the context for /data.



 drwxr-xr-x. root root system_u:object_r:home_root_t:s0 data


If /data has the same context as /home, why is SELinux restricting oddjobd to create /data/X.Y.local/first.last ?



# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted


[UPDATE]



Not sure if this is the correct way to solve this, but after adding the following three entries user's are now able to log in and get to their home directories. For new user's directories are getting created based on the context's defined below.



semanage fcontext -a -t home_root_t /data
semanage fcontext -a -t user_home_dir_t /data/x.y.local
semanage fcontext -a -t user_home_t "/data/x.y.local(/.*)?"


Is this the correct way to get around this problem?










share|improve this question
















We are using SSSD to authenticate users on CentOS servers. oddjobd-mkhomedir works perfectly fine when the default home directory is /home, but on a particular server, we had to change default home directory to /data, which is on a SAN mount.



Now, every time a user tries to log in, they are dropped into a bash shell with the following message.



Creating home directory for first.last.

Could not chdir to home directory /data/X.Y.local/first.last: No such file or directory

-bash-4.1$


I see the following AVC denial message for every attempt:



type=AVC msg=audit(1492004159.114:1428): avc:  denied  { create } for  pid=2832 
comm="mkhomedir" name="x.y.local"
scontext=system_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023
tcontext=system_u:object_r:default_t:s0 tclass=dir


Have made sure to change the context for /data.



 drwxr-xr-x. root root system_u:object_r:home_root_t:s0 data


If /data has the same context as /home, why is SELinux restricting oddjobd to create /data/X.Y.local/first.last ?



# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted


[UPDATE]



Not sure if this is the correct way to solve this, but after adding the following three entries user's are now able to log in and get to their home directories. For new user's directories are getting created based on the context's defined below.



semanage fcontext -a -t home_root_t /data
semanage fcontext -a -t user_home_dir_t /data/x.y.local
semanage fcontext -a -t user_home_t "/data/x.y.local(/.*)?"


Is this the correct way to get around this problem?







selinux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 31 '18 at 14:45









slm

254k71536687




254k71536687










asked Apr 12 '17 at 15:20









AbhiAbhi

786




786













  • Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

    – 0xSheepdog
    Jul 26 '17 at 12:38



















  • Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

    – 0xSheepdog
    Jul 26 '17 at 12:38

















Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

– 0xSheepdog
Jul 26 '17 at 12:38





Not sure if this is relevant to your issue, but it has caused me grief in the past: linux.die.net/man/8/nfs_selinux

– 0xSheepdog
Jul 26 '17 at 12:38










2 Answers
2






active

oldest

votes


















4














That last section with semanage fcontext is the correct way to permanently set the context yes. You will need to run restorecon to have it take effect though.



restorecon -Rv /data


restorecon will take into account anything in /etc/selinux/targeted/contexts/files/file_contexts.local, which should have your custom fcontexts that you just added using semanage



To set these contexts temporarily, refer to the chcon command:



chcon -Rv -t home_root_t /data 





share|improve this answer

































    1














    When relocating home directories, the best solution is probably to use the EQUAL mechanism of semanage fcontext as described in this answer on server fault:



    semanage fcontext -a -e /home /data


    This is to ensure that all rules of the original home location is also applied to the new one.






    share|improve this answer

























      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',
      autoActivateHeartbeat: false,
      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%2f358585%2fselinux-not-allowing-oddjobd-mkhomedir-to-create-user-home-directory-on-a-non-st%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      That last section with semanage fcontext is the correct way to permanently set the context yes. You will need to run restorecon to have it take effect though.



      restorecon -Rv /data


      restorecon will take into account anything in /etc/selinux/targeted/contexts/files/file_contexts.local, which should have your custom fcontexts that you just added using semanage



      To set these contexts temporarily, refer to the chcon command:



      chcon -Rv -t home_root_t /data 





      share|improve this answer






























        4














        That last section with semanage fcontext is the correct way to permanently set the context yes. You will need to run restorecon to have it take effect though.



        restorecon -Rv /data


        restorecon will take into account anything in /etc/selinux/targeted/contexts/files/file_contexts.local, which should have your custom fcontexts that you just added using semanage



        To set these contexts temporarily, refer to the chcon command:



        chcon -Rv -t home_root_t /data 





        share|improve this answer




























          4












          4








          4







          That last section with semanage fcontext is the correct way to permanently set the context yes. You will need to run restorecon to have it take effect though.



          restorecon -Rv /data


          restorecon will take into account anything in /etc/selinux/targeted/contexts/files/file_contexts.local, which should have your custom fcontexts that you just added using semanage



          To set these contexts temporarily, refer to the chcon command:



          chcon -Rv -t home_root_t /data 





          share|improve this answer















          That last section with semanage fcontext is the correct way to permanently set the context yes. You will need to run restorecon to have it take effect though.



          restorecon -Rv /data


          restorecon will take into account anything in /etc/selinux/targeted/contexts/files/file_contexts.local, which should have your custom fcontexts that you just added using semanage



          To set these contexts temporarily, refer to the chcon command:



          chcon -Rv -t home_root_t /data 






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 13 '18 at 13:13

























          answered May 23 '17 at 20:19









          PatrickPatrick

          507214




          507214

























              1














              When relocating home directories, the best solution is probably to use the EQUAL mechanism of semanage fcontext as described in this answer on server fault:



              semanage fcontext -a -e /home /data


              This is to ensure that all rules of the original home location is also applied to the new one.






              share|improve this answer






























                1














                When relocating home directories, the best solution is probably to use the EQUAL mechanism of semanage fcontext as described in this answer on server fault:



                semanage fcontext -a -e /home /data


                This is to ensure that all rules of the original home location is also applied to the new one.






                share|improve this answer




























                  1












                  1








                  1







                  When relocating home directories, the best solution is probably to use the EQUAL mechanism of semanage fcontext as described in this answer on server fault:



                  semanage fcontext -a -e /home /data


                  This is to ensure that all rules of the original home location is also applied to the new one.






                  share|improve this answer















                  When relocating home directories, the best solution is probably to use the EQUAL mechanism of semanage fcontext as described in this answer on server fault:



                  semanage fcontext -a -e /home /data


                  This is to ensure that all rules of the original home location is also applied to the new one.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 25 at 20:52









                  sebasth

                  8,59132250




                  8,59132250










                  answered Feb 25 at 20:29









                  mnkmnk

                  111




                  111






























                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f358585%2fselinux-not-allowing-oddjobd-mkhomedir-to-create-user-home-directory-on-a-non-st%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

                      How to make a Squid Proxy server?

                      Is this a new Fibonacci Identity?

                      Touch on Surface Book