[PATCH 4/5] ietd: add support to retrieve a list of CHAP accounts

View: New views
3 Messages — Rating Filter:   Alert me  

[PATCH 4/5] ietd: add support to retrieve a list of CHAP accounts

by Arne Redlich-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Implement C_ACCT_LIST ietadm request handling in ietd.
---
 usr/config.h  |    1 +
 usr/message.c |   14 ++++++++++++++
 usr/plain.c   |   25 +++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/usr/config.h b/usr/config.h
index b153bba..b3ecef5 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -14,6 +14,7 @@ struct config_operations {
  int (*account_add) (u32, int, char *, char *);
  int (*account_del) (u32, int, char *);
  int (*account_query) (u32, int, char *, char *);
+ int (*account_list) (u32, int, u32 *, u32 *, char *, size_t);
  int (*initiator_access) (u32, int);
 };
 
diff --git a/usr/message.c b/usr/message.c
index f44d1cc..e4b8994 100644
--- a/usr/message.c
+++ b/usr/message.c
@@ -110,6 +110,20 @@ static void ietadm_request_exec(struct ietadm_req *req, struct ietadm_rsp *rsp,
  req->u.acnt.u.user.name);
  break;
  case C_ACCT_LIST:
+ *rsp_data = malloc(req->u.acnt.u.list.alloc_len);
+ if (!*rsp_data) {
+ err = -ENOMEM;
+ break;
+ }
+
+ *rsp_data_sz = req->u.acnt.u.list.alloc_len;
+ memset(*rsp_data, 0x0, *rsp_data_sz);
+
+ err = cops->account_list(req->tid, req->u.acnt.auth_dir,
+ &req->u.acnt.u.list.count,
+ &req->u.acnt.u.list.overflow,
+ *rsp_data, *rsp_data_sz);
+ break;
  case C_ACCT_UPDATE:
  break;
  case C_ACCT_SHOW:
diff --git a/usr/plain.c b/usr/plain.c
index e653fbf..711f293 100644
--- a/usr/plain.c
+++ b/usr/plain.c
@@ -156,6 +156,30 @@ static int plain_account_query(u32 tid, int dir, char *name, char *pass)
  return 0;
 }
 
+static int plain_account_list(u32 tid, int dir, u32 *cnt, u32 *overflow,
+      char *buf, size_t buf_sz)
+{
+ struct __qelem *list = account_list_get(tid, dir);
+ struct user *user;
+
+ *cnt = *overflow = 0;
+
+ if (!list)
+ return -ENOENT;
+
+ list_for_each_entry(user, list, ulist) {
+ if (buf_sz >= ISCSI_NAME_LEN) {
+ strncpy(buf, user->name, ISCSI_NAME_LEN);
+ buf_sz -= ISCSI_NAME_LEN;
+ buf += ISCSI_NAME_LEN;
+ *cnt += 1;
+ } else
+ *overflow += 1;
+ }
+
+ return 0;
+}
+
 static void account_destroy(struct user *user)
 {
  if (!user)
@@ -617,5 +641,6 @@ struct config_operations plain_ops = {
  .account_add = plain_account_add,
  .account_del = plain_account_del,
  .account_query = plain_account_query,
+ .account_list = plain_account_list,
  .initiator_access = plain_initiator_access,
 };
--
1.5.4.3


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Iscsitarget-devel mailing list
Iscsitarget-devel@...
https://lists.sourceforge.net/lists/listinfo/iscsitarget-devel

Re: [PATCH 4/5] ietd: add support to retrieve a list of CHAP accounts

by Jeff Waller :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I found this did not compile for me due to a declaration of __qelem  
instead of
qelem  Here's a patch for that.


*** plain.c Fri Jun 27 20:48:17 2008
--- plain.c.orig Fri Jun 27 20:47:47 2008
***************
*** 159,165 ****
   static int plain_account_list(u32 tid, int dir, u32 *cnt, u32  
*overflow,
         char *buf, size_t buf_sz)
   {
! struct qelem *list = account_list_get(tid, dir);
    struct user *user;

    *cnt = *overflow = 0;
--- 159,165 ----
   static int plain_account_list(u32 tid, int dir, u32 *cnt, u32  
*overflow,
         char *buf, size_t buf_sz)
   {
! struct __qelem *list = account_list_get(tid, dir);
    struct user *user;

    *cnt = *overflow = 0;


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Iscsitarget-devel mailing list
Iscsitarget-devel@...
https://lists.sourceforge.net/lists/listinfo/iscsitarget-devel

Re: [PATCH 4/5] ietd: add support to retrieve a list of CHAP accounts

by Arne Redlich-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[Dropping Tomo and Vlad from CC]

Am Freitag, den 27.06.2008, 20:51 -0400 schrieb Jeff Waller:
> I found this did not compile for me due to a declaration of __qelem  
> instead of
> qelem  Here's a patch for that.

Yes, this is the correct change if you want to apply the patchset to
0.4.16.

However, the patchset was made against the svn trunk, which is the place
to look if you're interested in IET development - cf. "Developer Notes"
section in our README.

HTH,
Arne



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Iscsitarget-devel mailing list
Iscsitarget-devel@...
https://lists.sourceforge.net/lists/listinfo/iscsitarget-devel
LightInTheBox - Buy quality products at wholesale price!