how to get "native window" ?
-
Salvatore Terress wrote:
Apparently there are at least two ways to accomplish that.
All languages, C++ or anything else, for an external app has the following communication paths. - Start Up - Command line parameters. - Running. Exit code. Which is an int value and nothing else. - Running. Stdio: stderr, stdin, stdout. Using the above I have implemented the following in the past - One computer connecting to multiple hardware devices. - Error output collected. - Logging collected. - Commands controlling each device. - Binary data sent to and from each device. An application might provide another API. But that has nothing to do with running it from the first application. And for most standard 'OS Command line' commands it will not apply. As a specific example you can start and stop IIS using command line commands. But you are definitely not going to be accessing web sites from it using exactly the same commands (if at all using a OS command.) Using a command line app and controlling it requires that one understand exactly what the app does. And that has nothing to do with the controller code from the calling app. Using a OS shell is going to make the above MUCH harder. That is because the shell must then redirect all output from any commands it runs back along the stdio path (in and out.) Getting the shell to do that has nothing to do with the calling application. One will need to figure that out by looking for command line parameter to the shell itself. Although I suspect that that it is possible to do this, at the very least I know it is difficult.
-
Salvatore Terress wrote:
Apparently there are at least two ways to accomplish that.
All languages, C++ or anything else, for an external app has the following communication paths. - Start Up - Command line parameters. - Running. Exit code. Which is an int value and nothing else. - Running. Stdio: stderr, stdin, stdout. Using the above I have implemented the following in the past - One computer connecting to multiple hardware devices. - Error output collected. - Logging collected. - Commands controlling each device. - Binary data sent to and from each device. An application might provide another API. But that has nothing to do with running it from the first application. And for most standard 'OS Command line' commands it will not apply. As a specific example you can start and stop IIS using command line commands. But you are definitely not going to be accessing web sites from it using exactly the same commands (if at all using a OS command.) Using a command line app and controlling it requires that one understand exactly what the app does. And that has nothing to do with the controller code from the calling app. Using a OS shell is going to make the above MUCH harder. That is because the shell must then redirect all output from any commands it runs back along the stdio path (in and out.) Getting the shell to do that has nothing to do with the calling application. One will need to figure that out by looking for command line parameter to the shell itself. Although I suspect that that it is possible to do this, at the very least I know it is difficult.
Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.
-
Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.
Salvatore Terress wrote:
I need to have "sudo" access... Such access has NOTHING to do with Linux security.
Yes, it has everything to do with Linux security, as clearly explained in the man page: https://linux.die.net/man/8/sudo[^]. And although I have not tried this myself, I strongly suspect that you cannot use it in the way you are trying to do. If you want elevated/admin permissions then you most likely need to call
sudo
before you start the original application. And this question has nothing to do with C/C++; please use the correct forums for your questions. -
Thanks for all the replies. I have been thru this before and had to fix some other part of the project. Again , RTFM is little misreading...but that is not my concern. I may have said this before when my command is "hcitool dev" I get expected response (stdio)- non issue. To be able to do "hcitool info (address)" I need to have "sudo" access... Such access has NOTHING to do with Linux security. and that is when I need interactive repose and that is when SAME "shell" does not work. I'll to modify "sudo" configuration, but not sure if "hcitool info" will work.
In today's O/S security systems, there is usually a wall between normal user processes and admin-level processes. You cannot access the streams of an admin process from a normal user process. Think about it for just 5 seconds and you'll see why this is a security risk and is now not allowed.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
In today's O/S security systems, there is usually a wall between normal user processes and admin-level processes. You cannot access the streams of an admin process from a normal user process. Think about it for just 5 seconds and you'll see why this is a security risk and is now not allowed.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
-
Thank your very much for all these "security comments" they are very helpful in resolving the issue. Appreciate that very much.
ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :
system ("sudo -S su -ps q/n" );
system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");
and this output
[sudo] password for nov25-1:
sudo: no password was provided
sudo: a password is required
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required -
ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :
system ("sudo -S su -ps q/n" );
system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");
and this output
[sudo] password for nov25-1:
sudo: no password was provided
sudo: a password is required
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is requiredI'm sure've been over this before:
$ id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)create a new group for bluetooth users, call it btusers
$ sudo groupadd btusers
add user k5054 to the btusers group
$ sudo usermod -a -G btusers k5054
edit /etc/sudoers.d/btusers to allow any user in btusers group
to run hcitool without a password:
$ sudo visudo /etc/sudoers.d/btusers
add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitoollog out and log back in again ...
$ sudo ps
[sudo] password for k5054: (CTL-D)
sudo: no password was provided
sudo: a password is requiredWe're now part of the btusers group, so we don't need a password for hcitool
id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)
sudo hcitool without needing a password
$ sudo hcitool dev
Devices:If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.
%btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump
With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
ADDENDUM This is a request for C/C++ code... This is specific application I am asking for assistance with actual code. I am still asking for assistance in actual C/C++ code to implement system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33"); hcitool cc command require root / sudo , period. hence I need to enter password WITHOUT running "terminal" which "sudo -S" option should provide. I DO NOT KNOW HOW TO ENTER PASSWORD in code USING stdin... I need help with that - I need actual C/C++ code it won't work if I run "sudo su" prior to executing my application after connection is established the code no longer needs to run as "su", it is of non issue . I am trying a solve different task, plain (Linux ) command, and having difficulty implementing the "sudo" bypass. In an essence, I should be able to "enter" password using a sudo command options -S and -ps It is unclear , to me , how to actually code it. I have this code :
system ("sudo -S su -ps q/n" );
system ("sudo hcitool cc --role=c 98:D3:31:F8:29:33");
and this output
[sudo] password for nov25-1:
sudo: no password was provided
sudo: a password is required
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required -
I'm sure've been over this before:
$ id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)create a new group for bluetooth users, call it btusers
$ sudo groupadd btusers
add user k5054 to the btusers group
$ sudo usermod -a -G btusers k5054
edit /etc/sudoers.d/btusers to allow any user in btusers group
to run hcitool without a password:
$ sudo visudo /etc/sudoers.d/btusers
add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitoollog out and log back in again ...
$ sudo ps
[sudo] password for k5054: (CTL-D)
sudo: no password was provided
sudo: a password is requiredWe're now part of the btusers group, so we don't need a password for hcitool
id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)
sudo hcitool without needing a password
$ sudo hcitool dev
Devices:If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.
%btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump
With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
I'm sure've been over this before:
$ id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users)create a new group for bluetooth users, call it btusers
$ sudo groupadd btusers
add user k5054 to the btusers group
$ sudo usermod -a -G btusers k5054
edit /etc/sudoers.d/btusers to allow any user in btusers group
to run hcitool without a password:
$ sudo visudo /etc/sudoers.d/btusers
add line %btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitoollog out and log back in again ...
$ sudo ps
[sudo] password for k5054: (CTL-D)
sudo: no password was provided
sudo: a password is requiredWe're now part of the btusers group, so we don't need a password for hcitool
id
uid=1002(k5054) gid=1002(k5054) groups=1002(k5054),27(sudo),100(users),1003(btusers)
sudo hcitool without needing a password
$ sudo hcitool dev
Devices:If you need to be able to run other commands you can append them as a comma separated items to the sudoers file e.g.
%btusers ALL=(ALL) NOPASSWD:/usr/bin/hcitool,/usr/bin/hcidump
With knowledge comes great power. Use it wisely. But this should really be int the linux programming forum, or maybe System Admin.
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
per sudo man I am trying to implement this as C++ command: -S, --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal device. system (" sudo -S "); what am I missing ?
Salvatore Terress wrote:
what am I missing ?
It makes no difference how you run that command string, it will never work. If that command succeeds then the generated shell that runs the sudo command will be elevated to (possibly root) status. It will then terminate and return to your application which runs at non-elevated level. If you want root access in your application then you have two very simple choices: 1. Do what k5054 advised and set up your account to run at higher level. 2. Call sudo in your shell before launching your application.