Commit c56c3eec authored by Jussi Laakkonen's avatar Jussi Laakkonen

Merge branch 'jb49506' into 'master'

[connman] Add vpnd crash recovery functionality. Fixes JB#49506

See merge request mer-core/connman!270
parents 2877561f 0dc4cc02
......@@ -593,19 +593,15 @@ tools_dbus_test_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ @DBUS_LIBS@
tools_polkit_test_LDADD = @DBUS_LIBS@
tools_iptables_test_CFLAGS = -DDEFAULT_STORAGE_ROOT=\""$(storageroot)"\" \
-DDEFAULT_USER_STORAGE=\""$(userstorage)"\" \
@DBUS_CFLAGS@
tools_iptables_test_SOURCES = $(backtrace_sources) src/log.c src/storage.c \
tools_iptables_test_CFLAGS = @DBUS_CFLAGS@
tools_iptables_test_SOURCES = $(backtrace_sources) src/log.c \
src/inotify.c src/iptables.c tools/iptables-test.c \
src/error.c src/dbus.c
tools_iptables_test_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ \
@XTABLES_LIBS@ @LIBIPTC_LIBS@ @DBUS_LIBS@ -ldl
tools_ip6tables_test_CFLAGS = -DDEFAULT_STORAGE_ROOT=\""$(storageroot)"\" \
-DDEFAULT_USER_STORAGE=\""$(userstorage)"\" \
@DBUS_CFLAGS@
tools_ip6tables_test_SOURCES = $(backtrace_sources) src/log.c src/storage.c \
tools_ip6tables_test_CFLAGS = @DBUS_CFLAGS@
tools_ip6tables_test_SOURCES = $(backtrace_sources) src/log.c \
src/inotify.c src/iptables.c tools/ip6tables-test.c \
src/error.c src/dbus.c
tools_ip6tables_test_LDADD = gdbus/libgdbus-internal.la @GLIB_LIBS@ \
......
......@@ -59,9 +59,10 @@ struct connman_notifier {
void (*idle_state) (bool idle);
void (*tethering_changed) (struct connman_technology *tech, bool on);
void (*device_status_changed) (struct connman_device *device, bool on);
void (*storage_uid_changed) (uid_t uid);
/* Placeholders for future extensions */
void (*_reserved[9])(void);
void (*_reserved[8])(void);
/* api_level will remain zero (and ignored) until we run out of
* the above placeholders. Hopefully, forever. */
......
......@@ -1035,6 +1035,30 @@ static void config_notify_handler(struct inotify_event *event,
g_hash_table_remove(config_table, ident);
}
static char *user_storage_dir = NULL;
static void uid_changed(uid_t uid)
{
if (user_storage_dir) {
connman_inotify_unregister(user_storage_dir,
config_notify_handler, NULL);
g_free(user_storage_dir);
}
/* If not set USER_STORAGEDIR is NULL */
user_storage_dir = g_strdup(USER_STORAGEDIR);
if (uid != geteuid())
connman_inotify_register(user_storage_dir,
config_notify_handler, NULL, NULL);
}
static struct connman_notifier config_notifier = {
.name = "config",
.priority = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
.storage_uid_changed = uid_changed
};
int __connman_config_init(void)
{
DBG("");
......@@ -1043,6 +1067,7 @@ int __connman_config_init(void)
NULL, unregister_config);
connman_inotify_register(STORAGEDIR, config_notify_handler, NULL, NULL);
connman_notifier_register(&config_notifier);
return read_configs();
}
......@@ -1053,8 +1078,16 @@ void __connman_config_cleanup(void)
cleanup = true;
connman_notifier_unregister(&config_notifier);
connman_inotify_unregister(STORAGEDIR, config_notify_handler, NULL);
if (user_storage_dir) {
connman_inotify_unregister(user_storage_dir,
config_notify_handler, NULL);
g_free(user_storage_dir);
}
g_hash_table_destroy(config_table);
config_table = NULL;
......
......@@ -307,6 +307,9 @@ struct connman_storage_callbacks {
/* Additional data to be passed on finalize callback */
void *finalize_user_data;
/* Callback for notifying about user change. */
void (*uid_changed) (uid_t uid);
/* Callback to create access policy for connmand storage.*/
struct connman_access_storage_policy* (*access_policy_create)
(const char *spec);
......@@ -985,6 +988,7 @@ void __connman_notifier_tethering_changed(struct connman_technology* tech,
bool on);
void __connman_notifier_device_status_changed(struct connman_device *device,
bool on);
void __connman_notifier_storage_uid_changed(uid_t uid);
bool __connman_notifier_is_connected(void);
const char *__connman_notifier_get_state(void);
......
......@@ -840,6 +840,7 @@ static struct connman_storage_callbacks storage_callbacks = {
.unload = __connman_service_unload_services,
.load = __connman_service_load_services,
.post = __connman_technology_enable_from_config,
.uid_changed = __connman_notifier_storage_uid_changed,
.access_policy_create = __connman_access_storage_policy_create,
.access_change_user = __connman_access_storage_change_user,
.access_policy_free = __connman_access_storage_policy_free,
......
......@@ -400,6 +400,21 @@ void __connman_notifier_device_status_changed(struct connman_device *device,
}
}
void __connman_notifier_storage_uid_changed(uid_t uid)
{
GSList *l = notifier_list;
while (l) {
GSList *next = l->next;
const struct connman_notifier *notifier = l->data;
if (notifier->storage_uid_changed)
notifier->storage_uid_changed(uid);
l = next;
}
}
int __connman_notifier_init(void)
{
DBG("");
......
This diff is collapsed.
......@@ -1031,6 +1031,22 @@ static void clean_restore_sd_connection(gpointer user_data)
}
}
static void uid_changed(uid_t uid)
{
if (!login_data)
return;
DBG("uid change from %u to %u", login_data->active_uid, uid);
login_data->active_uid = uid;
}
static struct connman_notifier systemd_login_notifier = {
.name = "systemd_login",
.priority = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
.storage_uid_changed = uid_changed
};
int __systemd_login_init()
{
int err;
......@@ -1041,6 +1057,7 @@ int __systemd_login_init()
return -EALREADY;
login_data = g_new0(struct systemd_login_data, 1);
connman_notifier_register(&systemd_login_notifier);
err = init_sd_login_monitor(login_data);
if (err) {
......@@ -1086,6 +1103,8 @@ void __systemd_login_cleanup()
close_io_channel(login_data);
close_sd_login_monitor(login_data);
connman_notifier_unregister(&systemd_login_notifier);
g_free(login_data);
login_data = NULL;
}
......
......@@ -320,6 +320,7 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...)
}
static guint watch_id = 69;
static guint service_watch_id = 123654798;
guint g_dbus_add_signal_watch(DBusConnection *connection,
const char *sender, const char *path,
......@@ -330,9 +331,17 @@ guint g_dbus_add_signal_watch(DBusConnection *connection,
return watch_id;
}
guint g_dbus_add_service_watch(DBusConnection *connection, const char *name,
GDBusWatchFunction connect,
GDBusWatchFunction disconnect,
void *user_data, GDBusDestroyFunction destroy)
{
return service_watch_id;
}
gboolean g_dbus_remove_watch(DBusConnection *connection, guint id)
{
return id == watch_id;
return id == watch_id || id == service_watch_id;
}
// device dummies
......
......@@ -262,6 +262,21 @@ gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
timeout);
}
static guint watch_id = 123654798;
guint g_dbus_add_service_watch(DBusConnection *connection, const char *name,
GDBusWatchFunction connect,
GDBusWatchFunction disconnect,
void *user_data, GDBusDestroyFunction destroy)
{
return watch_id;
}
gboolean g_dbus_remove_watch(DBusConnection *connection, guint id)
{
return id == watch_id;
}
// Replaces function from libdbusaccess/src/dbusaccess_policy.c
// Needed to control permissions independent of reality
DAPolicy* da_policy_new_full(const char* spec, const DA_ACTION* actions)
......
This diff is collapsed.
......@@ -300,6 +300,18 @@ bool __connman_technology_disable_all(void)
/* END STORAGE STUB */
/* notifier stubs */
int connman_notifier_register(struct connman_notifier *notifier)
{
return 0;
}
void connman_notifier_unregister(struct connman_notifier *notifier)
{
return;
}
static void monitor_initialize(uid_t uid, enum sd_session_state initial_state,
const char *seat, int expected_return)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment