From b0bd5a37ec78664d255c86a809052debeb108d11 Mon Sep 17 00:00:00 2001 From: shen kun Date: Fri, 12 Mar 2021 16:00:26 +0800 Subject: [PATCH] rm src/bin/gs_ktool & rm build/srcipt/gsql_env.sh --- build/script/gsql_env.sh | 80 - build/script/mpp_release_list_kylin_aarch64 | 1399 ----------------- src/Makefile.global.in | 2 +- src/bin/Makefile | 7 +- src/bin/gs_ktool/Makefile | 42 - src/bin/gs_ktool/gs_ktool_conf.ini | 15 - src/bin/gs_ktool/kt_common.cpp | 415 ----- src/bin/gs_ktool/kt_common.h | 141 -- src/bin/gs_ktool/kt_interface.cpp | 115 -- src/bin/gs_ktool/kt_key_manage.cpp | 589 ------- src/bin/gs_ktool/kt_key_manage.h | 90 -- src/bin/gs_ktool/kt_kmc_callback.cpp | 467 ------ src/bin/gs_ktool/kt_kmc_callback.h | 58 - src/bin/gs_ktool/kt_log_manage.cpp | 361 ----- src/bin/gs_ktool/kt_log_manage.h | 108 -- src/bin/gs_ktool/kt_main.cpp | 820 ---------- src/bin/pg_dump/Makefile | 2 +- src/bin/psql/Makefile | 4 +- src/common/interfaces/libpq/Makefile | 4 +- .../libpq/client_logic_hooks/Makefile | 2 +- .../encryption_hooks/Makefile | 2 +- 21 files changed, 9 insertions(+), 4714 deletions(-) delete mode 100644 build/script/gsql_env.sh delete mode 100644 build/script/mpp_release_list_kylin_aarch64 delete mode 100644 src/bin/gs_ktool/Makefile delete mode 100644 src/bin/gs_ktool/gs_ktool_conf.ini delete mode 100644 src/bin/gs_ktool/kt_common.cpp delete mode 100644 src/bin/gs_ktool/kt_common.h delete mode 100644 src/bin/gs_ktool/kt_interface.cpp delete mode 100644 src/bin/gs_ktool/kt_key_manage.cpp delete mode 100644 src/bin/gs_ktool/kt_key_manage.h delete mode 100644 src/bin/gs_ktool/kt_kmc_callback.cpp delete mode 100644 src/bin/gs_ktool/kt_kmc_callback.h delete mode 100644 src/bin/gs_ktool/kt_log_manage.cpp delete mode 100644 src/bin/gs_ktool/kt_log_manage.h delete mode 100644 src/bin/gs_ktool/kt_main.cpp diff --git a/build/script/gsql_env.sh b/build/script/gsql_env.sh deleted file mode 100644 index bd36700890..0000000000 --- a/build/script/gsql_env.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -#----------------------------------------------------- -#Copyright (c): 2020, Huawei Tech. Co., Ltd. -#FileName : gsql_env.sh -#Version : V500R001C10 -#Date : 2020-08-06 -#Description : This file is to configure environment variables of gsql -#----------------------------------------------------- - -#find the absolute path of this script -LOCAL_PATH=${0} -if [ x${LOCAL_PATH:0:1} = "x-" ] || [ "x${LOCAL_PATH}" = "x/bin/bash" ] || [ "x${LOCAL_PATH}" = "x/bin/sh" ]; then - LOCAL_PATH="$(pwd)" -elif [ x${LOCAL_PATH:0:1} != "x/" ]; then - LOCAL_PATH="$(pwd)/$(dirname ${LOCAL_PATH})"; -fi - -function logerr() -{ - printf "ERROR: $* \n" >&2 -} - -function loghint() -{ - printf "HINT: $* \n" >&2 -} - -function logwarning() -{ - printf "WARNING: $* \n" >&2 -} - -function doing() -{ - length_of_line=60 - printf "$1 "; - for ((i=${#1};i<$length_of_line;i++)); do - printf '.'; - done; - printf " " -} - -#------------------------------ -# gsql things -#------------------------------ -function cofig_gsql_and_gs_ktool() -{ - doing 'Configuring LD_LIBRARY_PATH, PATH and GS_KTOOL_FILE_PATH for gsql and gs_ktool...' - LIB_PATH="${LOCAL_PATH}/lib" - BIN_PATH="${LOCAL_PATH}/bin" - GS_KT_FILE_PATH="${LOCAL_PATH}/gs_ktool_file" - if [ ! -f "${LOCAL_PATH}/bin/gsql" ]; then - logerr "failed to locate ./bin/gsql, please source this file at the path where it is. " - return 1; - fi; - if [ ! -f "${LOCAL_PATH}/bin/gs_ktool" ]; then - logerr "failed to locate ./bin/gs_ktool, please source this file at the path where it is. " - return 1; - fi; - if [ ! -f "${LOCAL_PATH}/gs_ktool_file/gs_ktool_conf.ini" ]; then - logerr "failed to locate ./gs_ktool_file/gs_ktool_con.ini, please source this file at the path where it is. " - return 1; - fi; - export LD_LIBRARY_PATH=${LIB_PATH}:${LD_LIBRARY_PATH} - export PATH=${BIN_PATH}:${PATH} - export GS_KTOOL_FILE_PATH=${GS_KT_FILE_PATH} - echo 'done' - return 0 -} - -if [ ! -z "$1" ]; then - echo "Usage:" - echo " source $0" -else - cofig_gsql_and_gs_ktool - if [ 0 -eq $? ]; then - echo 'All things done.' - fi -fi diff --git a/build/script/mpp_release_list_kylin_aarch64 b/build/script/mpp_release_list_kylin_aarch64 deleted file mode 100644 index 08a831d472..0000000000 --- a/build/script/mpp_release_list_kylin_aarch64 +++ /dev/null @@ -1,1399 +0,0 @@ -[server] -./bin/gds -./bin/gs_log -./bin/gsql -./bin/gaussdb -./bin/gaussdb.version.GaussDB200 -./bin/gaussdb.version.GaussDB300 -./bin/gaussdb.license.GaussDB200_Standard -./bin/gaussmaster -./bin/gstrace -./bin/gs_encrypt -./bin/gs_gtm -./bin/gs_dump -./bin/gs_dumpall -./bin/gs_initgtm -./bin/gs_initcm -./bin/gs_ctl -./bin/gs_initdb -./bin/gtm_ctl -./bin/cm_server -./bin/cm_agent -./bin/om_monitor -./bin/cm_ctl -./bin/etcd -./bin/etcdctl -./bin/seq_query -./bin/gs_guc -./bin/encrypt -./bin/gs_roach -./bin/gs_clean -./bin/gs_redis -./bin/gs_restore -./bin/gs_cgroup -./bin/openssl -./bin/pg_config -./bin/pg_controldata -./bin/pg_format_cu -./bin/pg_resetxlog -./bin/alarmItem.conf -./bin/retry_errcodes.conf -./bin/cluster_guc.conf -./bin/runsessionstat.sh -./bin/drop_caches.sh -./bin/run_drop_cache.sh -./bin/transfer.py -./bin/setArmOptimization.sh -./bin/bind_net_irq.sh -./bin/getDEK.jar -./bin/gs_plan_simulator.sh -./bin/dependences/clean_temp.sql -./bin/dependences/initdb.py -./bin/dependences/restore_temp.sql -./bin/dependences/store_pg_class_stats.sql -./bin/dependences/store_pg_statistic_ext_stats.sql -./bin/dependences/store_pg_statistic_stats.sql -./bin/dependences/store_pgxc_class.sql -./bin/krb5kdc -./bin/klist -./bin/kinit -./bin/kdestroy -./bin/kdb5_util -./bin/kadmin.local -./bin/lz4 -./bin/iperf3 -./bin/fio -./etc/kerberos/kadm5.acl -./etc/kerberos/kdc.conf -./etc/kerberos/krb5.conf -./etc/kerberos/mppdb-site.xml -./share/postgis/PostGIS_install.sh -./share/postgresql/tmp/udstools.py -./share/postgresql/snowball_create.sql -./share/postgresql/pmk_schema.sql -./share/postgresql/pmk_schema_single_inst.sql -./share/postgresql/pg_hba.conf.sample -./share/postgresql/pg_service.conf.sample -./share/postgresql/psqlrc.sample -./share/postgresql/conversion_create.sql -./share/postgresql/postgres.shdescription -./share/postgresql/pg_ident.conf.sample -./share/postgresql/postgres.description -./share/postgresql/postgresql.conf.sample -./share/postgresql/extension/plpgsql--1.0.sql -./share/postgresql/extension/hstore.control -./share/postgresql/extension/tsdb.control -./share/postgresql/extension/security_plugin.control -./share/postgresql/extension/security_plugin--1.0.sql -./share/postgresql/extension/tsdb--1.0.sql -./share/postgresql/extension/streaming--1.0.sql -./share/postgresql/extension/streaming.control -./share/postgresql/extension/file_fdw--1.0.sql -./share/postgresql/extension/plpgsql.control -./share/postgresql/extension/dist_fdw.control -./share/postgresql/extension/dist_fdw--1.0.sql -./share/postgresql/extension/hstore--1.1.sql -./share/postgresql/extension/plpgsql--unpackaged--1.0.sql -./share/postgresql/extension/file_fdw.control -./share/postgresql/extension/hstore--unpackaged--1.0.sql -./share/postgresql/extension/hstore--1.0--1.1.sql -./share/postgresql/extension/hdfs_fdw--1.0.sql -./share/postgresql/extension/hdfs_fdw.control -./share/postgresql/extension/gc_fdw--1.0.sql -./share/postgresql/extension/gc_fdw.control -./share/postgresql/extension/roach_api--1.0.sql -./share/postgresql/extension/roach_api.control -./share/postgresql/extension/log_fdw--1.0.sql -./share/postgresql/extension/log_fdw.control -./share/postgresql/extension/dimsearch--1.0.sql -./share/postgresql/extension/dimsearch.control -./share/postgresql/extension/packages--1.0.sql -./share/postgresql/extension/packages--1.0--1.1.sql -./share/postgresql/extension/packages.control -./share/postgresql/extension/gsredistribute.control -./share/postgresql/extension/gsredistribute--1.0.sql -./share/postgresql/extension/gsredistribute--unpackaged--1.0.sql -./share/postgresql/timezone/GB-Eire -./share/postgresql/timezone/Turkey -./share/postgresql/timezone/Kwajalein -./share/postgresql/timezone/UCT -./share/postgresql/timezone/Mexico/BajaSur -./share/postgresql/timezone/Mexico/BajaNorte -./share/postgresql/timezone/Mexico/General -./share/postgresql/timezone/Japan -./share/postgresql/timezone/Israel -./share/postgresql/timezone/US/Eastern -./share/postgresql/timezone/US/Samoa -./share/postgresql/timezone/US/Michigan -./share/postgresql/timezone/US/Aleutian -./share/postgresql/timezone/US/Pacific -./share/postgresql/timezone/US/Pacific-New -./share/postgresql/timezone/US/Indiana-Starke -./share/postgresql/timezone/US/Mountain -./share/postgresql/timezone/US/East-Indiana -./share/postgresql/timezone/US/Hawaii -./share/postgresql/timezone/US/Arizona -./share/postgresql/timezone/US/Alaska -./share/postgresql/timezone/US/Central -./share/postgresql/timezone/Greenwich -./share/postgresql/timezone/Poland -./share/postgresql/timezone/CET -./share/postgresql/timezone/GMT-0 -./share/postgresql/timezone/Indian/Mauritius -./share/postgresql/timezone/Indian/Cocos -./share/postgresql/timezone/Indian/Reunion -./share/postgresql/timezone/Indian/Maldives -./share/postgresql/timezone/Indian/Comoro -./share/postgresql/timezone/Indian/Antananarivo -./share/postgresql/timezone/Indian/Christmas -./share/postgresql/timezone/Indian/Kerguelen -./share/postgresql/timezone/Indian/Chagos -./share/postgresql/timezone/Indian/Mayotte -./share/postgresql/timezone/Indian/Mahe -./share/postgresql/timezone/GMT0 -./share/postgresql/timezone/Antarctica/Palmer -./share/postgresql/timezone/Antarctica/Syowa -./share/postgresql/timezone/Antarctica/South_Pole -./share/postgresql/timezone/Antarctica/McMurdo -./share/postgresql/timezone/Antarctica/Rothera -./share/postgresql/timezone/Antarctica/Mawson -./share/postgresql/timezone/Antarctica/Casey -./share/postgresql/timezone/Antarctica/Davis -./share/postgresql/timezone/Antarctica/DumontDUrville -./share/postgresql/timezone/Antarctica/Vostok -./share/postgresql/timezone/Antarctica/Macquarie -./share/postgresql/timezone/ROK -./share/postgresql/timezone/Chile/EasterIsland -./share/postgresql/timezone/Chile/Continental -./share/postgresql/timezone/posixrules -./share/postgresql/timezone/Atlantic/Azores -./share/postgresql/timezone/Atlantic/St_Helena -./share/postgresql/timezone/Atlantic/Madeira -./share/postgresql/timezone/Atlantic/Jan_Mayen -./share/postgresql/timezone/Atlantic/Faroe -./share/postgresql/timezone/Atlantic/Stanley -./share/postgresql/timezone/Atlantic/Cape_Verde -./share/postgresql/timezone/Atlantic/Reykjavik -./share/postgresql/timezone/Atlantic/Canary -./share/postgresql/timezone/Atlantic/South_Georgia -./share/postgresql/timezone/Atlantic/Bermuda -./share/postgresql/timezone/Atlantic/Faeroe -./share/postgresql/timezone/Hongkong -./share/postgresql/timezone/Libya -./share/postgresql/timezone/Iceland -./share/postgresql/timezone/UTC -./share/postgresql/timezone/Australia/Darwin -./share/postgresql/timezone/Australia/North -./share/postgresql/timezone/Australia/NSW -./share/postgresql/timezone/Australia/Sydney -./share/postgresql/timezone/Australia/Hobart -./share/postgresql/timezone/Australia/LHI -./share/postgresql/timezone/Australia/Victoria -./share/postgresql/timezone/Australia/South -./share/postgresql/timezone/Australia/Melbourne -./share/postgresql/timezone/Australia/Lord_Howe -./share/postgresql/timezone/Australia/West -./share/postgresql/timezone/Australia/Brisbane -./share/postgresql/timezone/Australia/Perth -./share/postgresql/timezone/Australia/Eucla -./share/postgresql/timezone/Australia/Canberra -./share/postgresql/timezone/Australia/Queensland -./share/postgresql/timezone/Australia/Broken_Hill -./share/postgresql/timezone/Australia/Lindeman -./share/postgresql/timezone/Australia/ACT -./share/postgresql/timezone/Australia/Currie -./share/postgresql/timezone/Australia/Adelaide -./share/postgresql/timezone/Australia/Yancowinna -./share/postgresql/timezone/Australia/Tasmania -./share/postgresql/timezone/Jamaica -./share/postgresql/timezone/EST5EDT -./share/postgresql/timezone/MET -./share/postgresql/timezone/W-SU -./share/postgresql/timezone/Mideast/Riyadh87 -./share/postgresql/timezone/Mideast/Riyadh88 -./share/postgresql/timezone/Mideast/Riyadh89 -./share/postgresql/timezone/WET -./share/postgresql/timezone/ROC -./share/postgresql/timezone/Factory -./share/postgresql/timezone/EET -./share/postgresql/timezone/PST8PDT -./share/postgresql/timezone/Portugal -./share/postgresql/timezone/NZ -./share/postgresql/timezone/Brazil/West -./share/postgresql/timezone/Brazil/DeNoronha -./share/postgresql/timezone/Brazil/Acre -./share/postgresql/timezone/Brazil/East -./share/postgresql/timezone/EST -./share/postgresql/timezone/Egypt -./share/postgresql/timezone/Universal -./share/postgresql/timezone/Pacific/Enderbury -./share/postgresql/timezone/Pacific/Noumea -./share/postgresql/timezone/Pacific/Kwajalein -./share/postgresql/timezone/Pacific/Norfolk -./share/postgresql/timezone/Pacific/Nauru -./share/postgresql/timezone/Pacific/Efate -./share/postgresql/timezone/Pacific/Kosrae -./share/postgresql/timezone/Pacific/Galapagos -./share/postgresql/timezone/Pacific/Truk -./share/postgresql/timezone/Pacific/Fiji -./share/postgresql/timezone/Pacific/Auckland -./share/postgresql/timezone/Pacific/Samoa -./share/postgresql/timezone/Pacific/Port_Moresby -./share/postgresql/timezone/Pacific/Johnston -./share/postgresql/timezone/Pacific/Apia -./share/postgresql/timezone/Pacific/Tarawa -./share/postgresql/timezone/Pacific/Pitcairn -./share/postgresql/timezone/Pacific/Marquesas -./share/postgresql/timezone/Pacific/Chatham -./share/postgresql/timezone/Pacific/Tahiti -./share/postgresql/timezone/Pacific/Tongatapu -./share/postgresql/timezone/Pacific/Saipan -./share/postgresql/timezone/Pacific/Fakaofo -./share/postgresql/timezone/Pacific/Guam -./share/postgresql/timezone/Pacific/Niue -./share/postgresql/timezone/Pacific/Chuuk -./share/postgresql/timezone/Pacific/Easter -./share/postgresql/timezone/Pacific/Wallis -./share/postgresql/timezone/Pacific/Gambier -./share/postgresql/timezone/Pacific/Majuro -./share/postgresql/timezone/Pacific/Kiritimati -./share/postgresql/timezone/Pacific/Guadalcanal -./share/postgresql/timezone/Pacific/Funafuti -./share/postgresql/timezone/Pacific/Rarotonga -./share/postgresql/timezone/Pacific/Pago_Pago -./share/postgresql/timezone/Pacific/Midway -./share/postgresql/timezone/Pacific/Palau -./share/postgresql/timezone/Pacific/Honolulu -./share/postgresql/timezone/Pacific/Yap -./share/postgresql/timezone/Pacific/Pohnpei -./share/postgresql/timezone/Pacific/Wake -./share/postgresql/timezone/Pacific/Ponape -./share/postgresql/timezone/Iran -./share/postgresql/timezone/Etc/GMT-4 -./share/postgresql/timezone/Etc/GMT-9 -./share/postgresql/timezone/Etc/UCT -./share/postgresql/timezone/Etc/GMT-7 -./share/postgresql/timezone/Etc/Greenwich -./share/postgresql/timezone/Etc/GMT-0 -./share/postgresql/timezone/Etc/GMT-5 -./share/postgresql/timezone/Etc/GMT0 -./share/postgresql/timezone/Etc/GMT+7 -./share/postgresql/timezone/Etc/GMT-2 -./share/postgresql/timezone/Etc/GMT-10 -./share/postgresql/timezone/Etc/GMT+6 -./share/postgresql/timezone/Etc/GMT+1 -./share/postgresql/timezone/Etc/UTC -./share/postgresql/timezone/Etc/GMT-3 -./share/postgresql/timezone/Etc/GMT-1 -./share/postgresql/timezone/Etc/GMT-8 -./share/postgresql/timezone/Etc/GMT-11 -./share/postgresql/timezone/Etc/GMT+12 -./share/postgresql/timezone/Etc/GMT+10 -./share/postgresql/timezone/Etc/GMT-12 -./share/postgresql/timezone/Etc/GMT+5 -./share/postgresql/timezone/Etc/Universal -./share/postgresql/timezone/Etc/GMT-13 -./share/postgresql/timezone/Etc/GMT-6 -./share/postgresql/timezone/Etc/GMT+9 -./share/postgresql/timezone/Etc/GMT+3 -./share/postgresql/timezone/Etc/GMT-14 -./share/postgresql/timezone/Etc/GMT+4 -./share/postgresql/timezone/Etc/Zulu -./share/postgresql/timezone/Etc/GMT+2 -./share/postgresql/timezone/Etc/GMT+0 -./share/postgresql/timezone/Etc/GMT+8 -./share/postgresql/timezone/Etc/GMT+11 -./share/postgresql/timezone/Etc/GMT -./share/postgresql/timezone/Zulu -./share/postgresql/timezone/GMT+0 -./share/postgresql/timezone/Singapore -./share/postgresql/timezone/NZ-CHAT -./share/postgresql/timezone/Cuba -./share/postgresql/timezone/GB -./share/postgresql/timezone/Arctic/Longyearbyen -./share/postgresql/timezone/MST7MDT -./share/postgresql/timezone/PRC -./share/postgresql/timezone/Canada/Eastern -./share/postgresql/timezone/Canada/Yukon -./share/postgresql/timezone/Canada/Atlantic -./share/postgresql/timezone/Canada/Newfoundland -./share/postgresql/timezone/Canada/Saskatchewan -./share/postgresql/timezone/Canada/Pacific -./share/postgresql/timezone/Canada/East-Saskatchewan -./share/postgresql/timezone/Canada/Mountain -./share/postgresql/timezone/Canada/Central -./share/postgresql/timezone/CST6CDT -./share/postgresql/timezone/HST -./share/postgresql/timezone/America/Boa_Vista -./share/postgresql/timezone/America/New_York -./share/postgresql/timezone/America/Santarem -./share/postgresql/timezone/America/Boise -./share/postgresql/timezone/America/St_Lucia -./share/postgresql/timezone/America/Mendoza -./share/postgresql/timezone/America/Mexico_City -./share/postgresql/timezone/America/Chihuahua -./share/postgresql/timezone/America/Indianapolis -./share/postgresql/timezone/America/Virgin -./share/postgresql/timezone/America/Atka -./share/postgresql/timezone/America/Winnipeg -./share/postgresql/timezone/America/Hermosillo -./share/postgresql/timezone/America/Indiana/Indianapolis -./share/postgresql/timezone/America/Indiana/Tell_City -./share/postgresql/timezone/America/Indiana/Winamac -./share/postgresql/timezone/America/Indiana/Knox -./share/postgresql/timezone/America/Indiana/Vincennes -./share/postgresql/timezone/America/Indiana/Vevay -./share/postgresql/timezone/America/Indiana/Petersburg -./share/postgresql/timezone/America/Indiana/Marengo -./share/postgresql/timezone/America/Moncton -./share/postgresql/timezone/America/Campo_Grande -./share/postgresql/timezone/America/Guyana -./share/postgresql/timezone/America/Caracas -./share/postgresql/timezone/America/Maceio -./share/postgresql/timezone/America/Godthab -./share/postgresql/timezone/America/Thunder_Bay -./share/postgresql/timezone/America/Havana -./share/postgresql/timezone/America/Santiago -./share/postgresql/timezone/America/Los_Angeles -./share/postgresql/timezone/America/Buenos_Aires -./share/postgresql/timezone/America/Manaus -./share/postgresql/timezone/America/Bahia -./share/postgresql/timezone/America/North_Dakota/New_Salem -./share/postgresql/timezone/America/North_Dakota/Beulah -./share/postgresql/timezone/America/North_Dakota/Center -./share/postgresql/timezone/America/Bahia_Banderas -./share/postgresql/timezone/America/Edmonton -./share/postgresql/timezone/America/Tegucigalpa -./share/postgresql/timezone/America/Rankin_Inlet -./share/postgresql/timezone/America/Monterrey -./share/postgresql/timezone/America/Cambridge_Bay -./share/postgresql/timezone/America/Porto_Velho -./share/postgresql/timezone/America/Antigua -./share/postgresql/timezone/America/Atikokan -./share/postgresql/timezone/America/Vancouver -./share/postgresql/timezone/America/Anchorage -./share/postgresql/timezone/America/Port-au-Prince -./share/postgresql/timezone/America/Lima -./share/postgresql/timezone/America/Grenada -./share/postgresql/timezone/America/Creston -./share/postgresql/timezone/America/La_Paz -./share/postgresql/timezone/America/Panama -./share/postgresql/timezone/America/Blanc-Sablon -./share/postgresql/timezone/America/Cayenne -./share/postgresql/timezone/America/Santo_Domingo -./share/postgresql/timezone/America/Grand_Turk -./share/postgresql/timezone/America/Toronto -./share/postgresql/timezone/America/Rainy_River -./share/postgresql/timezone/America/Merida -./share/postgresql/timezone/America/Port_of_Spain -./share/postgresql/timezone/America/Nipigon -./share/postgresql/timezone/America/Jamaica -./share/postgresql/timezone/America/Rosario -./share/postgresql/timezone/America/Dawson_Creek -./share/postgresql/timezone/America/Belize -./share/postgresql/timezone/America/Costa_Rica -./share/postgresql/timezone/America/Barbados -./share/postgresql/timezone/America/Danmarkshavn -./share/postgresql/timezone/America/Argentina/La_Rioja -./share/postgresql/timezone/America/Argentina/Mendoza -./share/postgresql/timezone/America/Argentina/Buenos_Aires -./share/postgresql/timezone/America/Argentina/Tucuman -./share/postgresql/timezone/America/Argentina/Ushuaia -./share/postgresql/timezone/America/Argentina/Catamarca -./share/postgresql/timezone/America/Argentina/ComodRivadavia -./share/postgresql/timezone/America/Argentina/Jujuy -./share/postgresql/timezone/America/Argentina/Cordoba -./share/postgresql/timezone/America/Argentina/San_Luis -./share/postgresql/timezone/America/Argentina/Rio_Gallegos -./share/postgresql/timezone/America/Argentina/Salta -./share/postgresql/timezone/America/Argentina/San_Juan -./share/postgresql/timezone/America/Pangnirtung -./share/postgresql/timezone/America/Anguilla -./share/postgresql/timezone/America/Curacao -./share/postgresql/timezone/America/Cancun -./share/postgresql/timezone/America/Montreal -./share/postgresql/timezone/America/Shiprock -./share/postgresql/timezone/America/Thule -./share/postgresql/timezone/America/Scoresbysund -./share/postgresql/timezone/America/Catamarca -./share/postgresql/timezone/America/Sao_Paulo -./share/postgresql/timezone/America/Sitka -./share/postgresql/timezone/America/Asuncion -./share/postgresql/timezone/America/Regina -./share/postgresql/timezone/America/St_Johns -./share/postgresql/timezone/America/Montevideo -./share/postgresql/timezone/America/Eirunepe -./share/postgresql/timezone/America/Denver -./share/postgresql/timezone/America/Metlakatla -./share/postgresql/timezone/America/Araguaina -./share/postgresql/timezone/America/Juneau -./share/postgresql/timezone/America/Marigot -./share/postgresql/timezone/America/Menominee -./share/postgresql/timezone/America/Glace_Bay -./share/postgresql/timezone/America/Tijuana -./share/postgresql/timezone/America/Detroit -./share/postgresql/timezone/America/Belem -./share/postgresql/timezone/America/Jujuy -./share/postgresql/timezone/America/St_Thomas -./share/postgresql/timezone/America/Resolute -./share/postgresql/timezone/America/Cuiaba -./share/postgresql/timezone/America/Halifax -./share/postgresql/timezone/America/St_Barthelemy -./share/postgresql/timezone/America/Guatemala -./share/postgresql/timezone/America/Nassau -./share/postgresql/timezone/America/St_Kitts -./share/postgresql/timezone/America/Cordoba -./share/postgresql/timezone/America/Miquelon -./share/postgresql/timezone/America/Bogota -./share/postgresql/timezone/America/Rio_Branco -./share/postgresql/timezone/America/Ensenada -./share/postgresql/timezone/America/Yakutat -./share/postgresql/timezone/America/Noronha -./share/postgresql/timezone/America/Kentucky/Monticello -./share/postgresql/timezone/America/Kentucky/Louisville -./share/postgresql/timezone/America/Porto_Acre -./share/postgresql/timezone/America/Santa_Isabel -./share/postgresql/timezone/America/El_Salvador -./share/postgresql/timezone/America/Yellowknife -./share/postgresql/timezone/America/Cayman -./share/postgresql/timezone/America/Whitehorse -./share/postgresql/timezone/America/Ojinaga -./share/postgresql/timezone/America/Aruba -./share/postgresql/timezone/America/Nome -./share/postgresql/timezone/America/Fortaleza -./share/postgresql/timezone/America/Martinique -./share/postgresql/timezone/America/Recife -./share/postgresql/timezone/America/Knox_IN -./share/postgresql/timezone/America/Guayaquil -./share/postgresql/timezone/America/Goose_Bay -./share/postgresql/timezone/America/Iqaluit -./share/postgresql/timezone/America/Matamoros -./share/postgresql/timezone/America/Lower_Princes -./share/postgresql/timezone/America/Louisville -./share/postgresql/timezone/America/Coral_Harbour -./share/postgresql/timezone/America/Phoenix -./share/postgresql/timezone/America/Guadeloupe -./share/postgresql/timezone/America/Mazatlan -./share/postgresql/timezone/America/Swift_Current -./share/postgresql/timezone/America/Paramaribo -./share/postgresql/timezone/America/Dominica -./share/postgresql/timezone/America/Kralendijk -./share/postgresql/timezone/America/Montserrat -./share/postgresql/timezone/America/St_Vincent -./share/postgresql/timezone/America/Fort_Wayne -./share/postgresql/timezone/America/Dawson -./share/postgresql/timezone/America/Inuvik -./share/postgresql/timezone/America/Adak -./share/postgresql/timezone/America/Managua -./share/postgresql/timezone/America/Puerto_Rico -./share/postgresql/timezone/America/Tortola -./share/postgresql/timezone/America/Chicago -./share/postgresql/timezone/Africa/Lome -./share/postgresql/timezone/Africa/Brazzaville -./share/postgresql/timezone/Africa/Khartoum -./share/postgresql/timezone/Africa/Ceuta -./share/postgresql/timezone/Africa/Djibouti -./share/postgresql/timezone/Africa/Lagos -./share/postgresql/timezone/Africa/Accra -./share/postgresql/timezone/Africa/El_Aaiun -./share/postgresql/timezone/Africa/Malabo -./share/postgresql/timezone/Africa/Windhoek -./share/postgresql/timezone/Africa/Tripoli -./share/postgresql/timezone/Africa/Bissau -./share/postgresql/timezone/Africa/Blantyre -./share/postgresql/timezone/Africa/Kinshasa -./share/postgresql/timezone/Africa/Porto-Novo -./share/postgresql/timezone/Africa/Nairobi -./share/postgresql/timezone/Africa/Ouagadougou -./share/postgresql/timezone/Africa/Asmera -./share/postgresql/timezone/Africa/Cairo -./share/postgresql/timezone/Africa/Lubumbashi -./share/postgresql/timezone/Africa/Tunis -./share/postgresql/timezone/Africa/Dar_es_Salaam -./share/postgresql/timezone/Africa/Casablanca -./share/postgresql/timezone/Africa/Algiers -./share/postgresql/timezone/Africa/Mbabane -./share/postgresql/timezone/Africa/Monrovia -./share/postgresql/timezone/Africa/Nouakchott -./share/postgresql/timezone/Africa/Banjul -./share/postgresql/timezone/Africa/Kampala -./share/postgresql/timezone/Africa/Conakry -./share/postgresql/timezone/Africa/Mogadishu -./share/postgresql/timezone/Africa/Ndjamena -./share/postgresql/timezone/Africa/Niamey -./share/postgresql/timezone/Africa/Lusaka -./share/postgresql/timezone/Africa/Addis_Ababa -./share/postgresql/timezone/Africa/Sao_Tome -./share/postgresql/timezone/Africa/Abidjan -./share/postgresql/timezone/Africa/Harare -./share/postgresql/timezone/Africa/Asmara -./share/postgresql/timezone/Africa/Douala -./share/postgresql/timezone/Africa/Freetown -./share/postgresql/timezone/Africa/Libreville -./share/postgresql/timezone/Africa/Luanda -./share/postgresql/timezone/Africa/Maseru -./share/postgresql/timezone/Africa/Gaborone -./share/postgresql/timezone/Africa/Maputo -./share/postgresql/timezone/Africa/Timbuktu -./share/postgresql/timezone/Africa/Bangui -./share/postgresql/timezone/Africa/Bamako -./share/postgresql/timezone/Africa/Dakar -./share/postgresql/timezone/Africa/Juba -./share/postgresql/timezone/Africa/Bujumbura -./share/postgresql/timezone/Africa/Johannesburg -./share/postgresql/timezone/Africa/Kigali -./share/postgresql/timezone/Eire -./share/postgresql/timezone/Europe/Vaduz -./share/postgresql/timezone/Europe/Podgorica -./share/postgresql/timezone/Europe/Rome -./share/postgresql/timezone/Europe/Vienna -./share/postgresql/timezone/Europe/Dublin -./share/postgresql/timezone/Europe/Zurich -./share/postgresql/timezone/Europe/London -./share/postgresql/timezone/Europe/Monaco -./share/postgresql/timezone/Europe/Sofia -./share/postgresql/timezone/Europe/Uzhgorod -./share/postgresql/timezone/Europe/Minsk -./share/postgresql/timezone/Europe/Malta -./share/postgresql/timezone/Europe/Busingen -./share/postgresql/timezone/Europe/Gibraltar -./share/postgresql/timezone/Europe/Volgograd -./share/postgresql/timezone/Europe/Budapest -./share/postgresql/timezone/Europe/Vatican -./share/postgresql/timezone/Europe/Luxembourg -./share/postgresql/timezone/Europe/Chisinau -./share/postgresql/timezone/Europe/Nicosia -./share/postgresql/timezone/Europe/Warsaw -./share/postgresql/timezone/Europe/San_Marino -./share/postgresql/timezone/Europe/Copenhagen -./share/postgresql/timezone/Europe/Ljubljana -./share/postgresql/timezone/Europe/Athens -./share/postgresql/timezone/Europe/Skopje -./share/postgresql/timezone/Europe/Andorra -./share/postgresql/timezone/Europe/Kaliningrad -./share/postgresql/timezone/Europe/Amsterdam -./share/postgresql/timezone/Europe/Guernsey -./share/postgresql/timezone/Europe/Isle_of_Man -./share/postgresql/timezone/Europe/Tirane -./share/postgresql/timezone/Europe/Jersey -./share/postgresql/timezone/Europe/Madrid -./share/postgresql/timezone/Europe/Helsinki -./share/postgresql/timezone/Europe/Riga -./share/postgresql/timezone/Europe/Zagreb -./share/postgresql/timezone/Europe/Bratislava -./share/postgresql/timezone/Europe/Prague -./share/postgresql/timezone/Europe/Tallinn -./share/postgresql/timezone/Europe/Stockholm -./share/postgresql/timezone/Europe/Tiraspol -./share/postgresql/timezone/Europe/Belgrade -./share/postgresql/timezone/Europe/Bucharest -./share/postgresql/timezone/Europe/Vilnius -./share/postgresql/timezone/Europe/Sarajevo -./share/postgresql/timezone/Europe/Belfast -./share/postgresql/timezone/Europe/Zaporozhye -./share/postgresql/timezone/Europe/Oslo -./share/postgresql/timezone/Europe/Mariehamn -./share/postgresql/timezone/Europe/Moscow -./share/postgresql/timezone/Europe/Brussels -./share/postgresql/timezone/Europe/Paris -./share/postgresql/timezone/Europe/Istanbul -./share/postgresql/timezone/Europe/Simferopol -./share/postgresql/timezone/Europe/Lisbon -./share/postgresql/timezone/Europe/Berlin -./share/postgresql/timezone/Europe/Kiev -./share/postgresql/timezone/Europe/Samara -./share/postgresql/timezone/MST -./share/postgresql/timezone/Asia/Khandyga -./share/postgresql/timezone/Asia/Manila -./share/postgresql/timezone/Asia/Novokuznetsk -./share/postgresql/timezone/Asia/Baghdad -./share/postgresql/timezone/Asia/Macau -./share/postgresql/timezone/Asia/Urumqi -./share/postgresql/timezone/Asia/Ujung_Pandang -./share/postgresql/timezone/Asia/Ulan_Bator -./share/postgresql/timezone/Asia/Bishkek -./share/postgresql/timezone/Asia/Qatar -./share/postgresql/timezone/Asia/Qyzylorda -./share/postgresql/timezone/Asia/Calcutta -./share/postgresql/timezone/Asia/Riyadh87 -./share/postgresql/timezone/Asia/Dushanbe -./share/postgresql/timezone/Asia/Yekaterinburg -./share/postgresql/timezone/Asia/Dhaka -./share/postgresql/timezone/Asia/Jakarta -./share/postgresql/timezone/Asia/Shanghai -./share/postgresql/timezone/Asia/Ulaanbaatar -./share/postgresql/timezone/Asia/Jerusalem -./share/postgresql/timezone/Asia/Ashkhabad -./share/postgresql/timezone/Asia/Tokyo -./share/postgresql/timezone/Asia/Macao -./share/postgresql/timezone/Asia/Krasnoyarsk -./share/postgresql/timezone/Asia/Saigon -./share/postgresql/timezone/Asia/Omsk -./share/postgresql/timezone/Asia/Damascus -./share/postgresql/timezone/Asia/Phnom_Penh -./share/postgresql/timezone/Asia/Bangkok -./share/postgresql/timezone/Asia/Kamchatka -./share/postgresql/timezone/Asia/Choibalsan -./share/postgresql/timezone/Asia/Ust-Nera -./share/postgresql/timezone/Asia/Aden -./share/postgresql/timezone/Asia/Vientiane -./share/postgresql/timezone/Asia/Sakhalin -./share/postgresql/timezone/Asia/Ashgabat -./share/postgresql/timezone/Asia/Katmandu -./share/postgresql/timezone/Asia/Almaty -./share/postgresql/timezone/Asia/Baku -./share/postgresql/timezone/Asia/Nicosia -./share/postgresql/timezone/Asia/Riyadh88 -./share/postgresql/timezone/Asia/Kashgar -./share/postgresql/timezone/Asia/Riyadh89 -./share/postgresql/timezone/Asia/Taipei -./share/postgresql/timezone/Asia/Tehran -./share/postgresql/timezone/Asia/Kabul -./share/postgresql/timezone/Asia/Samarkand -./share/postgresql/timezone/Asia/Kuala_Lumpur -./share/postgresql/timezone/Asia/Tashkent -./share/postgresql/timezone/Asia/Thimbu -./share/postgresql/timezone/Asia/Thimphu -./share/postgresql/timezone/Asia/Yerevan -./share/postgresql/timezone/Asia/Chungking -./share/postgresql/timezone/Asia/Hebron -./share/postgresql/timezone/Asia/Karachi -./share/postgresql/timezone/Asia/Kolkata -./share/postgresql/timezone/Asia/Aqtobe -./share/postgresql/timezone/Asia/Muscat -./share/postgresql/timezone/Asia/Hong_Kong -./share/postgresql/timezone/Asia/Chongqing -./share/postgresql/timezone/Asia/Oral -./share/postgresql/timezone/Asia/Pontianak -./share/postgresql/timezone/Asia/Colombo -./share/postgresql/timezone/Asia/Pyongyang -./share/postgresql/timezone/Asia/Hovd -./share/postgresql/timezone/Asia/Kuwait -./share/postgresql/timezone/Asia/Anadyr -./share/postgresql/timezone/Asia/Kathmandu -./share/postgresql/timezone/Asia/Irkutsk -./share/postgresql/timezone/Asia/Bahrain -./share/postgresql/timezone/Asia/Dubai -./share/postgresql/timezone/Asia/Jayapura -./share/postgresql/timezone/Asia/Riyadh -./share/postgresql/timezone/Asia/Ho_Chi_Minh -./share/postgresql/timezone/Asia/Singapore -./share/postgresql/timezone/Asia/Tel_Aviv -./share/postgresql/timezone/Asia/Dili -./share/postgresql/timezone/Asia/Rangoon -./share/postgresql/timezone/Asia/Harbin -./share/postgresql/timezone/Asia/Yakutsk -./share/postgresql/timezone/Asia/Magadan -./share/postgresql/timezone/Asia/Amman -./share/postgresql/timezone/Asia/Kuching -./share/postgresql/timezone/Asia/Novosibirsk -./share/postgresql/timezone/Asia/Seoul -./share/postgresql/timezone/Asia/Dacca -./share/postgresql/timezone/Asia/Vladivostok -./share/postgresql/timezone/Asia/Istanbul -./share/postgresql/timezone/Asia/Beirut -./share/postgresql/timezone/Asia/Aqtau -./share/postgresql/timezone/Asia/Brunei -./share/postgresql/timezone/Asia/Gaza -./share/postgresql/timezone/Asia/Tbilisi -./share/postgresql/timezone/Asia/Makassar -./share/postgresql/timezone/Asia/Beijing -./share/postgresql/timezone/Navajo -./share/postgresql/timezone/GMT -./share/postgresql/gtm.conf.sample -./share/postgresql/system_views.sql -./share/postgresql/performance_views.sql -./share/postgresql/sql_features.txt -./share/postgresql/pg_cast_oid.txt -./share/postgresql/recovery.conf.sample -./share/postgresql/cm_server.conf.sample -./share/postgresql/tsearch_data/english.stop -./share/postgresql/tsearch_data/dutch.stop -./share/postgresql/tsearch_data/hungarian.stop -./share/postgresql/tsearch_data/french.stop -./share/postgresql/tsearch_data/synonym_sample.syn -./share/postgresql/tsearch_data/turkish.stop -./share/postgresql/tsearch_data/portuguese.stop -./share/postgresql/tsearch_data/spanish.stop -./share/postgresql/tsearch_data/hunspell_sample.affix -./share/postgresql/tsearch_data/ispell_sample.affix -./share/postgresql/tsearch_data/danish.stop -./share/postgresql/tsearch_data/german.stop -./share/postgresql/tsearch_data/thesaurus_sample.ths -./share/postgresql/tsearch_data/norwegian.stop -./share/postgresql/tsearch_data/finnish.stop -./share/postgresql/tsearch_data/russian.stop -./share/postgresql/tsearch_data/swedish.stop -./share/postgresql/tsearch_data/ispell_sample.dict -./share/postgresql/tsearch_data/italian.stop -./share/postgresql/cm_agent.conf.sample -./share/postgresql/information_schema.sql -./share/postgresql/timezonesets/Antarctica.txt -./share/postgresql/timezonesets/Australia.txt -./share/postgresql/timezonesets/Europe.txt -./share/postgresql/timezonesets/America.txt -./share/postgresql/timezonesets/Australia -./share/postgresql/timezonesets/Indian.txt -./share/postgresql/timezonesets/India -./share/postgresql/timezonesets/Pacific.txt -./share/postgresql/timezonesets/Atlantic.txt -./share/postgresql/timezonesets/Africa.txt -./share/postgresql/timezonesets/Asia.txt -./share/postgresql/timezonesets/Default -./share/postgresql/timezonesets/Etc.txt -./share/postgresql/postgres.bki -./share/llvmir/GaussDB_expr.ir -./share/sslcert/gsql/openssl.cnf -./share/sslcert/gds/openssl.cnf -./share/sslcert/etcd/openssl.cnf -./share/sslcert/grpc/openssl.cnf -./lib/libsimsearch/ -./lib/postgresql/latin2_and_win1250.so -./lib/postgresql/euc2004_sjis2004.so -./lib/postgresql/euc_kr_and_mic.so -./lib/postgresql/utf8_and_uhc.so -./lib/postgresql/euc_tw_and_big5.so -./lib/postgresql/cyrillic_and_mic.so -./lib/postgresql/utf8_and_johab.so -./lib/postgresql/utf8_and_gb18030.so -./lib/postgresql/pgxs/src/makefiles/pgxs.mk -./lib/postgresql/pgxs/src/Makefile.shlib -./lib/postgresql/pgxs/src/Makefile.port -./lib/postgresql/pgxs/src/nls-global.mk -./lib/postgresql/pgxs/src/Makefile.global -./lib/postgresql/pgxs/config/install-sh -./lib/postgresql/euc_cn_and_mic.so -./lib/postgresql/latin_and_mic.so -./lib/postgresql/utf8_and_sjis2004.so -./lib/postgresql/utf8_and_euc_jp.so -./lib/postgresql/utf8_and_sjis.so -./lib/postgresql/utf8_and_cyrillic.so -./lib/postgresql/hstore.so -./lib/postgresql/tsdb.so -./lib/postgresql/streaming.so -./lib/postgresql/packages.so -./lib/postgresql/utf8_and_euc_kr.so -./lib/postgresql/ascii_and_mic.so -./lib/postgresql/utf8_and_iso8859_1.so -./lib/postgresql/euc_jp_and_sjis.so -./lib/postgresql/dict_snowball.so -./lib/postgresql/utf8_and_ascii.so -./lib/postgresql/utf8_and_euc_tw.so -./lib/postgresql/utf8_and_iso8859.so -./lib/postgresql/utf8_and_win.so -./lib/postgresql/utf8_and_euc_cn.so -./lib/postgresql/utf8_and_gbk.so -./lib/postgresql/utf8_and_euc2004.so -./lib/postgresql/utf8_and_big5.so -./lib/postgresql/roach_api.so -./lib/postgresql/mppdb_decoding.so -./lib/postgresql/gsredistribute.so -./lib/postgresql/dimsearch.so -./lib/postgresql/pg_plugin -./lib/postgresql/proc_srclib -./lib/postgresql/security_plugin.so -./lib/postgresql/pg_upgrade_support.so -./lib/postgresql/java/pljava.jar -./lib/postgresql/gsredistribute.so -./lib/libpljava.so -./lib/libpq.a -./lib/libpq.so -./lib/libpq.so.5 -./lib/libpq.so.5.5 -./lib/libpq_ce.so -./lib/libpq_ce.so.5 -./lib/libpq_ce.so.5.5 -./lib/libcgroup.so -./lib/libcgroup.so.1 -./lib/libcom_err_gauss.so -./lib/libcom_err_gauss.so.3 -./lib/libcom_err_gauss.so.3.0 -./lib/libgpr.so -./lib/libgpr.so.9 -./lib/libgpr.so.9.0.0 -./lib/libgrpc.so -./lib/libgrpc++.so -./lib/libgrpc++.so.1 -./lib/libgrpc++.so.1.28.1 -./lib/libgrpc.so.9 -./lib/libgrpc.so.9.0.0 -./lib/libupb.so -./lib/libupb.so.9 -./lib/libupb.so.9.0.0 -./lib/libabsl_str_format_internal.so -./lib/libabsl_strings.so -./lib/libabsl_throw_delegate.so -./lib/libabsl_strings_internal.so -./lib/libabsl_base.so -./lib/libabsl_dynamic_annotations.so -./lib/libabsl_spinlock_wait.so -./lib/libabsl_int128.so -./lib/libabsl_bad_optional_access.so -./lib/libabsl_raw_logging_internal.so -./lib/libabsl_log_severity.so -./lib/libaddress_sorting.so -./lib/libaddress_sorting.so.9 -./lib/libgssapi_krb5_gauss.so -./lib/libgssapi_krb5_gauss.so.2 -./lib/libgssapi_krb5_gauss.so.2.2 -./lib/libgssrpc_gauss.so -./lib/libgssrpc_gauss.so.4 -./lib/libgssrpc_gauss.so.4.2 -./lib/libk5crypto_gauss.so -./lib/libk5crypto_gauss.so.3 -./lib/libk5crypto_gauss.so.3.1 -./lib/libkadm5clnt.so -./lib/libkadm5clnt_mit.so -./lib/libkadm5clnt_mit.so.11 -./lib/libkadm5clnt_mit.so.11.0 -./lib/libkadm5srv.so -./lib/libkadm5srv_mit.so -./lib/libkadm5srv_mit.so.11 -./lib/libkadm5srv_mit.so.11.0 -./lib/libkdb5.so -./lib/libkdb5.so.9 -./lib/libkdb5.so.9.0 -./lib/libkrad.so -./lib/libkrad.so.0 -./lib/libkrad.so.0.0 -./lib/libkrb5_gauss.so -./lib/libkrb5_gauss.so.3 -./lib/libkrb5_gauss.so.3.3 -./lib/libkrb5support_gauss.so -./lib/libkrb5support_gauss.so.0 -./lib/libkrb5support_gauss.so.0.1 -./lib/krb5/plugins/kdb/db2.so -./lib/libverto.so -./lib/libverto.so.0 -./lib/libverto.so.0.0 -./lib/libcurl.so -./lib/libcurl.so.4 -./lib/libcurl.so.4.6.0 -./lib/libcrypto.so -./lib/libcrypto.so.1.1 -./lib/libssl.so -./lib/libssl.so.1.1 -./lib/libgcc_s.so.1 -./lib/libtsan.so -./lib/libtsan.so.0 -./lib/libtsan.so.0.0.0 -./lib/libstdc++.so.6 -./lib/libz.so -./lib/libz.so.1 -./lib/libz.so.1.2.11 -./lib/liblz4.so -./lib/liblz4.so.1 -./lib/liblz4.so.1.9.2 -./lib/libcjson.so -./lib/libcjson.so.1 -./lib/libcjson.so.1.7.13 -./lib/libconfig.so -./lib/libconfig.so.4 -./lib/libcmclient.so -./lib/libcmclient.so.1 -./lib/libcmcommon.so -./lib/libcmcommon.so.2 -./lib/libcmpq.so -./lib/libcmpq.so.1 -./lib/libetcdapi.so -./lib/libetcdapi.so.1 -./lib/libpgport_tool.so -./lib/libpgport_tool.so.1 -./lib/lib_roach_show.so -./lib/roach_contrib.so -./share/llvmir/GaussDB_expr.ir -./lib/libeSDKLogAPI.so -./lib/libeSDKOBS.so -./lib/liblog4cpp.so -./lib/liblog4cpp.so.5 -./lib/liblog4cpp.so.5.0.6 -./lib/libcharset.so -./lib/libcharset.so.1 -./lib/libcharset.so.1.0.0 -./lib/libiconv.so -./lib/libiconv.so.2 -./lib/libiconv.so.2.6.1 -./lib/libnghttp2.so -./lib/libnghttp2.so.14 -./lib/libnghttp2.so.14.20.0 -./lib/libpcre.so -./lib/libpcre.so.1 -./lib/libpcre.so.1.2.12 -./lib/libsecurec.so -./lib/libxml2.so -./lib/libxml2.so.2 -./lib/libxml2.so.2.9.9 -./lib/libparquet.so -./lib/libparquet.so.11 -./lib/libparquet.so.11.1.0 -./lib/OBS.ini -./lib/postgresql/latin2_and_win1250.so -./lib/postgresql/euc2004_sjis2004.so -./lib/libhll.so -./lib/libnuma.so -./lib/libnuma.so.1 -./lib/libnuma.so.1.0.0 -./lib/libiperf.so.0 -./include/postgresql/server/postgres_ext.h -./include/postgresql/server/pg_config_os.h -./include/postgresql/server/pgtime.h -./include/postgresql/server/datatypes.h -./include/postgresql/server/client_logic/client_logic_enums.h -./include/postgresql/server/nodes/primnodes.h -./include/postgresql/server/nodes/parsenodes.h -./include/postgresql/server/nodes/parsenodes_common.h -./include/postgresql/server/nodes/bitmapset.h -./include/postgresql/server/nodes/pg_list.h -./include/postgresql/server/nodes/value.h -./include/postgresql/server/nodes/nodes.h -./include/postgresql/server/utils/sortsupport.h -./include/postgresql/server/utils/varbit.h -./include/postgresql/server/utils/spccache.h -./include/postgresql/server/utils/rangetypes.h -./include/postgresql/server/utils/plpgsql.h -./include/postgresql/server/utils/memtrack.h -./include/postgresql/server/utils/pg_locale.h -./include/postgresql/server/utils/tzparser.h -./include/postgresql/server/utils/syscall_lock.h -./include/postgresql/server/utils/partitionmap.h -./include/postgresql/server/utils/array.h -./include/postgresql/server/utils/relmapper.h -./include/postgresql/server/utils/hsearch.h -./include/postgresql/server/utils/xml.h -./include/postgresql/server/utils/bytea.h -./include/postgresql/server/utils/relcache.h -./include/postgresql/server/utils/pg_rusage.h -./include/postgresql/server/utils/numeric.h -./include/postgresql/server/utils/mmpool.h -./include/postgresql/server/utils/nabstime.h -./include/postgresql/server/utils/fmgrtab.h -./include/postgresql/server/utils/snapmgr.h -./include/postgresql/server/utils/syscache.h -./include/postgresql/server/utils/logtape.h -./include/postgresql/server/utils/datum.h -./include/postgresql/server/utils/guc_tables.h -./include/postgresql/server/utils/snapshot.h -./include/postgresql/server/utils/geo_decls.h -./include/postgresql/server/utils/errcodes.h -./include/postgresql/server/utils/inval.h -./include/postgresql/server/utils/help_config.h -./include/postgresql/server/utils/distribute_test.h -./include/postgresql/server/utils/aiomem.h -./include/postgresql/server/utils/tuplestore.h -./include/postgresql/server/utils/rbtree.h -./include/postgresql/server/utils/gs_bitmap.h -./include/postgresql/server/utils/tuplesort.h -./include/postgresql/server/utils/tqual.h -./include/postgresql/server/utils/ps_status.h -./include/postgresql/server/utils/palloc.h -./include/postgresql/server/utils/reltrigger.h -./include/postgresql/server/utils/acl.h -./include/postgresql/server/utils/ascii.h -./include/postgresql/server/utils/selfuncs.h -./include/postgresql/server/utils/json.h -./include/postgresql/server/utils/portal.h -./include/postgresql/server/utils/atomic.h -./include/postgresql/server/utils/elog.h -./include/postgresql/server/utils/date.h -./include/postgresql/server/utils/plancache.h -./include/postgresql/server/utils/int8.h -./include/postgresql/server/utils/timestamp.h -./include/postgresql/server/utils/bloom_filter.h -./include/postgresql/server/utils/fmgroids.h -./include/postgresql/server/utils/pg_crc_tables.h -./include/postgresql/server/utils/probes.h -./include/postgresql/server/utils/datetime.h -./include/postgresql/server/utils/inet.h -./include/postgresql/server/utils/pg_lzcompress.h -./include/postgresql/server/utils/pg_crc.h -./include/postgresql/server/utils/attoptcache.h -./include/postgresql/server/utils/dynahash.h -./include/postgresql/server/utils/rel.h -./include/postgresql/server/utils/partcache.h -./include/postgresql/server/utils/lsyscache.h -./include/postgresql/server/utils/memutils.h -./include/postgresql/server/utils/memprot.h -./include/postgresql/server/utils/uuid.h -./include/postgresql/server/utils/combocid.h -./include/postgresql/server/utils/builtins.h -./include/postgresql/server/utils/guc.h -./include/postgresql/server/utils/dfs_vector.h -./include/postgresql/server/utils/dynamic_loader.h -./include/postgresql/server/utils/resowner.h -./include/postgresql/server/utils/aes.h -./include/postgresql/server/utils/cash.h -./include/postgresql/server/utils/typcache.h -./include/postgresql/server/utils/formatting.h -./include/postgresql/server/utils/partitionkey.h -./include/postgresql/server/utils/aset.h -./include/postgresql/server/utils/catcache.h -./include/postgresql/server/utils/atomic_arm.h -./include/postgresql/server/datatype/timestamp.h -./include/postgresql/server/access/rmgr.h -./include/postgresql/server/access/xlogreader.h -./include/postgresql/server/access/xlog_basic.h -./include/postgresql/server/access/tupdesc.h -./include/postgresql/server/access/rmgrlist.h -./include/postgresql/server/access/htup.h -./include/postgresql/server/access/xlogdefs.h -./include/postgresql/server/access/attnum.h -./include/postgresql/server/access/tupmacs.h -./include/postgresql/server/access/xlogrecord.h -./include/postgresql/server/tcop/dest.h -./include/postgresql/server/catalog/pg_type.h -./include/postgresql/server/catalog/pg_attribute.h -./include/postgresql/server/catalog/genbki.h -./include/postgresql/server/gs_thread.h -./include/postgresql/server/port/pg_bswap.h -./include/postgresql/server/port/pg_crc32c.h -./include/postgresql/server/securec.h -./include/postgresql/server/securectype.h -./include/postgresql/server/storage/off.h -./include/postgresql/server/storage/buf/block.h -./include/postgresql/server/storage/item/item.h -./include/postgresql/server/storage/relfilenode.h -./include/postgresql/server/storage/buf/bufpage.h -./include/postgresql/server/storage/spin.h -./include/postgresql/server/storage/buf/buf.h -./include/postgresql/server/storage/item/itemid.h -./include/postgresql/server/storage/lock/pg_sema.h -./include/postgresql/server/storage/item/itemptr.h -./include/postgresql/server/storage/lock/s_lock.h -./include/postgresql/server/storage/backendid.h -./include/postgresql/server/storage/lock/lock.h -./include/postgresql/server/storage/lock/lwlock.h -./include/postgresql/server/storage/barrier.h -./include/postgresql/server/storage/shmem.h -./include/postgresql/server/pg_config.h -./include/postgresql/server/lib/stringinfo.h -./include/postgresql/server/fmgr.h -./include/postgresql/server/fmgr/fmgr_comp.h -./include/postgresql/server/fmgr/fmgr_core.h -./include/postgresql/server/gs_threadlocal.h -./include/postgresql/server/postgres.h -./include/postgresql/server/executor/tuptable.h -./include/postgresql/server/pg_config_manual.h -./include/postgresql/server/mb/pg_wchar.h -./include/postgresql/server/c.h -./include/postgresql/server/port.h -./include/postgresql/server/utils/be_module.h -./include/postgresql/server/nodes/params.h -./include/postgresql/server/securec_check.h -./include/postgresql/server/nodes/memnodes.h -./include/postgresql/server/access/skey.h -./include/postgresql/server/lib/dllist.h -./include/postgresql/server/lib/ilist.h -./include/postgresql/server/pgxc/locator.h -./include/postgresql/server/gstrace/gstrace_infra.h -./include/postgresql/server/extension_dependency.h -./jre/ASSEMBLY_EXCEPTION -./jre/bin/java -./jre/bin/jjs -./jre/bin/keytool -./jre/bin/orbd -./jre/bin/pack200 -./jre/bin/policytool -./jre/bin/rmid -./jre/bin/rmiregistry -./jre/bin/servertool -./jre/bin/tnameserv -./jre/bin/unpack200 -./jre/lib/aarch64/jli/libjli.so -./jre/lib/aarch64/jvm.cfg -./jre/lib/aarch64/libattach.so -./jre/lib/aarch64/libavplugin-ffmpeg-58.so -./jre/lib/aarch64/libawt_headless.so -./jre/lib/aarch64/libawt.so -./jre/lib/aarch64/libawt_xawt.so -./jre/lib/aarch64/libdecora_sse.so -./jre/lib/aarch64/libdt_socket.so -./jre/lib/aarch64/libfontmanager.so -./jre/lib/aarch64/libfxplugins.so -./jre/lib/aarch64/libglassgtk2.so -./jre/lib/aarch64/libglassgtk3.so -./jre/lib/aarch64/libglass.so -./jre/lib/aarch64/libgstreamer-lite.so -./jre/lib/aarch64/libhprof.so -./jre/lib/aarch64/libinstrument.so -./jre/lib/aarch64/libj2gss.so -./jre/lib/aarch64/libj2pcsc.so -./jre/lib/aarch64/libj2pkcs11.so -./jre/lib/aarch64/libjaas_unix.so -./jre/lib/aarch64/libjava_crw_demo.so -./jre/lib/aarch64/libjavafx_font_freetype.so -./jre/lib/aarch64/libjavafx_font_pango.so -./jre/lib/aarch64/libjavafx_font.so -./jre/lib/aarch64/libjavafx_iio.so -./jre/lib/aarch64/libjava.so -./jre/lib/aarch64/libjawt.so -./jre/lib/aarch64/libjdwp.so -./jre/lib/aarch64/libjfxmedia.so -./jre/lib/aarch64/libjfxwebkit.so -./jre/lib/aarch64/libjpeg.so -./jre/lib/aarch64/libjsdt.so -./jre/lib/aarch64/libjsig.so -./jre/lib/aarch64/libjsoundalsa.so -./jre/lib/aarch64/libjsound.so -./jre/lib/aarch64/liblcms.so -./jre/lib/aarch64/libmanagement.so -./jre/lib/aarch64/libmlib_image.so -./jre/lib/aarch64/libnet.so -./jre/lib/aarch64/libnio.so -./jre/lib/aarch64/libnpt.so -./jre/lib/aarch64/libprism_common.so -./jre/lib/aarch64/libprism_es2.so -./jre/lib/aarch64/libprism_sw.so -./jre/lib/aarch64/libsaproc.so -./jre/lib/aarch64/libsctp.so -./jre/lib/aarch64/libsplashscreen.so -./jre/lib/aarch64/libsunec.so -./jre/lib/aarch64/libunpack.so -./jre/lib/aarch64/libverify.so -./jre/lib/aarch64/libzip.so -./jre/lib/aarch64/server/libjvm.so -./jre/lib/aarch64/server/Xusage.txt -./jre/lib/calendars.properties -./jre/lib/charsets.jar -./jre/lib/classlist -./jre/lib/cmm/CIEXYZ.pf -./jre/lib/cmm/GRAY.pf -./jre/lib/cmm/LINEAR_RGB.pf -./jre/lib/cmm/PYCC.pf -./jre/lib/cmm/sRGB.pf -./jre/lib/content-types.properties -./jre/lib/currency.data -./jre/lib/ext/cldrdata.jar -./jre/lib/ext/dnsns.jar -./jre/lib/ext/jaccess.jar -./jre/lib/ext/jfxrt.jar -./jre/lib/ext/localedata.jar -./jre/lib/ext/meta-index -./jre/lib/ext/nashorn.jar -./jre/lib/ext/sunec.jar -./jre/lib/ext/sunjce_provider.jar -./jre/lib/ext/sunpkcs11.jar -./jre/lib/ext/zipfs.jar -./jre/lib/flavormap.properties -./jre/lib/fontconfig.Euler.properties -./jre/lib/fontconfig.properties -./jre/lib/fontconfig.Ubuntu.properties -./jre/lib/fonts/Roboto-Regular.ttf -./jre/lib/hijrah-config-umalqura.properties -./jre/lib/images/cursors/cursors.properties -./jre/lib/images/cursors/invalid32x32.gif -./jre/lib/images/cursors/motif_CopyDrop32x32.gif -./jre/lib/images/cursors/motif_CopyNoDrop32x32.gif -./jre/lib/images/cursors/motif_LinkDrop32x32.gif -./jre/lib/images/cursors/motif_LinkNoDrop32x32.gif -./jre/lib/images/cursors/motif_MoveDrop32x32.gif -./jre/lib/images/cursors/motif_MoveNoDrop32x32.gif -./jre/lib/javafx-mx.jar -./jre/lib/javafx.properties -./jre/lib/jce.jar -./jre/lib/jexec -./jre/lib/jfr/default.jfc -./jre/lib/jfr.jar -./jre/lib/jfr/profile.jfc -./jre/lib/jfxswt.jar -./jre/lib/jsse.jar -./jre/lib/jvm.hprof.txt -./jre/lib/logging.properties -./jre/lib/management-agent.jar -./jre/lib/management/jmxremote.access -./jre/lib/management/jmxremote.password.template -./jre/lib/management/management.properties -./jre/lib/management/snmp.acl.template -./jre/lib/meta-index -./jre/lib/net.properties -./jre/lib/psfontj2d.properties -./jre/lib/psfont.properties.ja -./jre/lib/resources.jar -./jre/lib/rt.jar -./jre/lib/security/blacklisted.certs -./jre/lib/security/cacerts -./jre/lib/security/java.policy -./jre/lib/security/java.security -./jre/lib/security/policy/limited/local_policy.jar -./jre/lib/security/policy/limited/US_export_policy.jar -./jre/lib/security/policy/unlimited/local_policy.jar -./jre/lib/security/policy/unlimited/US_export_policy.jar -./jre/lib/sound.properties -./jre/lib/tzdb.dat -./jre/LICENSE -./jre/THIRD_PARTY_README -[client] -./bin/gsql -./bin/gs_dump -./bin/gs_dumpall -./bin/gs_restore -./jdbc/gsjdbc4.jar -./jdbc/gsjdbc200.jar -./lib/postgresql/latin2_and_win1250.so -./lib/postgresql/euc2004_sjis2004.so -./lib/postgresql/euc_kr_and_mic.so -./lib/postgresql/utf8_and_uhc.so -./lib/postgresql/euc_tw_and_big5.so -./lib/postgresql/cyrillic_and_mic.so -./lib/postgresql/utf8_and_johab.so -./lib/postgresql/utf8_and_gb18030.so -./lib/postgresql/pgxs/src/makefiles/pgxs.mk -./lib/postgresql/pgxs/src/Makefile.shlib -./lib/postgresql/pgxs/src/Makefile.port -./lib/postgresql/pgxs/src/nls-global.mk -./lib/postgresql/pgxs/src/Makefile.global -./lib/postgresql/pgxs/config/install-sh -./lib/postgresql/euc_cn_and_mic.so -./lib/postgresql/latin_and_mic.so -./lib/postgresql/utf8_and_sjis2004.so -./lib/postgresql/utf8_and_euc_jp.so -./lib/postgresql/utf8_and_sjis.so -./lib/postgresql/utf8_and_cyrillic.so -./lib/postgresql/utf8_and_euc_kr.so -./lib/postgresql/ascii_and_mic.so -./lib/postgresql/utf8_and_iso8859_1.so -./lib/postgresql/euc_jp_and_sjis.so -./lib/postgresql/dict_snowball.so -./lib/postgresql/utf8_and_ascii.so -./lib/postgresql/utf8_and_euc_tw.so -./lib/postgresql/utf8_and_iso8859.so -./lib/postgresql/utf8_and_win.so -./lib/postgresql/utf8_and_euc_cn.so -./lib/postgresql/utf8_and_gbk.so -./lib/postgresql/utf8_and_euc2004.so -./lib/postgresql/utf8_and_big5.so -./lib/postgresql/java/pljava.jar -./lib/libpljava.so -./lib/libpq.a -./lib/libpq.so -./lib/libpq.so.5 -./lib/libpq.so.5.5 -./lib/libpq_ce.so -./lib/libpq_ce.so.5 -./lib/libpq_ce.so.5.5 -./lib/libcrypto.so -./lib/libcrypto.so.1.1 -./lib/libstdc++.so.6 -./lib/libssl.so -./lib/libssl.so.1.1 -./lib/libgssapi_krb5_gauss.so -./lib/libgssapi_krb5_gauss.so.2 -./lib/libgssapi_krb5_gauss.so.2.2 -./lib/libgssrpc_gauss.so -./lib/libgssrpc_gauss.so.4 -./lib/libgssrpc_gauss.so.4.2 -./lib/libk5crypto_gauss.so -./lib/libk5crypto_gauss.so.3 -./lib/libk5crypto_gauss.so.3.1 -./lib/libkrb5support_gauss.so -./lib/libkrb5support_gauss.so.0 -./lib/libkrb5support_gauss.so.0.1 -./lib/libkrb5_gauss.so -./lib/libkrb5_gauss.so.3 -./lib/libkrb5_gauss.so.3.3 -./lib/libcom_err_gauss.so -./lib/libcom_err_gauss.so.3 -./lib/libcom_err_gauss.so.3.0 -./odbc/lib/psqlodbcw.la -./odbc/lib/psqlodbcw.so -[libpq] -./lib/libpq.a -./lib/libpq.so -./lib/libpq.so.5 -./lib/libpq.so.5.5 -./lib/libpq_ce.so -./lib/libpq_ce.so.5 -./lib/libpq_ce.so.5.5 -./lib/libconfig.so -./lib/libconfig.so.4 -./lib/libcmclient.so -./lib/libcmclient.so.1 -./lib/libcmcommon.so -./lib/libcmcommon.so.2 -./lib/libcmpq.so -./lib/libcmpq.so.1 -./lib/libcrypto.so -./lib/libcrypto.so.1.1 -./lib/libstdc++.so.6 -./lib/libssl.so -./lib/libssl.so.1.1 -./lib/libpgport_tool.so -./lib/libpgport_tool.so.1 -./lib/libgssapi_krb5_gauss.so -./lib/libgssapi_krb5_gauss.so.2 -./lib/libgssapi_krb5_gauss.so.2.2 -./lib/libgssrpc_gauss.so -./lib/libgssrpc_gauss.so.4 -./lib/libgssrpc_gauss.so.4.2 -./lib/libk5crypto_gauss.so -./lib/libk5crypto_gauss.so.3 -./lib/libk5crypto_gauss.so.3.1 -./lib/libkrb5support_gauss.so -./lib/libkrb5support_gauss.so.0 -./lib/libkrb5support_gauss.so.0.1 -./lib/libkrb5_gauss.so -./lib/libkrb5_gauss.so.3 -./lib/libkrb5_gauss.so.3.3 -./lib/libcom_err_gauss.so -./lib/libcom_err_gauss.so.3 -./lib/libcom_err_gauss.so.3.0 -[cmlibrary] -./lib/libconfig.a -./lib/libcmclient.a -./lib/libcmcommon.a -./lib/libcmpq.a -./lib/libpgport.a -[header] -./include/libpq-fe.h -./include/postgres_ext.h -./include/gs_thread.h -./include/gs_threadlocal.h -./include/pg_config.h -./include/pg_config_manual.h -./include/pg_config_os.h -./include/cm_config.h -./include/c.h -./include/port.h -./include/cm_msg.h -./include/cm_c.h -./include/cm_misc.h -./include/libpq-int.h -./include/pqcomm.h -./include/pqexpbuffer.h -./include/xlogdefs.h -./include/cm-libpq-fe.h -[gds] -./bin/gds -./bin/gds_ctl.py -./share/postgresql/gds.conf -./share/postgresql/gds.conf.sample -./lib/libcjson.so -./lib/libcjson.so.1 -./lib/libcjson.so.1.7.13 -[version] -V500R001C20 -[script] -./script/__init__.py -./script/gs_check -./script/gs_checkos -./script/gs_checkperf -./script/gs_collector -./script/gs_backup -./script/gs_expand -./script/gs_install -./script/gs_om -./script/gs_hotpatch -./script/gs_postuninstall -./script/gs_preinstall -./script/gs_replace -./script/gs_shrink -./script/gs_ssh -./script/gs_sshexkey -./script/gs_uninstall -./script/gs_upgradectl -./script/gs_lcctl -./script/gs_resize -./script/uninstall_force.py -./script/checkRunStatus.py -./script/JsonToDbClustorInfo.py -./script/killall -./script/nodegroup_migrate.sh diff --git a/src/Makefile.global.in b/src/Makefile.global.in index d4ff23c16f..fcdc631ae9 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1077,7 +1077,7 @@ endif libpq = -L$(libpq_builddir) -lpq ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -libpq_ce = -L$(libpq_builddir) -lpq_ce -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -lsecurec -lkmc +libpq_ce = -L$(libpq_builddir) -lpq_ce -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -lsecurec -lkmc else libpq_ce = -L$(libpq_builddir) -lpq_ce endif diff --git a/src/bin/Makefile b/src/bin/Makefile index d08ef81413..fc0e256d0f 100644 --- a/src/bin/Makefile +++ b/src/bin/Makefile @@ -34,8 +34,7 @@ SUBDIRS = \ gsqlerr \ pg_upgrade \ pg_basebackup \ - pg_probackup \ - gs_ktool + pg_probackup ifeq ($(PORTNAME), win32) SUBDIRS += pgevent @@ -57,10 +56,6 @@ SUBDIRS = \ pg_basebackup \ pg_probackup -ifeq ($(enable_privategauss), yes) -SUBDIRS += gs_ktool -endif - endif $(recurse) diff --git a/src/bin/gs_ktool/Makefile b/src/bin/gs_ktool/Makefile deleted file mode 100644 index f49304e659..0000000000 --- a/src/bin/gs_ktool/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -#------------------------------------------------------------------------- -# -# Copyright (c) 2020 Huawei Technologies Co.,Ltd. -# -# src/bin/gs_tool/Makefile -# -#------------------------------------------------------------------------- - -subdir = src/bin/gs_ktool -top_builddir = ../../.. - -include $(top_builddir)/src/Makefile.global - -override CPPFLAGS += -I. -I$(top_builddir)/src/include/gs_ktool -I$(LIBKMC_INCLUDE_PATH) -override LDFLAGS += -L. -L$(LIBKMC_LIB_PATH) -override LDLIBS += -lsecurec -lssl -lcrypto -lkmc -ldl -lrt -Wl,-z,relro,-z,now -ftrapv -fstack-protector-strong - -override CPPFLAGS := $(filter-out -fPIE, $(CPPFLAGS)) -fPIC -shared - -OBJS = kt_common.o kt_kmc_callback.o kt_log_manage.o kt_key_manage.o kt_interface.o kt_main.o - -all: gs_ktool libgs_ktool.so - -gs_ktool: $(OBJS) - $(CC) -fPIE -pie $(CPPLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@ - -libgs_ktool.so: $(OBJS) - $(CC) -fPIC -shared $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@ - -install: all installdirs - $(INSTALL_PROGRAM) gs_ktool$(X) '$(DESTDIR)$(bindir)/gs_ktool$(X)' - $(INSTALL_DATA) gs_ktool_conf.ini$(X) '$(DESTDIR)$(bindir)/../etc/gs_ktool_file/gs_ktool_conf.ini$(X)' - $(INSTALL_DATA) libgs_ktool.so$(X) '$(DESTDIR)$(bindir)/../lib/libgs_ktool.so$(X)' - $(INSTALL_DATA) $(LIBKMC_LIB_PATH)/libkmc.so$(X) '$(DESTDIR)$(bindir)/../lib/libkmc.so$(X)' - rm -f ./gs_ktool - -installdirs: - $(MKDIR_P) '$(DESTDIR)$(bindir)' - -clean distclean maintainer-clean: - rm -f ./*.o ./gs_ktool ./*.so - diff --git a/src/bin/gs_ktool/gs_ktool_conf.ini b/src/bin/gs_ktool/gs_ktool_conf.ini deleted file mode 100644 index 2bd56dc598..0000000000 --- a/src/bin/gs_ktool/gs_ktool_conf.ini +++ /dev/null @@ -1,15 +0,0 @@ -# use '#' to comment out a line in this file. -# we use "key = value" to config gs_ktool, please do not change the name of "key" - -[KeyManage] -rk_validity = 3650; # (days) this configure is only valid for the first installtion, but you can update it when it is expired -cmk_validity = 365; # (days) -cmk_length = 32; # (bytes) -# you can config the file path and file name of key-store-file(ksf) by yourself, but the path must be real path -pri_ksf = DEFAULT; # DEFAULT = $GS_KTOOL_FILE_PATH/primary_ksf.dat -sec_ksf = DEFAULT; # DEFAULT = $GS_KTOOL_FILE_PATH/secondary_ksf.dat -export_ksf = DEFAULT; # DEFAULT = $GS_KTOOL_FILE_PATH/export_ksf.dat - -[LogManage] -is_logmodule_open = ON; -log_file = DEFAULT; # DEFAULT = $GS_KTOOL_FILE_PATH/gs_ktool.log \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_common.cpp b/src/bin/gs_ktool/kt_common.cpp deleted file mode 100644 index 7b135165e3..0000000000 --- a/src/bin/gs_ktool/kt_common.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_common.cpp - * Some common functions used by both key manage_module and log manage module, including: - * 1. define global var read from configuration file - * 2. report error - * 3. read configuration file - * 4. converse time and date format - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_common.cpp - * - * ------------------------------------------------------------------------- - */ - -#include "kt_common.h" - -#include -#include -#include -#include -#include -#include "securec.h" -#include "securec_check.h" -#include "pthread.h" - -const char *CONF_FILE_NAME = "gs_ktool_conf.ini"; -const char *ZERO_BUF = " "; - -char g_env_value[MAX_REAL_PATH_LEN] = {0}; -char g_conf_file[MAX_REAL_PATH_LEN ] = {0}; -/* globa vars read from configuration file */ -ConfIterm g_conf = { 0 }; -static pthread_mutex_t g_env_lock; -bool g_is_print_err = true; - -static bool find_conf_segment(FILE *conf_file_handle, const char *conf_segment_name); -static void read_conf_lines(FILE *conf_file_handle, char key_list[][MAX_CONF_KEY_LEN], - char value_list[][MAX_CONF_VALUE_LEN], size_t *conf_item_num); -static unsigned int trans_date_to_int(const Time date); - -char *gs_getenv_r(const char *name) -{ - char *ret = NULL; - (void)pthread_mutex_lock(&g_env_lock); - ret = getenv(name); - (void)pthread_mutex_unlock(&g_env_lock); - return ret; -} - -static bool find_conf_segment(FILE *conf_file_handle, const char *conf_segment_name) -{ - int conf_item_cnt = 0; - char cur_line[MAX_CONF_LINE_LEN] = {0}; - char cur_segment[MAX_SETMENT_NAME_LEN] = {0}; - bool is_find_segment = false; - - while (is_find_segment == false && fgets(cur_line, MAX_CONF_LINE_LEN, conf_file_handle)) { - if (conf_item_cnt > MAX_CONF_ITEM_QUANTITY) { - printf("WARING: only %d configuration items can be read.\n", MAX_CONF_ITEM_QUANTITY); - return false; - } - - if (strlen(cur_line) < strlen("[]")) { - continue; - } - - /* find configuration segment location */ - size_t ps = 0; /* position of segment */ - for (size_t i = 0; i < strlen(cur_line); i++) { - if (cur_line[i] == ' ') { - continue; - } else if (cur_line[i] == '[') { - /* the configuration segment is defined as [Segment], if we find '[', then we will try to find ']' */ - for (i = i + 1; i < strlen(cur_line); i++) { - if (cur_line[i] == ']') { - cur_segment[ps] = '\0'; - break; - } else if (i == strlen(cur_line) - 1) { - printf("WARNING: incomplete configuration segment declaration: '%s'\n", cur_line); - break; - } else { - cur_segment[ps] = cur_line[i]; - ps++; - } - } - if (strcmp(cur_segment, conf_segment_name) == 0) { - is_find_segment = true; - } - } else { - break; - } - } - } - - return is_find_segment; -} - -static void read_conf_lines(FILE *conf_file_handle, char key_list[][MAX_CONF_KEY_LEN], - char value_list[][MAX_CONF_VALUE_LEN], size_t *conf_item_num) -{ - bool is_in_segment = true; - char cur_line[MAX_CONF_LINE_LEN] = {0}; - char cur_key[MAX_CONF_KEY_LEN] = {0}; - char cur_value[MAX_CONF_VALUE_LEN] = {0}; - size_t pl = 0; /* position of line */ - size_t pk = 0; /* position of key */ - size_t pv = 0; /* position of value */ - size_t conf_item_cnt = 0; - errno_t rc = 0; - - while (is_in_segment == true && fgets(cur_line, MAX_CONF_LINE_LEN, conf_file_handle)) { - if (strlen(cur_line) < strlen(" = ;")) { - continue; - } - - /* check segment end, then read key from configureation line */ - for (; pl < strlen(cur_line); pl++) { - if (cur_line[pl] == '#') { - break; - } else if (cur_line[pl] == ' ') { - continue; - } else if (cur_line[pl] == '[') { - is_in_segment = false; - break; - } else if (cur_line[pl] == '=') { - cur_key[pk] = '\0'; - break; - } else { - cur_key[pk] = cur_line[pl]; - pk++; - } - } - - /* read value from configureation line */ - if (is_in_segment == true) { - for (pl = pl + 1; pl < strlen(cur_line); pl++) { - if (cur_line[pl] == ' ') { - continue; - } else if (cur_line[pl] == ';') { - cur_value[pv] = '\0'; - break; - } else { - cur_value[pv] = cur_line[pl]; - pv++; - } - } - - if (strlen(cur_key) > 0 && strlen(cur_value) > 0) { - rc = strcpy_s(key_list[conf_item_cnt], MAX_CONF_KEY_LEN, cur_key); - securec_check_c(rc, "", ""); - rc = strcpy_s(value_list[conf_item_cnt], MAX_CONF_VALUE_LEN, cur_value); - securec_check_c(rc, "", ""); - conf_item_cnt++; - } - } - - rc = memset_s(cur_line, MAX_CONF_LINE_LEN, 0, MAX_CONF_LINE_LEN); - securec_check_c(rc, "", ""); - rc = memset_s(cur_key, MAX_CONF_KEY_LEN, 0, MAX_CONF_KEY_LEN); - securec_check_c(rc, "", ""); - rc = memset_s(cur_value, MAX_CONF_VALUE_LEN, 0, MAX_CONF_VALUE_LEN); - securec_check_c(rc, "", ""); - pl = 0; - pk = 0; - pv = 0; - } - - *conf_item_num = conf_item_cnt; -} - -bool read_conf_segment(const char *conf_file, const char *conf_segment_name, char key_list[][MAX_CONF_KEY_LEN], - char value_list[][MAX_CONF_VALUE_LEN], size_t *conf_item_num) -{ - FILE *fp = NULL; - - fp = fopen(conf_file, "rb"); - if (fp == NULL) { - return false; - } - - if (!find_conf_segment(fp, conf_segment_name)) { - fclose(fp); - return false; - } - - read_conf_lines(fp, key_list, value_list, conf_item_num); - fclose(fp); - - return true; -} - -bool set_global_file(char *kt_file, const GlobalKtoolFile file_type, const char *file_str) -{ - char default_kt_file_name[MAX_FILE_NAME_LEN]; - errno_t rc = 0; - - if (kt_file == NULL || g_env_value == NULL) { - return false; - } - - if (strlen(file_str) >= MAX_REAL_PATH_LEN) { - return false; - } - - /* - * file_str is read from configure file, it has 2 types: - * (1) “real_path/file_name” : the real_path and file_name are set by user. - * (2) “DEFAULT” :in this case, we will use the default file_path and file_name - */ - if (strcmp(file_str, "DEFAULT") != 0) { - /* file_str is a real path read from configuration file */ - rc = sprintf_s(kt_file, MAX_REAL_PATH_LEN, "%s", file_str); - securec_check_ss_c(rc, "", ""); - - if (!check_kt_env_value(kt_file)) { - printf("ERROR: failed to set configuration, the path '%s' contains angerous character.\n", kt_file); - return false; - } - return true; - } else { - switch (file_type) { - case G_PRI_KSF: - rc = strcpy_s(default_kt_file_name, MAX_FILE_NAME_LEN, "primary_ksf.dat"); - securec_check_c(rc, "", ""); - break; - case G_SEC_KSF: - rc = strcpy_s(default_kt_file_name, MAX_FILE_NAME_LEN, "secondary_ksf.dat"); - securec_check_c(rc, "", ""); - break; - case G_EXPORT_KSF: - rc = strcpy_s(default_kt_file_name, MAX_FILE_NAME_LEN, "export_ksf.dat"); - securec_check_c(rc, "", ""); - break; - case G_LOG_FILE: - rc = strcpy_s(default_kt_file_name, MAX_FILE_NAME_LEN, "gs_ktool.log"); - securec_check_c(rc, "", ""); - break; - default: - break; - } - - rc = sprintf_s(kt_file, MAX_REAL_PATH_LEN, "%s/%s", g_env_value, default_kt_file_name); - securec_check_ss_c(rc, "", ""); - } - - return true; -} - -bool check_kt_env_value(const char *env_value) -{ - const char* danger_char_list[] = {"|", ";", "&", "$", "<", ">", "`", "\\", "'", "\"", - "{", "}", "(", ")", "[", "]", "~", "*", "?", "!", "\n", NULL}; - - for (int i = 0; danger_char_list[i] != NULL; i++) { - if (strstr(env_value, danger_char_list[i]) != NULL) { - return false; - } - } - - return true; -} - -bool compare_list_element(const char list_a[][MAX_CONF_KEY_LEN], size_t list_a_cnt, char list_b[][MAX_CONF_KEY_LEN], - size_t list_b_cnt, size_t *loss_pos) -{ - bool is_find_element = false; - - for (size_t i = 0; i < list_a_cnt; i++) { - for (size_t j = 0; j < list_b_cnt; j++) { - if (strcmp(list_a[i], list_b[j]) == 0) { - is_find_element = true; - break; - } - } - - if (!is_find_element) { - *loss_pos = i; - return false; - } else { - is_find_element = false; - } - } - - return true; -} - -/* to print pretty table, create line like "---------" */ -void make_table_line(char *line_buf, const size_t buf_len, const size_t line_len) -{ - size_t i = 0; - - if (line_len >= buf_len) { - return; - } - - for (i = 0; i < line_len; i++) { - line_buf[i] = '-'; - } - - line_buf[i] = '\0'; -} - -bool atoi_strictly(const char *str, unsigned int *num) -{ - for (size_t i = 0; i < strlen(str); i++) { - if (str[i] < '0' || str[i] > '9') { - return false; - } - } - - *num = atoi(str); - return true; -} - -bool get_sys_time(Time *sys_time) -{ - time_t t_time = { 0 }; - struct tm *tm_time = { 0 }; - unsigned int initial_year = 1900; - unsigned int initial_moth = 1; - - time(&t_time); - tm_time = localtime(&t_time); - if (tm_time == NULL) { - return false; - } - - sys_time->year = tm_time->tm_year + initial_year; - sys_time->month = tm_time->tm_mon + initial_moth; - sys_time->day = tm_time->tm_mday; - sys_time->hour = tm_time->tm_hour; - sys_time->minute = tm_time->tm_min; - sys_time->second = tm_time->tm_sec; - return true; -} - -void date_ttos(const Time date_t, char *date_s, const size_t buf_size) -{ - errno_t rc = 0; - rc = sprintf_s(date_s, buf_size, "%04u-%02u-%02u", date_t.year, date_t.month, date_t.day); - securec_check_ss_c(rc, "", ""); -} - -void time_ttos(const Time time_t, char *time_s, const size_t buf_size) -{ - errno_t rc = 0; - rc = sprintf_s(time_s, buf_size, "%02u:%02u:%02u", time_t.hour, time_t.minute, time_t.second); - securec_check_ss_c(rc, "", ""); -} - -void trans_wsectime_to_time(WsecSysTime wsec_time_t, Time *time_t) -{ - time_t->year = wsec_time_t.kmcYear; - time_t->month = wsec_time_t.kmcMonth; - time_t->day = wsec_time_t.kmcDate; - time_t->hour = wsec_time_t.kmcHour; - time_t->minute = wsec_time_t.kmcMinute; - time_t->second = wsec_time_t.kmcSecond; -} - -static unsigned int trans_date_to_int(const Time date) -{ - unsigned int days = 0; - /* my epochs, not use 1970.1.1, but use 2019.1.1 */ - unsigned int origin_y = 2019; - unsigned int origin_m = 1; - /* origin_d = 1 */ - const unsigned int leap_year[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - const unsigned int lunar_year[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - - for (unsigned int y = (origin_y + 1); y <= date.year; y++) { - if ((y - 1) % 4 == 0) { - days += 366; - } else { - days += 365; - } - } - - for (unsigned int m = (origin_m + 1); m <= date.month; m++) { - if (date.year % 4 == 0) { - days += leap_year[m - 1]; - } else { - days += lunar_year[m - 1]; - } - } - - days += date.day; - - return days; -} - -void timecpy(Time *dest_time, Time src_time) -{ - securec_check_c(memcpy_s(dest_time, sizeof(Time), &src_time, sizeof(Time)), "\0", "\0"); -} - -/* to determine whether the key has expired */ -int calculate_interval(Time start, Time end) -{ - return (trans_date_to_int(end) - trans_date_to_int(start)); -} \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_common.h b/src/bin/gs_ktool/kt_common.h deleted file mode 100644 index 07e2fc1712..0000000000 --- a/src/bin/gs_ktool/kt_common.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_common.h - * Some common functions used by both key manage_module and log manage module, including: - * 1. define global var read from configuration file - * 2. report error - * 3. read configuration file - * 4. converse time and date format - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_common.h - * - * ------------------------------------------------------------------------- - */ - -#ifndef GS_KT_COMMON_H -#define GS_KT_COMMON_H - -#include "kt_kmc_callback.h" - -extern const char *CONF_FILE_NAME; -extern const char *ZERO_BUF; - -/* check length from conf file && from gs_ktool interfacs */ -const int MAX_CONF_ITEM_QUANTITY = 100; -const int MAX_CONF_LINE_LEN = 2048; -const int MAX_CONF_KEY_LEN = 512; -const int MAX_CONF_VALUE_LEN = 512; -const int MAX_SETMENT_NAME_LEN = 1024; -const int MAX_RK_VALIDITY = 10000; -const int MAX_CMK_VALIDITY = 3660; -const int MAX_FILE_NAME_LEN = 512; -const int MAX_REAL_PATH_LEN = 4096; - -const int MIN_CMK_LEN = 16; -const int MAX_CMK_LEN = 112; /* 112 bytes (the max length that KMC support) */ -const int DEFAULT_DOMAIN = 2; - -/* general limit */ -const int MAX_LOG_RESULT_LEN = 2048; -const int MAX_USER_INPUT_LEN = 1024; - -typedef enum KeyManageConf { - RK_VALIDITY = 0, - CMK_VALIDITY, - CMK_LENGTH, - PRI_KSF, - SEC_KSF, - EXPORT_KSF, -} KeyManageConf; - -enum LogManageConf { - IS_LOGMODULE_OPEN = 0, - LOG_FILE, -}; - -typedef enum GlobalKtoolFile { - G_CONF_FILE = 0, - G_PRI_KSF, - G_SEC_KSF, - G_EXPORT_KSF, - G_LOG_FILE, -} GlobalKtoolFile; - -typedef enum LogModuleStatus { - ON = 0, - OFF, -} LogModuleStatus; - -typedef struct Time { - unsigned int year; - unsigned int month; - unsigned int day; - unsigned int hour; - unsigned int minute; - unsigned int second; -} Time; - -typedef struct ConfIterm { - unsigned int rk_validity; - unsigned int cmk_validity; - unsigned int cmk_length; - char pri_ksf[MAX_REAL_PATH_LEN ]; - char sec_ksf[MAX_REAL_PATH_LEN ]; - char export_ksf[MAX_REAL_PATH_LEN ]; - - unsigned char is_logmodule_open; - char log_file[MAX_REAL_PATH_LEN ]; -} ConfIterm; - -#define return_false_if(condition) {\ - if ((condition)) { \ - return false; \ - } \ - } - -#define kt_free(ptr) \ - { \ - free(ptr); \ - ptr = NULL; \ - } - -extern char g_env_value[MAX_REAL_PATH_LEN]; -extern char g_conf_file[MAX_REAL_PATH_LEN ]; -/* globa vars read from configuration file */ -extern ConfIterm g_conf; -extern bool g_is_print_err; - -extern char *gs_getenv_r(const char *name); -extern bool read_conf_segment(const char *conf_file, const char *conf_segment_name, char key_list[][MAX_CONF_KEY_LEN], - char value_list[][MAX_CONF_VALUE_LEN], size_t *conf_item_num); -extern bool set_global_file(char *kt_file, const GlobalKtoolFile file_type, const char *file_str); -extern bool check_kt_env_value(const char *env_value); - -extern bool compare_list_element(const char list_a[][MAX_CONF_KEY_LEN], size_t list_a_cnt, - char list_b[][MAX_CONF_KEY_LEN], size_t list_b_cnt, size_t *loss_pos); -void make_table_line(char *line_buf, const size_t buf_len, const size_t line_len); -bool atoi_strictly(const char *str, unsigned int *num); - -/* convert and calculate the time */ -extern bool get_sys_time(Time *sys_time); -void date_ttos(const Time date_t, char *date_s, const size_t buf_size); -void time_ttos(const Time time_t, char *time_s, const size_t buf_size); -void trans_wsectime_to_time(WsecSysTime wsec_time_t, Time *time_t); -void timecpy(Time *dest_time, Time src_time); -/* to determine whether the key has expired */ -int calculate_interval(Time start, Time end); -#endif diff --git a/src/bin/gs_ktool/kt_interface.cpp b/src/bin/gs_ktool/kt_interface.cpp deleted file mode 100644 index d5e8c28570..0000000000 --- a/src/bin/gs_ktool/kt_interface.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_interface.cpp - * APIs for Encrypted Database. - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_interface.cpp - * - * ------------------------------------------------------------------------- - */ - -#include "kt_interface.h" -#include -#include -#include "kt_common.h" -#include "kt_key_manage.h" -#include "kt_log_manage.h" - -const int MAX_CMK_PLAIN_LEN = 112; - -static bool init_kt_ksf(); - -static bool init_kt_ksf() -{ - const char required_conf[][MAX_CONF_KEY_LEN] = {"pri_ksf", "sec_ksf"}; - size_t required_conf_cnt = sizeof(required_conf) / sizeof(required_conf[0]); - - if (!reg_callback_funcs()) { - printf("ERROR(GS_KTOOL): failed to register callback functions.\n"); - return false; - } - - if (!initialize_logmodule()) { - return false; - } - - if (!load_key_manage_conf(required_conf, required_conf_cnt)) { - return false; - } - - if (!has_ksf_existed()) { - insert_format_log(L_OPEN_FILE, KT_ERROR, - "please make sure 'gs_ktool' is installed and the key store file already exists"); - return false; - } - - return init_or_create_ksf(); -} - -bool get_cmk_len(unsigned int cmk_id, unsigned int *cmk_len) -{ - KmcMkInfo cmk_info = { 0 }; - unsigned char cmk_plain[MAX_CMK_PLAIN_LEN] = { 0 }; - unsigned int cmk_plain_buf_len = MAX_CMK_PLAIN_LEN; - bool ret = true; - - return_false_if(cmk_len == NULL); - - if (!init_kt_ksf()) { - return false; - } - - if (KmcGetMkDetail(DEFAULT_DOMAIN, cmk_id, &cmk_info, cmk_plain, &cmk_plain_buf_len) == WSEC_SUCCESS) { - insert_format_log(L_SELECT_CMK_LEN, KT_SUCCEED, "cmk id: %d", cmk_id); - } else { - insert_format_log(L_SELECT_CMK_LEN, KT_ERROR, "cmk id: %d", cmk_id); - ret = false; - } - WsecFinalizeEx(); - - *cmk_len = cmk_plain_buf_len; - return ret; -} - -bool get_cmk_plain(unsigned int cmk_id, unsigned char *cmk_plain, unsigned int *cmk_len) -{ - KmcMkInfo cmk_info = { 0 }; - unsigned char tmp_cmk_plain[MAX_CMK_PLAIN_LEN] = {0}; - unsigned int tmp_plain_buf_len = MAX_CMK_PLAIN_LEN; - bool ret = true; - - return_false_if(cmk_plain == NULL); - - if (!init_kt_ksf()) { - return false; - } - - if (KmcGetMkDetail(DEFAULT_DOMAIN, cmk_id, &cmk_info, tmp_cmk_plain, &tmp_plain_buf_len) == WSEC_SUCCESS) { - for (unsigned int i = 0; i < tmp_plain_buf_len; i++) { - cmk_plain[i] = tmp_cmk_plain[i]; - } - *cmk_len = tmp_plain_buf_len; - - insert_format_log(L_SELECT_CMK_PLAIN, KT_SUCCEED, "cmk id: %d", cmk_id); - } else { - insert_format_log(L_SELECT_CMK_PLAIN, KT_ERROR, "cmk id: %d", cmk_id); - ret = false; - } - WsecFinalizeEx(); - - return ret; -} diff --git a/src/bin/gs_ktool/kt_key_manage.cpp b/src/bin/gs_ktool/kt_key_manage.cpp deleted file mode 100644 index 10b330aa94..0000000000 --- a/src/bin/gs_ktool/kt_key_manage.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_key_manage.cpp - * Foreword : before reading this part of code, you should be familiar with the principle for key classification; - * This part is mainly used for encrypted database; - * Describe : in the scenario of three-level-key-schema, we use rk (root key) to encrypt cmk (client master key), - * use cmk to encrypt cek (client encrypt key), use cek to encrypt data. We use KMC to manage cmk and rk; - * Function : cmk manage : 1) generate cmk; 2) delete cmk; 3) select cmk info; 4) export cmk; 5) import cmk; - * rk manage : 1) select rk info; 2) update rk; - * (this module calls KMC interfaces to realize the key management functions.) - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_key_manage.cpp - * - * ------------------------------------------------------------------------- - */ -#include "kt_key_manage.h" - -#include -#include -#include -#include "kt_log_manage.h" - -static const char g_all_key_manage_conf[][MAX_CONF_KEY_LEN] = {"rk_validity", "cmk_validity", "cmk_length", "pri_ksf", - "sec_ksf", "export_ksf"}; - -static bool set_global_key_conf(KeyManageConf key_conf, const char *conf_key, const char *conf_value); -static bool set_rk_validity(); -static bool check_rk_validity(int *days); - -bool reg_callback_funcs(void) -{ - return (RegFunCallback() == WSEC_SUCCESS); -} - -bool load_key_manage_conf(const char required_conf[MAX_CONF_ITEM_QUANTITY][MAX_CONF_KEY_LEN], - size_t required_conf_cnt) -{ - char key_list[MAX_CONF_ITEM_QUANTITY][MAX_CONF_KEY_LEN] = {0}; - char value_list[MAX_CONF_ITEM_QUANTITY][MAX_CONF_VALUE_LEN] = {0}; - size_t lost_conf_pos = 0; - size_t conf_item_cnt = 0; - bool ret = true; - bool is_find_conf_item = false; - - if (!read_conf_segment(g_conf_file, "KeyManage", key_list, value_list, &conf_item_cnt)) { - insert_format_log(L_READ_CONF, KT_ERROR, "cannot find configuration segment : '%s'", "KeyManage"); - return false; - } - - if (!compare_list_element(required_conf, required_conf_cnt, key_list, conf_item_cnt, &lost_conf_pos)) { - insert_format_log(L_READ_CONF, KT_ERROR, "lost configuration item : '%s'", required_conf[lost_conf_pos]); - return false; - } - - for (size_t i = 0; i < required_conf_cnt; i++) { - for (size_t j = 0; j < sizeof(g_all_key_manage_conf) / sizeof(g_all_key_manage_conf[0]); j++) { - if (strcmp(required_conf[i], g_all_key_manage_conf[j]) == 0) { - is_find_conf_item = true; - switch (j) { - case RK_VALIDITY: - if (!set_global_key_conf(RK_VALIDITY, key_list[j], value_list[j])) { - return false; - } - break; - case CMK_VALIDITY: - if (!set_global_key_conf(CMK_VALIDITY, key_list[j], value_list[j])) { - return false; - } - break; - case CMK_LENGTH: - if (!set_global_key_conf(CMK_LENGTH, key_list[j], value_list[j])) { - return false; - } - break; - case PRI_KSF: - ret = set_global_file(g_conf.pri_ksf, G_PRI_KSF, value_list[j]); - break; - case SEC_KSF: - ret = set_global_file(g_conf.sec_ksf, G_SEC_KSF, value_list[j]); - break; - case EXPORT_KSF: - ret = set_global_file(g_conf.export_ksf, G_EXPORT_KSF, value_list[j]); - break; - default: - break; - } - } - - if (!ret) { - printf("%s %s\n", key_list[j], value_list[j]); - insert_format_log(L_SET_CONF, KT_ERROR, "the value of '%s' is invalid", key_list[i]); - return false; - } - } - - if (!is_find_conf_item) { - insert_format_log(L_READ_CONF, KT_ERROR, "lost configuration item : '%s'", key_list[i]); - return false; - } else { - is_find_conf_item = false; - } - } - - return true; -} - -static bool set_global_key_conf(KeyManageConf key_conf, const char *conf_key, const char *conf_value) -{ - unsigned int input_num = 0; - - if (!atoi_strictly(conf_value, &input_num)) { - insert_format_log(L_SET_CONF, KT_ERROR, "this configuration value '%s' is expected to be an positive integer", - conf_value); - return false; - } - - switch (key_conf) { - case RK_VALIDITY: - if (input_num < 1 || input_num > MAX_RK_VALIDITY) { - insert_format_log(L_SET_CONF, KT_ERROR, "'%s' should be in range (0, %d]", conf_key, MAX_RK_VALIDITY); - return false; - } - g_conf.rk_validity = input_num; - break; - case CMK_VALIDITY: { - if (input_num < 1 || input_num > MAX_CMK_VALIDITY) { - insert_format_log(L_SET_CONF, KT_ERROR, "'%s' should be in range (0, %d]", conf_key, MAX_CMK_VALIDITY); - return false; - } - g_conf.cmk_validity = input_num; - break; - } - case CMK_LENGTH: - if (input_num < MIN_CMK_LEN || input_num > MAX_CMK_LEN) { - insert_format_log(L_SET_CONF, KT_ERROR, "cmk_length '%u' should be in range [%d, %d]", input_num, - MIN_CMK_LEN, MAX_CMK_LEN); - return false; - } - g_conf.cmk_length = input_num; - break; - default: - break; - } - - return true; -} - -bool has_ksf_existed(void) -{ - FILE *pri_fp = NULL; - FILE *sec_fp = NULL; - - pri_fp = fopen(g_conf.pri_ksf, "r"); - if (pri_fp == NULL) { - return false; - } - - sec_fp = fopen(g_conf.sec_ksf, "r"); - if (sec_fp == NULL) { - fclose(pri_fp); - return false; - } - - fclose(pri_fp); - fclose(sec_fp); - return true; -} - -bool init_or_create_ksf(void) -{ - KmcKsfName ksf_paths = { 0 }; - - ksf_paths.keyStoreFile[0] = g_conf.pri_ksf; - ksf_paths.keyStoreFile[1] = g_conf.sec_ksf; - - /* - * in WsecInitializeEx(): - * if the ksf cannot be found, this func will create a new one - * else if the ksf is found, this func only initialize it - */ - return (WsecInitializeEx(KMC_ROLE_MASTER, &ksf_paths, WSEC_FALSE, NULL) == WSEC_SUCCESS); -} - -static bool set_rk_validity() -{ - KmcCfgRootKey rk_conf = { 0 }; - rk_conf.validity = g_conf.rk_validity; - rk_conf.rmkIter = DEFAULT_RK_ITER; - - return (KmcSetDefaultRootKeyCfg(&rk_conf) == WSEC_SUCCESS); -} - -static bool check_rk_validity(int *days) -{ - KmcRkAttributes rk_attr = { 0 }; - Time today = { 0 }; - Time expired_day = { 0 }; - - if (KmcGetRootKeyInfo(&rk_attr) != WSEC_SUCCESS) { - insert_format_log(L_SELECT_RK, KT_ERROR, ""); - return false; - } - - if (!get_sys_time(&today)) { - insert_format_log(L_GET_TIME, KT_ERROR, ""); - return false; - } - - trans_wsectime_to_time(rk_attr.rkExpiredTimeUtc, &expired_day); - *days = calculate_interval(today, expired_day); - - return true; -} - -bool init_keytool(void) -{ - int rk_expired_days = 0; - const char required_conf[][MAX_CONF_KEY_LEN] = {"rk_validity", "cmk_validity", "cmk_length", - "pri_ksf", "sec_ksf", "export_ksf"}; - size_t required_conf_cnt = sizeof(required_conf) / sizeof(required_conf[0]); - - if (!reg_callback_funcs()) { - insert_format_log(L_REG_CALLBACK_FUNC, KT_ERROR, ""); - return false; - } - - if (!load_key_manage_conf(required_conf, required_conf_cnt)) { - return false; - } - - if (!set_rk_validity()) { - insert_format_log(L_SET_RK_VALIDITY, KT_ERROR, ""); - return false; - } - - bool ret = has_ksf_existed(); - - if (!init_or_create_ksf()) { - insert_format_log(L_INIT_KMC, KT_ERROR, ""); - return false; - } - - if (!ret) { - printf("NOTICE: created new key store file : %s.\n", g_conf.pri_ksf); - insert_format_log(L_CREATE_FILE, KT_NOTICE, "new key store file : '%s'", g_conf.pri_ksf); - } - - if (!check_rk_validity(&rk_expired_days)) { - return false; - } - - if (rk_expired_days < 0) { - printf("WARNING: your root key has expired \"%d\" days.\n", -rk_expired_days); - insert_format_log(L_CHECK_RK_VALIDITY, KT_ALARM, "expired : %d", -rk_expired_days); - - printf("HINT: you can use following conmmand to cycle root key:"); - printf(" gs_ktool -R -u\n"); - } - - return true; -} - -CmkInfo *init_cmk_info_list() -{ - CmkInfo *cmk_info_list = NULL; - - cmk_info_list = (CmkInfo *)malloc(sizeof(CmkInfo)); - if (cmk_info_list == NULL) { - insert_format_log(L_MALLOC_MEMORY, KT_ERROR, ""); - exit(1); - } - - cmk_info_list->cmk_id = INVALID_CMK_KD; - cmk_info_list->next = NULL; - - return cmk_info_list; -} - -bool add_cmk_info_node(CmkInfo *cmk_info_list, unsigned int cmk_id, unsigned int cmk_plain_len, - const Time cmk_create_time, const Time cmk_expired_time) -{ - bool is_list_empty = false; - CmkInfo *last_node = NULL; - CmkInfo *new_node = NULL; - - Time today = { 0 }; - bool is_expired = false; - int days = 0; - - if (cmk_info_list->cmk_id == INVALID_CMK_KD) { - is_list_empty = true; - new_node = cmk_info_list; - } else { - new_node = (CmkInfo *)malloc(sizeof(CmkInfo)); - if (new_node == NULL) { - insert_format_log(L_MALLOC_MEMORY, KT_ERROR, ""); - return false; - } - } - - /* check is cmk expired */ - if (!get_sys_time(&today)) { - insert_format_log(L_GET_TIME, KT_ERROR, ""); - if (new_node != NULL) { - kt_free(new_node); - } - return false; - } - days = calculate_interval(today, cmk_expired_time); - - new_node->cmk_id = cmk_id; - new_node->cmk_plain_len = cmk_plain_len; - timecpy(&(new_node->create_time), cmk_create_time); - timecpy(&(new_node->expired_time), cmk_expired_time); - new_node->is_expired = is_expired; - if (days <= 0) { - new_node->is_expired = true; - new_node->expired_days = -days; - } else { - new_node->is_expired = false; - new_node->expired_days = 0; - } - new_node->next = NULL; - - if (!is_list_empty) { - last_node = cmk_info_list; - while (last_node->next != NULL) { - last_node = last_node->next; - } - last_node->next = new_node; - } - - return true; -} - -void trav_cmk_info_list(CmkInfo *cmk_info_list) -{ - char table_line[15 + 1] = {0}; - CmkInfo *cur = cmk_info_list; - unsigned int cmk_cnt = 0; - char create_date_str[strlen("0000-00-00/")] = {0}; - char create_time_str[strlen("00:00:00/")] = {0}; - char expired_date_str[strlen("0000-00-00/")] = {0}; - - if (cmk_info_list != NULL && cmk_info_list->cmk_id == INVALID_CMK_KD) { - printf("no cmk found.\n"); - return; - } - - make_table_line(table_line, sizeof(table_line), 15); - printf(" %10s | %10s | %15s | %15s | %15s\n", "cmk id", "cmk length", "create date UTC", "create time UTC", - "expired date UTC"); - printf(" %10s-+-%10s-+-%15s-+-%15s-+-%15s\n", "----------", "----------", table_line, table_line, table_line); - - while (cur != NULL) { - cmk_cnt++; - date_ttos(cur->create_time, create_date_str, sizeof(create_date_str)); - time_ttos(cur->create_time, create_time_str, sizeof(create_time_str)); - date_ttos(cur->expired_time, expired_date_str, sizeof(expired_date_str)); - - printf(" %10u | %10u | %15s | %15s | %15s", cur->cmk_id, cur->cmk_plain_len, create_date_str, create_time_str, - expired_date_str); - - if (cur->is_expired) { - printf(" (WARNING : EXPIRED %d days)\n", cur->expired_days); - } else { - printf("\n"); - } - - cur = cur->next; - } - - printf("(%u Rows)\n", cmk_cnt); -} - -void destroy_cmk_info_list(CmkInfo *cmk_info_list) -{ - CmkInfo *to_free = NULL; - - while (cmk_info_list != NULL) { - to_free = cmk_info_list; - cmk_info_list = cmk_info_list->next; - kt_free(to_free); - } -} - -void print_rk_info(const RkInfo *rk_info) -{ - char table_line[15 + 1] = {0}; - char create_date_str[strlen("0000-00-00/")] = {0}; - char create_time_str[strlen("00:00:00/")] = {0}; - char expired_date_str[strlen("0000-00-00/")] = {0}; - - date_ttos(rk_info->create_time, create_date_str, sizeof(create_date_str)); - time_ttos(rk_info->create_time, create_time_str, sizeof(create_time_str)); - date_ttos(rk_info->expired_time, expired_date_str, sizeof(expired_date_str)); - - make_table_line(table_line, sizeof(table_line), 15); - printf(" %15s | %15s | %15s\n", "create date UTC", "create time UTC", "expired date UTC"); - printf(" %15s-+-%15s-+-%15s\n", table_line, table_line, table_line); - printf(" %15s | %15s | %15s\n", create_date_str, create_time_str, expired_date_str); - - if (rk_info->is_expired) { - printf("\nWARNNING: your root key has expired %d days.\n", rk_info->expired_days); - printf("HINT: you can use following conmmand to cycle root key:"); - printf(" gs_ktool -R -u\n"); - } -} - -bool generate_cmk(const bool has_set_len, unsigned int key_len, unsigned int *key_id) -{ - KmcCfgDomainInfo domain_info = { 0 }; - KmcCfgKeyType k_type = { 0 }; - unsigned int cmk_plain_len = 0; - - domain_info = { DEFAULT_DOMAIN, KMC_MK_GEN_BY_INNER, { 0 }, KMC_DOMAIN_TYPE_SHARE, 0 }; - errno_t rc = strcpy_s(domain_info.desc, sizeof(domain_info.desc), "CMK"); - securec_check_c(rc, "", ""); - - if (has_set_len) { - cmk_plain_len = key_len; - } else { - cmk_plain_len = g_conf.cmk_length; - } - - k_type = { KMC_KEY_TYPE_ENCRPT_INTEGRITY, cmk_plain_len, g_conf.cmk_validity, 0 }; - - return_false_if(KmcAddDomainEx(&domain_info) != WSEC_SUCCESS); - return_false_if(KmcAddDomainKeyTypeEx(DEFAULT_DOMAIN, &k_type) != WSEC_SUCCESS); - - *key_id = KmcGetMkCount(); - if (*key_id >= MAX_CMK_QUANTITY) { - insert_format_log(L_GEN_CMK, KT_ERROR, "the number of CMKs exceeds the upper limit : %d.", MAX_CMK_QUANTITY); - return false; - } - - return (KmcCreateMkEx(DEFAULT_DOMAIN, key_id) == WSEC_SUCCESS); -} - -bool delete_cmk(const bool has_set_all, unsigned int cmk_id, unsigned int del_cmk_id_list[], unsigned int *del_cmk_cnt) -{ - KmcCfgDomainInfo domain_info = { 0 }; - KmcMkInfo kmc_cmk_info = { 0 }; - unsigned int all_cmk_cnt = 0; - - domain_info = { DEFAULT_DOMAIN, KMC_MK_GEN_BY_INNER, { 0 }, KMC_DOMAIN_TYPE_SHARE, 0 }; - if (KmcAddDomainEx(&domain_info) != WSEC_SUCCESS) { - return false; - } - - /* delete one cmk (user has specificed the cmk id) */ - if (!has_set_all) { - return (KmcRmvMk(DEFAULT_DOMAIN, cmk_id) == WSEC_SUCCESS); - } else { /* delete all cmk */ - all_cmk_cnt = KmcGetMkCount(); - for (unsigned int i = 0; i < all_cmk_cnt; i++) { - if (KmcGetMk(1, &kmc_cmk_info) == WSEC_SUCCESS && kmc_cmk_info.domainId == DEFAULT_DOMAIN) { - return_false_if(KmcRmvMk(DEFAULT_DOMAIN, kmc_cmk_info.keyId) != WSEC_SUCCESS); - del_cmk_id_list[*del_cmk_cnt] = kmc_cmk_info.keyId; - (*del_cmk_cnt)++; - } - } - return true; - } - - return false; -} - -CmkInfo *select_cmk_info(const bool has_set_all, unsigned int key_id) -{ - KmcMkInfo kmc_cmk_info = { 0 }; - /* only used for call the func of selecting cmk plian len */ - unsigned char cmk_plain[MAX_CMK_LEN] = {0}; - unsigned int cmk_plain_len = 0; - Time cmk_create_time = { 0 }; - Time cmk_expired_time = { 0 }; - CmkInfo *cmk_info_list = NULL; - errno_t rc = 0; - int all_cmk_cnt = 0; - - all_cmk_cnt = KmcGetMkCount(); - if (all_cmk_cnt <= 0) { - return NULL; - } - - cmk_info_list = (CmkInfo *)malloc(sizeof(CmkInfo)); - if (cmk_info_list == NULL) { - insert_format_log(L_MALLOC_MEMORY, KT_ERROR, ""); - return NULL; - } - cmk_info_list->cmk_id = INVALID_CMK_KD; - cmk_info_list->next = NULL; - - for (int i = 0; i < all_cmk_cnt; i++) { - if (KmcGetMk(i, &kmc_cmk_info) != WSEC_SUCCESS) { - destroy_cmk_info_list(cmk_info_list); - return NULL; - } - - if (kmc_cmk_info.domainId != DEFAULT_DOMAIN) { - continue; - } - - if (kmc_cmk_info.keyId == key_id || has_set_all) { - cmk_plain_len = sizeof(cmk_plain); - - if (KmcGetMkDetail(DEFAULT_DOMAIN, kmc_cmk_info.keyId, &kmc_cmk_info, cmk_plain, &cmk_plain_len) - == WSEC_SUCCESS) { - /* cmk plain is unused */ - rc = memset_s(cmk_plain, MAX_CMK_LEN, 0, sizeof(cmk_plain)); - securec_check_c(rc, "", ""); - - trans_wsectime_to_time(kmc_cmk_info.mkCreateTimeUtc, &cmk_create_time); - trans_wsectime_to_time(kmc_cmk_info.mkExpiredTimeUtc, &cmk_expired_time); - if (!add_cmk_info_node(cmk_info_list, kmc_cmk_info.keyId, cmk_plain_len, cmk_create_time, - cmk_expired_time)) { - destroy_cmk_info_list(cmk_info_list); - return NULL; - } - } - } - } - - return cmk_info_list; -} - -bool import_cmks_from_ksf(const char *ksf, const unsigned char *ksf_passwd, unsigned int ksf_pass_len) -{ - return (KmcImportMkFileEx(ksf, ksf_passwd, ksf_pass_len) == WSEC_SUCCESS); -} - -bool export_cmks_to_ksf(const bool has_set_export_ksf, const char *ksf, const unsigned char *ksf_passwd, - unsigned int ksf_pass_len) -{ - return_false_if(ksf_passwd == NULL); - - if (has_set_export_ksf) { - return (KmcExportMkFileEx(KMC_MKF_VER, ksf, ksf_passwd, ksf_pass_len, ITER_ROUND) == WSEC_SUCCESS); - } else { - return (KmcExportMkFileEx(KMC_MKF_VER, g_conf.export_ksf, ksf_passwd, ksf_pass_len, ITER_ROUND) == - WSEC_SUCCESS); - } -} - -bool select_rk_info(RkInfo *rk_info) -{ - KmcRkAttributes rk_attr = { 0 }; - Time today = { 0 }; - int days = 0; - - return_false_if(KmcGetRootKeyInfo(&rk_attr) != WSEC_SUCCESS); - - trans_wsectime_to_time(rk_attr.rkCreateTimeUtc, &rk_info->create_time); - trans_wsectime_to_time(rk_attr.rkExpiredTimeUtc, &rk_info->expired_time); - - /* check if cmk expired */ - if (!get_sys_time(&today)) { - insert_format_log(L_GET_TIME, KT_ERROR, ""); - } - days = calculate_interval(today, rk_info->expired_time); - if (days <= 0) { - rk_info->is_expired = true; - rk_info->expired_days = -days; - } else { - rk_info->is_expired = false; - rk_info->expired_days = 0; - } - - return true; -} - -bool cycle_rk(void) -{ - return (KmcUpdateRootKey(NULL, 0) == WSEC_SUCCESS); -} \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_key_manage.h b/src/bin/gs_ktool/kt_key_manage.h deleted file mode 100644 index ea204e35b1..0000000000 --- a/src/bin/gs_ktool/kt_key_manage.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_key_manage.cpp - * Foreword : before reading this part of code, you should be familiar with the principle for key classification; - * This part is mainly used for encrypted database; - * Describe : in the scenario of three-level-key-schema, we use rk (root key) to encrypt cmk (client master key), - * use cmk to encrypt cek (client encrypt key), use cek to encrypt data. We use KMC to manage cmk and rk; - * Function : cmk manage : 1) generate cmk; 2) delete cmk; 3) select cmk info; 4) export cmk; 5) import cmk; - * rk manage : 1) select rk info; 2) update rk; - * (this module calls KMC interfaces to realize the key management functions.) - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_key_manage.cpp - * - * ------------------------------------------------------------------------- - */ - -#ifndef GS_KT_KEY_MANAGE_H -#define GS_KT_KEY_MANAGE_H - -#include "kt_common.h" - -const int INVALID_CMK_KD = 0; -const unsigned int DEFAULT_RK_ITER = 10000; - -/* key configure limited by both KMC and me */ -const int MAX_CMK_QUANTITY = 4095; -const int MAX_KSF_PASS_BUF_LEN = 256; -const int MIN_KSF_PASS_LEN = 8; -const int ITER_ROUND = 10000; - -typedef struct RkInfo { - Time create_time; - Time expired_time; - bool is_expired; - unsigned int expired_days; -} RkInfo; - -typedef struct CmkInfo { - unsigned int cmk_id; - unsigned int cmk_plain_len; - Time create_time; - Time expired_time; - bool is_expired; - unsigned int expired_days; - struct CmkInfo *next; -} CmkInfo; - -/* Description : before opetating cmk and rk, gs_ktool needs to be initialized first. */ -extern bool reg_callback_funcs(void); -extern bool load_key_manage_conf(const char required_conf[MAX_CONF_ITEM_QUANTITY][MAX_CONF_KEY_LEN], - size_t required_conf_cnt); -extern bool has_ksf_existed(void); -extern bool init_or_create_ksf(void); -extern bool init_keytool(void); - -extern CmkInfo *init_cmk_info_list(); -extern bool add_cmk_info_node(CmkInfo *cmk_info_list, unsigned int cmk_id, unsigned int cmk_plain_len, - const Time cmk_create_time, const Time cmk_expired_time); -extern void trav_cmk_info_list(CmkInfo *cmk_info_list); -extern void destroy_cmk_info_list(CmkInfo *cmk_info_list); -extern void print_rk_info(const RkInfo *rk_info); - -/* functions to manage cmk : generate, delete, select, import, export. */ -extern bool generate_cmk(const bool has_set_len, unsigned int key_len, unsigned int *key_id); -extern bool delete_cmk(const bool has_set_all, unsigned int cmk_id, unsigned int del_cmk_id_list[], - unsigned int *del_cmk_cnt); -extern CmkInfo *select_cmk_info(const bool has_set_all, unsigned int key_id); -extern bool import_cmks_from_ksf(const char *ksf, const unsigned char *ksf_passwd, unsigned int ksf_pass_len); -extern bool export_cmks_to_ksf(const bool has_set_export_ksf, const char *ksf, const unsigned char *ksf_passwd, - unsigned int ksf_pass_len); - -/* functions to manage rk : select, cycle(update). */ -extern bool select_rk_info(RkInfo *rk_info); /* we can use the same Struct to describ rk_info */ -extern bool cycle_rk(void); - -#endif diff --git a/src/bin/gs_ktool/kt_kmc_callback.cpp b/src/bin/gs_ktool/kt_kmc_callback.cpp deleted file mode 100644 index 2148f6e80d..0000000000 --- a/src/bin/gs_ktool/kt_kmc_callback.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_kmc_callback.cpp - * Register callback functions of KMC : - * There are 8 types of callback functions, each type has several functions - * Wsec[Type]Callbacks : Callback[Func] - * type | func | set - * ----------+------------------------------------------------------------------+-------- - * mem | memAlloc, memFree, memCmp | default - * file | fileOpen, fileClose, fileRead, fileWrite, fileFlush, | - * | fileRemove, fileTell, fileSeek, fileEof, fileErrno | 11 - * lock | createLock, destroyLock, lock, unlock | 4 - * procLock | createProcLock, destroyProcLock, procLock, procUnlock | 4 - * basicRely | writeLog, notify, doEvents | 3 - * rng | getRandomNum, getEntropty, cleanupEntopy | 3 - * time | gmTimeSate | 1 - * hardWare | hwGetEncExtraData...(all 12) | - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_kmc_callback.cpp - * - * ------------------------------------------------------------------------- - */ - -#include "kt_kmc_callback.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kt_log_manage.h" - -const char *RND_DEVICE = "/dev/random"; -const int ENTROPY_BUFF_SIZE = 128; -const int MAX_PROCESS_LOCK_NAME_LEN = 256; - -static WsecBool KeCallbackCreateProcLock(WsecHandle *CProcLock); -static WsecVoid KeCallbackDestroyProcLock(WsecHandle DProcLock); -static WsecVoid KeCallbackProcLock(WsecHandle ProcLock); -static WsecVoid KeCallbackProcUnlock(WsecHandle ProcUnlock); -static WsecBool KeCallbackCreateThreadLock(WsecHandle *phMutex); -static WsecVoid KeCallbackDestroyThreadLock(WsecHandle phMutex); -static WsecVoid KeCallbackThreadLock(WsecHandle phMutex); -static WsecVoid KeCallbackThreadUnlock(WsecHandle phMutex); -static WsecHandle KeCallbackFopen(const char *filePathName, const KmcFileOpenMode mode); -static int KeCallbackFclose(WsecHandle stream); -/* only need to do single read process. the KMC caller has done the multiple read process */ -static WsecBool KeCallbackFread(WsecVoid *buffer, size_t count, WsecHandle stream); -/* remove fsync, just kmc will flush data or close file after WSEC_FWRITE */ -static WsecBool KeCallbackFwrite(const WsecVoid *buffer, size_t count, WsecHandle stream); -static int KeCallbackFflush(WsecHandle stream); -static int KeCallbackFremove(const char *path); -static long KeCallbackFtell(WsecVoid *stream); -/* return offset position if success(relative to file beginning), return -1 if failed */ -static long KeCallbackFseek(WsecVoid *stream, long offset, KmcFileSeekPos origin); -static int KeCallbackFeof(WsecVoid *stream, WsecBool *endOfFile); -static int KeCallbackFerrno(WsecVoid *stream); -static int KeCallbackFexist(const char *filePathName); -static WsecBool KeCallbackUtcTime(const time_t *curTime, struct tm *curTm); -static unsigned long GetRandomNumbers(unsigned char *buff, size_t len); -static WsecBool KeCallbackGetEntropy(unsigned char **ppEnt, size_t buffLen); -static WsecVoid KeCallbackCleanupEntropy(unsigned char *pEnt, size_t buffLen); -static WsecVoid KeCallbackDoEvents(void); -static WsecVoid KeCallbackNotify(WsecUint32 eNtfCode, const WsecVoid *pData, size_t nDataSize); -static WsecVoid KeCallbackWriteLog(int nLevel, const char *module, const char *function, int line, const char *logCtx); - -WsecBool KeCallbackCreateProcLock(WsecHandle* CProcLock) -{ - sem_t* h = NULL; - uid_t user_id = 0; - char user_pro_lock_name[MAX_PROCESS_LOCK_NAME_LEN] = {0}; - errno_t rc = 0; - int sem_val = 0; - int ret = 0; - - if (CProcLock == NULL) { - return WSEC_FALSE; - } - - user_id = getuid(); - rc = sprintf_s(user_pro_lock_name, MAX_PROCESS_LOCK_NAME_LEN, "GS_KTOOL_PROCESS_LOCK_FOR_%u", user_id); - securec_check_ss_c(rc, "", ""); - h = sem_open(user_pro_lock_name, O_CREAT, S_IRUSR | S_IWUSR, 1); - if (h == NULL) { - insert_format_log(L_OPEN_SEM, KT_ERROR, "semaphore name : '%s'", user_pro_lock_name); - return WSEC_FALSE; - } - - ret = sem_getvalue(h, &sem_val); - if (ret == -1) { - insert_format_log(L_OPEN_SEM, KT_ERROR, "semaphore name : '%s'", user_pro_lock_name); - return WSEC_FALSE; - } - - if (sem_val <= 0) { - if (sem_init(h, 0, 1) != 0) { - insert_format_log(L_INIT_SEM, KT_ERROR, "semaphore name : '%s', semaphore value : %d", - user_pro_lock_name, sem_val); - } - insert_format_log(L_INIT_SEM, KT_NOTICE, - "semaphore name : '%s', old semaphore value : %d, new semaphore value : 1", user_pro_lock_name, sem_val); - } - - *CProcLock = h; - return WSEC_TRUE; -} - -WsecVoid KeCallbackDestroyProcLock(WsecHandle DProcLock) -{ - sem_t* h = (sem_t*)DProcLock; - if (h != NULL) { - (void)sem_close(h); - } - return; -} - -WsecVoid KeCallbackProcLock(WsecHandle ProcLock) -{ - sem_t* h = (sem_t*)ProcLock; - int ret = 0; - ret = (sem_wait(h) == 0); - if (ret == WSEC_FALSE) { - insert_format_log(L_WAIT_SEM, KT_ERROR, ""); - } - return; -} - -WsecVoid KeCallbackProcUnlock(WsecHandle ProcUnlock) -{ - sem_t* h = (sem_t*)ProcUnlock; - int ret = 0; - ret = (sem_post(h) == 0); - if (ret == WSEC_FALSE) { - insert_format_log(L_POST_SEM, KT_ERROR, ""); - } - return; -} - -static WsecBool KeCallbackCreateThreadLock(WsecHandle *phMutex) -{ - if (phMutex == NULL) { - return WSEC_FALSE; - } - if (*phMutex != NULL) { - return WSEC_FALSE; - } - - pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); - if (mutex == NULL) { - return WSEC_FALSE; - } - - int result = pthread_mutex_init(mutex, NULL); - if (result != 0) { - kt_free(mutex); - return WSEC_FALSE; - } - *phMutex = mutex; - return WSEC_TRUE; -} - -static WsecVoid KeCallbackDestroyThreadLock(WsecHandle phMutex) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)phMutex; - if (mutex == NULL) { - return; - } - - pthread_mutex_destroy(mutex); - kt_free(mutex); -} - -static WsecVoid KeCallbackThreadLock(WsecHandle phMutex) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)phMutex; - if (mutex == NULL) { - return; - } - pthread_mutex_lock(mutex); -} - -static WsecVoid KeCallbackThreadUnlock(WsecHandle phMutex) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)phMutex; - if (mutex == NULL) { - return; - } - pthread_mutex_unlock(mutex); -} - -static WsecHandle KeCallbackFopen(const char *filePathName, const KmcFileOpenMode mode) -{ - int flag = 0; - int *ret = NULL; - if (mode == KMC_FILE_READ_BINARY) { - flag = O_RDONLY; - } else if (mode == KMC_FILE_WRITE_BINARY) { - flag = O_CREAT | O_WRONLY; - } else if (mode == KMC_FILE_READWRITE_BINARY) { - flag = O_CREAT | O_RDWR; - } else { - return NULL; - } - int retFd = open(filePathName, flag, S_IRUSR | S_IWUSR); - if (-1 != retFd) { - ret = (int *)malloc(sizeof(int)); - if (ret == NULL) { - insert_format_log(L_MALLOC_MEMORY, KT_ERROR, ""); - close(retFd); - return NULL; - } - *ret = retFd; - } - return ret; -} - -int KeCallbackFclose(WsecHandle stream) -{ - int fd = *(int *)stream; - int ret = close(fd); - kt_free(stream); - return ret; -} - -/* only need to do sigle read process. the KMC callee has done the multiple read process */ -static WsecBool KeCallbackFread(WsecVoid *buffer, size_t count, WsecHandle stream) -{ - int fd = *(int *)stream; - size_t ret = -1; - while (true) { - ret = read(fd, buffer, count); - if ((int)ret == -1 && errno == EINTR) { - continue; - } - break; - } - if ((int)ret == -1) { - return WSEC_FALSE; - } - return (count == ret) ? WSEC_TRUE : WSEC_FALSE; -} - -/* - * remove fsync, just kmc will flush data or close file after WSEC_FWRITE - */ -static WsecBool KeCallbackFwrite(const WsecVoid *buffer, size_t count, WsecHandle stream) -{ - int fd = *(int *)stream; - size_t ret = -1; - while (true) { - ret = write(fd, buffer, count); - if ((int)ret == -1 && errno == EINTR) { - continue; - } - break; - } - if ((int)ret == -1) { - return WSEC_FALSE; - } - return (count == ret) ? WSEC_TRUE : WSEC_FALSE; -} - -/* Return 0 if success, return -1 if failed */ -static int KeCallbackFflush(WsecHandle stream) -{ - return fsync(*(int *)stream); -} - -/* Return 0 if success, return -1 if failed */ -static int KeCallbackFremove(const char *path) -{ - return remove(path); -} - -static long KeCallbackFtell(WsecVoid *stream) -{ - return lseek(*(int *)stream, 0, SEEK_CUR); -} - -/* return offset position if success(relative to file beginning), return -1 if failed */ -static long KeCallbackFseek(WsecVoid *stream, long offset, KmcFileSeekPos origin) -{ - int realOri = 0; - int fd = *(int *)stream; - long ret; - if (origin == KMC_FILE_SEEK_CUR) { - realOri = SEEK_CUR; - } else if (origin == KMC_FILE_SEEK_SET) { - realOri = SEEK_SET; - } else if (origin == KMC_FILE_SEEK_END) { - realOri = SEEK_END; - } else { - return -1; - } - ret = lseek(fd, offset, realOri); - return ret; -} - -static int KeCallbackFeof(WsecVoid *stream, WsecBool *endOfFile) -{ - int fd = *(int *)stream; - long len; - long curPos; - if (endOfFile == NULL) { - return -1; - } - curPos = lseek(fd, 0, SEEK_CUR); - if (curPos == -1) { - return -1; - } - len = lseek(fd, 0, SEEK_END); - if (len == -1) { - return -1; - } - if (lseek(fd, curPos, SEEK_SET) != curPos) { - return -1; - } - if (len != curPos) { - *endOfFile = WSEC_FALSE; - } else { - *endOfFile = WSEC_TRUE; - } - return 0; -} -static int KeCallbackFerrno(WsecVoid *stream) -{ - return errno; -} - -static int KeCallbackFexist(const char *filePathName) -{ - return (access(filePathName, F_OK) == 0) ? WSEC_TRUE : WSEC_FALSE; -} - -static WsecBool KeCallbackUtcTime(const time_t *curTime, struct tm *curTm) -{ - return (gmtime_r(curTime, curTm) == NULL) ? WSEC_FALSE : WSEC_TRUE; -} - - -static unsigned long GetRandomNumbers(unsigned char *buff, size_t len) -{ - unsigned long ret = 0xF; - FILE *fet = NULL; - fet = fopen(RND_DEVICE, "rb"); - if (fet != NULL) { - if (len == fread(buff, 1, len, fet)) { - ret = 0; - } - fclose(fet); - fet = NULL; - } else { - insert_format_log(L_OPEN_FILE, KT_ERROR, "please make sure the device '%s' is avalilable", RND_DEVICE); - } - return ret; -} - -static WsecBool KeCallbackGetEntropy(unsigned char **ppEnt, size_t buffLen) -{ - errno_t rc = 0; - - if (buffLen <= 0 || buffLen > ENTROPY_BUFF_SIZE) { - return WSEC_FALSE; - } - *ppEnt = (unsigned char *)malloc(buffLen); - if (*ppEnt == NULL) { - return WSEC_FALSE; - } - if (GetRandomNumbers(*ppEnt, buffLen) != 0) { - rc = memset_s(*ppEnt, buffLen, 0, buffLen); - securec_check_c(rc, "", ""); - kt_free(*ppEnt); - return WSEC_FALSE; - } - return WSEC_TRUE; -} - -static WsecVoid KeCallbackCleanupEntropy(unsigned char *pEnt, size_t buffLen) -{ - errno_t rc = 0; - rc = memset_s(pEnt, buffLen, 0, buffLen); - securec_check_c(rc, "", ""); - kt_free(pEnt); -} - -static WsecVoid KeCallbackDoEvents(void) {} - -static WsecVoid KeCallbackNotify(WsecUint32 eNtfCode, const WsecVoid *pData, size_t nDataSize) -{ - (void)eNtfCode; - (void)pData; - (void)nDataSize; -} - -static WsecVoid KeCallbackWriteLog(int nLevel, const char *module, const char *function, int line, const char *logCtx) -{ - (void)nLevel; - (void)module; - (void)function; - (void)line; - (void)logCtx; -} - -unsigned long RegFunCallback() -{ - WsecCallbacks stMandatoryFun = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }; - - /* register application dependended callback functions */ - stMandatoryFun.basicRelyCallbacks.writeLog = KeCallbackWriteLog; - stMandatoryFun.basicRelyCallbacks.notify = KeCallbackNotify; - stMandatoryFun.basicRelyCallbacks.doEvents = KeCallbackDoEvents; - - /* Register Process Locker operation + Critical Section callback functions */ - stMandatoryFun.procLockCallbacks.createProcLock = KeCallbackCreateProcLock; - stMandatoryFun.procLockCallbacks.destroyProcLock = KeCallbackDestroyProcLock; - stMandatoryFun.procLockCallbacks.procLock = KeCallbackProcLock; - stMandatoryFun.procLockCallbacks.procUnlock = KeCallbackProcUnlock; - - /* Register Thread Locker + Critical Section callback functions */ - stMandatoryFun.lockCallbacks.createLock = KeCallbackCreateThreadLock; - stMandatoryFun.lockCallbacks.destroyLock = KeCallbackDestroyThreadLock; - stMandatoryFun.lockCallbacks.lock = KeCallbackThreadLock; - stMandatoryFun.lockCallbacks.unlock = KeCallbackThreadUnlock; - - /* Register File Operated related callback functions */ - stMandatoryFun.fileCallbacks.fileOpen = KeCallbackFopen; - stMandatoryFun.fileCallbacks.fileClose = KeCallbackFclose; - stMandatoryFun.fileCallbacks.fileRead = KeCallbackFread; - stMandatoryFun.fileCallbacks.fileWrite = KeCallbackFwrite; - stMandatoryFun.fileCallbacks.fileRemove = KeCallbackFremove; - stMandatoryFun.fileCallbacks.fileSeek = KeCallbackFseek; - stMandatoryFun.fileCallbacks.fileTell = KeCallbackFtell; - stMandatoryFun.fileCallbacks.fileFlush = KeCallbackFflush; - stMandatoryFun.fileCallbacks.fileEof = KeCallbackFeof; - stMandatoryFun.fileCallbacks.fileErrno = KeCallbackFerrno; - stMandatoryFun.fileCallbacks.fileExist = KeCallbackFexist; - - /* Register Random Number callback functions */ - stMandatoryFun.rngCallbacks.getRandomNum = NULL; - stMandatoryFun.rngCallbacks.getEntropy = KeCallbackGetEntropy; - stMandatoryFun.rngCallbacks.cleanupEntropy = KeCallbackCleanupEntropy; - - /* Register Time Related callback functions */ - stMandatoryFun.timeCallbacks.gmTimeSafe = KeCallbackUtcTime; - - unsigned long wsecRet = WsecRegFuncEx(&stMandatoryFun); - return wsecRet; -} diff --git a/src/bin/gs_ktool/kt_kmc_callback.h b/src/bin/gs_ktool/kt_kmc_callback.h deleted file mode 100644 index a5aea2c51e..0000000000 --- a/src/bin/gs_ktool/kt_kmc_callback.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_kmc_callback.cpp - * Register callback functions of KMC : - * There are 8 types of callback functions, each type has several functions - * Wsec[Type]Callbacks : Callback[Func] - * type | func | set - * ----------+------------------------------------------------------------------+-------- - * mem | memAlloc, memFree, memCmp | default - * file | fileOpen, fileClose, fileRead, fileWrite, fileFlush, | - * | fileRemove, fileTell, fileSeek, fileEof, fileErrno | 11 - * lock | createLock, destroyLock, lock, unlock | 4 - * procLock | createProcLock, destroyProcLock, procLock, procUnlock | 4 - * basicRely | writeLog, notify, doEvents | 3 - * rng | getRandomNum, getEntropty, cleanupEntopy | 3 - * time | gmTimeSate | 1 - * hardWare | hwGetEncExtraData...(all 12) | - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_kmc_callback.cpp - * - * ------------------------------------------------------------------------- - */ - -#ifndef GS_KT_CALLBACK_H -#define GS_KT_CALLBACK_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "wsecv2_errorcode.h" -#include "wsecv2_type.h" -#include "kmcv2_itf.h" -#include "wsecv2_itf.h" -#include "securec.h" -#include "securec_check.h" - -extern unsigned long RegFunCallback(); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_log_manage.cpp b/src/bin/gs_ktool/kt_log_manage.cpp deleted file mode 100644 index b42b410b8f..0000000000 --- a/src/bin/gs_ktool/kt_log_manage.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_log_manage.h - * Log manage module : - * 1. reading and writing log file; - * 2. providing log management interface. - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_log_manage.h - * - * ------------------------------------------------------------------------- - */ - -#include "kt_log_manage.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "kt_common.h" - -bool g_has_init_log_module = false; -static const char log_manage_conf[][MAX_CONF_KEY_LEN] = {"is_logmodule_open", "log_file"}; - -/* the log format recorded in log file : date time operation result [object] [level] information */ -static const KtLog g_log_type[] = { - /* log type operation object level */ - {L_CREATE_FILE, "create file", "system", "high"}, - {L_INIT_KMC, "initlize kmc", "system", "high"}, - {L_OPEN_FILE, "open file", "system", "high"}, - - {L_GEN_CMK, "generate cmk", "cmk", "high"}, - {L_DEL_CMK, "delete cmk", "cmk", "high"}, - {L_SELECT_CMK, "select cmk", "cmk", "high"}, - {L_EXPORT_CMK, "export cmk", "cmk", "high"}, - {L_IMPORT_CMK, "import cmk", "cmk", "high"}, - {L_SELECT_CMK_LEN, "select cmk len", "cmk", "high"}, - {L_SELECT_CMK_PLAIN, "select cmk plain", "cmk", "high"}, - - {L_SELECT_RK, "select rk", "rk", "high"}, - {L_UPDATE_RK, "update rk", "rk", "high"}, - {L_SET_RK_VALIDITY, "set rk validity", "rk", "high"}, - {L_CHECK_RK_VALIDITY, "check rk validity", "rk", "high"}, - - {L_PARSE_USER_INPUT, "parse user input", "user input", "low"}, - {L_CHECK_USER_INPUT, "check user input", "user input", "low"}, - - {L_READ_CONF, "read configuration", "configuration", "low"}, - {L_SET_CONF, "set configuration", "configuration", "low"}, - - {L_REG_CALLBACK_FUNC, "register callback function", "system", "middle"}, - {L_MALLOC_MEMORY, "malloc memory", "system", "middle"}, - {L_GET_TIME, "get system time", "system", "middle"}, - {L_GET_ENV_VALUE, "get environment value", "system", "middle"}, - {L_CHECK_ENV_VALUE, "check environment value", "system", "middle"}, - {L_OPEN_SEM, "open posix semaphore", "system", "middle"}, - {L_INIT_SEM, "init posix semaphore", "system", "middle"}, - {L_POST_SEM, "post posix semaphore", "system", "middle"}, - {L_WAIT_SEM, "wait posix semaphore", "system", "middle"}, -}; - -/* - * initialize log module. - * including read configure file, check or create log file. - */ -static bool set_global_env_value(); -static bool load_conf_file(void); -static bool load_log_manage_conf(); -static bool set_global_log_conf(LogManageConf log_conf, const char *conf_key, const char *conf_value); - -static bool has_exist_logfile(); -static bool create_logfile(); - -static void get_log_by_logtype(const KtLogType log_type, KtLog *log); -static char* log_class_enum_to_str(LogClass log_class); - -static bool set_global_env_value() -{ - char *gs_kt_file_path = NULL; - errno_t rc = 0; - /* - * this env path is not used alone, but used like : GS_KTOOL_FILE_PATH/filename - * so it is no need to check the path here, as well as the GAUSSHOME - */ - gs_kt_file_path = gs_getenv_r("GS_KTOOL_FILE_PATH"); - if (gs_kt_file_path == NULL || realpath(gs_kt_file_path, g_env_value) == NULL) { - /* try to get GAUSSHOME */ - gs_kt_file_path = gs_getenv_r("GAUSSHOME"); - /* fail to get GAUSSHOME and GS_KTOOL_FILE_PATH */ - if (gs_kt_file_path == NULL || realpath(gs_kt_file_path, g_env_value) == NULL) { - printf("ERROR: failed to get environment value : %s.\n", "GS_KTOOL_FILE_PATH"); - return false; - } - - /* fail to get GS_KTOOL_FILE_PATH but get GAUSSHOME */ - rc = sprintf_s(g_env_value, MAX_REAL_PATH_LEN, "%s/%s", gs_kt_file_path, "/etc/gs_ktool_file"); - securec_check_ss_c(rc, "", ""); - } - - if (!check_kt_env_value(gs_kt_file_path)) { - printf("ERROR: failed to check environment value, '$GS_KTOOL_FILE_PATH' contains dangerous character.\n"); - return false; - } - - return true; -} - -static bool load_conf_file(void) -{ - FILE *fp = NULL; - errno_t rc = 0; - - if (g_env_value == NULL || g_conf_file == NULL) { - return false; - } - - rc = sprintf_s(g_conf_file, MAX_REAL_PATH_LEN, "%s/%s", g_env_value, CONF_FILE_NAME); - securec_check_ss_c(rc, "", ""); - - if (!check_kt_env_value(g_conf_file)) { - printf("ERROR: environment value '%s' contains dangerous character.\n", g_conf_file); - return false; - } - - fp = fopen(g_conf_file, "rb"); - if (fp == NULL) { - insert_format_log(L_OPEN_FILE, KT_ERROR, - "please make sure the configuration file '$GS_KTOOL_FILE_PATH/gs_ktool_conf.ini' exists"); - return false; - } - fclose(fp); - - return true; -} - -static bool load_log_manage_conf() -{ - const char required_conf[][MAX_CONF_KEY_LEN] = {"is_logmodule_open", "log_file"}; - size_t required_conf_cnt = sizeof(required_conf) / sizeof(required_conf[0]); - - char key_list[MAX_CONF_ITEM_QUANTITY][MAX_CONF_KEY_LEN] = {0}; - char value_list[MAX_CONF_ITEM_QUANTITY][MAX_CONF_VALUE_LEN] = {0}; - size_t lost_conf_pos = 0; - size_t conf_item_cnt = 0; - bool is_set_log_conf = true; - - if (!read_conf_segment(g_conf_file, "LogManage", key_list, value_list, &conf_item_cnt)) { - insert_format_log(L_READ_CONF, KT_ERROR, "cannot find configuration segment : %s", "LogManage"); - return false; - } - - if (!compare_list_element(required_conf, required_conf_cnt, key_list, conf_item_cnt, &lost_conf_pos)) { - insert_format_log(L_READ_CONF, KT_ERROR, "lost configuration item : %s", required_conf[lost_conf_pos]); - return false; - } - - /* check confs (because the amount of data is small, use the algorithm whose time complexity is O(n^2)) */ - for (size_t i = 0; i < conf_item_cnt; i++) { - for (size_t j = 0; j < sizeof(log_manage_conf) / sizeof(log_manage_conf[0]); j++) { - if (strcmp(key_list[i], log_manage_conf[j]) == 0) { - switch (j) { - case IS_LOGMODULE_OPEN: - is_set_log_conf = set_global_log_conf(IS_LOGMODULE_OPEN, key_list[j], value_list[j]); - break; - case LOG_FILE: - is_set_log_conf = set_global_file(g_conf.log_file, G_LOG_FILE, value_list[j]); - break; - /* remain to add new log configuration */ - default: - break; - } - - if (!is_set_log_conf) { - return false; - } - } - } - } - - return true; -} - -static bool set_global_log_conf(LogManageConf log_conf, const char *conf_key, const char *conf_value) -{ - switch (log_conf) { - case IS_LOGMODULE_OPEN: - if (strcmp(conf_value, "ON") == 0) { - g_conf.is_logmodule_open = ON; - } else if (strcmp(conf_value, "OFF") == 0) { - g_conf.is_logmodule_open = OFF; - } else { - insert_format_log(L_SET_CONF, KT_ERROR, "the log configuration %s should be in one of {ON, OFF}", - conf_value); - return false; - } - break; - /* remain to add new log configuration : such as LOG_VALIDITY, LOG_QUANTITY and etc. */ - default: - break; - } - - return true; -} - -static bool has_exist_logfile() -{ - FILE *lfp = fopen(g_conf.log_file, "r"); - if (lfp == NULL) { - return false; - } - - fclose(lfp); - return true; -} - -static bool create_logfile() -{ - int logfile_handle = 0; - char log_file_header[MAX_LOG_RESULT_LEN] = { 0 }; - errno_t rc = 0; - - logfile_handle = open(g_conf.log_file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); - if (logfile_handle == -1) { - printf("ERROR: failed to create log file '%s'.\n", g_conf.log_file); - return false; - } - - /* create header */ - rc = sprintf_s(log_file_header, MAX_LOG_RESULT_LEN, "%-12s %-12s %-30s %-10s %-14s %-8s %s\n", "create_date", - "create_time", "operation", "result", "object", "level", "information"); - securec_check_ss_c(rc, "", ""); - - write(logfile_handle, log_file_header, strlen(log_file_header)); - close(logfile_handle); - - g_has_init_log_module = true; - - printf("NOTICE: created new log file : %s.\n", g_conf.log_file); - insert_format_log(L_CREATE_FILE, KT_NOTICE, "new log file : %s", g_conf.log_file); - - return true; -} - -bool initialize_logmodule() -{ - if (!set_global_env_value()) { - return false; - }; - - if (!load_conf_file()) { - return false; - } - - if (!load_log_manage_conf()) { - return false; - } - - if (g_conf.is_logmodule_open != ON) { - return false; - } - - if (!has_exist_logfile()) { - if (!create_logfile()) { - return false; - } - } - - g_has_init_log_module = true; - return true; -} - -static void get_log_by_logtype(const KtLogType log_type, KtLog *log) -{ - for (size_t i = 0; i < sizeof(g_log_type) / sizeof(g_log_type[0]); i++) { - if (g_log_type[i].log_type == log_type) { - *log = g_log_type[i]; - } - } -} - -static char* log_class_enum_to_str(LogClass log_class) -{ - char *log_class_str = NULL; - const char all_log_class[][MAX_LOG_CLASS_STR_LEN] = {"error", "succeeded", "alarm", "warning", "notice", "hint"}; - error_t rc = 0; - - log_class_str = (char *) malloc(MAX_LOG_CLASS_STR_LEN); - if (log_class_str == NULL) { - printf("ERROR: failed to malloc memory.\n"); - exit(1); - } - - rc = strcpy_s(log_class_str, MAX_LOG_CLASS_STR_LEN, all_log_class[log_class]); - securec_check_c(rc, "", ""); - - return log_class_str; -} - -void insert_raw_log(const KtLogType log_type, const LogClass log_class, const char op_info[MAX_OP_RESULT_LEN]) -{ - KtLog kt_log = {0}; - Time sys_time = {0}; - errno_t rc = 0; - char create_date[strlen("0000-00-00/")] = {0}; - char create_time[strlen("00:00:00/")] = {0}; - char *result = NULL; - FILE *lfp = NULL; - char log_buf[MAX_LOG_RESULT_LEN] = {0}; - - get_log_by_logtype(log_type, &kt_log); - - if (log_class == KT_ERROR && g_is_print_err) { - if (strlen(op_info) > 0) { - printf("ERROR: failed to %s, %s.\n", kt_log.operation, op_info); - } else { - printf("ERROR: failed to %s.\n", kt_log.operation); - } - } - - if (!g_has_init_log_module || g_conf.is_logmodule_open == OFF) { - return; - } - - if (!get_sys_time(&sys_time)) { - printf("ERROR: failed to get system time.\n"); - return; - } - date_ttos(sys_time, create_date, sizeof(create_date)); - time_ttos(sys_time, create_time, sizeof(create_time)); - - result = log_class_enum_to_str(log_class); - rc = sprintf_s(log_buf, MAX_LOG_RESULT_LEN, "%-12s %-12s %-30s %-10s %-14s %-8s %s\n", create_date, - create_time, kt_log.operation, result, kt_log.object, kt_log.level, op_info); - securec_check_ss_c(rc, "", ""); - kt_free(result); - - lfp = fopen(g_conf.log_file, "a"); - if (lfp == NULL) { - printf("ERROR: failed to open log file '%s'.\n", g_conf.log_file); - return; - } - fwrite(log_buf, strlen(log_buf), sizeof(char), lfp); - fclose(lfp); -} \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_log_manage.h b/src/bin/gs_ktool/kt_log_manage.h deleted file mode 100644 index 2e2abd4296..0000000000 --- a/src/bin/gs_ktool/kt_log_manage.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - * ------------------------------------------------------------------------- - * - * kt_log_manage.h - * Log manage module : - * 1. reading and writing log file; - * 2. providing log management interface. - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_log_manage.h - * - * ------------------------------------------------------------------------- - */ - -#ifndef GS_KT_LOG_MANAGE_H -#define GS_KT_LOG_MANAGE_H - -#include "kt_common.h" - -const int MAX_OP_LEN = 256; -const int MAX_OP_RESULT_LEN = 4096; -const int MAX_LOG_TYPE_STR_LEN = 15; -const int MAX_OBJECT_LEN = 15; -const int MAX_LOG_CLASS_STR_LEN = 15; - -enum LogClass { - KT_ERROR = 0, - KT_SUCCEED, - KT_ALARM, - KT_WARNING, - KT_NOTICE, - KT_HINT, -}; - -enum KtLogType { - L_CREATE_FILE = 0, - L_INIT_KMC, - - /* cmk manage */ - L_GEN_CMK, - L_DEL_CMK, - L_SELECT_CMK, - L_EXPORT_CMK, - L_IMPORT_CMK, - L_SELECT_CMK_LEN, - L_SELECT_CMK_PLAIN, - - /* rk manage */ - L_SELECT_RK, - L_UPDATE_RK, - L_SET_RK_VALIDITY, - L_CHECK_RK_VALIDITY, - - /* invalid cmd input */ - L_PARSE_USER_INPUT, - L_CHECK_USER_INPUT, - - /* invalid conf file input */ - L_READ_CONF, - L_SET_CONF, - - /* sys call */ - L_REG_CALLBACK_FUNC, - L_MALLOC_MEMORY, - L_GET_TIME, - L_OPEN_FILE, - L_GET_ENV_VALUE, - L_CHECK_ENV_VALUE, - L_OPEN_SEM, - L_INIT_SEM, - L_POST_SEM, - L_WAIT_SEM, -}; - -typedef struct KtLog { - int log_type; - char operation[MAX_OP_LEN]; - char object[MAX_OBJECT_LEN]; - char level[MAX_LOG_CLASS_STR_LEN]; -} KtLog; - -extern bool g_has_init_log_module; - -#define insert_format_log(log_type, log_class, format_info, ...) \ - { \ - errno_t def_rc = 0; \ - char res[MAX_LOG_RESULT_LEN] = {0}; \ - def_rc = sprintf_s(res, MAX_LOG_RESULT_LEN, format_info, ##__VA_ARGS__); \ - securec_check_ss_c(def_rc, "", ""); \ - insert_raw_log(log_type, log_class, res); \ - } - -extern bool initialize_logmodule(); -extern void insert_raw_log(const KtLogType log_type, const LogClass log_class, const char op_info[MAX_OP_RESULT_LEN]); - -#endif \ No newline at end of file diff --git a/src/bin/gs_ktool/kt_main.cpp b/src/bin/gs_ktool/kt_main.cpp deleted file mode 100644 index b5d0e361f0..0000000000 --- a/src/bin/gs_ktool/kt_main.cpp +++ /dev/null @@ -1,820 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * openGauss is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - *------------------------------------------------------------------------- - * - * kt_main.cpp - * Entry of gs_ktool : - * 1. parsing and checking commands read from the command line; - * 2. invoking executor to process commands. - * - * IDENTIFICATION - * src/bin/gs_ktool/kt_main.cpp - * - * ------------------------------------------------------------------------- - */ - -#include -#include -#include -#include -#include - -#include "kt_key_manage.h" -#include "kt_log_manage.h" -#include "kt_kmc_callback.h" - -const char *KT_VERSION = "gs_ktool V1.0.0 || KMC V3.0.0.SPC005"; -const int EXIT = 0; -const int NOT_EXIT = 1; -const int UNUSED = 0; -const int MIN_KSF_PASS_CHAR_TYPE = 3; - -const char *g_cmk_manage_arg[] = {"-g", "-l", "-d", "-s", "-i", "-e", "-f", "-p"}; -const char g_invalid_cmk_manage_arg[] = {0, 0, 0, 0, 0, 0, 0, 0}; -const int CMK_ARG_CNT = 8; - -typedef struct ArgValue { - bool has_set_all; - unsigned int cmk_id; - unsigned int cmk_len; - char ksf[MAX_REAL_PATH_LEN]; - char ksf_passwd[MAX_KSF_PASS_BUF_LEN]; -} ArgValue; - -typedef void (*ManageCmkHookFunc)(ArgValue *arg_value); - -typedef struct CmkManageFunc { - char arg_patten[CMK_ARG_CNT]; - ManageCmkHookFunc manage_cmk_func; - struct CmkManageFunc *next; -} CmkManageFunc; - -typedef struct CmkManageFuncList { - size_t node_cnt; - CmkManageFunc *first_node; -} CmkManageFuncList; - -enum ArgType { - ARG_G = 0, - ARG_L, - ARG_D, - ARG_S, - ARG_I, - ARG_E, - ARG_F, - ARG_P, -}; - -enum InputType { - I_KEY_ID = 0, - I_KEY_LEN, - I_KSF, -}; - -enum AdviseType { - HELP = 0, - INPUT_PASSWD, -}; - -enum PasswdCharType { - NUM = 0, - UPPER, - LOWER, - SYMBOL, -}; - -enum PasswdErrType { - LEGAL = 0, - INVALID_LEN, - INVALID_CHAR, - FEW_TYPES, -}; - -/* read command from terminal */ -int main(int argc, char *argv[]); -static void print_kt_version(void); -static void print_advise(AdviseType advise_type); -static void print_help_info(void); - -/* parse command */ -static void parse_cmd(int argc, char *argv[], char *arg_patten, ArgValue *arg_value); -static void parse_rk_manage_cmd(int argc, char *argv[]); - -/* check commnad */ -static bool get_passwd(char *passwd, const size_t pwbuf_size); -static PasswdErrType check_passwd(char *ksf_passwd); -static void report_passwd_err(PasswdErrType passwd_err); -static void check_user_input(const InputType input_type, const char *user_input); - -/* register commnad and process funcs */ -static bool is_arg_patten_equal(const char base_list[CMK_ARG_CNT], const char new_list[CMK_ARG_CNT]); -static bool reg_cmk_manage_func(CmkManageFuncList *cmk_manage_func_list, CmkManageFunc *new_func_node); -static CmkManageFunc *create_cmk_manage_func(const char arg_patten[CMK_ARG_CNT], ManageCmkHookFunc manage_cmk_func); -static void destroy_cmk_manage_func_list(CmkManageFuncList *cmk_manage_func_list); -static void reg_all_cmk_manage_func(CmkManageFuncList *cmk_manage_func_list); - -/* process command */ -static void process_cmd(const char arg_patten[CMK_ARG_CNT], ArgValue *arg_value); -static void process_gen_cmk_cmd(ArgValue *arg_value); -static void process_del_cmk_cmd(ArgValue *arg_value); -static void process_select_cmk_cmd(ArgValue *arg_value); -static void process_import_cmk_cmd(ArgValue *arg_value); -static void process_export_cmk_cmd(ArgValue *arg_value); - -/* entry to all commands */ -int main(int argc, char *argv[]) -{ - /* cmk manage args: -g -l -d -s -i -e -f -p */ - char arg_patten[] = {0, 0, 0, 0, 0, 0, 0, 0}; - ArgValue arg_value = { 0 }; - - if (!initialize_logmodule()) { - exit(1); - } - - if (argc <= 1) { - print_help_info(); - exit(0); - } else if (argc > 6) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "the number of parameters exceeds the upper limit"); - exit(1); - } - - /* start parsing single CLI commands */ - if (strcmp(argv[1], "-?") == 0) { - print_help_info(); - } else if (strcmp(argv[1], "-R") == 0) { - parse_rk_manage_cmd(argc, argv); - } else { - /* unrecognized commnads will also be processed in this func */ - parse_cmd(argc, argv, arg_patten, &arg_value); - process_cmd((const char *)arg_patten, &arg_value); - } - - return 0; -} - -static void print_advise(AdviseType advise_type) -{ - switch (advise_type) { - case HELP: - printf("HINT: try '-h' or '-?' for more infromation.\n"); - break; - case INPUT_PASSWD: - printf("WARNING:it is safer to enter password interactively than use '-p'\n"); - default: - break; - } -} - -static void print_kt_version(void) -{ - printf("%s\n", KT_VERSION); -} - -static void print_help_info(void) -{ - printf("Description: gs_ktool is a CMK(Client Master Key) & RK(Root Key) management tool.\n"); - printf("\n"); - printf("Usage:\n"); - printf(" gs_ktool [OPTION] [[CMK_ID] \"all\" [FILE] [FILE_PASSWD] ...]\n"); - printf("\n"); - printf("General options:\n"); - printf(" %-7s %-40s\n", "-v", "Select gs_ktool version."); - printf(" %-7s %-40s\n", "-h/-?", "Select help info."); - printf("\n"); - printf("CMK management options:\n"); - printf(" %-7s %-40s\n", "-g", "Generate a CMK, can use '-l' to set key length."); - printf(" %-7s %-40s\n", "-l", "Set the key length while generating CMK."); - printf(" %-7s %-40s\n", "-d", "Delete specified CMK or delete all."); - printf(" %-7s %-40s\n", "-s", "Select specified CMK info or select all."); - printf(" %-7s %-40s\n", "-e", - "Export all CMKs to ksf, can use '-f' to set export file, can use '-p' to set password."); - printf(" %-7s %-40s\n", "-i", - "Import all CMKs from ksf, should use '-f' to specify import file, can use '-p' to specify password."); - printf(" %-7s %-40s\n", "-f", "Set or specify key store file while exporting or importing all keys."); - printf(" %-7s %-40s\n", "-p", - "Set or specify the password of key store file while exporting or importing all keys."); - printf("\n"); - printf("RK management options:\n"); - printf(" %-7s %-40s\n", "-R -s", "Select RK info."); - printf(" %-7s %-40s\n", "-R -u", "Update RK."); -} - -static void parse_cmd(int argc, char *argv[], char *arg_patten, ArgValue *arg_value) -{ - errno_t rc = 0; - bool is_passwd_too_long = false; - - /* extern global variables in "getopt.h" */ - optind = 1; - /* optarg */ - - const char *optstring = "vhgl:d:s:ief:p:"; - static struct option long_options[] = {0}; /* remain */ - int cur_arg = 0; - int cur_pos = 0; - - arg_value->has_set_all = false; - - while (optind < argc) { - cur_pos++; - - cur_arg = getopt_long(argc, argv, optstring, long_options, NULL); - if (cur_arg == -1) { - insert_format_log(L_PARSE_USER_INPUT, KT_HINT, "unknown option '%s'", argv[cur_pos]); - print_advise(HELP); - exit(1); - } - - switch (cur_arg) { - case 'v': - printf("VERSION\n"); - print_kt_version(); - exit(0); - case 'h': - printf("HELP\n"); - print_help_info(); - exit(0); - case 'g': - arg_patten[ARG_G]++; - break; - case 'l': - check_user_input(I_KEY_LEN, optarg); - arg_value->cmk_len = atoi(optarg); - arg_patten[ARG_L]++; - break; - case 'd': - check_user_input(I_KEY_ID, optarg); - if (strcmp(optarg, "all") == 0) { - arg_value->has_set_all = true; - } else { - arg_value->cmk_id = atoi(optarg); - } - arg_patten[ARG_D]++; - break; - case 's': - check_user_input(I_KEY_ID, optarg); - if (strcmp(optarg, "all") == 0) { - arg_value->has_set_all = true; - } else { - arg_value->cmk_id = atoi(optarg); - } - arg_patten[ARG_S]++; - break; - case 'i': - arg_patten[ARG_I]++; - break; - case 'e': - arg_patten[ARG_E]++; - break; - case 'f': - check_user_input(I_KSF, optarg); - rc = strcpy_s(arg_value->ksf, sizeof(arg_value->ksf), optarg); - securec_check_c(rc, "", ""); - arg_patten[ARG_F]++; - break; - case 'p': - print_advise(INPUT_PASSWD); - if (strlen(optarg) >= MAX_KSF_PASS_BUF_LEN) { - is_passwd_too_long = true; - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the password is too long"); - } else { - rc = strcpy_s(arg_value->ksf_passwd, sizeof(arg_value->ksf_passwd), optarg); - securec_check_c(rc, "", ""); - arg_patten[ARG_P]++; - } - - rc = memset_s(optarg, strlen(optarg), 0, strlen(optarg)); - securec_check_c(rc, "", ""); - if (is_passwd_too_long) { - exit(1); - } - break; - case '?': - insert_format_log(L_PARSE_USER_INPUT, KT_HINT, "unknown option '%s'", argv[cur_pos]); - print_advise(HELP); - exit(1); - default: - print_advise(HELP); - exit(1); - } - } -} - -static void parse_rk_manage_cmd(int argc, char *argv[]) -{ - /* extern global variables in "getopt.h" */ - optind = 1; - /* optarg */ - int option_index; - - const char *optstring = "Rsu"; - static struct option long_options[] = {0}; - int cur_arg = 0; - int cur_pos = 0; - unsigned char is_exit = NOT_EXIT; - RkInfo rk_info = { 0 }; - - if (argc != 3) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "unrecognized root key management option combination"); - print_advise(HELP); - exit(1); - } - - if (!init_keytool()) { - exit(1); - } - - while (is_exit == NOT_EXIT) { - is_exit = EXIT; - cur_arg = getopt_long(argc, argv, optstring, long_options, &option_index); - cur_pos++; - - if (cur_arg == -1) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "unknown root key management option '%s'", argv[cur_pos]); - print_advise(HELP); - break; - } - - switch (cur_arg) { - case 'R': - is_exit = NOT_EXIT; - break; - case 's': - if (select_rk_info(&rk_info)) { - insert_format_log(L_SELECT_RK, KT_SUCCEED, ""); - print_rk_info(&rk_info); - } else { - insert_format_log(L_SELECT_RK, KT_ERROR, ""); - } - break; - case 'u': - if (cycle_rk()) { - printf("UPDATE ROOTKEY\n"); - insert_format_log(L_UPDATE_RK, KT_SUCCEED, ""); - } else { - insert_format_log(L_UPDATE_RK, KT_ERROR, ""); - } - break; - default: - print_advise(HELP); - break; - } - } - - WsecFinalizeEx(); -} - -static bool get_passwd(char *passwd, const size_t pwbuf_size) -{ - char *tmp_buf = NULL; - error_t rc = 0; - - if (strlen(passwd) > 0) { - return true; - } - - tmp_buf = getpass("please input the password of key store file :"); - if (tmp_buf == NULL) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "cannot get password"); - return false; - } - - rc = strcpy_s(passwd, pwbuf_size, tmp_buf); - securec_check_c(rc, "", ""); - - rc = memset_s(tmp_buf, strlen(tmp_buf), 0, strlen(tmp_buf)); - securec_check_c(rc, "", ""); - kt_free(tmp_buf); - - return true; -} - -static PasswdErrType check_passwd(char *ksf_passwd) -{ - char chara_type_cnt = 0; - bool has_chara_type[4] = {false, false, false, false}; /* [num, upper letter, lower letter, symbol] */ - const char legal_symbol[] = " !#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; - bool is_legal_symbol = false; - error_t rc = 0; - - if (strlen(ksf_passwd) < MIN_KSF_PASS_LEN || strlen(ksf_passwd) >= MAX_KSF_PASS_BUF_LEN) { - rc = memset_s(ksf_passwd, strlen(ksf_passwd), 0, strlen(ksf_passwd)); - securec_check_c(rc, "", ""); - return INVALID_LEN; - } - - for (size_t i = 0; i < strlen(ksf_passwd); i++) { - if (ksf_passwd[i] >= '0' && ksf_passwd[i] <= '9') { - has_chara_type[NUM] = true; - } else if (ksf_passwd[i] >= 'A' && ksf_passwd[i] <= 'Z') { - has_chara_type[UPPER] = true; - } else if (ksf_passwd[i] >= 'a' && ksf_passwd[i] <= 'z') { - has_chara_type[LOWER] = true; - } else { - for (size_t j = 0; j < sizeof(legal_symbol) / sizeof(legal_symbol[0]); j++) { - if (ksf_passwd[i] == legal_symbol[j]) { - is_legal_symbol = true; - has_chara_type[SYMBOL] = true; - break; - } - } - - if (is_legal_symbol == false) { - rc = memset_s(ksf_passwd, strlen(ksf_passwd), 0, strlen(ksf_passwd)); - securec_check_c(rc, "", ""); - return INVALID_CHAR; - } - - is_legal_symbol = false; - } - } - - for (size_t i = 0; i < sizeof(has_chara_type) / sizeof(has_chara_type[0]); i++) { - chara_type_cnt += has_chara_type[i]; - } - - if (chara_type_cnt < MIN_KSF_PASS_CHAR_TYPE) { - rc = memset_s(ksf_passwd, strlen(ksf_passwd), 0, strlen(ksf_passwd)); - securec_check_c(rc, "", ""); - return FEW_TYPES; - } - - return LEGAL; -} - -static void report_passwd_err(PasswdErrType passwd_err) -{ - switch (passwd_err) { - case INVALID_LEN: - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the password length should be in range [%d, %d)", - MIN_KSF_PASS_LEN, MAX_KSF_PASS_BUF_LEN); - break; - case INVALID_CHAR: - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the password contains invalid character"); - break; - case FEW_TYPES: - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the password should contain 3 types of characters"); - break; - default: - break; - } -} - -static void check_user_input(const InputType input_type, const char *user_input) -{ - char real_path_file[MAX_REAL_PATH_LEN] = { 0 }; - unsigned int input_num = 0; - - switch (input_type) { - case I_KEY_ID: - if (strcmp(optarg, "all") == 0 || strcmp(optarg, "all\n") == 0) { - break; - } else { - if (!atoi_strictly(user_input, &input_num)) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, - "this input '%s' is expected to be an positive integer", user_input); - exit(1); - } - if (input_num < 1 || input_num > MAX_CMK_QUANTITY) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the key id '%s' should be in range [1, %d]", - user_input, MAX_CMK_QUANTITY); - exit(1); - } - } - break; - case I_KEY_LEN: - if (!atoi_strictly(user_input, &input_num)) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, - "this input '%s' is expected to be an positive integer", user_input); - exit(1); - } - if (input_num < MIN_CMK_LEN || input_num > MAX_CMK_LEN) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the key len '%s' should be in range [%d, %d]", - user_input, MIN_CMK_LEN, MAX_CMK_LEN); - exit(1); - } - break; - case I_KSF: - if (strlen(user_input) >= MAX_REAL_PATH_LEN) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the length of key store file name is too long"); - exit(1); - } - - realpath(user_input, real_path_file); - if (!check_kt_env_value(real_path_file)) { - insert_format_log(L_CHECK_USER_INPUT, KT_ERROR, "the path '%s' is invalid", real_path_file); - exit(1); - } - break; - default: - break; - } -} - -static bool is_arg_patten_equal(const char base_list[CMK_ARG_CNT], const char new_list[CMK_ARG_CNT]) -{ - for (int i = 0; i < CMK_ARG_CNT; i++) { - if (base_list[i] != new_list[i]) { - if (new_list[i] > 1) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "too many options : '%s'", g_cmk_manage_arg[i]); - exit(1); - } - return false; - } - } - - return true; -} - -static bool reg_cmk_manage_func(CmkManageFuncList *cmk_manage_func_list, CmkManageFunc *new_func_node) -{ - CmkManageFunc *last_node = NULL; - - if (cmk_manage_func_list == NULL || new_func_node == NULL) { - return false; - } - - if (cmk_manage_func_list->first_node == NULL) { - cmk_manage_func_list->first_node = new_func_node; - cmk_manage_func_list->node_cnt++; - return true; - } - - last_node = cmk_manage_func_list->first_node; - while (last_node->next != NULL) { - last_node = last_node->next; - } - - last_node->next = new_func_node; - cmk_manage_func_list->node_cnt++; - return true; -} - -static CmkManageFunc *create_cmk_manage_func(const char arg_patten[CMK_ARG_CNT], ManageCmkHookFunc manage_cmk_func) -{ - errno_t rc = 0; - CmkManageFunc *cmk_manage_func = NULL; - - cmk_manage_func = (CmkManageFunc *)malloc(sizeof(CmkManageFunc)); - if (cmk_manage_func == NULL) { - insert_format_log(L_MALLOC_MEMORY, KT_ERROR, ""); - return NULL; - } - - rc = memcpy_s(cmk_manage_func->arg_patten, CMK_ARG_CNT, arg_patten, CMK_ARG_CNT); - securec_check_c(rc, "", ""); - - cmk_manage_func->manage_cmk_func = manage_cmk_func; - cmk_manage_func->next = NULL; - - return cmk_manage_func; -} - -static void destroy_cmk_manage_func_list(CmkManageFuncList *cmk_manage_func_list) -{ - CmkManageFunc *cur_node = NULL; - CmkManageFunc *to_free = NULL; - - cur_node = cmk_manage_func_list->first_node; - while (cur_node != NULL) { - to_free = cur_node; - cur_node = cur_node->next; - kt_free(to_free); - } -} - -static void reg_all_cmk_manage_func(CmkManageFuncList *cmk_manage_func_list) -{ - const char support_patten[][CMK_ARG_CNT] = { - /* g l d s i e f p */ - {1, 0, 0, 0, 0, 0, 0, 0}, - {1, 1, 0, 0, 0, 0, 0, 0}, - {0, 0, 1, 0, 0, 0, 0, 0}, - {0, 0, 0, 1, 0, 0, 0, 0}, - {0, 0, 0, 0, 1, 0, 1, 1}, - {0, 0, 0, 0, 1, 0, 1, 0}, - {0, 0, 0, 0, 0, 1, 0, 0}, - {0, 0, 0, 0, 0, 1, 0, 1}, - {0, 0, 0, 0, 0, 1, 1, 1}, - {0, 0, 0, 0, 0, 1, 1, 0}, - }; - const ManageCmkHookFunc manage_cmk_func[] = { - process_gen_cmk_cmd, - process_gen_cmk_cmd, - process_del_cmk_cmd, - process_select_cmk_cmd, - process_import_cmk_cmd, - process_import_cmk_cmd, - process_export_cmk_cmd, - process_export_cmk_cmd, - process_export_cmk_cmd, - process_export_cmk_cmd, - }; - CmkManageFunc *new_func_node = NULL; - - for (size_t i = 0; i < sizeof(support_patten) / sizeof(support_patten[0]); i++) { - new_func_node = create_cmk_manage_func(support_patten[i], manage_cmk_func[i]); - if (!reg_cmk_manage_func(cmk_manage_func_list, new_func_node)) { - kt_free(new_func_node); - destroy_cmk_manage_func_list(cmk_manage_func_list); - exit(1); - } - } -} - -static void process_cmd(const char arg_patten[CMK_ARG_CNT], ArgValue *arg_value) -{ - CmkManageFuncList cmk_manage_func_list = {0, NULL}; - CmkManageFunc *cur_func = NULL; - bool is_arg_patten_legal = false; - - /* step 1 : register key manage function */ - reg_all_cmk_manage_func(&cmk_manage_func_list); - - cur_func = cmk_manage_func_list.first_node; - while (cur_func != NULL) { - if (is_arg_patten_equal(cur_func->arg_patten, arg_patten)) { - is_arg_patten_legal = true; - - /* step 2 : init gs_ktool */ - if (!init_keytool()) { - break; - } - - /* step 3 : call key manage function to process arg_value */ - cur_func->manage_cmk_func(arg_value); - break; - } - cur_func = cur_func->next; - } - - if (is_arg_patten_legal == false) { - insert_format_log(L_PARSE_USER_INPUT, KT_ERROR, "unrecognized option combination"); - print_advise(HELP); - } - - /* step 4 : clean call back functions and kmc */ - destroy_cmk_manage_func_list(&cmk_manage_func_list); - WsecFinalizeEx(); -} - -static void process_gen_cmk_cmd(ArgValue *arg_value) -{ - unsigned int cmk_id = 0; - - if (arg_value->cmk_len == 0) { - if (generate_cmk(false, UNUSED, &cmk_id)) { - printf("GENERATE\n%u\n", cmk_id); - insert_format_log(L_GEN_CMK, KT_SUCCEED, "new cmk : %u", cmk_id); - } else { - insert_format_log(L_GEN_CMK, KT_ERROR, ""); - } - } else { - if (generate_cmk(true, arg_value->cmk_len, &cmk_id)) { - printf("GENERATE\n%u\n", cmk_id); - insert_format_log(L_GEN_CMK, KT_SUCCEED, "new cmk : %d, cmk len : %d", cmk_id, arg_value->cmk_len); - } else { - insert_format_log(L_GEN_CMK, KT_ERROR, ""); - } - } -} - -static void process_del_cmk_cmd(ArgValue *arg_value) -{ - unsigned int del_cmk_id_list[MAX_CMK_QUANTITY] = {0}; - unsigned int del_cmk_cnt = 0; - - if (arg_value->has_set_all == true) { - if (delete_cmk(true, UNUSED, del_cmk_id_list, &del_cmk_cnt)) { - printf("DELETE ALL\n"); - for (unsigned int i = 0; i < del_cmk_cnt; i++) { - printf(" %u", del_cmk_id_list[i]); - } - printf("\n"); - insert_format_log(L_DEL_CMK, KT_SUCCEED, "deleted all") - } else { - insert_format_log(L_DEL_CMK, KT_ERROR, ""); - } - } else { - if (delete_cmk(false, arg_value->cmk_id, { 0 }, &del_cmk_cnt)) { - printf("DELETE\n%u\n", arg_value->cmk_id); - insert_format_log(L_DEL_CMK, KT_SUCCEED, "delete cmk : %d", arg_value->cmk_id); - } else { - insert_format_log(L_DEL_CMK, KT_ERROR, "which id is '%s'", optarg); - } - } -} - -static void process_select_cmk_cmd(ArgValue *arg_value) -{ - CmkInfo *cmk_info_list = NULL; - - if (arg_value->has_set_all == true) { - cmk_info_list = select_cmk_info(true, UNUSED); - if (cmk_info_list == NULL) { - insert_format_log(L_SELECT_CMK, KT_ERROR, ""); - return; - } else { - printf("SELECT ALL\n"); - trav_cmk_info_list(cmk_info_list); - insert_format_log(L_SELECT_CMK, KT_SUCCEED, "select all"); - } - } else { - cmk_info_list = select_cmk_info(false, arg_value->cmk_id); - if (cmk_info_list == NULL) { - insert_format_log(L_SELECT_CMK, KT_ERROR, "which id is '%s'", optarg); - return; - } else { - printf("SELECT\n"); - trav_cmk_info_list(cmk_info_list); - insert_format_log(L_SELECT_CMK, KT_SUCCEED, "select : %d", arg_value->cmk_id); - } - } - - destroy_cmk_info_list(cmk_info_list); -} - -static void process_import_cmk_cmd(ArgValue *arg_value) -{ - unsigned int ksf_pass_len = 0; - CmkInfo *cmk_info_list = NULL; - PasswdErrType pw_err = LEGAL; - - if (!get_passwd(arg_value->ksf_passwd, sizeof(arg_value->ksf_passwd))) { - return; - } - - pw_err = check_passwd(arg_value->ksf_passwd); - if (pw_err != LEGAL) { - insert_format_log(L_IMPORT_CMK, KT_ERROR, - "please make sure the key store file '%s' is legal and the password is correct", arg_value->ksf); - return; - } - - ksf_pass_len = strlen(arg_value->ksf_passwd); - if (import_cmks_from_ksf(arg_value->ksf, (unsigned char *)arg_value->ksf_passwd, ksf_pass_len)) { - printf("SAFE IMPORT\n%s\n", arg_value->ksf); - cmk_info_list = select_cmk_info(true, UNUSED); - if (cmk_info_list == NULL) { - insert_format_log(L_SELECT_CMK, KT_ERROR, ""); - return; - } else { - trav_cmk_info_list(cmk_info_list); - insert_format_log(L_SELECT_CMK, KT_SUCCEED, "select all"); - } - insert_format_log(L_IMPORT_CMK, KT_SUCCEED, "import from : '%s'", arg_value->ksf); - } else { - insert_format_log(L_IMPORT_CMK, KT_ERROR, - "please make sure the key store file '%s' is legal and the password is correct", arg_value->ksf); - } - - destroy_cmk_info_list(cmk_info_list); -} - -static void process_export_cmk_cmd(ArgValue *arg_value) -{ - unsigned int ksf_pass_len = 0; - bool ret = false; - PasswdErrType pw_err = LEGAL; - errno_t rc = 0; - - if (!get_passwd(arg_value->ksf_passwd, sizeof(arg_value->ksf_passwd))) { - return; - } - - pw_err = check_passwd(arg_value->ksf_passwd); - if (pw_err != LEGAL) { - report_passwd_err(pw_err); - return; - } - - ksf_pass_len = strlen(arg_value->ksf_passwd); - - if (strlen(arg_value->ksf) > 0) { - ret = export_cmks_to_ksf(true, arg_value->ksf, (unsigned char *)arg_value->ksf_passwd, ksf_pass_len); - } else { - ret = export_cmks_to_ksf(false, NULL, (unsigned char *)arg_value->ksf_passwd, ksf_pass_len); - rc = strcpy_s(arg_value->ksf, sizeof(arg_value->ksf), "path configured in gs_ktool_conf.ini"); - securec_check_c(rc, "", ""); - } - - if (ret) { - printf("SAFE EXPORT\n%s\n", arg_value->ksf); - insert_format_log(L_EXPORT_CMK, KT_SUCCEED, "exported to : '%s'", arg_value->ksf); - } else { - insert_format_log(L_EXPORT_CMK, KT_ERROR, "please check the path : '%s'", arg_value->ksf); - } -} \ No newline at end of file diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile index cfb75a7644..eeac40dbfb 100644 --- a/src/bin/pg_dump/Makefile +++ b/src/bin/pg_dump/Makefile @@ -59,7 +59,7 @@ all: submake-aes gs_dump gs_restore gs_dumpall libpq_pgport:=$(subst -lpq,-lpq_ce,$(libpq_pgport)) ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -libpq_pgport += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc +libpq_pgport += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc endif gs_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(KEYWRDOBJS) $(COMMON_OBJS) | submake-libpq_ce submake-libpgport diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile index 38d75b7a47..d1ad626368 100644 --- a/src/bin/psql/Makefile +++ b/src/bin/psql/Makefile @@ -24,7 +24,7 @@ SGMLDIR= $(top_builddir)/doc/src/sgml override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump -DHAVE_CE $(CPPFLAGS) ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -CPPFLAGS += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc +CPPFLAGS += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc endif $(top_builddir)/src/common/interfaces/libpq/client_logic_processor/stmt_processor.o: @@ -72,7 +72,7 @@ all: submake-aes gsql libpq_pgport:=$(subst -lpq,-lpq_ce,$(libpq_pgport)) ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -libpq_pgport += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc +libpq_pgport += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc endif $(top_builddir)/src/lib/elog/elog.a: diff --git a/src/common/interfaces/libpq/Makefile b/src/common/interfaces/libpq/Makefile index 9b59217662..b3255a234c 100755 --- a/src/common/interfaces/libpq/Makefile +++ b/src/common/interfaces/libpq/Makefile @@ -29,7 +29,7 @@ override CPPFLAGS += -I$(top_builddir)/$(subdir)/client_logic_hooks/encryption_h ifeq "$(ENABLE_CE)" "1" override CPPFLAGS += -DHAVE_CE -DWORDS_BIGENDIAN ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -override CPPFLAGS += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc +override CPPFLAGS += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -L$(LIBKMC_LIB_PATH) -lkmc endif endif @@ -175,7 +175,7 @@ endif ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) all: gs_ktool all-lib-depends gs_ktool: - $(MAKE) -C $(top_builddir)/src/bin/gs_ktool + $(MAKE) -C $(top_builddir)/src/distribute/bin/gs_ktool else all: all-lib-depends endif diff --git a/src/common/interfaces/libpq/client_logic_hooks/Makefile b/src/common/interfaces/libpq/client_logic_hooks/Makefile index ee851da094..c31babf2dd 100755 --- a/src/common/interfaces/libpq/client_logic_hooks/Makefile +++ b/src/common/interfaces/libpq/client_logic_hooks/Makefile @@ -20,7 +20,7 @@ override CPPFLAGS := -DFRONTEND -DFRONTEND_PARSER -DPGXC -fstack-protector-all - override CPPFLAGS += -I$(top_builddir)/src/common/interfaces/libpq/ -I$(top_builddir)/src/include/libpq/ -I$(top_builddir)/src/include/libpq/client_logic_cache override CPPFLAGS += -I$(top_builddir)/src/common/interfaces/libpq/client_logic_hooks -I$(encryption_hooks_dir) ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -override CPPFLAGS += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc +override CPPFLAGS += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc endif override CPPFLAGS := $(filter-out -fPIE, $(CPPFLAGS)) -fPIC -shared override CFLAGS := $(filter-out -fPIE, $(CFLAGS)) -fPIC -shared diff --git a/src/common/interfaces/libpq/client_logic_hooks/encryption_hooks/Makefile b/src/common/interfaces/libpq/client_logic_hooks/encryption_hooks/Makefile index 63d1b46ece..721f00c1b2 100644 --- a/src/common/interfaces/libpq/client_logic_hooks/encryption_hooks/Makefile +++ b/src/common/interfaces/libpq/client_logic_hooks/encryption_hooks/Makefile @@ -18,7 +18,7 @@ NAME=client_logic_encryption_hooks override CPPFLAGS := -DFRONTEND -DPGXC -Wno-write-strings -fstack-protector-all -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/ -I$(top_builddir)/src/include -I$(top_builddir)/src/include/libpq -I$(top_builddir)/src/common/interfaces/libpq -I$(top_builddir)/src/common/interfaces/libpq/client_logic_hooks/ -I. override CPPFLAGS += -lsecurec -lssl -lcrypto ifneq ($(enable_multiple_nodes)_$(enable_privategauss), no_no) -override CPPFLAGS += -L$(top_builddir)/src/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc +override CPPFLAGS += -L$(top_builddir)/src/distribute/bin/gs_ktool/ -lgs_ktool -lsecurec -L$(LIBKMC_LIB_PATH) -lkmc endif override CPPFLAGS := $(filter-out -fPIE, $(CPPFLAGS)) -fPIC -shared override CFLAGS := $(filter-out -fPIE, $(CFLAGS)) -fPIC -shared -- Gitee