*/
int subsession_unregister_bus_watch_callback(subsession_watch_context *ctx);
+/**
+ * @brief Request sessiond to recreate its internal cache
+ * @since_tizen 9.0
+ *
+ * @return This function does return error if it occurred
+ * @retval #SUBSESSION_ERROR_IO_ERROR Unable to regegenerate cache
+ * @remarks This function is to be used when system's /etc/skel changes.
+ * sessiond caches it's contents to be able to perform fast user
+ * additions. If original filesystem changed the cache needs to
+ * be rebuilt. Supposed to be called from pkgmgr plugin only.
+ */
+int subsession_regenerate_cache(void);
+
#ifdef __cplusplus
}
#endif
gchar * GetUserList;
gchar * SwitchUserDone;
gchar * GetCurrentUser;
+ gchar * RegenerateCache;
} dbus_method_call = {
.AddUser = "AddUser",
.RemoveUserDone = "RemoveUserDone",
.GetUserList = "GetUserList",
.SwitchUserDone = "SwitchUserDone",
- .GetCurrentUser = "GetCurrentUser"
+ .GetCurrentUser = "GetCurrentUser",
+ .RegenerateCache = "RegenerateCache"
};
typedef struct {
return SUBSESSION_ERROR_NONE;
}
+
+// This is privileged call
+EXPORT_API int subsession_regenerate_cache(void)
+{
+ return_with_log_error_result_(method_call_async(dbus_method_call.RegenerateCache, g_variant_new("()"), NULL, NULL));
+}
if (isRestoreOnly(argc, argv)) {
restore_all_user_sessions();
} else if (isGenSkel(argc, argv)) {
- regenerate_skel();
+ regenerate_skel_cache();
} else {
g_sessiond_context = std::make_unique <sessiond_context> ();
restore_all_user_sessions();
#include "globals.hpp"
#include "fs_helpers.hpp"
#include "main_restore.hpp"
+#include "main_skel.hpp"
#include "os_ops.hpp"
#include "tuple_g_variant_helpers.hpp"
#include "tuple_hash.hpp"
g_dbus_method_invocation_return_value(invocation, ret);
}
+ void on_regenerate_cache(GDBusMethodInvocation *invocation, std::string_view sender, GVariant *parameters)
+ {
+ LOGD("Regenerate Skel Cache started");
+ try {
+ regenerate_skel_cache();
+ } catch (std::exception& ex) {
+ g_dbus_method_invocation_return_dbus_error(invocation,
+ get_dbus_error_mapping(SUBSESSION_ERROR_IO_ERROR), ex.what());
+ throw;
+ }
+ LOGD("Regenerate Skel Cache succesfully finished");
+ }
+
static void glib_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data)
{
auto self = static_cast<sessiond_context *>(user_data);
"<arg name=\"session_uid\" type=\"i\" direction=\"in\"/>"
"<arg name=\"subsession_id\" type=\"s\" direction=\"out\"/>"
"</method>"
+ "<method name=\"RegenerateCache\">"
+ "</method>"
"<signal name=\"AddUserStarted\">"
"<arg name=\"session_uid\" type=\"i\" direction=\"out\"/>"
"<arg name=\"subsession_id\" type=\"s\" direction=\"out\"/>"
std::make_pair( "SwitchUserDone"sv, &sessiond_context::on_switch_user_done ),
std::make_pair( "GetUserList"sv, &sessiond_context::on_get_user_list ),
std::make_pair( "GetCurrentUser"sv, &sessiond_context::on_get_current_user ),
+ std::make_pair( "RegenerateCache"sv, &sessiond_context::on_regenerate_cache ),
};
// TODO: Currently, the first parameter is always a single-element tuple.
}
-int regenerate_skel()
+void regenerate_skel_cache(void)
{
print_creds();
continue;
}
}
-
- return 0;
}
#pragma once
-void regenerate_skel();
+void regenerate_skel_cache(void);
INCLUDE(GNUInstallDirs)
pkg_check_modules(deps REQUIRED
+ IMPORTED_TARGET
dlog
capi-system-info
pkgmgr-info
ADD_LIBRARY(libsessiond-update-skelimg SHARED plugin.c)
TARGET_COMPILE_OPTIONS(libsessiond-update-skelimg PUBLIC -fPIC ${deps_CFLAGS})
-TARGET_LINK_LIBRARIES(libsessiond-update-skelimg PRIVATE ${deps_LDFLAGS})
+TARGET_LINK_LIBRARIES(libsessiond-update-skelimg PRIVATE ${deps_LDFLAGS} libsessiond)
INSTALL(TARGETS libsessiond-update-skelimg LIBRARY DESTINATION /etc/package-manager/parserlib/)
INSTALL(FILES sessiond-update-skelimg.info DESTINATION /usr/share/parser-plugins/)
#include <libxml/tree.h>
#include <pkgmgr-info.h>
#include <stdlib.h>
+#include "sessiond.h"
+#include "sessiond-platform.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
#define LOG_TAG "SESSIOND_GEN_SKEL_IMG"
static int gen_skel(void) {
- // The logic for skel generation is not in plugin to make it possible to call it also manually during image build
- return system("/usr/bin/sessiond --regenerate-skel");
+ (void)subsession_regenerate_cache();
+
+ // Failure to regenerate cache should not cause package to not install
+ // NOTE: sessiond has to also depend on other mechanisms (eg. compare timestamp of cached data vs timestamp of skel to ensure data is up to date
+ return 0;
}
EXPORT_API