def validate_file(file, type)
if (file)
rng_location = nil
if (type == CONF_FILE)
rng_location = @rng_path + "/conf.rng"
else
rng_location = @rng_path + "/kasp.rng"
end
rng_location = (rng_location.to_s + "").untaint
file = (file.to_s + "").untaint
r, w = IO.pipe
pid = fork {
r.close
$stdout.reopen w
ret = system("#{(@xmllint.to_s + "").untaint} --noout --relaxng #{rng_location} #{file}")
w.close
exit!(ret)
}
w.close
ret_strings = []
r.each {|l| ret_strings.push(l)}
Process.waitpid(pid)
ret_val = $?.exitstatus
ret_strings.each {|line|
line.chomp!
if line.index(" validates")
else
log(LOG_ERR, line)
end
}
if (!ret_val)
log(LOG_ERR, "Errors found validating " +
((file== nil)? "unknown file" : file) +
" against " + ((type == CONF_FILE) ? "conf" : "kasp") + ".rng")
end
else
log(LOG_ERR, "Not validating : no file passed to validate against " +
(((type == CONF_FILE) ? "conf" : "kasp") + ".rng"))
end
end