Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Linux Programming
  4. How to "provide password " REMOVED

How to "provide password " REMOVED

Scheduled Pinned Locked Moved Linux Programming
tutorial
15 Posts 6 Posters 77 Views 1 Watching
  • 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

    J L G K D 6 Replies Last reply
    0
    • L Lost User

      It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      I googled the following. It appears to return answers.

      C system stdin

      L 1 Reply Last reply
      0
      • J jschell

        I googled the following. It appears to return answers.

        C system stdin

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I am trying to satisfy this sudo -S option requirement: (from RTFM ) -S' The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character. Is that telling me I have to "post" via stdin password BEFORE I execute "sudo -S "? In other words " option causes sudo to read the password from the standard input " - hence I want / need to emulate users input , in code , and I just do not see how. Mrs Google stdin examples "read" from user or from file.

        J 1 Reply Last reply
        0
        • L Lost User

          It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          It would be much easier to call sudo from the terminal before you try to run whatever code itb is that you are trying to run that requires privileged access. My limited testing does not seem to allow this to be run from inside a program.

          1 Reply Last reply
          0
          • L Lost User

            It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

            G Offline
            G Offline
            Graham Breach
            wrote on last edited by
            #5

            An easier option might be to configure sudo to allow the user of your program to call it without a password. The sudoers file is the place to do this. Obviously there may be security implications with this, but that is up to you to decide. Another alternative is to set the set-user-id bit on your executable so that it automatically runs as root (using chmod and chown). Again, this has security implications to think about.

            1 Reply Last reply
            0
            • L Lost User

              It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

              K Offline
              K Offline
              k5054
              wrote on last edited by
              #6

              Rather than system() take a look at popen() [popen(3): pipe stream to/from process - Linux man page](https://linux.die.net/man/3/popen) But before you do that, you should stop and think about whatever it is you think you need to sudo. As a general rule user level programs should not need to elevate privilege to perform work. That's a security hole waiting to be exploited. If you need to create a device file, load a kernel module or change permissions on a device file, that should be handled by the OS at boot time or device initialization time (eg a USB device being plugged in). Using sudo is almost certainly the Wrong Thing, and should only be considered when all other options have been exhausted.

              Keep Calm and Carry On

              L 1 Reply Last reply
              0
              • K k5054

                Rather than system() take a look at popen() [popen(3): pipe stream to/from process - Linux man page](https://linux.die.net/man/3/popen) But before you do that, you should stop and think about whatever it is you think you need to sudo. As a general rule user level programs should not need to elevate privilege to perform work. That's a security hole waiting to be exploited. If you need to create a device file, load a kernel module or change permissions on a device file, that should be handled by the OS at boot time or device initialization time (eg a USB device being plugged in). Using sudo is almost certainly the Wrong Thing, and should only be considered when all other options have been exhausted.

                Keep Calm and Carry On

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I need to be honest - I am getting discouraged by posters "making small talk" posts such as ...make sure you have a backup... ...it is a security issue... I am trying to resolve an issues , not to having to listen to such well meaning but in my view superficial commentaries... OK , I said it ...now you how I feel,,, Will it stop such commentaries ?? I seriously doubt it -some folks are just immune... PS Here is the latest "solution": system ( "echo ""q"" | sudo -S -k ln -s -v /dev/ttyUSB0 /dev/rfcomm0 "); I like to add to it pipe the result to C code variable (string ) AND (temporary) file...

                K J L 3 Replies Last reply
                0
                • L Lost User

                  I need to be honest - I am getting discouraged by posters "making small talk" posts such as ...make sure you have a backup... ...it is a security issue... I am trying to resolve an issues , not to having to listen to such well meaning but in my view superficial commentaries... OK , I said it ...now you how I feel,,, Will it stop such commentaries ?? I seriously doubt it -some folks are just immune... PS Here is the latest "solution": system ( "echo ""q"" | sudo -S -k ln -s -v /dev/ttyUSB0 /dev/rfcomm0 "); I like to add to it pipe the result to C code variable (string ) AND (temporary) file...

                  K Offline
                  K Offline
                  k5054
                  wrote on last edited by
                  #8

                  The expression "echo ""q"" | sudo ... " doesn't do what I think you think it does. But it all works out anyway. This time. Successive string constants, with only intervening white space get concatenated together so

                  printf("Hello"
                  " World!\n");

                  prints Hello World!. See. You learned something from "sidechatter"!

                  Member 14968771 wrote:

                  I need to be honest - I am getting discouraged by posters "making small talk" posts such as ...make sure you have a backup... ...it is a security issue...

                  To my mind, there's been very little in your previous posts that suggest you have any idea what issues you might be unleashing with your blind man with a sledgehammer approach. There's no sense that you understand what the possible consequences of your choices are. Given that, it would be remiss of us not to point out the possible pitfalls of your "solutions" ... many of which, I at least, find dubious. And most of us have "Been there, done that" in terms of making unwise or uninformed choices, and had to rebuild, repair, and recover. If we're lucky, damage to customer systems, and our reputations, has been minimal. But we learn. We grow. We pass on our insights (and war stories) to others in hopes that they will learn, remember and be proactive in areas like security before it affects them or their customer's in negative ways. It's all about an ounce of prevention being worth a pound of cure. If we can guide others away from dangers, I think we should, rather then letting the foolhardy walk unprepared into the lions den. For example, I don't think that creating /dev/rfcomm0 as a soft link to /dev/ttyUSB0 is going to achieve what you expect. Have you tested this approach and got the results you want? Looking at this post [https://unix.stackexchange.com/a/410128\](https://unix.stackexchange.com/a/410128) regarding a missing /dev/rfcomm0, it seems highly unlikely that creating a link between what seems to be a USB serial device and what I can only assume is supposed to be a bluetooth device binding is going to work. They're completely different objects. It seems like you're trying to create a link between, say /dev/sda and /dev/console, and expect GPU I/O operations to somehow be magically interpreted to save video to the disk. But maybe you have already done some testing and know that works. I don't know. I can only wish you luck.

                  1 Reply Last reply
                  0
                  • L Lost User

                    I need to be honest - I am getting discouraged by posters "making small talk" posts such as ...make sure you have a backup... ...it is a security issue... I am trying to resolve an issues , not to having to listen to such well meaning but in my view superficial commentaries... OK , I said it ...now you how I feel,,, Will it stop such commentaries ?? I seriously doubt it -some folks are just immune... PS Here is the latest "solution": system ( "echo ""q"" | sudo -S -k ln -s -v /dev/ttyUSB0 /dev/rfcomm0 "); I like to add to it pipe the result to C code variable (string ) AND (temporary) file...

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #9

                    Member 14968771 wrote:

                    I am trying to resolve an issues , not to having to listen to such well meaning but in my view superficial commentaries...

                    Then pay someone for the answer maybe? Forums, free forums, depend on posters posting whatever they want.

                    1 Reply Last reply
                    0
                    • L Lost User

                      I am trying to satisfy this sudo -S option requirement: (from RTFM ) -S' The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character. Is that telling me I have to "post" via stdin password BEFORE I execute "sudo -S "? In other words " option causes sudo to read the password from the standard input " - hence I want / need to emulate users input , in code , and I just do not see how. Mrs Google stdin examples "read" from user or from file.

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #10

                      Member 14968771 wrote:

                      The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

                      Which is what my post it about. You run the command in code. Then you code that code so you can control "standard input" (ie "stdin") which is exactly what I suggested via my google search. By steps. 1. Write code to run the command 2. Figure out how to use the 'stdin' input in the code. That allows your code to pass content to the 'stdin' of the command. 3. You then pass input in via that code to the command.

                      L 1 Reply Last reply
                      0
                      • J jschell

                        Member 14968771 wrote:

                        The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

                        Which is what my post it about. You run the command in code. Then you code that code so you can control "standard input" (ie "stdin") which is exactly what I suggested via my google search. By steps. 1. Write code to run the command 2. Figure out how to use the 'stdin' input in the code. That allows your code to pass content to the 'stdin' of the command. 3. You then pass input in via that code to the command.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        ...what we have here is a failure to communicate... The command expect the password to be in stdin.... Hence to get the password into stdin I want to have a C code writing it to stdin not reading it form file or typing it at console Besides it is unclear WHEN to emulate the password by "writing in stdin " But that is all irrelevant since I have found and tested another sudo option. ...and if it is OK with you "for everybody to write what they feel like - in here" I am assuming that I am also included "as everybody "....

                        1 Reply Last reply
                        0
                        • L Lost User

                          I need to be honest - I am getting discouraged by posters "making small talk" posts such as ...make sure you have a backup... ...it is a security issue... I am trying to resolve an issues , not to having to listen to such well meaning but in my view superficial commentaries... OK , I said it ...now you how I feel,,, Will it stop such commentaries ?? I seriously doubt it -some folks are just immune... PS Here is the latest "solution": system ( "echo ""q"" | sudo -S -k ln -s -v /dev/ttyUSB0 /dev/rfcomm0 "); I like to add to it pipe the result to C code variable (string ) AND (temporary) file...

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          Member 14968771 wrote:

                          I am getting discouraged by posters "making small talk"

                          And we are largely doing this because, as usual, it is far from clear what actual problem you are trying to solve. The original question is fine as it stands, but with more detail we may be able to offer alternative answers. There may be a perfectly reasonable answer to your real problem, but we cannot giuess what that is. You really need to stop attacking everyone for not providing what you determine is the right answer, and stop and think about the quality of the questions you post here.

                          1 Reply Last reply
                          0
                          • L Lost User

                            It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            The quality of the answers you get is directly dictated by the quality of the questions you ask.

                            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                            Dave Kreskowiak

                            1 Reply Last reply
                            0
                            • L Lost User

                              It was suggested to "...stop and think about the quality of the questions you post here." hence directly stating that my post was inappropriate, of poor quality to be posted here. therefore I am removing it.

                              V Offline
                              V Offline
                              Victor Nijegorodov
                              wrote on last edited by
                              #14

                              Member 14968771 wrote:

                              therefore I am removing it.

                              It was bad idea to delete the original question. :thumbsdown: Now no one reading this discussion won't understand its subject... :sigh:

                              L 1 Reply Last reply
                              0
                              • V Victor Nijegorodov

                                Member 14968771 wrote:

                                therefore I am removing it.

                                It was bad idea to delete the original question. :thumbsdown: Now no one reading this discussion won't understand its subject... :sigh:

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #15

                                You need to understand that he really doesn't care for advice.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups