1e1051a39Sopenharmony_ci#! /usr/bin/env perl 2e1051a39Sopenharmony_ci# Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci# 4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci# this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ciuse strict; 11e1051a39Sopenharmony_ciuse warnings; 12e1051a39Sopenharmony_ci 13e1051a39Sopenharmony_cimy @directory_vars = ( "dir", "certs", "crl_dir", "new_certs_dir" ); 14e1051a39Sopenharmony_cimy @file_vars = ( "database", "certificate", "serial", "crlnumber", 15e1051a39Sopenharmony_ci "crl", "private_key", "RANDFILE" ); 16e1051a39Sopenharmony_ciwhile(<STDIN>) { 17e1051a39Sopenharmony_ci s|\R$||; 18e1051a39Sopenharmony_ci foreach my $d (@directory_vars) { 19e1051a39Sopenharmony_ci if (/^(\s*\#?\s*${d}\s*=\s*)\.\/([^\s\#]*)([\s\#].*)$/) { 20e1051a39Sopenharmony_ci $_ = "$1sys\\\$disk:\[.$2$3"; 21e1051a39Sopenharmony_ci } elsif (/^(\s*\#?\s*${d}\s*=\s*)(\w[^\s\#]*)([\s\#].*)$/) { 22e1051a39Sopenharmony_ci $_ = "$1sys\\\$disk:\[.$2$3"; 23e1051a39Sopenharmony_ci } 24e1051a39Sopenharmony_ci s/^(\s*\#?\s*${d}\s*=\s*\$\w+)\/([^\s\#]*)([\s\#].*)$/$1.$2\]$3/; 25e1051a39Sopenharmony_ci while(/^(\s*\#?\s*${d}\s*=\s*(\$\w+\.|sys\\\$disk:\[\.)[\w\.]+)\/([^\]]*)\](.*)$/) { 26e1051a39Sopenharmony_ci $_ = "$1.$3]$4"; 27e1051a39Sopenharmony_ci } 28e1051a39Sopenharmony_ci } 29e1051a39Sopenharmony_ci foreach my $f (@file_vars) { 30e1051a39Sopenharmony_ci s/^(\s*\#?\s*${f}\s*=\s*)\.\/(.*)$/$1sys\\\$disk:\[\/$2/; 31e1051a39Sopenharmony_ci while(/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/(\w+\/[^\s\#]*)([\s\#].*)$/) { 32e1051a39Sopenharmony_ci $_ = "$1.$3$4"; 33e1051a39Sopenharmony_ci } 34e1051a39Sopenharmony_ci if (/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/(\w+)([\s\#].*)$/) { 35e1051a39Sopenharmony_ci $_ = "$1]$3.$4"; 36e1051a39Sopenharmony_ci } elsif (/^(\s*\#?\s*${f}\s*=\s*(\$\w+|sys\\\$disk:\[)[^\/]*)\/([^\s\#]*)([\s\#].*)$/) { 37e1051a39Sopenharmony_ci $_ = "$1]$3$4"; 38e1051a39Sopenharmony_ci } 39e1051a39Sopenharmony_ci } 40e1051a39Sopenharmony_ci print $_,"\n"; 41e1051a39Sopenharmony_ci} 42