From 1e869b75dd665a3ac79648269e1416bf7e04dcdd Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 29 Mar 2004 15:48:14 +0000 Subject: [PATCH] Fixed bug in return of handle for init when authentication failed. Support idPass authentication. Add preliminary support for user permissios (to allow safer remote update for certain users). --- CHANGELOG | 7 +++++++ configure.in | 4 ++-- debian/changelog | 6 ++++++ index/index.h | 3 ++- index/zebra.cfg | 22 ---------------------- index/zebraapi.c | 49 +++++++++++++++++++++++++++++++++++++------------ index/zserver.c | 12 +++++++++--- win/zebra.nsi | 4 ++-- 8 files changed, 65 insertions(+), 42 deletions(-) delete mode 100644 index/zebra.cfg diff --git a/CHANGELOG b/CHANGELOG index 373e0d6..23019ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ +--- 1.3.16 2004/03/29 + For text filter, return only header if elementSetName=H . elementSetName=R returns contents only. Other elementSetName returns both header+content. @@ -9,6 +11,11 @@ Added feature charmaps (.chr) so that characters may be specified in Fixed problem with encoding directive for charmap(.chr) files. +Allow Remote insert/delete/replace/update with record, recordIdNumber +(sysno) and/or recordIdOpaque(user supplied record Id). If both +IDs are omitted internal record ID match is assumed (recordId: - in +zebra cfg). + --- 1.3.15 2004/01/15 Fix bug. X-Path attribute expressions with spaces in them now works. diff --git a/configure.in b/configure.in index e1223d1..63084bc 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,8 @@ dnl Zebra, Index Data Aps, 1995-2004 -dnl $Id: configure.in,v 1.89 2004-03-09 15:12:14 adam Exp $ +dnl $Id: configure.in,v 1.90 2004-03-29 15:48:14 adam Exp $ dnl AC_INIT(include/zebraver.h) -AM_INIT_AUTOMAKE(idzebra,1.3.15) +AM_INIT_AUTOMAKE(idzebra,1.3.16) dnl ------ Substitutions AC_SUBST(TCL_INCLUDE) AC_SUBST(TCL_LIB) diff --git a/debian/changelog b/debian/changelog index 57b03e2..38f80a6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +idzebra (1.3.16-1) unstable; urgency=low + + * Upstream. + + -- Adam Dickmeiss Mon, 29 Mar 2004 14:48:50 +0200 + idzebra (1.3.15-1) unstable; urgency=low * Upstream. diff --git a/index/index.h b/index/index.h index 54ffa52..35abd54 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.104 2004-01-22 15:40:25 heikki Exp $ +/* $Id: index.h,v 1.105 2004-03-29 15:48:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -301,6 +301,7 @@ struct zebra_session { int destroyed; ZebraSet sets; Res res; + char *user_perm; int errCode; int hits; char *errString; diff --git a/index/zebra.cfg b/index/zebra.cfg deleted file mode 100644 index 8e15c62..0000000 --- a/index/zebra.cfg +++ /dev/null @@ -1,22 +0,0 @@ -# Zebra configuration file -# $Id: zebra.cfg,v 1.2 1996-10-11 10:57:05 adam Exp $ -# -#register: dir1:100M - -# News group. Indexed as normal text -news.recordType.: text -news.database: news - -# Grs group. Indexed as GRS. -grs.recordType.grs: grs.sgml -grs.recordId: $database (1,12) -grs.database: esdd - -profilePath: /usr/local/yaz - -attset: bib1.att -attset: gils.att - -wordisam.blocktypes: 64 1K 4K -wordisam.maxkeys: 160 750 -wordisam.nicefill: 80 80 80 diff --git a/index/zebraapi.c b/index/zebraapi.c index df8b8af..5392073 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.117 2004-01-22 15:40:25 heikki Exp $ +/* $Id: zebraapi.c,v 1.118 2004-03-29 15:48:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -108,6 +108,7 @@ ZebraHandle zebra_open (ZebraService zs) zh->errCode = 0; zh->errString = 0; zh->res = 0; + zh->user_perm = 0; zh->reg_name = xstrdup (""); zh->path_reg = 0; @@ -508,6 +509,7 @@ int zebra_close (ZebraHandle zh) } zebra_mutex_cond_unlock (&zs->session_lock); xfree (zh->reg_name); + xfree (zh->user_perm); zh->service=0; /* more likely to trigger an assert */ xfree (zh->path_reg); xfree (zh); @@ -974,18 +976,25 @@ void zebra_clearError(ZebraHandle zh) int zebra_auth (ZebraHandle zh, const char *user, const char *pass) { + const char *p; + char u[40]; ZebraService zs; + ASSERTZH; - yaz_log(LOG_API,"zebra_auth u=%s p=%s",user,pass); zh->errCode=0; zs= zh->service; + + sprintf(u, "perm.%.30s", user ? user : "anonymous"); + p = res_get(zs->global_res, u); + xfree (zh->user_perm); + zh->user_perm = xstrdup(p ? p : "r"); + + /* users that don't require a password .. */ + if (zh->user_perm && strchr(zh->user_perm, 'a')) + return 0; + if (!zs->passwd_db || !passwd_db_auth (zs->passwd_db, user, pass)) - { - logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS"); return 0; - } - - logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS"); return 1; } @@ -998,7 +1007,8 @@ int zebra_admin_import_begin (ZebraHandle zh, const char *database, zh->errCode=0; if (zebra_select_database(zh, database)) return 1; - zebra_begin_trans (zh, 1); + if (zebra_begin_trans (zh, 1)) + return 1; return 0; } @@ -1069,7 +1079,8 @@ int zebra_admin_exchange_record (ZebraHandle zh, memcpy (recid_z, recid_buf, recid_len); recid_z[recid_len] = 0; - zebra_begin_trans(zh,1); + if (zebra_begin_trans(zh, 1)) + return -1; rinfo = dict_lookup (zh->reg->matchDict, recid_z); if (rinfo) @@ -1308,6 +1319,17 @@ int zebra_begin_trans (ZebraHandle zh, int rw) } ASSERTZHRES; yaz_log(LOG_API,"zebra_begin_trans rw=%d",rw); + + if (zh->user_perm) + { + if (rw && !strchr(zh->user_perm, 'w')) + { + zh->errCode = 223; + zh->errString = 0; + return -1; + } + } + assert (zh->res); if (rw) { @@ -1932,7 +1954,8 @@ int zebra_insert_record (ZebraHandle zh, if (buf_size < 1) buf_size = strlen(buf); - zebra_begin_trans(zh, 1); + if (zebra_begin_trans(zh, 1)) + return 1; res = buffer_extract_record (zh, buf, buf_size, 0, /* delete_flag */ 0, /* test_mode */ @@ -1957,7 +1980,8 @@ int zebra_update_record (ZebraHandle zh, if (buf_size < 1) buf_size = strlen(buf); - zebra_begin_trans(zh, 1); + if (zebra_begin_trans(zh, 1)) + return 1; res = buffer_extract_record (zh, buf, buf_size, 0, /* delete_flag */ 0, /* test_mode */ @@ -1981,7 +2005,8 @@ int zebra_delete_record (ZebraHandle zh, if (buf_size < 1) buf_size = strlen(buf); - zebra_begin_trans(zh, 1); + if (zebra_begin_trans(zh, 1)) + return 1; res = buffer_extract_record (zh, buf, buf_size, 1, /* delete_flag */ 0, /* test_mode */ diff --git a/index/zserver.c b/index/zserver.c index b0f2be7..cfa6587 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.113 2004-01-22 11:27:21 adam Exp $ +/* $Id: zserver.c,v 1.114 2004-03-29 15:48:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -79,6 +79,7 @@ bend_initresult *bend_init (bend_initrequest *q) r->errcode = 1; return r; } + r->handle = zh; if (q->auth) { if (q->auth->which == Z_IdAuthentication_open) @@ -93,15 +94,20 @@ bend_initresult *bend_init (bend_initrequest *q) } xfree (openpass); } + else if (q->auth->which == Z_IdAuthentication_idPass) + { + Z_IdPass *idPass = q->auth->u.idPass; + + user = idPass->userId; + passwd = idPass->password; + } } if (zebra_auth (zh, user, passwd)) { r->errcode = 222; r->errstring = user; - zebra_close (zh); return r; } - r->handle = zh; if (q->charneg_request) /* characater set and langauge negotiation? */ { char **charsets = 0; diff --git a/win/zebra.nsi b/win/zebra.nsi index 53c4d8c..c1aff56 100644 --- a/win/zebra.nsi +++ b/win/zebra.nsi @@ -1,6 +1,6 @@ -; $Id: zebra.nsi,v 1.19 2004-01-15 14:22:22 adam Exp $ +; $Id: zebra.nsi,v 1.20 2004-03-29 15:48:14 adam Exp $ -!define VERSION "1.3.15" +!define VERSION "1.3.16" Name "Zebra" Caption "Index Data Zebra ${VERSION} Setup" -- 1.7.10.4