Skip to content

Commit db0925d

Browse files
committed
Address a few more python setuptools upgrade issues
The current version of python setuptools no longer puts binary files in the same name directory tree as the python libraries. As a result, the eservice and pservice enclaves could not be found and loaded. This commit addresses the problem with several changes: 1) the names of the enclave libraries are now unique (libpdo-eservice-enclave.signed.so and libpdo-pservice-enclave.signed.so) 2) the enclave libraries are installed into the PDO_HOME directory tree (in the lib directory). This directory is now created when the rest of the enviroment is created. 3) the search path used by the pservice and eservice python modules reflect the new location. 4) cachetools is explicitly installed Signed-off-by: Mic Bowman <mic.bowman@intel.com>
1 parent a7253b9 commit db0925d

File tree

10 files changed

+42
-31
lines changed

10 files changed

+42
-31
lines changed

build/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ $(DSTDIR) :
8989
@mkdir -p $(DSTDIR)/opt/pdo/etc/keys/sgx
9090
@mkdir -p $(DSTDIR)/opt/pdo/etc/keys/ledger
9191
@mkdir -p $(DSTDIR)/opt/pdo/keys
92+
@mkdir -p $(DSTDIR)/opt/pdo/lib
9293
@mkdir -p $(DSTDIR)/opt/pdo/logs
9394

9495
verify-pre-build :

build/python_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build>=0.10.0
2+
cachetools>=5.5.2
23
colorlog>=6.7.0
34
importlib_resources>=6.0.0
45
lmdb>=1.4.0

eservice/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525

2626
EGG_FILE=dist/pdo_eservice-${MOD_VERSION}-py${PY_VERSION}-linux-x86_64.egg
2727

28-
ENCLAVE_LIB=deps/bin/libpdo-enclave.signed.so
28+
ENCLAVE_LIB=deps/bin/libpdo-eservice-enclave.signed.so
2929

3030
SWIG_SOURCES = \
3131
pdo_enclave_internal.i\

eservice/lib/libpdo_enclave/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
1616

17-
PROJECT(libpdo-enclave CXX C)
17+
PROJECT(libpdo-eservice-enclave CXX C)
1818

1919
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2020
# Source Code

eservice/pdo/eservice/pdo_enclave.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
# -----------------------------------------------------------------
6767
# -----------------------------------------------------------------
6868
def __find_enclave_library(config) :
69-
enclave_file_name = 'libpdo-enclave.signed.so'
69+
enclave_file_name = 'libpdo-eservice-enclave.signed.so'
7070
enclave_file_path = None
7171

7272
if config :
@@ -78,18 +78,18 @@ def __find_enclave_library(config) :
7878
if os.path.exists(filep) :
7979
return filep
8080
else :
81+
install_directory = os.environ.get('PDO_HOME', '/opt/pdo')
8182
script_directory = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
83+
8284
search_path = [
8385
script_directory,
84-
os.path.abspath(os.path.join(script_directory, '..')),
85-
os.path.abspath(os.path.join(script_directory, '..', 'lib')),
86-
os.path.abspath(os.path.join(script_directory, '..', '..')),
87-
os.path.abspath(os.path.join(script_directory, '..', '..', 'lib')),
88-
os.path.abspath(os.path.join('/usr', 'lib'))
86+
os.path.abspath(os.path.join(install_directory, 'lib')),
8987
]
9088

9189
return putils.find_file_in_path(enclave_file_name, search_path)
9290

91+
raise IOError("Could not find enclave shared object: {}".format(enclave_file_name))
92+
9393
# -----------------------------------------------------------------
9494
# -----------------------------------------------------------------
9595
def update_sig_rl():
@@ -149,7 +149,8 @@ def initialize_with_configuration(config) :
149149
'{}'.format(
150150
', '.join(sorted(list(missing_keys)))))
151151

152-
NumberOfEnclaves = int(config.get('NumberOfEnclaves', 1))
152+
# NumberOfEnclaves = int(config.get('NumberOfEnclaves', 1))
153+
NumberOfEnclaves = 2
153154

154155
try:
155156
spid = Path(os.path.join(config['sgx_key_root'], "sgx_spid.txt")).read_text().strip()
@@ -166,10 +167,16 @@ def initialize_with_configuration(config) :
166167

167168
if not _pdo:
168169
signed_enclave = __find_enclave_library(config)
169-
logger.debug("Attempting to load enclave at: %s", signed_enclave)
170-
_pdo = enclave.pdo_enclave_info(signed_enclave, spid, NumberOfEnclaves)
171-
logger.info("Basename: %s", get_enclave_basename())
172-
logger.info("MRENCLAVE: %s", get_enclave_measurement())
170+
logger.error("Attempting to load enclave at: %s", signed_enclave)
171+
logger.error(f'SPID: {spid}, NumberOfEnclaves: {NumberOfEnclaves}')
172+
try :
173+
_pdo = enclave.pdo_enclave_info(signed_enclave, spid, NumberOfEnclaves)
174+
except Exception as e:
175+
logger.exception(e)
176+
raise e
177+
178+
logger.error("Basename: %s", get_enclave_basename())
179+
logger.error("MRENCLAVE: %s", get_enclave_measurement())
173180

