From db96a910dc72eccaae5fb6b8bc16b31fdd56fdf5 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 10 Jun 2010 18:30:51 +0200 Subject: Remove the -g option from useradd The local domain has the magic private groups option set unconditionally. Therefore, it does not make any sense to let user configure the primary GID. As a side-effect, this fixes #522. --- src/tools/sss_useradd.c | 59 ++----------------------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) (limited to 'src/tools') diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c index 510c0f5b..f9b95155 100644 --- a/src/tools/sss_useradd.c +++ b/src/tools/sss_useradd.c @@ -32,53 +32,9 @@ #include "tools/tools_util.h" #include "tools/sss_sync_ops.h" -/* Returns a gid for a given groupname. If a numerical gid - * is given, returns that as integer (rationale: shadow-utils) - * On error, returns -EINVAL - */ -static int get_gid(struct tools_ctx *tctx, const char *groupname) -{ - struct ldb_result *res; - char *end_ptr; - int ret; - - errno = 0; - tctx->octx->gid = strtoul(groupname, &end_ptr, 10); - if (groupname == '\0' || *end_ptr != '\0' || - errno != 0 || tctx->octx->gid == 0) { - /* Does not look like a gid - find the group name */ - - ret = sysdb_getgrnam(tctx->octx, tctx->sysdb, - tctx->octx->domain, groupname, &res); - if (ret != EOK) { - DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret)); - return ret; - } - - switch (res->count) { - case 0: - return ENOENT; - - case 1: - tctx->octx->gid = ldb_msg_find_attr_as_uint(res->msgs[0], - SYSDB_GIDNUM, 0); - if (tctx->octx->gid == 0) { - return ERANGE; - } - break; - - default: - return EFAULT; - } - } - - return EOK; -} - int main(int argc, const char **argv) { uid_t pc_uid = 0; - const char *pc_group = NULL; const char *pc_gecos = NULL; const char *pc_home = NULL; char *pc_shell = NULL; @@ -91,7 +47,6 @@ int main(int argc, const char **argv) POPT_AUTOHELP { "debug", '\0', POPT_ARG_INT | POPT_ARGFLAG_DOC_HIDDEN, &pc_debug, 0, _("The debug level to run with"), NULL }, { "uid", 'u', POPT_ARG_INT, &pc_uid, 0, _("The UID of the user"), NULL }, - { "gid", 'g', POPT_ARG_STRING, &pc_group, 0, _("The GID or group name of the user"), NULL }, { "gecos", 'c', POPT_ARG_STRING, &pc_gecos, 0, _("The comment string"), NULL }, { "home", 'h', POPT_ARG_STRING, &pc_home, 0, _("Home directory"), NULL }, { "shell", 's', POPT_ARG_STRING, &pc_shell, 0, _("Login shell"), NULL }, @@ -202,16 +157,6 @@ int main(int argc, const char **argv) } } - /* Same as shadow-utils useradd, -g can specify gid or group name */ - if (pc_group != NULL) { - ret = get_gid(tctx, pc_group); - if (ret != EOK) { - ERROR("Cannot get group information for the user\n"); - ret = EXIT_FAILURE; - goto fini; - } - } - tctx->octx->uid = pc_uid; /* @@ -262,9 +207,9 @@ int main(int argc, const char **argv) /* Create user's home directory and/or mail spool */ if (tctx->octx->create_homedir) { - /* We need to know the UID and GID of the user, if + /* We need to know the UID of the user, if * sysdb did assign it automatically, do a lookup */ - if (tctx->octx->uid == 0 || tctx->octx->gid == 0) { + if (tctx->octx->uid == 0) { ret = sysdb_getpwnam_sync(tctx, tctx->sysdb, tctx->octx->name, -- cgit