Click here to Skip to main content
15,887,283 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Paige-Tarjan algorithm in C Pin
Maximilien26-Feb-24 5:51
Maximilien26-Feb-24 5:51 
GeneralRe: Paige-Tarjan algorithm in C Pin
Joeyabuki26-Feb-24 6:20
Joeyabuki26-Feb-24 6:20 
QuestionExtracting the Points from a CRgn Object - C / C++ / MFC ... Pin
Member 1601389325-Feb-24 18:47
Member 1601389325-Feb-24 18:47 
AnswerRe: Extracting the Points from a CRgn Object - C / C++ / MFC ... Pin
Victor Nijegorodov25-Feb-24 20:09
Victor Nijegorodov25-Feb-24 20:09 
QuestionHow to create a hover popup window beside the mouse cursor Pin
Member 1185324-Feb-24 15:51
Member 1185324-Feb-24 15:51 
AnswerRe: How to create a hover popup window beside the mouse cursor Pin
Richard MacCutchan24-Feb-24 20:50
mveRichard MacCutchan24-Feb-24 20:50 
QuestionPLEASE help (me) with syntax for placings redirection to file. Pin
Salvatore Terress19-Feb-24 6:08
Salvatore Terress19-Feb-24 6:08 
AnswerRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Mircea Neacsu19-Feb-24 6:50
Mircea Neacsu19-Feb-24 6:50 
I don't know what's the difference between the two commands. I don't know what hcitool does, but I don't think that matters.

What the command(s) do, is to pass the string "q" as stdin to sudo. If "q" is the user password, that's fine because sudo expects to read the user password. On my machine I tried:
Shell
echo xxxxxx | sudo -S ps -A > results
and that works fine. I get the output of ps in the results file ("xxxxxx" is the user "password").

Now how useful or portable such an approach is, is another question.
- Do you plan to have user's password embedded in your code? What if you change your password? would you recompile the code or what?
- Wouldn't it be simpler to just accept that your code has to be run as root?
- Maybe you can set hcitool to be run with sudo without a password. Take a look at Sudoers Manual[^]:
Quote:
PASSWD and NOPASSWD

By default, sudo requires that a user authenticate before running a command. This behavior can be modified via the NOPASSWD tag. Like a Runas_Spec, the NOPASSWD tag sets a default for the commands that follow it in the Cmnd_Spec_List. Conversely, the PASSWD tag can be used to reverse things. For example:

ray rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm

would allow the user ray to run /bin/kill, /bin/ls, and /usr/bin/lprm as root on the machine “rushmore” without authenticating himself. If we only want ray to be able to run /bin/kill without a password the entry would be:

ray rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm

Mircea

GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Salvatore Terress19-Feb-24 7:32
Salvatore Terress19-Feb-24 7:32 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Mircea Neacsu19-Feb-24 7:47
Mircea Neacsu19-Feb-24 7:47 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Salvatore Terress19-Feb-24 16:16
Salvatore Terress19-Feb-24 16:16 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Mircea Neacsu19-Feb-24 16:19
Mircea Neacsu19-Feb-24 16:19 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Salvatore Terress20-Feb-24 5:24
Salvatore Terress20-Feb-24 5:24 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Richard MacCutchan20-Feb-24 6:07
mveRichard MacCutchan20-Feb-24 6:07 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Mircea Neacsu20-Feb-24 6:09
Mircea Neacsu20-Feb-24 6:09 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
k505420-Feb-24 6:53
mvek505420-Feb-24 6:53 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Mircea Neacsu20-Feb-24 6:55
Mircea Neacsu20-Feb-24 6:55 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Salvatore Terress20-Feb-24 10:02
Salvatore Terress20-Feb-24 10:02 
GeneralRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Richard MacCutchan20-Feb-24 21:45
mveRichard MacCutchan20-Feb-24 21:45 
AnswerRe: PLEASE help (me) with syntax for placings redirection to file. Pin
Richard MacCutchan19-Feb-24 21:42
mveRichard MacCutchan19-Feb-24 21:42 
QuestionRepost This is a request for C/C++ code... Pin
Salvatore Terress16-Feb-24 6:49
Salvatore Terress16-Feb-24 6:49 
AnswerRe: Repost This is a request for C/C++ code... Pin
jschell16-Feb-24 7:22
jschell16-Feb-24 7:22 
AnswerRe: Repost This is a request for C/C++ code... Pin
k505416-Feb-24 7:57
mvek505416-Feb-24 7:57 
GeneralRe: Repost This is a request for C/C++ code... Pin
Salvatore Terress16-Feb-24 16:02
Salvatore Terress16-Feb-24 16:02 
QuestionVisual Studio Resource Editor Pin
Richard Andrew x6416-Feb-24 2:03
professionalRichard Andrew x6416-Feb-24 2:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.