int main(int argc, char *argv[]) { QApplication app(argc, argv); bool superUser = getuid() == 0; GuardPuppyFireWall firewall( superUser ); GuardPuppyDialog_w guardPuppyDialog( firewall ); if ( !superUser ) { QMessageBox::information(0, QString::null, QString("WARNING"), QObject::tr( "Since you do not have superuser privileges, Guarddog is running with\n" "reduced functionality. Firewall scripts may be Imported/Exported, but\n" "the system's firewall settings may not be changed.\n")); } int rc = 0; try { guardPuppyDialog.show(); rc = app.exec(); } catch ( std::string const & msg ) { std::cout << "Caught: " << msg << std::endl; } return rc; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); bool superUser = getuid() == 0; //this only checks to see if the user is root. but there may be other groups or users who have superuser privlages. //a better method of checking if the user can perform the needed tasks is required. //in fact i don't think there should be any check at all. GuardPuppyFireWall firewall( superUser ); GuardPuppyDialog_w guardPuppyDialog( firewall ); if ( !superUser ) { QMessageBox::information(0, QString::null, QString("WARNING"), QObject::tr( "Since you do not have superuser privileges, Guarddog is running with\n" "reduced functionality. Firewall scripts may be Imported/Exported, but\n" "the system's firewall settings may not be changed.\n")); } int rc = 0; try { guardPuppyDialog.show(); rc = app.exec(); } catch ( std::string const & msg ) { std::cout << "Caught: " << msg << std::endl; } return rc; }
// // Download // void Options::Download() { VarString firewall("$.firewall", this); VarString localAddress("$.localAddress", this); VarInteger port("$.port", this); VarString proxy("$.proxy", this); Settings::SetFirewallStatus(Crc::CalcStr(firewall)); Settings::SetLocalAddress(inet_addr(*localAddress)); Settings::SetPort(port); Settings::SetProxy(proxy); Settings::SaveToUser(); }
// // Upload // void Options::Upload() { VarString firewall("$.firewall", this); VarString localAddress("$.localAddress", this); VarInteger port("$.port", this); VarString proxy("$.proxy", this); Settings::LoadFromUser(); switch (Settings::GetConfigFirewallStatus()) { case Settings::FirewallStatus::AutoDetect: firewall = "FirewallStatus::AutoDetect"; break; case Settings::FirewallStatus::BehindFirewall: firewall = "FirewallStatus::BehindFirewall"; break; case Settings::FirewallStatus::NotBehindFirewall: firewall = "FirewallStatus::NotBehindFirewall"; break; } if (Settings::GetLocalAddress()) { in_addr addr; addr.s_addr = Settings::GetLocalAddress(); localAddress = inet_ntoa(addr); } else { localAddress = ""; } port = Settings::GetConfigPort(); proxy = Settings::GetProxy(); }
SAT_returnState route_pkt (tc_tm_pkt *pkt) { SAT_returnState res; TC_TM_app_id id; if ( !C_ASSERT(pkt != NULL && pkt->data != NULL)) { free_pkt(pkt); return SATR_ERROR; } if (!C_ASSERT(pkt->type == TC || pkt->type == TM)) { free_pkt(pkt); return SATR_ERROR; } if (!C_ASSERT(pkt->app_id < LAST_APP_ID && pkt->dest_id < LAST_APP_ID)) { free_pkt(pkt); return SATR_ERROR; } if (pkt->type == TC) { id = pkt->app_id; } else if (pkt->type == TM) { id = pkt->dest_id; } else { return SATR_ERROR; } if(firewall(pkt) != SATR_OK) { verification_app (pkt); free_pkt (pkt); return SATR_OK; } if (id == SYSTEM_APP_ID && pkt->ser_type == TC_HOUSEKEEPING_SERVICE && pkt->ser_subtype == TM_HK_PARAMETERS_REPORT && pkt->data[0] == WOD_REP) { /* * A new WOD arrived from the OBC. Store it and extract the information. * The transmission of each WOD is handled by the COMMS dispatcher function */ SYSVIEW_PRINT("WOD from OBC"); store_wod_obc(pkt->data + 1, pkt->len - 1); } else if (id == SYSTEM_APP_ID && pkt->ser_type == TC_HOUSEKEEPING_SERVICE && pkt->ser_subtype == TM_HK_PARAMETERS_REPORT && pkt->data[0] == EXT_WOD_REP) { /* * A new exWOD arrived from the OBC. Store it and extract the information. * The transmission of each exWOD is handled by the COMMS dispatcher function */ SYSVIEW_PRINT("exWOD from OBC"); store_ex_wod_obc(pkt->data, pkt->len); } else if (id == SYSTEM_APP_ID && pkt->ser_type == TC_HOUSEKEEPING_SERVICE) { res = hk_app (pkt); } else if (id == SYSTEM_APP_ID && pkt->ser_type == TC_FUNCTION_MANAGEMENT_SERVICE) { res = function_management_app (pkt); } else if (id == SYSTEM_APP_ID && pkt->ser_type == TC_LARGE_DATA_SERVICE) { res = large_data_app (pkt); if (res == SATR_OK) { free_pkt (pkt); return SATR_OK; } } else if (id == SYSTEM_APP_ID && pkt->ser_type == TC_TEST_SERVICE) { //C_ASSERT(pkt->ser_subtype == 1 || pkt->ser_subtype == 2 || pkt->ser_subtype == 9 || pkt->ser_subtype == 11 || pkt->ser_subtype == 12 || pkt->ser_subtype == 13) { free_pkt(pkt); return SATR_ERROR; } res = test_app (pkt); } else if (id == EPS_APP_ID) { queuePush (pkt, OBC_APP_ID); } else if (id == ADCS_APP_ID) { queuePush (pkt, OBC_APP_ID); } else if (id == OBC_APP_ID) { queuePush (pkt, OBC_APP_ID); } else if (id == IAC_APP_ID) { queuePush (pkt, OBC_APP_ID); } else if (id == GND_APP_ID) { if (pkt->len > MAX_PKT_DATA) { large_data_downlinkTx_api (pkt); } else { tx_ecss (pkt); } } else if (id == DBG_APP_ID) { queuePush (pkt, OBC_APP_ID); } else { free_pkt(pkt); } return SATR_OK; }