gnutls changes from ubuntu package
This commit is contained in:
parent
0913287ee1
commit
ce61512a0d
|
@ -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
|
||||
*
|
||||
* 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
|
||||
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
|
||||
// Special initialisation for libgcrypt
|
||||
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_md5[32+1] = "";
|
||||
size_t md5len = 32;
|
||||
unsigned char md5sum[md5len];
|
||||
unsigned char md5sum[MD5_DIGEST_LENGTH];
|
||||
|
||||
time_t now = time( 0 );
|
||||
int max_tries = 2;
|
||||
|
@ -217,14 +216,9 @@ User *zmLoadAuthUser( const char *auth, bool use_remote_addr )
|
|||
now_tm->tm_year
|
||||
);
|
||||
|
||||
#if HAVE_DECL_MD5
|
||||
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';
|
||||
for ( int j = 0; j < md5len; j++ )
|
||||
for ( int j = 0; j < MD5_DIGEST_LENGTH; j++ )
|
||||
{
|
||||
sprintf( &auth_md5[2*j], "%02x", md5sum[j] );
|
||||
}
|
||||
|
|
143
src/zm_user.h
143
src/zm_user.h
|
@ -1,73 +1,70 @@
|
|||
/*
|
||||
* ZoneMinder User Class Interface, $Date$, $Revision$
|
||||
* Copyright (C) 2001-2008 Philip Coombes
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "zm.h"
|
||||
#include "zm_db.h"
|
||||
|
||||
#ifndef ZM_USER_H
|
||||
#define ZM_USER_H
|
||||
|
||||
#if HAVE_GNUTLS_OPENSSL_H
|
||||
#include <gnutls/openssl.h>
|
||||
#endif
|
||||
#if HAVE_GNUTLS_GNUTLS_H
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
#if HAVE_GCRYPT_H
|
||||
#include <gcrypt.h>
|
||||
#elif HAVE_LIBCRYPTO
|
||||
#include <openssl/md5.h>
|
||||
#endif // HAVE_L || HAVE_LIBCRYPTO
|
||||
|
||||
class User
|
||||
{
|
||||
public:
|
||||
typedef enum { PERM_NONE=1, PERM_VIEW, PERM_EDIT } Permission;
|
||||
|
||||
protected:
|
||||
char username[32+1];
|
||||
char password[64+1];
|
||||
bool enabled;
|
||||
Permission stream;
|
||||
Permission events;
|
||||
Permission control;
|
||||
Permission monitors;
|
||||
Permission system;
|
||||
int *monitor_ids;
|
||||
|
||||
public:
|
||||
User();
|
||||
User( MYSQL_ROW &dbrow );
|
||||
~User();
|
||||
|
||||
const char *getUsername() const { return( username ); }
|
||||
const char *getPassword() const { return( password ); }
|
||||
bool isEnabled() const { return( enabled ); }
|
||||
Permission getStream() const { return( stream ); }
|
||||
Permission getEvents() const { return( events ); }
|
||||
Permission getControl() const { return( control ); }
|
||||
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 );
|
||||
|
||||
#endif // ZM_USER_H
|
||||
/*
|
||||
* ZoneMinder User Class Interface, $Date: 2010-11-11 12:11:06 +0000 (Thu, 11 Nov 2010) $, $Revision: 3188 $
|
||||
* Copyright (C) 2001-2008 Philip Coombes
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "zm.h"
|
||||
#include "zm_db.h"
|
||||
|
||||
#ifndef ZM_USER_H
|
||||
#define ZM_USER_H
|
||||
|
||||
#if HAVE_LIBGNUTLS_OPENSSL
|
||||
#include <gnutls/openssl.h>
|
||||
#if HAVE_GCRYPT_H
|
||||
#include <gcrypt.h>
|
||||
#endif // HAVE_GCRYPT_H
|
||||
#elif HAVE_LIBCRYPTO
|
||||
#include <openssl/md5.h>
|
||||
#endif // HAVE_LIBGNUTLS_OPENSSL || HAVE_LIBCRYPTO
|
||||
|
||||
class User
|
||||
{
|
||||
public:
|
||||
typedef enum { PERM_NONE=1, PERM_VIEW, PERM_EDIT } Permission;
|
||||
|
||||
protected:
|
||||
char username[32+1];
|
||||
char password[64+1];
|
||||
bool enabled;
|
||||
Permission stream;
|
||||
Permission events;
|
||||
Permission control;
|
||||
Permission monitors;
|
||||
Permission system;
|
||||
int *monitor_ids;
|
||||
|
||||
public:
|
||||
User();
|
||||
User( MYSQL_ROW &dbrow );
|
||||
~User();
|
||||
|
||||
const char *getUsername() const { return( username ); }
|
||||
const char *getPassword() const { return( password ); }
|
||||
bool isEnabled() const { return( enabled ); }
|
||||
Permission getStream() const { return( stream ); }
|
||||
Permission getEvents() const { return( events ); }
|
||||
Permission getControl() const { return( control ); }
|
||||
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 );
|
||||
|
||||
#endif // ZM_USER_H
|
||||
|
|
Loading…
Reference in New Issue