|
|
ee8dc1 |
From cac0fa9df8888245399f2db187e05e31f93d1471 Mon Sep 17 00:00:00 2001
|
|
|
ee8dc1 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
ee8dc1 |
Date: Mon, 15 Apr 2019 17:56:37 +0200
|
|
|
ee8dc1 |
Subject: [PATCH 2/7] tools: remove errx from user and group commands
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1588596
|
|
|
ee8dc1 |
---
|
|
|
ee8dc1 |
tools/entry.c | 232 +++++++++++++++++++++++++++++++++-----------------
|
|
|
ee8dc1 |
1 file changed, 154 insertions(+), 78 deletions(-)
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
diff --git a/tools/entry.c b/tools/entry.c
|
|
|
ee8dc1 |
index de56586..97ec6e7 100644
|
|
|
ee8dc1 |
--- a/tools/entry.c
|
|
|
ee8dc1 |
+++ b/tools/entry.c
|
|
|
ee8dc1 |
@@ -232,21 +232,30 @@ adcli_tool_user_create (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc != 1)
|
|
|
ee8dc1 |
- errx (2, "specify one user name to create");
|
|
|
ee8dc1 |
+ if (argc != 1) {
|
|
|
ee8dc1 |
+ warnx ("specify one user name to create");
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_user (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
adcli_entry_set_domain_ou (entry, ou);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
if (has_unix_attr && !has_nis_domain) {
|
|
|
ee8dc1 |
@@ -254,16 +263,20 @@ adcli_tool_user_create (adcli_conn *conn,
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
- errx (-res, "couldn't get NIS domain");
|
|
|
ee8dc1 |
+ warnx ("couldn't get NIS domain");
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_create (entry, attrs);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "creating user %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("creating user %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
@@ -317,28 +330,36 @@ adcli_tool_user_delete (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc != 1)
|
|
|
ee8dc1 |
- errx (2, "specify one user name to delete");
|
|
|
ee8dc1 |
+ if (argc != 1) {
|
|
|
ee8dc1 |
+ warnx ("specify one user name to delete");
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_user (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_delete (entry);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "deleting user %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("deleting user %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
@@ -404,29 +425,41 @@ adcli_tool_group_create (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc != 1)
|
|
|
ee8dc1 |
- errx (2, "specify one group to create");
|
|
|
ee8dc1 |
+ if (argc != 1) {
|
|
|
ee8dc1 |
+ warnx ("specify one group to create");
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_group (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
adcli_entry_set_domain_ou (entry, ou);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to domain %s: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to domain %s: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_create (entry, attrs);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "creating group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("creating group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
@@ -480,28 +513,36 @@ adcli_tool_group_delete (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc != 1)
|
|
|
ee8dc1 |
- errx (2, "specify one group name to delete");
|
|
|
ee8dc1 |
+ if (argc != 1) {
|
|
|
ee8dc1 |
+ warnx ("specify one group name to delete");
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_group (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_delete (entry);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "deleting group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("deleting group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
@@ -509,7 +550,7 @@ adcli_tool_group_delete (adcli_conn *conn,
|
|
|
ee8dc1 |
return 0;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
-static void
|
|
|
ee8dc1 |
+static int
|
|
|
ee8dc1 |
expand_user_dn_as_member (adcli_conn *conn,
|
|
|
ee8dc1 |
adcli_attrs *attrs,
|
|
|
ee8dc1 |
const char *user,
|
|
|
ee8dc1 |
@@ -523,16 +564,19 @@ expand_user_dn_as_member (adcli_conn *conn,
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_load (entry);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't lookup user %s in domain %s: %s",
|
|
|
ee8dc1 |
- user, adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't lookup user %s in domain %s: %s",
|
|
|
ee8dc1 |
+ user, adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
dn = adcli_entry_get_dn (entry);
|
|
|
ee8dc1 |
if (dn == NULL) {
|
|
|
ee8dc1 |
- errx (-ADCLI_ERR_CONFIG,
|
|
|
ee8dc1 |
- "couldn't found user %s in domain %s",
|
|
|
ee8dc1 |
- user, adcli_conn_get_domain_name (conn));
|
|
|
ee8dc1 |
+ warnx ("couldn't found user %s in domain %s",
|
|
|
ee8dc1 |
+ user, adcli_conn_get_domain_name (conn));
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -ADCLI_ERR_CONFIG;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
if (adding)
|
|
|
ee8dc1 |
@@ -541,6 +585,8 @@ expand_user_dn_as_member (adcli_conn *conn,
|
|
|
ee8dc1 |
adcli_attrs_delete1 (attrs, "member", dn);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+
|
|
|
ee8dc1 |
+ return ADCLI_SUCCESS;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
int
|
|
|
ee8dc1 |
@@ -590,33 +636,48 @@ adcli_tool_member_add (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc < 2)
|
|
|
ee8dc1 |
- errx (2, "specify a group name and a user to add");
|
|
|
ee8dc1 |
+ if (argc < 2) {
|
|
|
ee8dc1 |
+ warnx ("specify a group name and a user to add");
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_group (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
attrs = adcli_attrs_new ();
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- for (i = 1; i < argc; i++)
|
|
|
ee8dc1 |
- expand_user_dn_as_member (conn, attrs, argv[i], 1);
|
|
|
ee8dc1 |
+ for (i = 1; i < argc; i++) {
|
|
|
ee8dc1 |
+ res = expand_user_dn_as_member (conn, attrs, argv[i], 1);
|
|
|
ee8dc1 |
+ if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return res;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_modify (entry, attrs);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "adding member(s) to group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("adding member(s) to group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
@@ -672,33 +733,48 @@ adcli_tool_member_remove (adcli_conn *conn,
|
|
|
ee8dc1 |
argc -= optind;
|
|
|
ee8dc1 |
argv += optind;
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- if (argc < 2)
|
|
|
ee8dc1 |
- errx (2, "specify a group name and a user to remove");
|
|
|
ee8dc1 |
+ if (argc < 2) {
|
|
|
ee8dc1 |
+ warnx ("specify a group name and a user to remove");
|
|
|
ee8dc1 |
+ return 2;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
entry = adcli_entry_new_group (conn, argv[0]);
|
|
|
ee8dc1 |
- if (entry == NULL)
|
|
|
ee8dc1 |
- errx (-1, "unexpected memory problems");
|
|
|
ee8dc1 |
+ if (entry == NULL) {
|
|
|
ee8dc1 |
+ warnx ("unexpected memory problems");
|
|
|
ee8dc1 |
+ return -1;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_conn_connect (conn);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("couldn't connect to %s domain: %s",
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
attrs = adcli_attrs_new ();
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
- for (i = 1; i < argc; i++)
|
|
|
ee8dc1 |
- expand_user_dn_as_member (conn, attrs, argv[i], 0);
|
|
|
ee8dc1 |
+ for (i = 1; i < argc; i++) {
|
|
|
ee8dc1 |
+ res = expand_user_dn_as_member (conn, attrs, argv[i], 0);
|
|
|
ee8dc1 |
+ if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return res;
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
+ }
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
res = adcli_entry_modify (entry, attrs);
|
|
|
ee8dc1 |
if (res != ADCLI_SUCCESS) {
|
|
|
ee8dc1 |
- errx (-res, "adding member(s) to group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
- adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
- adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
- adcli_get_last_error ());
|
|
|
ee8dc1 |
+ warnx ("adding member(s) to group %s in domain %s failed: %s",
|
|
|
ee8dc1 |
+ adcli_entry_get_sam_name (entry),
|
|
|
ee8dc1 |
+ adcli_conn_get_domain_name (conn),
|
|
|
ee8dc1 |
+ adcli_get_last_error ());
|
|
|
ee8dc1 |
+ adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
+ adcli_entry_unref (entry);
|
|
|
ee8dc1 |
+ return -res;
|
|
|
ee8dc1 |
}
|
|
|
ee8dc1 |
|
|
|
ee8dc1 |
adcli_attrs_free (attrs);
|
|
|
ee8dc1 |
--
|
|
|
ee8dc1 |
2.20.1
|
|
|
ee8dc1 |
|