From dee8d121d532f90a48d56d3741443a59ea6a32cc Mon Sep 17 00:00:00 2001 From: Imran Zaman Date: Mon, 9 Feb 2015 17:19:49 +0200 Subject: [PATCH] Fixed copying of extended attributes from skel folder Signed-off-by: Imran Zaman --- configure.ac | 2 +- data/tizen/etc/gumd/gumd-tizen-common.conf | 4 ++-- data/tizen/etc/gumd/gumd-tizen-ivi.conf | 2 +- dists/debian/changelog | 12 ++++++++++ dists/rpm/gum-suse.spec | 8 ++++++- dists/rpm/tizen/packaging/gumd.changes | 6 +++++ dists/rpm/tizen/packaging/gumd.spec | 4 ++-- docs/utils.xml | 4 ++-- src/common/gum-file.c | 38 +++++++++++++++++------------- src/utils/gumd-utils.c | 12 +++++----- 10 files changed, 61 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 7b8691a..49f417a 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.60]) -AC_INIT([gumd], [1.0.5],[],[],[https://github.com/01org/gumd]) +AC_INIT([gumd], [1.0.7],[],[],[https://github.com/01org/gumd]) AC_CONFIG_SRCDIR([src/daemon/main.c]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/data/tizen/etc/gumd/gumd-tizen-common.conf b/data/tizen/etc/gumd/gumd-tizen-common.conf index 25de44e..53cda9d 100644 --- a/data/tizen/etc/gumd/gumd-tizen-common.conf +++ b/data/tizen/etc/gumd/gumd-tizen-common.conf @@ -15,7 +15,7 @@ USR_PRIMARY_GRPNAME=users # Comma separate listed of groups, which every user (other than system user) # will be added to at the time of user account creation. Default value is: # '' -#DEFAULT_USR_GROUPS= +DEFAULT_USR_GROUPS=audio,video,display # Comma separate listed of groups, which admin user will be added to at the # time of user account creation. Default value is: '' @@ -116,7 +116,7 @@ USR_PRIMARY_GRPNAME=users SMACK64_NEW_FILES=_ # Value used to set the smack label for User files and folders. -SMACK64_USER_FILES=User +SMACK64_USER_FILES=User::Home # # D-Bus related settings. diff --git a/data/tizen/etc/gumd/gumd-tizen-ivi.conf b/data/tizen/etc/gumd/gumd-tizen-ivi.conf index d48afd2..cc0a5ad 100644 --- a/data/tizen/etc/gumd/gumd-tizen-ivi.conf +++ b/data/tizen/etc/gumd/gumd-tizen-ivi.conf @@ -116,7 +116,7 @@ DEFAULT_USR_GROUPS=weston-launch,audio,video SMACK64_NEW_FILES=_ # Value used to set the smack label for User files and folders. -SMACK64_USER_FILES=User +SMACK64_USER_FILES=User::Home # # D-Bus related settings. diff --git a/dists/debian/changelog b/dists/debian/changelog index 6eab0b9..95e3653 100644 --- a/dists/debian/changelog +++ b/dists/debian/changelog @@ -1,3 +1,15 @@ +gumd (1.0.7-0) unstable; urgency=low + + * Fixed copying of extended attributes from skel folder + + -- Imran Zaman Mon, 09 Feb 2015 18:00:00 +0300 + +gumd (1.0.6-0) unstable; urgency=low + + * Fixed gum-utils documentation + + -- Imran Zaman Thu, 05 Feb 2015 18:00:00 +0300 + gumd (1.0.5-0) unstable; urgency=low * Added APIs for fetching users based on the type diff --git a/dists/rpm/gum-suse.spec b/dists/rpm/gum-suse.spec index 1fba2dc..247172d 100644 --- a/dists/rpm/gum-suse.spec +++ b/dists/rpm/gum-suse.spec @@ -7,7 +7,7 @@ Name: gumd Summary: User management daemon and client library -Version: 1.0.5 +Version: 1.0.7 Release: 0 Group: System/Daemons License: LGPL-2.1+ @@ -150,6 +150,12 @@ mkdir -p %{_sysconfdir}/%{name}/groupdel.d %changelog +* Mon Feb 09 2015 Imran Zaman +- Fixed copying of extended attributes from skel folder + +* Thu Feb 05 2015 Imran Zaman +- Fixed gum-utils documentation + * Wed Jan 28 2015 Imran Zaman - Added APIs for fetching users based on the type diff --git a/dists/rpm/tizen/packaging/gumd.changes b/dists/rpm/tizen/packaging/gumd.changes index dde1134..660598d 100644 --- a/dists/rpm/tizen/packaging/gumd.changes +++ b/dists/rpm/tizen/packaging/gumd.changes @@ -1,3 +1,9 @@ +* Mon Feb 09 2015 Imran Zaman +- Fixed copying of extended attributes from skel folder + +* Thu Feb 05 2015 Imran Zaman +- Fixed gum-utils documentation + * Wed Jan 28 2015 Imran Zaman - Added APIs for fetching users based on the type diff --git a/dists/rpm/tizen/packaging/gumd.spec b/dists/rpm/tizen/packaging/gumd.spec index bd09729..6697a2b 100644 --- a/dists/rpm/tizen/packaging/gumd.spec +++ b/dists/rpm/tizen/packaging/gumd.spec @@ -6,7 +6,7 @@ Name: gumd Summary: User management daemon and client library -Version: 1.0.5 +Version: 1.0.7 Release: 0 Group: Security/Accounts License: LGPL-2.1+ @@ -29,7 +29,7 @@ BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(gmodule-2.0) - +Requires: tizen-platform-config %description %{summary} files diff --git a/docs/utils.xml b/docs/utils.xml index 4a093a1..9bb1f41 100644 --- a/docs/utils.xml +++ b/docs/utils.xml @@ -41,7 +41,7 @@ mandatory-args are: --username=<username> OR --nickname=<nickname> --usertype=<usertype> - possible usertypes are: system(1), admin(2), guest(3), normal(4). + possible usertype can be system or admin or guest or normal. optional-args are: --usecret=<secret> --realname=<realname> @@ -134,7 +134,7 @@ mandatory-args are: --groupname=<groupname> --grouptype=<grouptype> - possible grouptypes are: system(1), user(2). + possible grouptypes are: system or user. optional-args are: --gsecret=<secret> diff --git a/src/common/gum-file.c b/src/common/gum-file.c index a56126a..d6f424a 100644 --- a/src/common/gum-file.c +++ b/src/common/gum-file.c @@ -129,7 +129,7 @@ _set_smack64_attr ( */ if (smack_label && len > 0 && - setxattr (path, XATTR_NAME_SMACK, smack_label, len, 0) != 0) { + lsetxattr (path, XATTR_NAME_SMACK, smack_label, len, 0) != 0) { g_object_unref (config); return FALSE; } @@ -182,10 +182,8 @@ _copy_file_attributes ( names[attrs_size] = '\0'; ssize_t size = 0; - while (name != end_names) { - if (name) - name = strchr (name,'\0')+1; - if (name && name[0] != '\0') { + while (name && name != end_names) { + if (name[0] != '\0') { size = lgetxattr (from_path, name, NULL, 0); if(size > 0 && (value = g_realloc (value, size)) && @@ -197,6 +195,7 @@ _copy_file_attributes ( } } } + name = strchr (name,'\0') + 1; } g_free (value); } @@ -253,16 +252,16 @@ gum_file_open_db_files ( goto _fail; } - if (!_copy_file_attributes (source_file_path, dup_file_path)) { + if (!_set_smack64_attr (dup_file_path, + GUM_CONFIG_GENERAL_SMACK64_NEW_FILES)) { GUM_SET_ERROR (GUM_ERROR_FILE_ATTRIBUTE, - "Unable to get/set file attributes", error, retval, FALSE); + "Unable to set smack file attributes", error, retval, FALSE); goto _fail; } - if (!_set_smack64_attr (dup_file_path, - GUM_CONFIG_GENERAL_SMACK64_NEW_FILES)) { + if (!_copy_file_attributes (source_file_path, dup_file_path)) { GUM_SET_ERROR (GUM_ERROR_FILE_ATTRIBUTE, - "Unable to set smack file attributes", error, retval, FALSE); + "Unable to get/set file attributes", error, retval, FALSE); goto _fail; } @@ -755,6 +754,7 @@ _copy_dir_recursively ( stop = !_set_smack64_attr (dest_filepath, GUM_CONFIG_GENERAL_SMACK64_USER_FILES); } + if (!stop) stop = !_copy_file_attributes (src_filepath, dest_filepath); if (!stop) stop = (chown (dest_filepath, uid, gid) < 0); _free_data: @@ -804,7 +804,11 @@ gum_file_create_home_dir ( } if (g_access (home_dir, F_OK) != 0) { - GumConfig *config = NULL; + GumConfig *config = gum_config_new (NULL); + const gchar *skel_dir = NULL; + + skel_dir = gum_config_get_string (config, GUM_CONFIG_GENERAL_SKEL_DIR); + g_object_unref (config); if (!g_file_test (home_dir, G_FILE_TEST_EXISTS)) { g_mkdir_with_parents (home_dir, mode); @@ -821,6 +825,11 @@ gum_file_create_home_dir ( "Unable to set smack64 home dir attr", error, FALSE); } + if (!_copy_file_attributes (skel_dir, home_dir)) { + GUM_RETURN_WITH_ERROR (GUM_ERROR_FILE_ATTRIBUTE, + "Unable to get/set dir attributes", error, FALSE); + } + /* when run in test mode, user may not exist */ #ifdef ENABLE_TESTS uid = getuid (); @@ -831,11 +840,8 @@ gum_file_create_home_dir ( "Home directory chown failure", error, FALSE); } - config = gum_config_new (NULL); - retval = _copy_dir_recursively (gum_config_get_string (config, - GUM_CONFIG_GENERAL_SKEL_DIR), home_dir, uid, gid, umask, error); - g_object_unref (config); - + retval = _copy_dir_recursively (skel_dir, home_dir, uid, gid, umask, + error); } return retval; diff --git a/src/utils/gumd-utils.c b/src/utils/gumd-utils.c index f54f913..5ab3629 100644 --- a/src/utils/gumd-utils.c +++ b/src/utils/gumd-utils.c @@ -645,7 +645,7 @@ main (int argc, char *argv[]) { "sysroot", 'q', 0, G_OPTION_ARG_STRING, &sysroot, "sysroot path " "[Offline mode ONLY]", "sysroot"}, { "user-list", 'r', 0, G_OPTION_ARG_NONE, &is_user_list_op, - "if user_types argument is specified, then the calls will " + "if usertypes argument is specified, then the calls will " "return the specified users only otherwise all the users will " "be returned", NULL}, { NULL } @@ -653,8 +653,8 @@ main (int argc, char *argv[]) GOptionEntry user_serv_entries[] = { - { "user_types", 0, 0, G_OPTION_ARG_STRING, &user_types, - "valid user_type can be system or admin or guest or normal." + { "usertypes", 0, 0, G_OPTION_ARG_STRING, &user_types, + "valid usertypes can be system or admin or guest or normal." "Multiple user types can be specified as comma separated " "values e.g. normal,system", "type"}, @@ -665,7 +665,7 @@ main (int argc, char *argv[]) { { "username", 0, 0, G_OPTION_ARG_STRING, &user->user_name, "user name", "name"}, - { "user_type", 0, 0, G_OPTION_ARG_STRING, &user->user_type, + { "usertype", 0, 0, G_OPTION_ARG_STRING, &user->user_type, "valid user_type can be system or admin or guest or normal.", "type"}, { "uid", 0, 0, G_OPTION_ARG_INT, &user->uid, "user id", "uid"}, @@ -693,7 +693,7 @@ main (int argc, char *argv[]) { { "groupname", 0, 0, G_OPTION_ARG_STRING, &group->group_name, "group name", "name"}, - { "group_type", 0, 0, G_OPTION_ARG_STRING, &group->group_type, + { "grouptype", 0, 0, G_OPTION_ARG_STRING, &group->group_type, "valid group type can be system or user", "type"}, { "gid", 0, 0, G_OPTION_ARG_INT, &group->gid, "group id", "gid"}, { "gsecret", 0, 0, G_OPTION_ARG_STRING, &group->group_secret, @@ -709,7 +709,7 @@ main (int argc, char *argv[]) context = g_option_context_new ("\n" " To add user in non-offline mode, gum-utils -a --username=user1 " - " --user_type=normal\n" + " --usertype=normal\n" " To delete user in offline mode, gum-utils -o -d --uid=2001\n" " NOTE: Only one command can be run at one time."); g_option_context_add_main_entries (context, main_entries, NULL); -- 2.7.4