How to Make Folder Only Accesible when User Run the Script












0















My question is how I can make one folder accessible when script running.



In this case lets call there is bob who copying his folder by using script to specific location and there is jeff who also sharing the same group as bob also he copying his file to there with using script.



The problem is that when I set file group they need write and execute permission and when I gave to them they are able to see each other file content if they know full path of the file.



To stop that I am thinking to completely deleting all permission on folder and only giving the permission when script running and doing copying process.



But problem is that when those users run the script and script try to chmod the file permission they are not going to be able to because they don't have enough permission to do it. Also if I add them on sudoers, they are going to be able to chmod and change anything as they want to change.



So I am so confused about how I can make the script change permission of folder and when copying completed turn back to previous permission










share|improve this question



























    0















    My question is how I can make one folder accessible when script running.



    In this case lets call there is bob who copying his folder by using script to specific location and there is jeff who also sharing the same group as bob also he copying his file to there with using script.



    The problem is that when I set file group they need write and execute permission and when I gave to them they are able to see each other file content if they know full path of the file.



    To stop that I am thinking to completely deleting all permission on folder and only giving the permission when script running and doing copying process.



    But problem is that when those users run the script and script try to chmod the file permission they are not going to be able to because they don't have enough permission to do it. Also if I add them on sudoers, they are going to be able to chmod and change anything as they want to change.



    So I am so confused about how I can make the script change permission of folder and when copying completed turn back to previous permission










    share|improve this question

























      0












      0








      0








      My question is how I can make one folder accessible when script running.



      In this case lets call there is bob who copying his folder by using script to specific location and there is jeff who also sharing the same group as bob also he copying his file to there with using script.



      The problem is that when I set file group they need write and execute permission and when I gave to them they are able to see each other file content if they know full path of the file.



      To stop that I am thinking to completely deleting all permission on folder and only giving the permission when script running and doing copying process.



      But problem is that when those users run the script and script try to chmod the file permission they are not going to be able to because they don't have enough permission to do it. Also if I add them on sudoers, they are going to be able to chmod and change anything as they want to change.



      So I am so confused about how I can make the script change permission of folder and when copying completed turn back to previous permission










      share|improve this question














      My question is how I can make one folder accessible when script running.



      In this case lets call there is bob who copying his folder by using script to specific location and there is jeff who also sharing the same group as bob also he copying his file to there with using script.



      The problem is that when I set file group they need write and execute permission and when I gave to them they are able to see each other file content if they know full path of the file.



      To stop that I am thinking to completely deleting all permission on folder and only giving the permission when script running and doing copying process.



      But problem is that when those users run the script and script try to chmod the file permission they are not going to be able to because they don't have enough permission to do it. Also if I add them on sudoers, they are going to be able to chmod and change anything as they want to change.



      So I am so confused about how I can make the script change permission of folder and when copying completed turn back to previous permission







      bash permissions privileges






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 2:10









      nem0nnem0n

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.



          Then the users invoke



          $ sudo /path/to/copy-to-restricted-dir files*


          but users don't have access to restricted directory nor to chmod.






          share|improve this answer


























          • This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

            – chepner
            Nov 26 '18 at 13:44











          • @chepner good point, added absolute path

            – Diego Torres Milano
            Nov 26 '18 at 16:57











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53473940%2fhow-to-make-folder-only-accesible-when-user-run-the-script%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









          1














          You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.



          Then the users invoke



          $ sudo /path/to/copy-to-restricted-dir files*


          but users don't have access to restricted directory nor to chmod.






          share|improve this answer


























          • This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

            – chepner
            Nov 26 '18 at 13:44











          • @chepner good point, added absolute path

            – Diego Torres Milano
            Nov 26 '18 at 16:57
















          1














          You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.



          Then the users invoke



          $ sudo /path/to/copy-to-restricted-dir files*


          but users don't have access to restricted directory nor to chmod.






          share|improve this answer


























          • This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

            – chepner
            Nov 26 '18 at 13:44











          • @chepner good point, added absolute path

            – Diego Torres Milano
            Nov 26 '18 at 16:57














          1












          1








          1







          You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.



          Then the users invoke



          $ sudo /path/to/copy-to-restricted-dir files*


          but users don't have access to restricted directory nor to chmod.






          share|improve this answer















          You should add a sudoers entry to allow ALL or the selected group to run a given script that does the copy to a restricted directory, with NOPASSWD to avoid the password prompt.



          Then the users invoke



          $ sudo /path/to/copy-to-restricted-dir files*


          but users don't have access to restricted directory nor to chmod.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 '18 at 16:55

























          answered Nov 26 '18 at 3:29









          Diego Torres MilanoDiego Torres Milano

          50.7k681109




          50.7k681109













          • This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

            – chepner
            Nov 26 '18 at 13:44











          • @chepner good point, added absolute path

            – Diego Torres Milano
            Nov 26 '18 at 16:57



















          • This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

            – chepner
            Nov 26 '18 at 13:44











          • @chepner good point, added absolute path

            – Diego Torres Milano
            Nov 26 '18 at 16:57

















          This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

          – chepner
          Nov 26 '18 at 13:44





          This doesn't really solve the problem, since sudo will allow access to the folder using any script named copy-to-restricted-dir.

          – chepner
          Nov 26 '18 at 13:44













          @chepner good point, added absolute path

          – Diego Torres Milano
          Nov 26 '18 at 16:57





          @chepner good point, added absolute path

          – Diego Torres Milano
          Nov 26 '18 at 16:57




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53473940%2fhow-to-make-folder-only-accesible-when-user-run-the-script%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

          Costa Masnaga

          Fotorealismo

          Sidney Franklin