⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 importconfig

📁 Perl写的CA认证程序
💻
字号:
## OpenCA - CA Command## (c) 1998-2001 by Massimiliano Pala and OpenCA Group####   File Name: exportRoles##       Brief: Export Roles## Description: Export the following data##              * RBAC/##              * extfiles/##              * OpenSSL/##              * openssl.cnf##              * table RBAC from DB                                                         ##  Parameters: my $cmdName = "importConfig";if ( $cmd !~ /$cmdName/i ) {        configError( "Wrong Command Usage ($cmd over $cmdName)!" );        exit 1;}## GNU Tar suggested for exporting Issued Certificates## to the CA. We use the GNU tar because of its availability## for all the platforms and its stability.## Get required parameters from the configuration filemy $sslconfig = getRequired ('sslconfig');my $map       = getRequired ('roles2openssl');my $command   = getRequired( 'UnpackArchive' );my $dev       = getRequired( 'ImportDev' );my $tmp       = getRequired( 'TempDir' );my $openssl     = getRequired ( 'sslconfig'   );my $rbac_dir    = getRequired ( 'RBAC_DIR'    );my $openssl_dir = getRequired ( 'OPENSSL_DIR' );my $ext_dir     = getRequired ( 'EXT_DIR'     );my $config_dir  = $rbac_dir; $config_dir  =~ s/\/[^\/]*$//;$rbac_dir    =~ s/^.*\///g;$openssl_dir =~ s/^.*\///g;$ext_dir     =~ s/^.*\///g;                                                                  my ( @lastExport );## Subtitute $orig and $dest$tmpdir = $tmp."/RBAC_".$$;$command = $query->subVar( $command, '$orig', $dev );$command = $query->subVar( $command, '$dest', $tmpdir );print startLogPage("RBAC Importing" );print addLogSection("Delete ACL ... ");my @acl = $db->searchItems (DATATYPE => "RBAC");my $right;foreach $right (@acl) {  $db->destroyItem (DATATYPE => "RBAC", KEY => $right->getParsed()->{SERIAL} );}print addLogLine( "Ok." );print closeLogSection ();print addLogSection("Create Temporary Directory for ACL ... ");if( not mkdir( "$tmpdir", 0700 )) {        print addErrorLog( "Failed creating dir $tmpdir" );        closePage();        exit 1;}if( not chdir( "$tmpdir" )) {        print addErrorLog( "Failed changing dir to $tmpdir" );        closePage();        exit 1;}print addLogLine( "Ok." );print closeLogSection ();print addLogSection("Importing files to $tmpdir ... ");$ret = `$command 2>&1`;if( $? != 0 ) {        print addErrorLog( "De-Archiving Failed from $dev!" );        closePage();        exit;} print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();## importing openssl.cnfmy $openssl = $sslconfig;$openssl =~ s/.*\///g;print addLogSection("Importing $openssl into RAServer ... ");$ret = `cp $openssl $sslconfig 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot copy $openssl to $sslconfig!");	print addLogLine( "cp $openssl $sslconfig" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();print addLogSection("Removing $openssl ... ");$ret = `rm -f $openssl 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot remove $openssl !");	print addLogLine( "rm -f  $openssl" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();## importing RBAC/print addLogSection("Importing $rbac_dir into RAServer ... ");$ret = `tar -c $rbac_dir | tar -x -C $config_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot copy $rbac_dir to $config_dir!");	print addLogLine( "tar -c $rbac_dir | tar -x -C $config_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();print addLogSection("Removing $rbac_dir ... ");if ( length ($rbac_dir) < 4 ) {	print addErrorLog("Stopping removing because $rbac_dir is shorter then 4 characters!");	closePage();	exit 1;}$ret = `rm -rf $rbac_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot remove $rbac_dir !");	print addLogLine( "rm -rf  $rbac_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();## importing OpenSSL/print addLogSection("Importing $openssl_dir into RAServer ... ");$ret = `tar -c $openssl_dir | tar -x -C $config_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot copy $openssl_dir to $config_dir!");	print addLogLine( "tar -c $openssl_dir | tar -x -C $config_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();print addLogSection("Removing $openssl_dir ... ");if ( length ($openssl_dir) < 4 ) {	print addErrorLog("Stopping removing because $openssl_dir is shorter then 4 characters!");	closePage();	exit 1;}$ret = `rm -rf $openssl_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot remove $openssl_dir !");	print addLogLine( "rm -rf  $openssl_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();## importing extfiles/print addLogSection("Importing $ext_dir into RAServer ... ");$ret = `tar -c $ext_dir | tar -x -C $config_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot copy $ext_dir to $config_dir!");	print addLogLine( "tar -c $ext_dir | tar -x -C $config_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();print addLogSection("Removing $ext_dir ... ");if ( length ($ext_dir) < 4 ) {	print addErrorLog("Stopping removing because $ext_dir is shorter then 4 characters!");	closePage();	exit 1;}$ret = `rm -rf $ext_dir 2>&1`;if( $? != 0 ) {	print addErrorLog("Cannot remove $ext_dir !");	print addLogLine( "rm -rf  $ext_dir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection ();## import the access controlprint addLogSection("Importing ACL ... ");my $txtItem;my $i=0;my $tools = new OpenCA::Tools;my $rbac;while (1) {  $txtItem = $tools->getFile ("rbac_".$i.".txt");  print $txtItem;  last if (not $txtItem);  $rbac = new OpenCA::RBAC (DATA => $txtItem);  $db->storeItem (DATATYPE => RBAC, OBJECT => $rbac, MODE => "INSERT");  print addLogLine ("import access right $i");  $i++;}print closeLogSection ();print addLogSection ("Removing Temporary Directory ... ");if( not chdir( "$tmp" )) {        print addErrorLog( "Failed changing dir to $tmp." );        closePage();        exit 1;}if ( length ($tmpdir) < 7 ) {	print addErrorLog("Stopping removing because $tmpdir is shorter then 7 characters!");	closePage();	exit 1;}$ret = `rm -rf $tmpdir 2>&1`;if( $? != 0 ) {	print addErrorLog("Removing Failed for $tmpdir!");	print addLogLine( "rm -rf $tmpdir" );	closePage();	exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection();closePage();1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -