sendhup.cpp 564 B

123456789101112131415161718192021222324252627282930
  1. #include <iostream>
  2. #include <sstream>
  3. #include <stdlib.h>
  4. using namespace std;
  5. void usage(const string& argv0)
  6. {
  7. cout << "Usage: " << argv0 << " (freeradius|dnsmasq)" << endl;
  8. }
  9. int main(int argc, char *argv[])
  10. {
  11. if (argc < 2) {
  12. usage(argv[0]);
  13. return 0;
  14. }
  15. string argv1 { argv[1] };
  16. // We're setuid, prevent people from abusing this
  17. if (argv1 != "freeradius" && argv1 != "dnsmasq") {
  18. usage(argv[0]);
  19. return 1;
  20. }
  21. ostringstream s;
  22. s << "pkill -HUP " << argv1;
  23. system(s.str().c_str());
  24. }