Add a better match() function.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@510 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-16 16:20:32 +00:00
parent 59f04bfddd
commit a2cce56134

View File

@@ -4,6 +4,7 @@
* This file is part of the SSH Library * This file is part of the SSH Library
* *
* Copyright (c) 2003-2008 by Aris Adamantiadis * Copyright (c) 2003-2008 by Aris Adamantiadis
* Copyright (c) 2009 by Andreas Schneider <mail@cynapses.org>
* *
* The SSH Library is free software; you can redistribute it and/or modify * The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -847,33 +848,29 @@ STRING *ssh_get_pubkey(SSH_SESSION *session){
return string_copy(session->current_crypto->server_pubkey); return string_copy(session->current_crypto->server_pubkey);
} }
/* XXX i doubt it is still needed, or may need some fix */
static int match(const char *group, const char *object){ static int match(const char *group, const char *object){
char *ptr,*saved; const char *p;
char *end; const char *z;
ptr=strdup(group);
if (ptr == NULL) { p = z = group;
return -1; do {
} p = strchr(z, ',');
saved=ptr; if (p == NULL) {
while(1){ if (strcmp(z, object) == 0) {
end=strchr(ptr,',');
if(end)
*end=0;
if(!strcmp(ptr,object)){
free(saved);
return 0;
}
if(end)
ptr=end+1;
else{
free(saved);
return -1;
}
}
/* not reached */
return 1; return 1;
} }
return 0;
} else {
if (strncmp(z, object, p - z) == 0) {
return 1;
}
}
z = p + 1;
} while(1);
/* not reached */
return 0;
}
static int sig_verify(SSH_SESSION *session, PUBLIC_KEY *pubkey, SIGNATURE *signature, static int sig_verify(SSH_SESSION *session, PUBLIC_KEY *pubkey, SIGNATURE *signature,
unsigned char *digest){ unsigned char *digest){