[stgt] [PATCH] Unbinding a non-existent account returns success

pajryan at gmail.com pajryan at gmail.com
Fri Oct 7 08:03:17 CEST 2011


From: Paul Ryan <pajryan at gmail.com>

This adds support so tgtadm can return an error code and error
message when a non-existent user account is deleted from a target.

Signed-off-by: Paul Ryan <pajryan at gmail.com>
---
 usr/mgmt.c   |    3 +--
 usr/target.c |    5 +++--
 usr/tgtd.h   |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/usr/mgmt.c b/usr/mgmt.c
index af37480..d8c398e 100644
--- a/usr/mgmt.c
+++ b/usr/mgmt.c
@@ -261,8 +261,7 @@ static int account_mgmt(int lld_no,  struct mgmt_task *mtask)
 			err = account_add(user, password);
 		} else {
 			if (req->op == OP_DELETE) {
-				account_del(user);
-				err = 0;
+				err = account_del(user);
 			} else
 				err = account_ctl(req->tid, req->ac_dir,
 						  user, req->op == OP_BIND);
diff --git a/usr/target.c b/usr/target.c
index 83f572c..e621b59 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -1412,14 +1412,14 @@ int account_ctl(int tid, int type, char *user, int bind)
 	return err;
 }
 
-void account_del(char *user)
+int account_del(char *user)
 {
 	struct account_entry *ac;
 	struct target *target;
 
 	ac = __account_lookup_user(user);
 	if (!ac)
-		return;
+		return TGTADM_NO_USER;
 
 	list_for_each_entry(target, &target_list, target_siblings) {
 		account_ctl(target->tid, ACCOUNT_TYPE_INCOMING, ac->user, 0);
@@ -1433,6 +1433,7 @@ void account_del(char *user)
 	free(ac->user);
 	free(ac->password);
 	free(ac);
+	return 0;
 }
 
 int account_available(int tid, int dir)
diff --git a/usr/tgtd.h b/usr/tgtd.h
index 86198c8..d5257f1 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -294,7 +294,7 @@ extern char *iqn_acl_get(int tid, int idx);
 
 extern int account_lookup(int tid, int type, char *user, int ulen, char *password, int plen);
 extern int account_add(char *user, char *password);
-extern void account_del(char *user);
+extern int account_del(char *user);
 extern int account_ctl(int tid, int type, char *user, int bind);
 extern int account_show(char *buf, int rest);
 extern int account_available(int tid, int dir);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list