From 0669db37ede2981d2ba68a30d9f1d32919e4b045 Mon Sep 17 00:00:00 2001 From: peijiankang Date: Mon, 18 Sep 2023 11:07:20 +0800 Subject: [PATCH] add background-file and formats-locale support (cherry picked from commit 00171787cce88f19952e46d3e27ff1b213a6dd4e) --- ....8-kylin-add-background-file-support.patch | 300 ++++++++++++++++++ ...8.8-kylin-add-formats-locale-support.patch | 278 ++++++++++++++++ accountsservice.spec | 10 +- 3 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 accountsservice-22.08.8-kylin-add-background-file-support.patch create mode 100644 accountsservice-22.08.8-kylin-add-formats-locale-support.patch diff --git a/accountsservice-22.08.8-kylin-add-background-file-support.patch b/accountsservice-22.08.8-kylin-add-background-file-support.patch new file mode 100644 index 0000000..54db853 --- /dev/null +++ b/accountsservice-22.08.8-kylin-add-background-file-support.patch @@ -0,0 +1,300 @@ +From 06f3b7c3f0f2afec76d370ff134a2d029c0482c7 Mon Sep 17 00:00:00 2001 +From: peijiankang +Date: Mon, 18 Sep 2023 10:29:43 +0800 +Subject: [PATCH] add-background-file-support + +--- + data/org.freedesktop.Accounts.User.xml | 45 +++++++++++++++ + src/libaccountsservice/act-user.c | 57 ++++++++++++++++++ + src/libaccountsservice/act-user.h | 3 + + src/user.c | 80 ++++++++++++++++++++++++++ + 4 files changed, 185 insertions(+) + +diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml +index ac5f4bb..f0bfa73 100644 +--- a/data/org.freedesktop.Accounts.User.xml ++++ b/data/org.freedesktop.Accounts.User.xml +@@ -379,6 +379,41 @@ + + + ++ ++ ++ ++ ++ ++ The absolute filename of a png file to use as the users background. ++ ++ ++ ++ ++ ++ ++ Sets the users background. ++ ++ ++ ++ The caller needs one of the following PolicyKit authorizations: ++ ++ ++ org.freedesktop.accounts.change-own-user-data ++ To change his own background ++ ++ ++ org.freedesktop.accounts.user-administration ++ To change the background of another user ++ ++ ++ ++ ++ if the caller lacks the appropriate PolicyKit authorization ++ if the operation failed ++ ++ ++ ++ + + + +@@ -842,6 +877,16 @@ + + + ++ ++ ++ ++ ++ The filename of a png file containing the users background. ++ ++ ++ ++ ++ + + + +diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c +index 01dd210..3163361 100644 +--- a/src/libaccountsservice/act-user.c ++++ b/src/libaccountsservice/act-user.c +@@ -89,6 +89,7 @@ enum { + PROP_LOGIN_FREQUENCY, + PROP_LOGIN_TIME, + PROP_LOGIN_HISTORY, ++ PROP_BACKGROUND_FILE, + PROP_ICON_FILE, + PROP_LANGUAGE, + PROP_X_SESSION, +@@ -366,6 +367,13 @@ act_user_class_init (ActUserClass *class) + G_VARIANT_TYPE ("a(xxa{sv})"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); ++ g_object_class_install_property (gobject_class, ++ PROP_BACKGROUND_FILE, ++ g_param_spec_string ("background-file", ++ "Background File", ++ "The path to a background for this user.", ++ NULL, ++ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, + PROP_ICON_FILE, + g_param_spec_string ("icon-file", +@@ -998,6 +1006,25 @@ act_user_is_nonexistent (ActUser *user) + return user->nonexistent; + } + ++/** ++ * act_user_get_background_file: ++ * @user: a #ActUser ++ * ++ * Returns the path to the account background belonging to @user. ++ * ++ * Returns: (transfer none): a path to a background ++ */ ++const char * ++act_user_get_background_file (ActUser *user) ++{ ++ g_return_val_if_fail (ACT_IS_USER (user), NULL); ++ ++ if (user->accounts_proxy == NULL) ++ return NULL; ++ ++ return accounts_user_get_background_file (user->accounts_proxy); ++} ++ + /** + * act_user_get_icon_file: + * @user: a #ActUser +@@ -1452,6 +1479,36 @@ act_user_set_language (ActUser *user, + } + } + ++/** ++ * act_user_set_background_file: ++ * @user: the user object to alter. ++ * @background_file: path to an background ++ * ++ * Assigns a new background for @user. ++ * ++ * Note this function is synchronous and ignores errors. ++ **/ ++void ++act_user_set_background_file (ActUser *user, ++ const char *background_file) ++{ ++ g_autoptr(GError) error = NULL; ++ ++ g_return_if_fail (ACT_IS_USER (user)); ++ g_return_if_fail (background_file != NULL); ++ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy)); ++ ++ if (!accounts_user_call_set_background_file_sync (user->accounts_proxy, ++ background_file, ++ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, ++ -1, ++ NULL, ++ &error)) { ++ g_warning ("SetBackgroundFile for backgroundfile %s failed: %s", background_file, error->message); ++ return; ++ } ++} ++ + /** + * act_user_set_x_session: + * @user: the user object to alter. +diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h +index b1fdd0d..dfcc5f9 100644 +--- a/src/libaccountsservice/act-user.h ++++ b/src/libaccountsservice/act-user.h +@@ -70,6 +70,7 @@ gboolean act_user_get_automatic_login (ActUser *user); + gboolean act_user_is_system_account (ActUser *user); + gboolean act_user_is_local_account (ActUser *user); + gboolean act_user_is_nonexistent (ActUser *user); ++const char *act_user_get_background_file (ActUser *user); + const char *act_user_get_icon_file (ActUser *user); + const char *act_user_get_language (ActUser *user); + const char *act_user_get_x_session (ActUser *user); +@@ -102,6 +103,8 @@ void act_user_set_email (ActUser *user, + const char *email); + void act_user_set_language (ActUser *user, + const char *language); ++void act_user_set_background_file (ActUser *user, ++ const char *background_file); + void act_user_set_x_session (ActUser *user, + const char *x_session); + void act_user_set_session (ActUser *user, +diff --git a/src/user.c b/src/user.c +index 199e54d..f9e3eea 100644 +--- a/src/user.c ++++ b/src/user.c +@@ -563,6 +563,12 @@ user_update_from_keyfile (User *user, + g_clear_pointer (&s, g_free); + } + ++ s = g_key_file_get_string (keyfile, "User", "Background", NULL); ++ if (s != NULL) { ++ accounts_user_set_background_file (ACCOUNTS_USER (user), s); ++ g_clear_pointer (&s, g_free); ++ } ++ + s = g_key_file_get_string (keyfile, "User", "Icon", NULL); + if (s != NULL) { + accounts_user_set_icon_file (ACCOUNTS_USER (user), s); +@@ -641,6 +647,9 @@ user_save_to_keyfile (User *user, + if (accounts_user_get_password_hint (ACCOUNTS_USER (user))) + g_key_file_set_string (keyfile, "User", "PasswordHint", accounts_user_get_password_hint (ACCOUNTS_USER (user))); + ++ if (accounts_user_get_background_file (ACCOUNTS_USER (user))) ++ g_key_file_set_string (keyfile, "User", "Background", accounts_user_get_background_file (ACCOUNTS_USER (user))); ++ + if (accounts_user_get_icon_file (ACCOUNTS_USER (user))) + g_key_file_set_string (keyfile, "User", "Icon", accounts_user_get_icon_file (ACCOUNTS_USER (user))); + +@@ -1900,6 +1909,76 @@ become_user (gpointer data) + } + } + ++static void ++user_change_background_file_authorized_cb (Daemon *daemon, ++ User *user, ++ GDBusMethodInvocation *context, ++ gpointer data) ++{ ++ g_autofree gchar *filename = NULL; ++ g_autoptr(GFile) file = NULL; ++ g_autoptr(GFileInfo) info = NULL; ++ GFileType type; ++ ++ filename = g_strdup (data); ++ ++ if (filename == NULL || ++ *filename == '\0') { ++ g_free (filename); ++ filename = NULL; ++ ++ goto background_saved; ++ } ++ ++ file = g_file_new_for_path (filename); ++ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, ++ 0, NULL, NULL); ++ type = g_file_info_get_file_type (info); ++ ++ if (type != G_FILE_TYPE_REGULAR) { ++ g_debug ("not a regular file\n"); ++ throw_error (context, ERROR_FAILED, "file '%s' is not a regular file", filename); ++ return; ++ } ++ ++background_saved: ++ accounts_user_set_background_file (ACCOUNTS_USER (user), filename); ++ ++ save_extra_data (user); ++ ++ accounts_user_complete_set_background_file (ACCOUNTS_USER (user), context); ++} ++ ++static gboolean ++user_set_background_file (AccountsUser *auser, ++ GDBusMethodInvocation *context, ++ const gchar *filename) ++{ ++ User *user = (User*)auser; ++ int uid; ++ const gchar *action_id; ++ ++ if (!get_caller_uid (context, &uid)) { ++ throw_error (context, ERROR_FAILED, "identifying caller failed"); ++ return FALSE; ++ } ++ ++ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid) ++ action_id = "org.freedesktop.accounts.change-own-user-data"; ++ else ++ action_id = "org.freedesktop.accounts.user-administration"; ++ ++ daemon_local_check_auth (user->daemon, ++ user, ++ action_id, ++ user_change_background_file_authorized_cb, ++ context, ++ g_strdup (filename), ++ (GDestroyNotify)g_free); ++ ++ return TRUE; ++} ++ + static void + user_change_icon_file_authorized_cb (Daemon *daemon, + User *user, +@@ -2576,6 +2655,7 @@ user_accounts_user_iface_init (AccountsUserIface *iface) + { + iface->handle_set_account_type = user_set_account_type; + iface->handle_set_automatic_login = user_set_automatic_login; ++ iface->handle_set_background_file = user_set_background_file; + iface->handle_set_email = user_set_email; + iface->handle_set_home_directory = user_set_home_directory; + iface->handle_set_icon_file = user_set_icon_file; +-- +2.41.0 + diff --git a/accountsservice-22.08.8-kylin-add-formats-locale-support.patch b/accountsservice-22.08.8-kylin-add-formats-locale-support.patch new file mode 100644 index 0000000..428ffa2 --- /dev/null +++ b/accountsservice-22.08.8-kylin-add-formats-locale-support.patch @@ -0,0 +1,278 @@ +From fb8f804e09c4505773e0324302c565df02ba250d Mon Sep 17 00:00:00 2001 +From: peijiankang +Date: Mon, 18 Sep 2023 10:55:57 +0800 +Subject: [PATCH] Addition of FormatsLocale property and SetFormatsLocale + +--- + data/org.freedesktop.Accounts.User.xml | 45 ++++++++++++++++++++ + src/libaccountsservice/act-user.c | 57 +++++++++++++++++++++++++ + src/libaccountsservice/act-user.h | 3 ++ + src/user.c | 58 ++++++++++++++++++++++++++ + 4 files changed, 163 insertions(+) + +diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml +index f0bfa73..5f654fb 100644 +--- a/data/org.freedesktop.Accounts.User.xml ++++ b/data/org.freedesktop.Accounts.User.xml +@@ -150,6 +150,41 @@ + + + ++ ++ ++ ++ ++ ++ The new regional formats, as a locale specification like "de_DE.UTF-8". ++ ++ ++ ++ ++ ++ ++ Sets the users regional formats. ++ ++ ++ ++ The caller needs one of the following PolicyKit authorizations: ++ ++ ++ org.freedesktop.accounts.change-own-user-data ++ To change regional formats ++ ++ ++ org.freedesktop.accounts.user-administration ++ To change egional formats of another user ++ ++ ++ ++ ++ if the caller lacks the appropriate PolicyKit authorization ++ if the operation failed ++ ++ ++ ++ + + + +@@ -819,6 +854,16 @@ + + + ++ ++ ++ ++ ++ The users regional formats, as a locale specification like "de_DE.UTF-8". ++ ++ ++ ++ ++ + + + +diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c +index 3163361..a4f031d 100644 +--- a/src/libaccountsservice/act-user.c ++++ b/src/libaccountsservice/act-user.c +@@ -92,6 +92,7 @@ enum { + PROP_BACKGROUND_FILE, + PROP_ICON_FILE, + PROP_LANGUAGE, ++ PROP_FORMATS_LOCALE, + PROP_X_SESSION, + PROP_IS_LOADED + }; +@@ -404,6 +405,13 @@ act_user_class_init (ActUserClass *class) + "User's locale.", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); ++ g_object_class_install_property (gobject_class, ++ PROP_FORMATS_LOCALE, ++ g_param_spec_string ("formats-locale", ++ "Regional Formats", ++ "User's regional formats.", ++ NULL, ++ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, + PROP_X_SESSION, + g_param_spec_string ("x-session", +@@ -1065,6 +1073,25 @@ act_user_get_language (ActUser *user) + return accounts_user_get_language (user->accounts_proxy); + } + ++/** ++ * act_user_get_formats_locale: ++ * @user: a #ActUser ++ * ++ * Returns the path to the configured formats locale of @user. ++ * ++ * Returns: (transfer none): a path to an icon ++ */ ++const char * ++act_user_get_formats_locale (ActUser *user) ++{ ++ g_return_val_if_fail (ACT_IS_USER (user), NULL); ++ ++ if (user->accounts_proxy == NULL) ++ return NULL; ++ ++ return accounts_user_get_formats_locale (user->accounts_proxy); ++} ++ + /** + * act_user_get_x_session: + * @user: a #ActUser +@@ -1418,6 +1445,36 @@ act_user_set_password_expiration_policy (ActUser *user, + } + } + ++/** ++ * act_user_set_formats_locale: ++ * @user: the user object to alter. ++ * @formats_locale: a locale (e.g. en_US.utf8) ++ * ++ * Assigns a new formats locale for @user. ++ * ++ * Note this function is synchronous and ignores errors. ++ **/ ++void ++act_user_set_formats_locale (ActUser *user, ++ const char *formats_locale) ++{ ++ g_autoptr(GError) error = NULL; ++ ++ g_return_if_fail (ACT_IS_USER (user)); ++ g_return_if_fail (formats_locale != NULL); ++ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy)); ++ ++ if (!accounts_user_call_set_formats_locale_sync (user->accounts_proxy, ++ formats_locale, ++ G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, ++ -1, ++ NULL, ++ &error)) { ++ g_warning ("SetFormatsLocale for formats_locale %s call failed: %s", formats_locale, error->message); ++ return; ++ } ++} ++ + /** + * act_user_set_email: + * @user: the user object to alter. +diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h +index dfcc5f9..b1f06bf 100644 +--- a/src/libaccountsservice/act-user.h ++++ b/src/libaccountsservice/act-user.h +@@ -73,6 +73,7 @@ gboolean act_user_is_nonexistent (ActUser *user); + const char *act_user_get_background_file (ActUser *user); + const char *act_user_get_icon_file (ActUser *user); + const char *act_user_get_language (ActUser *user); ++const char *act_user_get_formats_locale (ActUser *user); + const char *act_user_get_x_session (ActUser *user); + const char *act_user_get_session (ActUser *user); + const char *act_user_get_session_type (ActUser *user); +@@ -103,6 +104,8 @@ void act_user_set_email (ActUser *user, + const char *email); + void act_user_set_language (ActUser *user, + const char *language); ++void act_user_set_formats_locale (ActUser *user, ++ const char *formats_locale); + void act_user_set_background_file (ActUser *user, + const char *background_file); + void act_user_set_x_session (ActUser *user, +diff --git a/src/user.c b/src/user.c +index f9e3eea..413208c 100644 +--- a/src/user.c ++++ b/src/user.c +@@ -524,6 +524,12 @@ user_update_from_keyfile (User *user, + g_clear_pointer (&s, g_free); + } + ++ s = g_key_file_get_string (keyfile, "User", "FormatsLocale", NULL); ++ if (s != NULL) { ++ accounts_user_set_formats_locale (ACCOUNTS_USER (user), s); ++ g_clear_pointer (&s, g_free); ++ } ++ + s = g_key_file_get_string (keyfile, "User", "XSession", NULL); + if (s != NULL) { + accounts_user_set_xsession (ACCOUNTS_USER (user), s); +@@ -638,6 +644,9 @@ user_save_to_keyfile (User *user, + if (accounts_user_get_session_type (ACCOUNTS_USER (user))) + g_key_file_set_string (keyfile, "User", "SessionType", accounts_user_get_session_type (ACCOUNTS_USER (user))); + ++ if (accounts_user_get_formats_locale (ACCOUNTS_USER (user))) ++ g_key_file_set_string (keyfile, "User", "FormatsLocale", accounts_user_get_formats_locale (ACCOUNTS_USER (user))); ++ + if (accounts_user_get_xsession (ACCOUNTS_USER (user))) + g_key_file_set_string (keyfile, "User", "XSession", accounts_user_get_xsession (ACCOUNTS_USER (user))); + +@@ -1461,6 +1470,54 @@ user_set_session_type (AccountsUser *auser, + return TRUE; + } + ++static void ++user_change_formats_locale_authorized_cb (Daemon *daemon, ++ User *user, ++ GDBusMethodInvocation *context, ++ gpointer user_data) ++ ++{ ++ const gchar *formats_locale = user_data; ++ ++ if (g_strcmp0 (accounts_user_get_formats_locale (ACCOUNTS_USER (user)), formats_locale) != 0) { ++ accounts_user_set_formats_locale (ACCOUNTS_USER (user), formats_locale); ++ ++ save_extra_data (user); ++ } ++ ++ accounts_user_complete_set_formats_locale (ACCOUNTS_USER (user), context); ++} ++ ++static gboolean ++user_set_formats_locale (AccountsUser *auser, ++ GDBusMethodInvocation *context, ++ const gchar *formats_locale) ++{ ++ User *user = (User*)auser; ++ int uid; ++ const gchar *action_id; ++ ++ if (!get_caller_uid (context, &uid)) { ++ throw_error (context, ERROR_FAILED, "identifying caller failed"); ++ return FALSE; ++ } ++ ++ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid) ++ action_id = "org.freedesktop.accounts.change-own-user-data"; ++ else ++ action_id = "org.freedesktop.accounts.user-administration"; ++ ++ daemon_local_check_auth (user->daemon, ++ user, ++ action_id, ++ user_change_formats_locale_authorized_cb, ++ context, ++ g_strdup (formats_locale), ++ (GDestroyNotify) g_free); ++ ++ return TRUE; ++} ++ + static void + user_change_x_session_authorized_cb (Daemon *daemon, + User *user, +@@ -2657,6 +2714,7 @@ user_accounts_user_iface_init (AccountsUserIface *iface) + iface->handle_set_automatic_login = user_set_automatic_login; + iface->handle_set_background_file = user_set_background_file; + iface->handle_set_email = user_set_email; ++ iface->handle_set_formats_locale = user_set_formats_locale; + iface->handle_set_home_directory = user_set_home_directory; + iface->handle_set_icon_file = user_set_icon_file; + iface->handle_set_language = user_set_language; +-- +2.41.0 + diff --git a/accountsservice.spec b/accountsservice.spec index 57d0321..c05ba48 100644 --- a/accountsservice.spec +++ b/accountsservice.spec @@ -1,12 +1,15 @@ Name: accountsservice Version: 22.08.8 -Release: 1 +Release: 2 Summary: D-Bus service for accessing the list of user accounts and information attached to those accounts. License: GPLv3+ URL: https://www.freedesktop.org/wiki/Software/AccountsService/ Source0: https://www.freedesktop.org/software/%{name}/%{name}-%{version}.tar.xz +Patch1: accountsservice-22.08.8-kylin-add-background-file-support.patch +Patch2: accountsservice-22.08.8-kylin-add-formats-locale-support.patch + BuildRequires: gtk-doc polkit-devel libxslt pkgconfig(dbus-1) systemd systemd-devel BuildRequires: meson gobject-introspection-devel gettext-devel glib2-devel vala Requires: polkit shadow-utils @@ -37,7 +40,7 @@ are contained in %{name}-devel package. %package_help %prep -%autosetup -n %{name}-%{version} +%autosetup -n %{name}-%{version} -p 1 %build %meson -Dgtk_doc=true @@ -89,6 +92,9 @@ are contained in %{name}-devel package. %{_datadir}/gtk-doc/html/libaccountsservice/* %changelog +* Mon Sep 18 2023 peijiankang - 22.08.8-2 +- add background-file and formats-locale support + * Tue Jun 21 2022 yangzhao - 22.08.8-1 - Upgrade to version 22.08.8