gnutls changes from ubuntu package

This commit is contained in:
Isaac Connor 2013-04-29 15:32:55 -04:00
parent 0913287ee1
commit ce61512a0d
2 changed files with 74 additions and 83 deletions

View File

@ -1,5 +1,5 @@
/* /*
* ZoneMinder regular expression class implementation, $Date$, $Revision$ * ZoneMinder regular expression class implementation, $Date: 2011-08-03 12:31:06 +0100 (Wed, 03 Aug 2011) $, $Revision: 3489 $
* Copyright (C) 2001-2008 Philip Coombes * Copyright (C) 2001-2008 Philip Coombes
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -143,7 +143,7 @@ User *zmLoadUser( const char *username, const char *password )
// Function to validate an authentication string // Function to validate an authentication string
User *zmLoadAuthUser( const char *auth, bool use_remote_addr ) User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
{ {
#if HAVE_DECL_MD5 || HAVE_DECL_GNUTLS_FINGERPRINT #if HAVE_DECL_MD5
#ifdef HAVE_GCRYPT_H #ifdef HAVE_GCRYPT_H
// Special initialisation for libgcrypt // Special initialisation for libgcrypt
if ( !gcry_check_version( GCRYPT_VERSION ) ) if ( !gcry_check_version( GCRYPT_VERSION ) )
@ -196,8 +196,7 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
char auth_key[512] = ""; char auth_key[512] = "";
char auth_md5[32+1] = ""; char auth_md5[32+1] = "";
size_t md5len = 32; unsigned char md5sum[MD5_DIGEST_LENGTH];
unsigned char md5sum[md5len];
time_t now = time( 0 ); time_t now = time( 0 );
int max_tries = 2; int max_tries = 2;
@ -217,14 +216,9 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
now_tm->tm_year now_tm->tm_year
); );
#if HAVE_DECL_MD5
MD5( (unsigned char *)auth_key, strlen(auth_key), md5sum ); MD5( (unsigned char *)auth_key, strlen(auth_key), md5sum );
#elif HAVE_DECL_GNUTLS_FINGERPRINT
gnutls_datum_t md5data = { (unsigned char *)auth_key, strlen(auth_key) };
gnutls_fingerprint( GNUTLS_DIG_MD5, &md5data, md5sum, &md5len );
#endif
auth_md5[0] = '\0'; auth_md5[0] = '\0';
for ( int j = 0; j < md5len; j++ ) for ( int j = 0; j < MD5_DIGEST_LENGTH; j++ )
{ {
sprintf( &auth_md5[2*j], "%02x", md5sum[j] ); sprintf( &auth_md5[2*j], "%02x", md5sum[j] );
} }

View File

@ -1,73 +1,70 @@
/* /*
* ZoneMinder User Class Interface, $Date$, $Revision$ * ZoneMinder User Class Interface, $Date: 2010-11-11 12:11:06 +0000 (Thu, 11 Nov 2010) $, $Revision: 3188 $
* Copyright (C) 2001-2008 Philip Coombes * Copyright (C) 2001-2008 Philip Coombes
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "zm.h" #include "zm.h"
#include "zm_db.h" #include "zm_db.h"
#ifndef ZM_USER_H #ifndef ZM_USER_H
#define ZM_USER_H #define ZM_USER_H
#if HAVE_GNUTLS_OPENSSL_H #if HAVE_LIBGNUTLS_OPENSSL
#include <gnutls/openssl.h> #include <gnutls/openssl.h>
#endif #if HAVE_GCRYPT_H
#if HAVE_GNUTLS_GNUTLS_H #include <gcrypt.h>
#include <gnutls/gnutls.h> #endif // HAVE_GCRYPT_H
#endif #elif HAVE_LIBCRYPTO
#if HAVE_GCRYPT_H #include <openssl/md5.h>
#include <gcrypt.h> #endif // HAVE_LIBGNUTLS_OPENSSL || HAVE_LIBCRYPTO
#elif HAVE_LIBCRYPTO
#include <openssl/md5.h> class User
#endif // HAVE_L || HAVE_LIBCRYPTO {
public:
class User typedef enum { PERM_NONE=1, PERM_VIEW, PERM_EDIT } Permission;
{
public: protected:
typedef enum { PERM_NONE=1, PERM_VIEW, PERM_EDIT } Permission; char username[32+1];
char password[64+1];
protected: bool enabled;
char username[32+1]; Permission stream;
char password[64+1]; Permission events;
bool enabled; Permission control;
Permission stream; Permission monitors;
Permission events; Permission system;
Permission control; int *monitor_ids;
Permission monitors;
Permission system; public:
int *monitor_ids; User();
User( MYSQL_ROW &dbrow );
public: ~User();
User();
User( MYSQL_ROW &dbrow ); const char *getUsername() const { return( username ); }
~User(); const char *getPassword() const { return( password ); }
bool isEnabled() const { return( enabled ); }
const char *getUsername() const { return( username ); } Permission getStream() const { return( stream ); }
const char *getPassword() const { return( password ); } Permission getEvents() const { return( events ); }
bool isEnabled() const { return( enabled ); } Permission getControl() const { return( control ); }
Permission getStream() const { return( stream ); } Permission getMonitors() const { return( monitors ); }
Permission getEvents() const { return( events ); } Permission getSystem() const { return( system ); }
Permission getControl() const { return( control ); } bool canAccess( int monitor_id );
Permission getMonitors() const { return( monitors ); } };
Permission getSystem() const { return( system ); }
bool canAccess( int monitor_id ); User *zmLoadUser( const char *username, const char *password=0 );
}; User *zmLoadAuthUser( const char *auth, bool use_remote_addr );
User *zmLoadUser( const char *username, const char *password=0 ); #endif // ZM_USER_H
User *zmLoadAuthUser( const char *auth, bool use_remote_addr );
#endif // ZM_USER_H