-1

currently I am writing my master thesis and got a little problem in C++. Under certain conditions, I have to restart the ntp daemon, therefore I call:

system("service ntp restart");

But after this ntp is not listening on port 123, but rather 8377 and 8378. This port belong to an udp channel, which is used in the C++-prog.

Does anyone got an idea for this malicious behaviour ?

Thanks :)

Tobias S
  • 1,275
  • 8
  • 23

1 Answers1

0

The system() executes shell command and result of this shell command has nothing common with C++. You problem is definitely not with the C++ but with the shell script:

service ntp restart

Please verify the results of that command and check the command envrionment since there is a big chance that you need to set environment variables. But all this - shell issues, not C++ ones.

Tanuki
  • 449
  • 2
  • 8
  • Hot to set environment variables, when the program is called with sudo and the system call referes the shell? (yeah, i am not really confident with linux) – Tobias S Aug 11 '14 at 08:59
  • env = .. = .. – Tanuki Aug 11 '14 at 09:04
  • Sorry, but I've already said that I'm not confident with linux. Which parameters are to set? – Tobias S Aug 11 '14 at 12:29
  • This is particular for your system. To get the basic idea about that - type man bash and check the /etc/init.d/ntp. As alternative - please consult to your system administrator since the questions you are asking is not a C++ questions but it is general SA questions. I even have no idea about flavour of Linux you are using. I can count 40 flavors from scratch :) – Tanuki Aug 11 '14 at 17:07
  • I'll have a look, and by the way: it' Ubuntu with Unity, but I'll change for something more "basic", maybe Xubuntu with Enlightment as windows manager :) Thx – Tobias S Aug 11 '14 at 17:30