Skip to content

Commit

Permalink
Use getlogin() to get user for commands
Browse files Browse the repository at this point in the history
- Suggestion per @2bndy5
  • Loading branch information
TMRh20 committed Jun 19, 2024
1 parent 11f0d14 commit 1445413
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions RF24Gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ int ESBGateway<mesh_t, network_t, radio_t>::allocateTunDevice(char* dev, int fla
std::cerr << "RF24Gw: Error: enabling TUNSETIFF" << std::endl;
uint32_t UID = getuid();
if (UID) {
std::cout << "Not running as root, preconfigure the interface as follows, where 'pi' is your username" << std::endl;
std::cout << "sudo ip tuntap add dev tun_nrf24 mode tun user pi multi_queue" << std::endl;
std::cout << "Not running as root, preconfigure the interface as follows" << std::endl;
std::cout << "sudo ip tuntap add dev tun_nrf24 mode tun user " << getlogin() << " multi_queue" << std::endl;
std::cout << "sudo ifconfig tun_nrf24 10.10.2.2/24" << std::endl;
}
return -1;
Expand Down
4 changes: 2 additions & 2 deletions examples/ncurses/RF24Gateway_ncurses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ void drawCfg(bool isConf)
mvwprintw(win, 8, 1, "Unable to set IP/Subnet \n");
uint32_t UID = getuid();
if (UID) {
mvwprintw(win, 9, 1, "Not running as root, configure as follows, where 'pi' is your username:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user pi multi_queue\n");
mvwprintw(win, 9, 1, "Not running as root, configure as follows:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user %s multi_queue\n", getlogin());
mvwprintw(win, 11, 1, "sudo ifconfig tun_nrf24 10.10.2.2/24\n");
}
refresh();
Expand Down
4 changes: 2 additions & 2 deletions examples/ncursesInt/RF24Gateway_ncursesInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ void drawCfg(bool isConf)
mvwprintw(win, 8, 1, "Unable to set IP/Subnet \n");
uint32_t UID = getuid();
if (UID) {
mvwprintw(win, 9, 1, "Not running as root, configure as follows, where 'pi' is your username:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user pi multi_queue\n");
mvwprintw(win, 9, 1, "Not running as root, configure as follows:\n");
mvwprintw(win, 10, 1, "sudo ip tuntap add dev tun_nrf24 mode tun user %s multi_queue\n", getlogin());
mvwprintw(win, 11, 1, "sudo ifconfig tun_nrf24 10.10.2.2/24\n");
}
refresh();
Expand Down

0 comments on commit 1445413

Please sign in to comment.