2008-12-21 22:17:09 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-21 22:17:09 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
2008-12-21 22:17:09 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_user
|
|
|
|
#define headerfile_winix_core_user
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
changed: when winix demonizes it creates a three new descriptors (0, 1 and 3)
pointing to /dev/null
added: DbBase::AssertValueBin(PGresult * r, int row, int col, std::string & result)
it reads binary (bytea) data
added: DbTextStream can handle 'bool' types now
(is puts 'true' of 'false' to the stream)
changed: now passwords can be stored either as plain text, a hash or can be encrypted
with RSA
currently we have following hashes:
md4, md5, sha1, sha224, sha256, sha384, sha512
we are using openssl to manage them
(look at config options for more info)
changed: winix version to 0.4.7
added: class Run - you can run any program from os and send a buffer to its standard input
and read what the program put on its standard output
added: class Crypt (in System) - calculating hashes, and crypting/decrypting
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@734 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-06-09 23:22:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
a temporary struct used for hashing and encrypting a user's password
|
|
|
|
*/
|
|
|
|
struct UserPass
|
|
|
|
{
|
|
|
|
int pass_type; // the kind of hash (WINIX_CRYPT_HASH_* see crypt.h)
|
|
|
|
std::wstring pass; // password hashed or plain text if pass_type==0
|
|
|
|
std::string pass_encrypted; // password encrypted
|
|
|
|
bool pass_hash_salted; // true when the hash was salted (plain text passwords are never salted)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
struct User
|
|
|
|
{
|
|
|
|
long id;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring name;
|
2008-12-21 22:17:09 +01:00
|
|
|
bool super_user;
|
|
|
|
std::vector<long> groups;
|
2010-11-21 01:19:17 +01:00
|
|
|
std::wstring email;
|
2010-12-06 01:25:46 +01:00
|
|
|
int notify;
|
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
// !! currently all users have the same offset
|
|
|
|
// option in config: time_zone_offset
|
|
|
|
int time_zone_offset;
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
User()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
id = -1;
|
|
|
|
name.clear();
|
|
|
|
super_user = false;
|
|
|
|
groups.clear();
|
2009-10-01 00:31:20 +02:00
|
|
|
email.clear();
|
2010-12-06 01:25:46 +01:00
|
|
|
notify = 0;
|
2010-10-24 01:12:47 +02:00
|
|
|
time_zone_offset = 0;
|
2008-12-21 22:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IsMemberOf(long group)
|
|
|
|
{
|
|
|
|
std::vector<long>::iterator i;
|
|
|
|
|
|
|
|
for(i=groups.begin() ; i!=groups.end() ; ++i)
|
|
|
|
if( *i == group )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|