void swupd_deinit(void) { terminate_signature(); swupd_curl_deinit(); free_globals(); v_lockfile(); dump_file_descriptor_leaks(); }
void swupd_deinit(int lock_fd) { terminate_signature(); swupd_curl_cleanup(); free_subscriptions(); free_globals(); v_lockfile(lock_fd); dump_file_descriptor_leaks(); }
/* this function is intended to encapsulate the basic swupd * initializations for the majority of commands, that is: * - Make sure root is the user running the code * - Initialize globals * - initialize mounted directories * - Create necessary directories * - Get the lock * - Initialize curl * - Initialize signature checking */ int swupd_init(void) { int ret = 0; check_root(); record_fds(); /* Check that our system time is reasonably valid before continuing, * or the certificate verification will fail with invalid time */ if (timecheck) { if (!verify_time()) { ret = EBADTIME; goto out_fds; } } if (!init_globals()) { ret = EINIT_GLOBALS; goto out_fds; } get_mounted_directories(); if (create_required_dirs()) { ret = EREQUIRED_DIRS; goto out_fds; } if (p_lockfile() < 0) { ret = ELOCK_FILE; goto out_fds; } if (swupd_curl_init() != 0) { ret = ECURL_INIT; goto out_close_lock; } /* If --nosigcheck, we do not attempt any signature checking */ if (sigcheck && !initialize_signature()) { ret = ESIGNATURE; terminate_signature(); goto out_close_lock; } return ret; out_close_lock: v_lockfile(); out_fds: dump_file_descriptor_leaks(); return ret; }
/* this function is intended to encapsulate the basic swupd * initializations for the majority of commands, that is: * - Make sure root is the user running the code * - Initialize log facility * - Get the lock * - initialize mounted directories * - Initialize curl */ int swupd_init(int *lock_fd) { int ret = 0; check_root(); if (!init_globals()) { ret = EINIT_GLOBALS; goto out_fds; } get_mounted_directories(); if (create_required_dirs()) { ret = EREQUIRED_DIRS; goto out_fds; } *lock_fd = p_lockfile(); if (*lock_fd < 0) { ret = ELOCK_FILE; goto out_fds; } if (swupd_curl_init() != 0) { ret = ECURL_INIT; goto out_close_lock; } if (!initialize_signature()) { ret = ESIGNATURE; terminate_signature(); goto out_close_lock; } return ret; out_close_lock: v_lockfile(*lock_fd); out_fds: dump_file_descriptor_leaks(); return ret; }