174181
sig_rl_updated = False
175182
while not sig_rl_updated:

eservice/setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
bin_dir = os.path.join(install_root_dir, "bin")
3434
dat_dir = os.path.join(install_root_dir, "data")
3535
etc_dir = os.path.join(install_root_dir, "etc")
36+
lib_dir = os.path.join(install_root_dir, "lib")
3637
log_dir = os.path.join(install_root_dir, "logs")
3738
key_dir = os.path.join(install_root_dir, "keys")
3839

@@ -44,11 +45,11 @@
4445
(etc_dir, []),
4546
(log_dir, []),
4647
(key_dir, []),
47-
('lib', [ os.path.join(script_dir, 'deps/bin/libpdo-enclave.signed.so')])
48+
(lib_dir, [ os.path.join(script_dir, 'deps/bin/libpdo-eservice-enclave.signed.so')])
4849
]
4950

5051
ext_deps = [
51-
'deps/bin/libpdo-enclave.signed.so'
52+
'deps/bin/libpdo-eservice-enclave.signed.so'
5253
]
5354

5455
## -----------------------------------------------------------------

pservice/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525

2626
EGG_FILE=dist/pdo_pservice-${MOD_VERSION}-py${PY_VERSION}-linux-x86_64.egg
2727

28-
ENCLAVE_LIB=deps/bin/libpdo-enclave.signed.so
28+
ENCLAVE_LIB=deps/bin/libpdo-pservice-enclave.signed.so
2929

3030
SWIG_SOURCES = \
3131
pdo_enclave_internal.i\

pservice/lib/libpdo_enclave/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
1616

17-
PROJECT(libpdo-enclave C CXX)
17+
PROJECT(libpdo-pservice-enclave C CXX)
1818

1919
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2020
# Source Code

pservice/pdo/pservice/pdo_enclave.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pdo.pservice.utility import ias_client
2626

2727
import pdo.common.crypto as crypto
28+
import pdo.common.utility as putils
2829
import pdo.pservice.enclave.pdo_enclave_internal as enclave
2930

3031
import logging
@@ -59,30 +60,29 @@
5960
# -----------------------------------------------------------------
6061
# -----------------------------------------------------------------
6162
def __find_enclave_library(config) :
62-
enclave_file_name = config.get('enclave_library', 'libpdo-enclave.signed.so')
63-
enclave_file_path = config.get('enclave_library_path')
63+
enclave_file_name = 'libpdo-pservice-enclave.signed.so'
64+
enclave_file_path = None
65+
66+
if config :
67+
enclave_file_name = config.get('enclave_library', enclave_file_name)
68+
enclave_file_path = config.get('enclave_library_path', enclave_file_path)
6469

6570
if enclave_file_path :
6671
enclave_file = os.path.join(enclave_file_path, enclave_file_name);
6772
if os.path.exists(enclave_file) :
6873
return enclave_file
6974
else :
75+
install_directory = os.environ.get('PDO_HOME', '/opt/pdo')
7076
script_directory = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
77+
7178
search_path = [
7279
script_directory,
73-
os.path.abspath(os.path.join(script_directory, '..')),
74-
os.path.abspath(os.path.join(script_directory, '..', 'lib')),
75-
os.path.abspath(os.path.join(script_directory, '..', '..')),
76-
os.path.abspath(os.path.join(script_directory, '..', '..', 'lib')),
77-
os.path.abspath(os.path.join('/usr', 'lib'))
80+
os.path.abspath(os.path.join(install_directory, 'lib')),
7881
]
7982

80-
for path in search_path :
81-
enclave_file = os.path.join(path, enclave_file_name)
82-
if os.path.exists(enclave_file) :
83-
return enclave_file
83+
return putils.find_file_in_path(enclave_file_name, search_path)
8484

85-
raise IOError("Could not find enclave shared object")
85+
raise IOError("Could not find enclave shared object: {}".format(enclave_file_name))
8686

8787
# -----------------------------------------------------------------
8888
# -----------------------------------------------------------------

pservice/setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
bin_dir = os.path.join(install_root_dir, "bin")
3434
dat_dir = os.path.join(install_root_dir, "data")
3535
etc_dir = os.path.join(install_root_dir, "etc")
36+
lib_dir = os.path.join(install_root_dir, "lib")
3637
log_dir = os.path.join(install_root_dir, "logs")
3738
key_dir = os.path.join(install_root_dir, "keys")
3839

@@ -42,11 +43,11 @@
4243
(etc_dir, [ 'etc/sample_pservice.toml' ]),
4344
(log_dir, []),
4445
(key_dir, []),
45-
('lib', [ os.path.join(script_dir, 'deps/bin/libpdo-enclave.signed.so')])
46+
(lib_dir, [ os.path.join(script_dir, 'deps/bin/libpdo-pservice-enclave.signed.so')])
4647
]
4748

4849
ext_deps = [
49-
'deps/bin/libpdo-enclave.signed.so'
50+
'deps/bin/libpdo-pservice-enclave.signed.so'
5051
]
5152

5253
## -----------------------------------------------------------------

0 commit comments

Comments
 (0)