TRUST_ANCHOR_ERROR_OUT_OF_MEMORY = -ENOMEM,
TRUST_ANCHOR_ERROR_PERMISSION_DENIED = -EACCES,
TRUST_ANCHOR_ERROR_NO_SUCH_FILE = -ENOENT,
- TRUST_ANCHOR_ERROR_INTERNAL = TRUST_ANCHOR_ERROR_BASE | 0x01
+ TRUST_ANCHOR_ERROR_INTERNAL = TRUST_ANCHOR_ERROR_BASE | 0x01,
+ TRUST_ANCHOR_ERROR_NOT_INSTALLED = TRUST_ANCHOR_ERROR_BASE | 0x02
} trust_anchor_error_e;
* @retval #TRUST_ANCHOR_ERROR_PERMISSION_DENIED Permission denied error
* @retval #TRUST_ANCHOR_ERROR_NO_SUCH_FILE No such file or directory error
* @retval #TRUST_ANCHOR_ERROR_INTERNAL Internal error
+ * @retval #TRUST_ANCHOR_ERROR_NOT_INSTALLED Not installed error
* @see trust_anchor_install()
*/
int trust_anchor_launch(const char *package_id, uid_t uid);
int ret = trust_anchor_launch("pkgid", uid);
if (ret != TRUST_ANCHOR_ERROR_NONE) {
+ if (ret == TRUST_ANCHOR_ERROR_NOT_INSTALLED)
+ printf("This package is not installed with trsut-anchor.");
+
printf("Failed to launch operation");
return -1;
}
INFO(SINK, "Success to make pkg custom bundle.");
}
+bool Logic::isCustomBaseValid(void) const
+{
+ runtime::File customBaseDir(this->m_customBasePath);
+ return customBaseDir.exists();
+}
+
bool Logic::isPkgCertsValid(const std::string &path) const
{
runtime::File file(path);
void makeCustomCerts(void);
void makeCustomBundle(void);
+ bool isCustomBaseValid(void) const;
void setPkgCertsPath(const std::string &path) const;
std::string getPkgCertsPath(void) const;
void TrustAnchor::Impl::preLaunch(void)
{
+ if (!this->m_logic.isCustomBaseValid())
+ ThrowExc(TRUST_ANCHOR_ERROR_NOT_INSTALLED, "Base directory does not exist.");
+
if (!this->m_logic.isSystemCertsUsed())
return;
- DEBUG(SINK, "This package use system certificates.");
+ DEBUG(SINK, "This package uses system certificates.");
if (this->m_logic.isSystemCertsModified()) {
WARN(SINK, "System certificates be changed. Do re-install for refresh.");
this->install(this->m_logic.getPkgCertsPath(), true);
#include <unistd.h>
#include <iostream>
+#include <thread>
#include "test-util.hxx"
#include "test-resource.hxx"
TEST_EXPECT(true, beforeCat == afterCatParent);
}
}
+
+TESTCASE(TRUST_ANCHOR_LAUNCH_NOT_INSTALLED)
+{
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ tanchor::TrustAnchor ta(DUMMY_PKG_ID, DUMMY_UID);
+ int ret = ta.uninstall();
+ TEST_EXPECT(true, ret == TRUST_ANCHOR_ERROR_NONE);
+
+ // pre-condition
+ int pid = fork();
+ TEST_EXPECT(true, pid >= 0);
+
+ if (pid == 0) {
+ ret = ta.launch();
+ TEST_EXPECT(true, ret == TRUST_ANCHOR_ERROR_NOT_INSTALLED);
+
+ exit(0);
+ }
+}
+