C++: System call for restarting ntpd -> wrong port

170 Views Asked by At

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 :)

1

There are 1 best solutions below

5
On

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.