How to "provide password " REMOVED
-
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.
-
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.
-
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.
-
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.
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 (usingchmod
andchown
). Again, this has security implications to think about. -
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.
Rather than
system()
take a look atpopen()
[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
-
Rather than
system()
take a look atpopen()
[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
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...
-
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...
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 soprintf("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. -
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...
-
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.
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.
-
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.
...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 "....
-
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...
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.
-
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.
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 -
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.
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:
-
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: