Package: accountsservice
Version: 0.6.6-3
Severity: important
Hi,
the 0002-create-and-manage-groups-like-on-a-debian-system.patch patch is
incorrect for several reasons:
1. The administration group on Debian systems is named “sudo”, not
“admin”.
2. It is not needed to add users to “audio”, “plugdev” and whatnot.
ConsoleKit does everything needed now.
3. It is *dangerous* to add users to “dialout”.
Attached is a fixed version. I can commit it if you approve the change.
Cheers,
--
.''`.
: :' : “You would need to ask a lawyer if you don't know
`. `' that a handshake of course makes a valid contract.”
`- -- J???rg Schilling
From: Frederic Peters <[email protected]>
Bug-Debian: http://bugs.debian.org/618764
Forwarded: not-needed
Description: Create and manage groups like on a debian system.
---
daemon.c | 20 ++++++--------------
user.c | 24 +++++++++++++-----------
util.c | 42 ++++++++++++++++++++++++++++++++++++++++++
util.h | 9 +++++++++
4 files changed, 70 insertions(+), 25 deletions(-)
Index: accountsservice/src/daemon.c
===================================================================
--- accountsservice.orig/src/daemon.c 2011-03-28 17:08:12.599040731 +0530
+++ accountsservice/src/daemon.c 2011-03-28 17:13:15.803292345 +0530
@@ -1107,20 +1107,8 @@
argv[1] = "-m";
argv[2] = "-c";
argv[3] = cd->real_name;
- if (cd->account_type == ACCOUNT_TYPE_ADMINISTRATOR) {
- argv[4] = "-G";
- argv[5] = "wheel";
- argv[6] = cd->user_name;
- argv[7] = NULL;
- }
- else if (cd->account_type == ACCOUNT_TYPE_STANDARD) {
- argv[6] = cd->user_name;
- argv[7] = NULL;
- }
- else {
- throw_error (context, ERROR_FAILED, "Don't know how to add user of type %d", cd->account_type);
- return;
- }
+ argv[4] = cd->user_name;
+ argv[5] = NULL;
error = NULL;
if (!spawn_with_login_uid (context, argv, &error)) {
@@ -1129,6 +1117,10 @@
return;
}
+ if (cd->account_type == ACCOUNT_TYPE_ADMINISTRATOR) {
+ add_user_to_group (context, cd->user_name, "sudo");
+ }
+
user = daemon_local_find_user_by_name (daemon, cd->user_name);
dbus_g_method_return (context, user_local_get_object_path (user));
Index: accountsservice/src/user.c
===================================================================
--- accountsservice.orig/src/user.c 2011-03-28 17:02:43.615040892 +0530
+++ accountsservice/src/user.c 2011-03-28 17:13:13.471040456 +0530
@@ -412,7 +412,7 @@
account_type_from_pwent (struct passwd *pwent)
{
struct group *grp;
- gid_t wheel;
+ gid_t admin;
gid_t *groups;
gint ngroups;
gint i;
@@ -422,18 +422,20 @@
return ACCOUNT_TYPE_ADMINISTRATOR;
}
- grp = getgrnam ("wheel");
+ grp = getgrnam ("sudo");
if (grp == NULL) {
- g_debug ("wheel group not found");
+ g_debug ("sudo group not found");
return ACCOUNT_TYPE_STANDARD;
}
- wheel = grp->gr_gid;
+ admin = grp->gr_gid;
ngroups = get_user_groups (pwent->pw_name, pwent->pw_gid, &groups);
for (i = 0; i < ngroups; i++) {
- if (groups[i] == wheel)
+ if (groups[i] == admin) {
+ g_free (groups);
return ACCOUNT_TYPE_ADMINISTRATOR;
+ }
}
g_free (groups);
@@ -1584,7 +1586,7 @@
gid_t *groups;
gint ngroups;
GString *str;
- gid_t wheel;
+ gid_t admin;
struct group *grp;
gint i;
gchar *argv[5];
@@ -1594,24 +1596,24 @@
"change account type of user '%s' (%d) to %d",
user->user_name, user->uid, account_type);
- grp = getgrnam ("wheel");
+ grp = getgrnam ("sudo");
if (grp == NULL) {
- throw_error (context, ERROR_FAILED, "failed to set account type: wheel group not found");
+ throw_error (context, ERROR_FAILED, "failed to set account type: sudo group not found");
return;
}
- wheel = grp->gr_gid;
+ admin = grp->gr_gid;
ngroups = get_user_groups (user->user_name, user->gid, &groups);
str = g_string_new ("");
for (i = 0; i < ngroups; i++) {
- if (groups[i] == wheel)
+ if (groups[i] == admin)
continue;
g_string_append_printf (str, "%d,", groups[i]);
}
switch (account_type) {
case ACCOUNT_TYPE_ADMINISTRATOR:
- g_string_append_printf (str, "%d", wheel);
+ g_string_append_printf (str, "%d", admin);
break;
default:
/* remove excess comma */
Index: accountsservice/src/util.c
===================================================================
--- accountsservice.orig/src/util.c 2011-03-28 17:02:43.615040892 +0530
+++ accountsservice/src/util.c 2011-03-28 17:08:14.559043233 +0530
@@ -282,3 +282,45 @@
return TRUE;
}
+
+void
+add_user_to_group (DBusGMethodInvocation *context,
+ const char *user_name,
+ const char *group_name)
+{
+ GError *error;
+ gchar *argv[4];
+
+ argv[0] = (gchar*) "/usr/sbin/adduser";
+ argv[1] = (gchar*) user_name;
+ argv[2] = (gchar*) group_name;
+ argv[3] = NULL;
+
+ error = NULL;
+ if (!spawn_with_login_uid (context, argv, &error)) {
+ g_warning ("failed to add user %s to group %s", user_name, group_name);
+ g_error_free (error);
+ return;
+ }
+}
+
+void
+remove_user_from_group (DBusGMethodInvocation *context,
+ const char *user_name,
+ const char *group_name)
+{
+ GError *error;
+ gchar *argv[4];
+
+ argv[0] = (gchar*) "/usr/sbin/deluser";
+ argv[1] = (gchar*) user_name;
+ argv[2] = (gchar*) group_name;
+ argv[3] = NULL;
+
+ error = NULL;
+ if (!spawn_with_login_uid (context, argv, &error)) {
+ g_warning ("failed to remove user %s from group %s", user_name, group_name);
+ g_error_free (error);
+ return;
+ }
+}
Index: accountsservice/src/util.h
===================================================================
--- accountsservice.orig/src/util.h 2011-03-28 17:02:43.615040892 +0530
+++ accountsservice/src/util.h 2011-03-28 17:08:14.559043233 +0530
@@ -41,6 +41,15 @@
gid_t group,
gid_t **groups);
+void add_user_to_group (DBusGMethodInvocation *context,
+ const char *user_name,
+ const char *group_name);
+
+void remove_user_from_group (DBusGMethodInvocation *context,
+ const char *user_name,
+ const char *group_name);
+
+
G_END_DECLS
#endif /* __UTIL_H__ */