+++ /dev/null
-# 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
-/* $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
zh->errCode = 0;
zh->errString = 0;
zh->res = 0;
+ zh->user_perm = 0;
zh->reg_name = xstrdup ("");
zh->path_reg = 0;
}
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);
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;
}
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;
}
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)
}
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)
{
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 */
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 */
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 */
-/* $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
r->errcode = 1;
return r;
}
+ r->handle = zh;
if (q->auth)
{
if (q->auth->which == Z_IdAuthentication_open)
}
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;