| 344 | |
| 345 | |
| 346 | def get_encryption_lib_path(args): |
| 347 | if args.encrypt_lib is not None: |
| 348 | lib_path = args.encrypt_lib |
| 349 | |
| 350 | if not os.path.isfile(lib_path): |
| 351 | err = "Could not find manually specified encryption library {}".format(lib_path) |
| 352 | log.error(err) |
| 353 | raise Exception(err) |
| 354 | else: |
| 355 | # win32 doesn't mean necessarily 32 bits |
| 356 | if sys.platform == "win32" or sys.platform == "cygwin": |
| 357 | if platform.architecture()[0] == '64bit': |
| 358 | lib_name = "encrypt64bit.dll" |
| 359 | else: |
| 360 | lib_name = "encrypt32bit.dll" |
| 361 | |
| 362 | elif sys.platform == "darwin": |
| 363 | lib_name = "libencrypt-osx-64.so" |
| 364 | |
| 365 | elif os.uname()[4].startswith("arm") and platform.architecture()[0] == '32bit': |
| 366 | lib_name = "libencrypt-linux-arm-32.so" |
| 367 | |
| 368 | elif os.uname()[4].startswith("aarch64") and platform.architecture()[0] == '64bit': |
| 369 | lib_name = "libencrypt-linux-arm-64.so" |
| 370 | |
| 371 | elif sys.platform.startswith('linux'): |
| 372 | if "centos" in platform.platform(): |
| 373 | if platform.architecture()[0] == '64bit': |
| 374 | lib_name = "libencrypt-centos-x86-64.so" |
| 375 | else: |
| 376 | lib_name = "libencrypt-linux-x86-32.so" |
| 377 | else: |
| 378 | if platform.architecture()[0] == '64bit': |
| 379 | lib_name = "libencrypt-linux-x86-64.so" |
| 380 | else: |
| 381 | lib_name = "libencrypt-linux-x86-32.so" |
| 382 | |
| 383 | elif sys.platform.startswith('freebsd'): |
| 384 | lib_name = "libencrypt-freebsd-64.so" |
| 385 | |
| 386 | else: |
| 387 | err = "Unexpected/unsupported platform '{}'. If you have encrypt lib compiled for your platform, specify its location with '--encrypt-lib' parameter".format(sys.platform) |
| 388 | log.error(err) |
| 389 | raise Exception(err) |
| 390 | |
| 391 | lib_path = os.path.join(os.path.dirname(__file__), "libencrypt", lib_name) |
| 392 | |
| 393 | if not os.path.isfile(lib_path): |
| 394 | err = "Could not find {} encryption library {}".format(sys.platform, lib_path) |
| 395 | log.error(err) |
| 396 | raise Exception(err) |
| 397 | |
| 398 | return lib_path |
| 399 | |
| 400 | |
| 401 | class Timer(): |