[pubcookie-dev] WEBISO CVS update: willey;
keyserver.c,2.36,2.36.2.1 pbc_key_generic.c,1.5,1.5.2.1
pbc_key_local.c,1.9,1.9.2.1 pbc_logging.h,1.16,1.16.2.1
pbc_myconfig.c,1.32,1.32.2.1 pbc_myconfig.h,1.12,1.12.2.1
Stephen Willey
willey at cac.washington.edu
Thu Jul 10 11:58:34 PDT 2003
Update of /usr/local/cvsroot/webiso/pubcookie/src
In directory webiso-cvs.cac.washington.edu:/var/tmp/cvs-serv769
Modified Files:
Tag: UWash3
base64.c keyclient.c keyserver.c pbc_key_generic.c
pbc_key_local.c pbc_logging.h pbc_myconfig.c pbc_myconfig.h
Log Message:
added: component specific config files
bigger buffer for config lines
keyserver client list - restricts client operations to hosts on an optional list
more comments and Doxygen headers
Index: webiso/pubcookie/src/base64.c
diff -c webiso/pubcookie/src/base64.c:1.15 webiso/pubcookie/src/base64.c:1.15.2.1
*** webiso/pubcookie/src/base64.c:1.15 Wed Jul 2 21:25:21 2003
--- webiso/pubcookie/src/base64.c Thu Jul 10 11:58:31 2003
***************
*** 3,12 ****
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file base64.cgi.c
* Base64 functions
*
! * $Id: base64.c,v 1.15 2003/07/03 04:25:21 willey Exp $
*/
--- 3,12 ----
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file base64.c
* Base64 functions
*
! * $Id: base64.c,v 1.15.2.1 2003/07/10 18:58:31 willey Exp $
*/
Index: webiso/pubcookie/src/keyclient.c
diff -c webiso/pubcookie/src/keyclient.c:2.35 webiso/pubcookie/src/keyclient.c:2.35.2.1
*** webiso/pubcookie/src/keyclient.c:2.35 Fri Jul 4 00:41:58 2003
--- webiso/pubcookie/src/keyclient.c Thu Jul 10 11:58:31 2003
***************
*** 6,12 ****
/** @file keyclient.c
* Key administration tool for clients
*
! * $Id: keyclient.c,v 2.35 2003/07/04 07:41:58 ryanc Exp $
*/
--- 6,12 ----
/** @file keyclient.c
* Key administration tool for clients
*
! * $Id: keyclient.c,v 2.35.2.1 2003/07/10 18:58:31 willey Exp $
*/
***************
*** 180,185 ****
--- 180,186 ----
#endif
libpbc_config_init(p, NULL, "keyclient");
+ pbc_log_init(p, "keyclient", NULL, NULL, NULL);
libpbc_pubcookie_init(p);
keyfile = libpbc_config_getstring(p, "ssl_key_file", "server.pem");
certfile = libpbc_config_getstring(p, "ssl_cert_file", "server.pem");
Index: webiso/pubcookie/src/keyserver.c
diff -c webiso/pubcookie/src/keyserver.c:2.36 webiso/pubcookie/src/keyserver.c:2.36.2.1
*** webiso/pubcookie/src/keyserver.c:2.36 Wed Jul 2 21:25:21 2003
--- webiso/pubcookie/src/keyserver.c Thu Jul 10 11:58:31 2003
***************
*** 6,12 ****
/** @file keyserver.c
* Server side of key management structure
*
! * $Id: keyserver.c,v 2.36 2003/07/03 04:25:21 willey Exp $
*/
--- 6,12 ----
/** @file keyserver.c
* Server side of key management structure
*
! * $Id: keyserver.c,v 2.36.2.1 2003/07/10 18:58:31 willey Exp $
*/
***************
*** 259,267 ****
}
/**
* do the keyserver operation
* @param peer the name of the client that's connected to us
! * @param op the operation to perform, one of GENKEY, SETKEY, FETCHKEY
* @param newkey if the operation is SETKEY, "peer;base64(key)"
* @return 0 on success, non-zero on error
*/
--- 259,296 ----
}
/**
+ @param peer machine talking to the keyserver
+ @return PBC_FAIL if not in the access list, PBC_OK if ok.
+ */
+ static int check_access_list(const char *peer)
+ {
+ pool *p = NULL;
+ char **access_list = libpbc_config_getlist(p, "keyserver_client_list");
+ int i;
+
+ /* if there is no access list then everyone is ok */
+ if (access_list == NULL) {
+ pbc_log_activity(p, PBC_LOG_DEBUG_VERBOSE,
+ "No keyserver_client_list, hope that's ok");
+ return(PBC_OK);
+ }
+
+ for (i = 0; access_list[i] != NULL; i++)
+ if( strcasecmp(access_list[i], peer) == 0 )
+ return PBC_OK;
+
+ return PBC_FAIL;
+
+ }
+
+ /**
* do the keyserver operation
* @param peer the name of the client that's connected to us
! * @param op the operation to perform, one of:
! * GENKEY - generate a new key for peer
! * SETKEY - key from friend login server
! * FETCHKEY - peer requests it's key
! * NOOP - for completeness
* @param newkey if the operation is SETKEY, "peer;base64(key)"
* @return 0 on success, non-zero on error
*/
***************
*** 274,279 ****
--- 303,315 ----
/* no HTML headers for me */
myprintf("\r\n");
+ /* check access list for client operations */
+ if( op != SETKEY && check_access_list(peer) == PBC_FAIL ) {
+ myprintf("you (%s) are not in keyserver client list\r\n", peer);
+ pbc_log_activity(p, PBC_LOG_ERROR, "operation not allowed: %s", peer);
+ return(1);
+ }
+
switch (op) {
case GENKEY:
{
***************
*** 445,450 ****
--- 481,487 ----
pool *p = NULL;
libpbc_config_init(p, NULL, "keyserver");
+ pbc_log_init(p, "keyclient", NULL, NULL, NULL);
libpbc_pubcookie_init(p);
debug = libpbc_config_getint(p, "debug", 0);
Index: webiso/pubcookie/src/pbc_key_generic.c
diff -c webiso/pubcookie/src/pbc_key_generic.c:1.5 webiso/pubcookie/src/pbc_key_generic.c:1.5.2.1
*** webiso/pubcookie/src/pbc_key_generic.c:1.5 Wed Jul 2 15:04:04 2003
--- webiso/pubcookie/src/pbc_key_generic.c Thu Jul 10 11:58:31 2003
***************
*** 3,12 ****
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pbc_verify.c
! * Manually verify cookies
*
! * $Id: pbc_key_generic.c,v 1.5 2003/07/02 22:04:04 willey Exp $
*/
--- 3,12 ----
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pbc_key_generic.c
! * old key management
*
! * $Id: pbc_key_generic.c,v 1.5.2.1 2003/07/10 18:58:31 willey Exp $
*/
Index: webiso/pubcookie/src/pbc_key_local.c
diff -c webiso/pubcookie/src/pbc_key_local.c:1.9 webiso/pubcookie/src/pbc_key_local.c:1.9.2.1
*** webiso/pubcookie/src/pbc_key_local.c:1.9 Wed Jul 2 15:04:04 2003
--- webiso/pubcookie/src/pbc_key_local.c Thu Jul 10 11:58:31 2003
***************
*** 3,12 ****
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pub_key_local.c
* Old (and i think obsolete) key mgmt
*
! * $Id: pbc_key_local.c,v 1.9 2003/07/02 22:04:04 willey Exp $
*/
--- 3,12 ----
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pbc_key_local.c
* Old (and i think obsolete) key mgmt
*
! * $Id: pbc_key_local.c,v 1.9.2.1 2003/07/10 18:58:31 willey Exp $
*/
Index: webiso/pubcookie/src/pbc_logging.h
diff -c webiso/pubcookie/src/pbc_logging.h:1.16 webiso/pubcookie/src/pbc_logging.h:1.16.2.1
*** webiso/pubcookie/src/pbc_logging.h:1.16 Wed Jul 2 21:25:21 2003
--- webiso/pubcookie/src/pbc_logging.h Thu Jul 10 11:58:31 2003
***************
*** 3,11 ****
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /*
! $Id: pbc_logging.h,v 1.16 2003/07/03 04:25:21 willey Exp $
*/
#ifndef INCLUDED_PBC_LOGGING_H
#define INCLUDED_PBC_LOGGING_H
--- 3,14 ----
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pbc_logging.h
! * Header file for logging stuff
! *
! * $Id: pbc_logging.h,v 1.16.2.1 2003/07/10 18:58:31 willey Exp $
*/
+
#ifndef INCLUDED_PBC_LOGGING_H
#define INCLUDED_PBC_LOGGING_H
Index: webiso/pubcookie/src/pbc_myconfig.c
diff -c webiso/pubcookie/src/pbc_myconfig.c:1.32 webiso/pubcookie/src/pbc_myconfig.c:1.32.2.1
*** webiso/pubcookie/src/pbc_myconfig.c:1.32 Wed Jul 2 21:25:21 2003
--- webiso/pubcookie/src/pbc_myconfig.c Thu Jul 10 11:58:31 2003
***************
*** 6,12 ****
/** @file pbc_myconfig.c
* Runtime configuration
*
! * $Id: pbc_myconfig.c,v 1.32 2003/07/03 04:25:21 willey Exp $
*/
--- 6,12 ----
/** @file pbc_myconfig.c
* Runtime configuration
*
! * $Id: pbc_myconfig.c,v 1.32.2.1 2003/07/10 18:58:31 willey Exp $
*/
***************
*** 57,62 ****
--- 57,63 ----
# define EX_OSERR 71
#endif /* HAVE_SYSEXITS_H */
+ #include "pbc_logging.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
***************
*** 83,92 ****
char *value;
};
static struct configlist *configlist;
static int nconfiglist;
! static void myconfig_read(pool *p, const char *alt_config);
static void fatal(pool *p, const char *s, int ex);
#ifdef WIN32
--- 84,96 ----
char *value;
};
+ #define REQUIRED 1
+ #define NOT_REQUIRED 0
+
static struct configlist *configlist;
static int nconfiglist;
! static void myconfig_read(pool *p, const char *alt_config, int required);
static void fatal(pool *p, const char *s, int ex);
#ifdef WIN32
***************
*** 95,112 ****
#ifndef WIN32
- /**
- * libpbc_myconfig_init()
- * @param p memory pool
- * @param alt_config different config file to read
- */
int libpbc_myconfig_init(pool *p, const char *alt_config, const char *ident)
{
const char *val;
int umaskval = 0;
! myconfig_read(p, alt_config);
/* Look up umask */
val = libpbc_myconfig_getstring(p, "umask", "022");
while (*val) {
--- 99,135 ----
#ifndef WIN32
int libpbc_myconfig_init(pool *p, const char *alt_config, const char *ident)
{
const char *val;
int umaskval = 0;
+ char *sub_config, *ptr, *ptr2;
+ int len;
! myconfig_read(p, alt_config, REQUIRED);
+ /* get the sub config file for the pubcookie sub-system */
+ if (ident != NULL ) {
+ /* +1 for oes and +1 for extra '/' */
+ len = strlen(PBC_PATH) + strlen(ident) + strlen(PBC_SUBCONFIG) + 1 + 1;
+ sub_config = pbc_malloc(p, sizeof(char *) * len);
+ bzero(sub_config, len);
+ snprintf(sub_config, len, "%s/%s%s", PBC_PATH, ident, PBC_SUBCONFIG);
+
+ /* remove that extra slash */
+ ptr = ptr2 = sub_config;
+ while( *ptr2 ) {
+ if( ptr2 != sub_config && *ptr2 == '/' && *(ptr2-1) == '/' )
+ ptr2++;
+ else
+ *ptr++ = *ptr2++;
+ }
+ *ptr = '\0';
+
+ myconfig_read(p, sub_config, NOT_REQUIRED);
+ free(sub_config);
+ }
+
/* Look up umask */
val = libpbc_myconfig_getstring(p, "umask", "022");
while (*val) {
***************
*** 239,256 ****
#ifndef WIN32
#define CONFIGLISTGROWSIZE 30 /* 100 */
! static void myconfig_read(pool *p, const char *alt_config)
{
FILE *infile;
int lineno = 0;
int alloced = 0;
! char buf[4096];
char *ptr, *q, *key;
! infile = pbc_fopen(p, alt_config ? alt_config : PBC_CONFIG, "r");
if (!infile) {
snprintf(buf, sizeof(buf), "can't open configuration file %s: %s",
! alt_config ? alt_config : PBC_CONFIG,
strerror(errno));
fatal(p, buf, EX_CONFIG);
}
--- 262,284 ----
#ifndef WIN32
#define CONFIGLISTGROWSIZE 30 /* 100 */
! static void myconfig_read(pool *p, const char *alt_config, int required)
{
FILE *infile;
+ const char *filename;
int lineno = 0;
int alloced = 0;
! char buf[8192];
char *ptr, *q, *key;
! filename = alt_config ? alt_config : PBC_CONFIG;
! infile = pbc_fopen(p, filename, "r");
if (!infile) {
+ if ( required == NOT_REQUIRED ) {
+ return;
+ }
snprintf(buf, sizeof(buf), "can't open configuration file %s: %s",
! filename,
strerror(errno));
fatal(p, buf, EX_CONFIG);
}
***************
*** 269,276 ****
}
if (*ptr != ':') {
snprintf(buf, sizeof(buf),
! "invalid option name on line %d of configuration file",
! lineno);
fatal(p, buf, EX_CONFIG);
}
*ptr++ = '\0';
--- 297,304 ----
}
if (*ptr != ':') {
snprintf(buf, sizeof(buf),
! "invalid option name on line %d of configuration file %s",
! lineno, filename);
fatal(p, buf, EX_CONFIG);
}
*ptr++ = '\0';
***************
*** 284,291 ****
if (!*ptr) {
snprintf(buf, sizeof(buf),
! "empty option value on line %d of configuration file",
! lineno);
fatal(p, buf, EX_CONFIG);
}
--- 312,319 ----
if (!*ptr) {
snprintf(buf, sizeof(buf),
! "empty option value on line %d of configuration file %s",
! lineno, filename);
fatal(p, buf, EX_CONFIG);
}
Index: webiso/pubcookie/src/pbc_myconfig.h
diff -c webiso/pubcookie/src/pbc_myconfig.h:1.12 webiso/pubcookie/src/pbc_myconfig.h:1.12.2.1
*** webiso/pubcookie/src/pbc_myconfig.h:1.12 Wed Jul 2 21:25:21 2003
--- webiso/pubcookie/src/pbc_myconfig.h Thu Jul 10 11:58:31 2003
***************
*** 3,11 ****
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /*
! $Id: pbc_myconfig.h,v 1.12 2003/07/03 04:25:21 willey Exp $
*/
#ifndef INCLUDED_PBC_MYCONF_H
#define INCLUDED_PBC_MYCONF_H
--- 3,14 ----
For terms of use see doc/LICENSE.txt in this distribution.
*/
! /** @file pbc_myconfig.h
! * header file for Runtime configuration
! *
! * $Id: pbc_myconfig.h,v 1.12.2.1 2003/07/10 18:58:31 willey Exp $
*/
+
#ifndef INCLUDED_PBC_MYCONF_H
#define INCLUDED_PBC_MYCONF_H
end of message
More information about the pubcookie-dev
mailing list