Run command with specific arguments without password as root for all users [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite













This question already has an answer here:



  • How do I use command arguments with Cmnd_Alias in sudoers?

    2 answers



I want to be able to run fdisk -l as any user, without getting the whole fdisk: cannot open /dev/sda: Permission denied message.



I don't see how fdisk -l can be used for malicious purposes.



I have a PHP script, which first checks if the user is logged into my website, and if they are admin.



Then I have an admin control panel, where it shows the output of fdisk -l, however, I am getting the error fdisk: cannot open /dev/sda: Permission denied.



There is no user input, so they can't inject arguments into the command.







share|improve this question












marked as duplicate by Jeff Schaller, Romeo Ninov, Christopher, roaima, Timothy Martin Mar 24 at 0:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    0
    down vote

    favorite













    This question already has an answer here:



    • How do I use command arguments with Cmnd_Alias in sudoers?

      2 answers



    I want to be able to run fdisk -l as any user, without getting the whole fdisk: cannot open /dev/sda: Permission denied message.



    I don't see how fdisk -l can be used for malicious purposes.



    I have a PHP script, which first checks if the user is logged into my website, and if they are admin.



    Then I have an admin control panel, where it shows the output of fdisk -l, however, I am getting the error fdisk: cannot open /dev/sda: Permission denied.



    There is no user input, so they can't inject arguments into the command.







    share|improve this question












    marked as duplicate by Jeff Schaller, Romeo Ninov, Christopher, roaima, Timothy Martin Mar 24 at 0:22


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:



      • How do I use command arguments with Cmnd_Alias in sudoers?

        2 answers



      I want to be able to run fdisk -l as any user, without getting the whole fdisk: cannot open /dev/sda: Permission denied message.



      I don't see how fdisk -l can be used for malicious purposes.



      I have a PHP script, which first checks if the user is logged into my website, and if they are admin.



      Then I have an admin control panel, where it shows the output of fdisk -l, however, I am getting the error fdisk: cannot open /dev/sda: Permission denied.



      There is no user input, so they can't inject arguments into the command.







      share|improve this question













      This question already has an answer here:



      • How do I use command arguments with Cmnd_Alias in sudoers?

        2 answers



      I want to be able to run fdisk -l as any user, without getting the whole fdisk: cannot open /dev/sda: Permission denied message.



      I don't see how fdisk -l can be used for malicious purposes.



      I have a PHP script, which first checks if the user is logged into my website, and if they are admin.



      Then I have an admin control panel, where it shows the output of fdisk -l, however, I am getting the error fdisk: cannot open /dev/sda: Permission denied.



      There is no user input, so they can't inject arguments into the command.





      This question already has an answer here:



      • How do I use command arguments with Cmnd_Alias in sudoers?

        2 answers









      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 9:33









      Jacob Collins

      1




      1




      marked as duplicate by Jeff Schaller, Romeo Ninov, Christopher, roaima, Timothy Martin Mar 24 at 0:22


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Jeff Schaller, Romeo Ninov, Christopher, roaima, Timothy Martin Mar 24 at 0:22


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          A solution would be to create a program calling fdisk. Writing it in CC++ would be easy, you just need a compiler. Then change the owner of the executable to root and give it the SUID right (giving the SUID to a script won't work that's why you'll need an executable not a script). Make sure no other user can write to that file or it could cause a security issue.






          share|improve this answer



























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            A solution would be to create a program calling fdisk. Writing it in CC++ would be easy, you just need a compiler. Then change the owner of the executable to root and give it the SUID right (giving the SUID to a script won't work that's why you'll need an executable not a script). Make sure no other user can write to that file or it could cause a security issue.






            share|improve this answer
























              up vote
              0
              down vote













              A solution would be to create a program calling fdisk. Writing it in CC++ would be easy, you just need a compiler. Then change the owner of the executable to root and give it the SUID right (giving the SUID to a script won't work that's why you'll need an executable not a script). Make sure no other user can write to that file or it could cause a security issue.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                A solution would be to create a program calling fdisk. Writing it in CC++ would be easy, you just need a compiler. Then change the owner of the executable to root and give it the SUID right (giving the SUID to a script won't work that's why you'll need an executable not a script). Make sure no other user can write to that file or it could cause a security issue.






                share|improve this answer












                A solution would be to create a program calling fdisk. Writing it in CC++ would be easy, you just need a compiler. Then change the owner of the executable to root and give it the SUID right (giving the SUID to a script won't work that's why you'll need an executable not a script). Make sure no other user can write to that file or it could cause a security issue.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 13:39









                dev93

                115




                115












                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay