Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion traffic_ops_ort/traffic_ops_ort.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,33 @@ sub replace_cfg_file {
. $cfg_file_tracker->{$cfg_file}->{'backup_from_trops'} . " to "
. $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}
. "\n";
system("/bin/cp $cfg_file_tracker->{$cfg_file}->{'backup_from_trops'} $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}");
system("/bin/mv $cfg_file_tracker->{$cfg_file}->{'backup_from_trops'} "
. "$cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}.new");
# The return value is the exit status of the program as returned by the wait call.
# To get the actual exit value, shift right by eight (see below).
# https://perldoc.perl.org/functions/system.html
if ( ($? >> 8) != 0 ){
( $log_level >> $ERROR )
&& print "ERROR Failed moving "
. $cfg_file_tracker->{$cfg_file}->{'backup_from_trops'} . " to "
. $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'} . ".new"
. "\n";
# todo should I die()? i'm not sure what to do in this case
die();
}else {
system("/bin/mv $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'} "
. "$cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}.old && "
. "/bin/mv $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}.new "
. "$cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}");
if ( ($? >> 8) != 0 ) {
($log_level >> $ERROR)
&& print "ERROR Failed swapping " . $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}
. " out for new config at ". $cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'} . ".new"
. "\n";
# todo should I die()? i'm not sure what to do in this case
die();
}
}
if ( $cfg_file =~ /cron/ ) {
chown 0, 0, "$cfg_file_tracker->{$cfg_file}->{'headers'}->{'path'}";
}
Expand Down