Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
278dab96
Commit
278dab96
authored
Jun 24, 2008
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New user database layout and new encryption of password
parent
57b2dd6f
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
388 additions
and
250 deletions
+388
-250
src/lib/co/src/co_user.cpp
src/lib/co/src/co_user.cpp
+194
-105
src/lib/co/src/co_user.h
src/lib/co/src/co_user.h
+194
-145
No files found.
src/lib/co/src/co_user.cpp
View file @
278dab96
This diff is collapsed.
Click to expand it.
src/lib/co/src/co_user.h
View file @
278dab96
/**
* Proview $Id: co_user.h,v 1.
5 2005-09-20 13:21:45
claes Exp $
* Proview $Id: co_user.h,v 1.
6 2008-06-24 07:04:33
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -26,12 +26,15 @@
#include <fstream.h>
#include <string.h>
#include "pwr.h"
#if defined __cplusplus
extern
"C"
{
#endif
#define user_cFilename "pwra_db:pwr_user.dat"
#define user_cVersion "V1.0.0"
#define user_cFilename "pwra_db:pwr_user2.dat"
#define user_cVersion "V2.0.0"
#define user_cNId ((pwr_tOix)(~0))
#define FSPACE " "
typedef
enum
{
...
...
@@ -40,18 +43,27 @@ typedef enum {
user_eData_User
=
3
,
user_eData_End
=
99
,
user_eData_GeUserVersion
=
100
,
user_eData_GeNextId
=
101
,
user_eData_SystemName
=
200
,
user_eData_SystemLevel
=
201
,
user_eData_SystemAttributes
=
202
,
user_eData_SystemId
=
203
,
user_eData_SystemDescription
=
204
,
user_eData_UserName
=
300
,
user_eData_UserPassword
=
301
,
user_eData_UserPrivilege
=
302
}
user_eData
;
user_eData_UserPrivilege
=
302
,
user_eData_UserId
=
303
,
user_eData_UserDescription
=
304
,
user_eData_UserFullName
=
305
,
user_eData_UserPhone
=
306
,
user_eData_UserEmail
=
307
,
user_eData_UserSms
=
308
}
user_eData
;
typedef
enum
{
user_mSystemAttr_UserInherit
=
1
}
user_mSystemAttr
;
}
user_mSystemAttr
;
class
SystemName
{
public:
...
...
@@ -79,19 +91,24 @@ class SystemList {
friend
class
UserList
;
public:
SystemList
(
char
*
sl_name
,
int
sl_level
,
unsigned
int
sl_attributes
)
:
level
(
sl_level
),
attributes
(
sl_attributes
),
SystemList
(
pwr_tOix
sl_id
,
char
*
sl_name
,
int
sl_level
,
unsigned
int
sl_attributes
,
char
*
sl_descr
)
:
level
(
sl_level
),
attributes
(
sl_attributes
),
id
(
sl_id
),
next
(
0
),
childlist
(
0
),
userlist
(
0
)
{
strcpy
(
name
,
sl_name
);
if
(
sl_descr
)
strncpy
(
description
,
sl_descr
,
sizeof
(
description
));
else
strcpy
(
description
,
""
);
};
private:
char
name
[
40
]
;
pwr_tObjName
name
;
int
level
;
unsigned
long
attributes
;
pwr_tMask
attributes
;
pwr_tOix
id
;
pwr_tString80
description
;
SystemList
*
next
;
SystemList
*
childlist
;
UserList
*
userlist
;
...
...
@@ -99,18 +116,18 @@ class SystemList {
public:
int
load
(
ifstream
&
fp
);
void
save
(
ofstream
&
fp
);
void
print
(
);
void
print_all
(
);
void
print
(
int
brief
);
void
print_all
(
int
brief
);
void
*
find_user
(
char
*
name
);
int
add_user
(
char
*
user
,
char
*
password
,
unsigned
int
priv
);
int
add_system
(
SystemName
*
name
,
unsigned
int
attributes
);
int
add_user
(
pwr_tOix
ident
,
char
*
user
,
char
*
password
,
pwr_tMask
priv
,
char
*
fullname
,
char
*
descr
,
char
*
phone
,
char
*
email
,
char
*
sms
);
int
add_system
(
pwr_tOix
ident
,
SystemName
*
name
,
pwr_tMask
attributes
,
char
*
descr
);
int
load_system
(
ifstream
&
fp
);
int
load_user
(
ifstream
&
fp
);
SystemList
*
find_system
(
SystemName
*
name
);
int
remove_user
(
char
*
user
);
int
remove_system
(
SystemList
*
sys
);
void
modify
(
unsigned
int
attributes
);
void
get_data
(
unsigned
int
*
attributes
);
void
modify
(
pwr_tMask
attributes
,
char
*
description
);
void
get_data
(
pwr_tMask
*
attributes
,
pwr_tOix
*
id
,
char
*
description
);
SystemList
*
first_system
()
{
return
childlist
;}
SystemList
*
next_system
()
{
return
next
;}
UserList
*
first_user
()
{
return
userlist
;}
...
...
@@ -125,36 +142,64 @@ class UserList {
friend
class
GeUser
;
public:
UserList
(
char
*
ul_name
,
char
*
ul_password
,
unsigned
int
ul_priv
)
:
priv
(
ul_priv
),
next
(
NULL
)
UserList
(
pwr_tOix
ul_id
,
char
*
ul_name
,
char
*
ul_password
,
pwr_tMask
ul_priv
,
char
*
ul_fullname
,
char
*
ul_description
,
char
*
ul_email
,
char
*
ul_phone
,
char
*
ul_sms
)
:
priv
(
ul_priv
),
id
(
ul_id
),
next
(
NULL
)
{
strcpy
(
name
,
ul_name
);
strcpy
(
password
,
ul_password
);
if
(
ul_fullname
)
strncpy
(
fullname
,
ul_fullname
,
sizeof
(
fullname
));
else
strcpy
(
fullname
,
""
);
if
(
ul_description
)
strncpy
(
description
,
ul_description
,
sizeof
(
description
));
else
strcpy
(
description
,
""
);
if
(
ul_email
)
strncpy
(
email
,
ul_email
,
sizeof
(
email
));
else
strcpy
(
email
,
""
);
if
(
ul_phone
)
strncpy
(
phone
,
ul_phone
,
sizeof
(
phone
));
else
strcpy
(
phone
,
""
);
if
(
ul_sms
)
strncpy
(
sms
,
ul_sms
,
sizeof
(
sms
));
else
strcpy
(
sms
,
""
);
};
private:
char
name
[
40
]
;
pwr_tObjName
name
;
char
password
[
40
];
unsigned
long
priv
;
pwr_tMask
priv
;
pwr_tOix
id
;
pwr_tString80
fullname
;
pwr_tString80
description
;
pwr_tString80
email
;
pwr_tString40
phone
;
pwr_tString40
sms
;
UserList
*
next
;
char
*
crypt
(
char
*
str
);
unsigned
long
crypt
(
unsigned
long
i
);
char
*
decrypt
(
char
*
str
);
unsigned
long
decrypt
(
unsigned
long
i
);
unsigned
long
icrypt
(
unsigned
long
i
);
unsigned
long
idecrypt
(
unsigned
long
i
);
public:
int
load
(
ifstream
&
fp
);
void
save
(
ofstream
&
fp
);
void
print
();
void
print_all
();
void
modify
(
char
*
password
,
unsigned
int
priv
);
void
print
(
int
brief
);
void
print_all
(
int
brief
);
void
modify
(
char
*
password
,
pwr_tMask
priv
,
char
*
fullname
,
char
*
description
,
char
*
email
,
char
*
phone
,
char
*
sms
);
int
check_password
(
char
*
password
);
void
get_data
(
char
*
password
,
unsigned
int
*
priv
);
void
get_data
(
char
*
password
,
pwr_tMask
*
priv
,
pwr_tOix
*
id
,
char
*
fullname
,
char
*
description
,
char
*
email
,
char
*
phone
,
char
*
sms
);
UserList
*
next_user
()
{
return
next
;}
char
*
get_name
()
{
return
name
;}
unsigned
long
get_priv
()
{
return
priv
;}
static
char
*
pwcrypt
(
char
*
str
);
};
class
GeUser
{
...
...
@@ -171,6 +216,7 @@ class GeUser {
SystemList
*
last_system
;
char
version
[
20
];
char
fname
[
256
];
pwr_tOix
next_id
;
bool
get_system_name_child
(
SystemList
*
s
,
SystemList
*
system
,
char
*
name
);
SystemList
*
get_system_child
(
SystemList
*
system
,
UserList
*
user
);
...
...
@@ -182,19 +228,21 @@ class GeUser {
int
save
()
{
return
save
(
fname
);}
int
save
(
char
*
filename
);
int
load_system
(
ifstream
&
fp
);
void
print
(
);
void
print_all
(
);
void
print
(
int
brief
);
void
print_all
(
int
brief
);
SystemList
*
find_system
(
SystemName
*
name
);
int
add_system
(
char
*
name
,
unsigned
int
attributes
);
int
add_system
(
char
*
name
,
unsigned
int
attributes
,
char
*
description
,
pwr_tOix
id
=
user_cNId
);
int
add_user
(
char
*
system
,
char
*
user
,
char
*
password
,
unsigned
int
priv
);
unsigned
int
priv
,
char
*
fullname
,
char
*
description
,
char
*
email
,
char
*
phone
,
char
*
sms
,
pwr_tOix
id
=
user_cNId
);
int
remove_user
(
char
*
system
,
char
*
user
);
int
modify_user
(
char
*
system
,
char
*
user
,
char
*
password
,
unsigned
int
priv
);
unsigned
int
priv
,
char
*
fullname
,
char
*
description
,
char
*
email
,
char
*
phone
,
char
*
sms
);
int
get_user_data
(
char
*
system
,
char
*
user
,
char
*
password
,
unsigned
int
*
priv
);
int
modify_system
(
char
*
system
,
unsigned
int
attributes
);
int
get_system_data
(
char
*
system
,
unsigned
int
*
attributes
);
pwr_tMask
*
priv
,
pwr_tOix
*
id
,
char
*
fullname
,
char
*
description
,
char
*
email
,
char
*
phone
,
char
*
sms
);
int
modify_system
(
char
*
system
,
unsigned
int
attributes
,
char
*
description
);
int
get_system_data
(
char
*
system
,
pwr_tMask
*
attributes
,
pwr_tOix
*
id
,
char
*
description
);
int
remove_system
(
char
*
name
);
int
get_user
(
char
*
system
,
char
*
user
,
char
*
password
,
unsigned
int
*
priv
);
...
...
@@ -204,6 +252,7 @@ class GeUser {
SystemList
*
root_system
()
{
return
root
;}
SystemList
*
get_system
(
UserList
*
user
);
bool
get_system_name
(
SystemList
*
system
,
char
*
name
);
pwr_tOix
get_next_id
()
{
return
next_id
++
;}
static
void
priv_to_string
(
unsigned
int
priv
,
char
*
str
,
int
size
);
static
void
rt_priv_to_string
(
unsigned
int
priv
,
char
*
str
,
int
size
);
static
void
dev_priv_to_string
(
unsigned
int
priv
,
char
*
str
,
int
size
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment