summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-06-10 14:15:30 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-06-14 16:54:42 -0400
commit0b2d2bebfe41f86dab5c6ed0828d3e91389b08e4 (patch)
tree2977f42e2ce0de0ba493d43f336dec61bd390c9e
parentefeada8c40ade5e6911fa5b4ba58ce8c720d18f1 (diff)
downloadsssd-0b2d2bebfe41f86dab5c6ed0828d3e91389b08e4.tar.gz
sssd-0b2d2bebfe41f86dab5c6ed0828d3e91389b08e4.tar.xz
sssd-0b2d2bebfe41f86dab5c6ed0828d3e91389b08e4.zip
Remove the -g option from useradd
-rw-r--r--src/man/sss_useradd.8.xml13
-rw-r--r--src/tools/sss_useradd.c82
2 files changed, 2 insertions, 93 deletions
diff --git a/src/man/sss_useradd.8.xml b/src/man/sss_useradd.8.xml
index 4b745ab97..70998f8e6 100644
--- a/src/man/sss_useradd.8.xml
+++ b/src/man/sss_useradd.8.xml
@@ -52,19 +52,6 @@
</varlistentry>
<varlistentry>
<term>
- <option>-g</option>,<option>--gid</option>
- <replaceable>GID</replaceable>
- </term>
- <listitem>
- <para>
- Set the GID or group membership of the user to the value
- of <replaceable>GID</replaceable>. If not given, it is
- chosen automatically.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
<option>-c</option>,<option>--gecos</option>
<replaceable>COMMENT</replaceable>
</term>
diff --git a/src/tools/sss_useradd.c b/src/tools/sss_useradd.c
index a08024c60..9ead79854 100644
--- a/src/tools/sss_useradd.c
+++ b/src/tools/sss_useradd.c
@@ -32,76 +32,9 @@
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
-static void get_gid_callback(void *ptr, int error, struct ldb_result *res)
-{
- struct tools_ctx *tctx = talloc_get_type(ptr, struct tools_ctx);
-
- if (error) {
- tctx->error = error;
- return;
- }
-
- switch (res->count) {
- case 0:
- tctx->error = ENOENT;
- break;
-
- case 1:
- tctx->octx->gid = ldb_msg_find_attr_as_uint(res->msgs[0], SYSDB_GIDNUM, 0);
- if (tctx->octx->gid == 0) {
- tctx->error = ERANGE;
- }
- break;
-
- default:
- tctx->error = EFAULT;
- break;
- }
-}
-
-/* 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)
-{
- 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,
- get_gid_callback, tctx);
- if (ret != EOK) {
- DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret));
- goto done;
- }
-
- tctx->error = EOK;
- tctx->octx->gid = 0;
- while ((tctx->error == EOK) && (tctx->octx->gid == 0)) {
- tevent_loop_once(tctx->ev);
- }
-
- if (tctx->error) {
- DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret));
- goto done;
- }
- }
-
-done:
- return ret;
-}
-
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;
@@ -114,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 },
@@ -225,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;
/*
@@ -284,9 +206,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->ev,
tctx->sysdb,