Patch level : 10.0 1024

Files correlati     : ba0
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione permessi utente per esecuzione delle singole applcazioni (Possamai)
Nella richoesta di conferma  di elminazione di un record, il bottone predefinito ora è no invece di si (Tassan)


git-svn-id: svn://10.65.10.50/branches/R_10_00@22246 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-06-09 11:03:05 +00:00
parent 88dc261367
commit 89d22e2b8c
7 changed files with 65 additions and 72 deletions

View File

@ -2,7 +2,6 @@
#include <dongle.h> #include <dongle.h>
#include <execp.h> #include <execp.h>
#include <prefix.h>
#include <recarray.h> #include <recarray.h>
#include <user.h> #include <user.h>
@ -138,36 +137,28 @@ long TExternal_app::run(
bool TExternal_app::can_run() const bool TExternal_app::can_run() const
{ {
if (*prefix().name() <= '.') if (*prefix().name() <= '.')
return TRUE; return true;
const TLocalisamfile test(LF_USER); const TString& usr = user();
if (test.curr().exist(USR_PERMISSION)) if (usr.blank() || usr == dongle().administrator())
return true;
const TString_array& uag = user_and_groups();
TToken_string perm(255, '\n'), row(80,SAFE_PIPE_CHR);
FOR_EACH_ARRAY_ROW(uag, i, rec)
{ {
TRecord_cache utonti(LF_USER); // Non uso cache() per problemi durante conversioni perm = rec->after(rec->separator());
TToken_string perm(4096, '\n'), row(80,SAFE_PIPE_CHR); if (perm.full())
for (TString16 u = user(); u.not_empty(); u = utonti.get(u, USR_GROUPNAME))
{
if (utonti.already_loaded(u))
{
NFCHECK("L'utente %s ha dei permessi ricorsivi", (const char*)u);
break;
}
perm = utonti.get(u, USR_PERMISSION);
if (!perm.blank())
{ {
FOR_EACH_TOKEN(perm, tok) FOR_EACH_TOKEN(perm, tok)
{ {
row = tok; row = tok;
if (_path == row.get(0)) // Il nome corrisponde if (_path.compare(row.get(0), -1, true) == 0 && row.get_char(1) == 'N')
{ return false;
if (*row.get(1) == 'N')
return FALSE;
} }
} }
} }
} return true;
}
return TRUE;
} }
TExternal_app::TExternal_app(const char* p) TExternal_app::TExternal_app(const char* p)

View File

@ -180,10 +180,11 @@ void TMask::read_mask(
// Costruisce la lista dei gruppi di appartenenza dell'utente // Costruisce la lista dei gruppi di appartenenza dell'utente
const TString_array& uag = user_and_groups(); const TString_array& uag = user_and_groups();
TConfig ini(prof); TConfig ini(prof);
FOR_EACH_ARRAY_ROW_BACK(uag, c, utonto) FOR_EACH_ARRAY_ROW_BACK(uag, c, rec)
{ {
*utonto << "_Locks"; TString utonto = rec->get(0);
if (ini.set_paragraph(*utonto)) utonto << "_Locks";
if (ini.set_paragraph(utonto))
{ {
TBit_array read_only; TBit_array read_only;
TAuto_token_string lfields(ini.get("Lock")); TAuto_token_string lfields(ini.get("Lock"));

View File

@ -8,6 +8,8 @@
#include <utility.h> #include <utility.h>
#include <xml.h> #include <xml.h>
#include <user.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TRecipient // TRecipient
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -411,8 +413,6 @@ bool TPostman::dispatch_transaction(const TRectype& rec,
void TPostman::load_filters() void TPostman::load_filters()
{ {
TRecord_cache users(LF_USER);
TToken_string perm(4096, '\n'); TToken_string perm(4096, '\n');
TAuto_token_string row(80); TAuto_token_string row(80);
@ -434,14 +434,10 @@ void TPostman::load_filters()
TAssoc_array expr; TAssoc_array expr;
// Scandisce l'albero degli utenti/gruppi // Scandisce l'albero degli utenti/gruppi
for (TString16 u = user(); u.not_empty() && !users.already_loaded(u); ) const TString_array& uag = user_and_groups();
FOR_EACH_ARRAY_ROW(uag, r, rec)
{ {
const TRectype& urec = users.get(u); perm = rec->after(rec->separator()); // Permessi del nodo corrente
// Test di validita'del record da eseguire solo la prima volta
if (u == user() && !urec.exist("PERMISSION"))
break;
perm = urec.get("PERMISSION"); // Permessi del nodo corrente
if (!perm.blank()) if (!perm.blank())
{ {
FOR_EACH_TOKEN(perm, tok) FOR_EACH_TOKEN(perm, tok)
@ -482,7 +478,6 @@ void TPostman::load_filters()
} }
} }
} }
u = urec.get("GROUPNAME");
} }
// Trasforma le stringhe in espressioni // Trasforma le stringhe in espressioni

View File

@ -1,27 +1,27 @@
#include <dongle.h>
#include <prefix.h> #include <prefix.h>
#include <recarray.h> #include <recarray.h>
#include <tabmod.h> #include <tabmod.h>
#include <tabutil.h> #include <tabutil.h>
#include <user.h> #include <user.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TFast_isamfile // TFast_isamfile
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
class TFast_isamfile : public TIsamfile
{
public:
TFast_isamfile(int logicnum);
~TFast_isamfile() { close(); }
};
TFast_isamfile::TFast_isamfile(int logicnum) : TIsamfile(logicnum) TFast_isamfile::TFast_isamfile(int logicnum) : TIsamfile(logicnum)
{ {
int err = open(_excllock); int err = open(_excllock);
if (err != NOERR) if (err != NOERR)
err = open(_manulock); err = open(_manulock);
if (err != NOERR)
cantread_box(name());
} }
TFast_isamfile::~TFast_isamfile()
{ close(); }
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TRecord_Array // TRecord_Array
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -956,28 +956,34 @@ TRecord_cache& rec_cache(int file)
const TString_array& user_and_groups() const TString_array& user_and_groups()
{ {
static TString_array _uag; static TString_array _uag;
if (_uag.empty() || _uag.row(0) != user())
TString80 u = user();
if (u.blank())
u = dongle().administrator();
if (_uag.empty() || u != _uag.row(0).get(0))
{ {
_uag.destroy(); _uag.destroy();
_uag.add(user()); // Inserisco l'utente corrente come primo
if (prefix_valid()) // Costruisce lista dei gruppi solo se possibile if (prefix_valid()) // Costruisce lista dei gruppi solo se possibile
{ {
TLocalisamfile user(LF_USER); TFast_isamfile user(LF_USER);
int err = NOERR; while (u.full())
while (err == NOERR)
{ {
user.put(USR_USERNAME, _uag.row(_uag.last())); TToken_string* usr = new TToken_string(u);
err = user.read(); _uag.add(usr);
if (err == NOERR) user.put(USR_USERNAME, u);
if (user.read() == NOERR)
{ {
const TString& group = user.get(USR_GROUPNAME); if (user.curr().exist(USR_PERMISSION))
if (group.full()) usr->add(user.get(USR_PERMISSION));
_uag.add(group); u = user.get(USR_GROUPNAME);
}
else else
err = _iskeynotfound; break;
}
} }
} }
else
_uag.add(u);
} }
return _uag; return _uag;
} }

View File

@ -271,6 +271,14 @@ public:
{ rec_cache(file).test_file_changes(t); } { rec_cache(file).test_file_changes(t); }
}; };
// Best performance by exclusive locking ... when possible :-)
class TFast_isamfile : public TIsamfile
{
public:
TFast_isamfile(int logicnum);
~TFast_isamfile();
};
TDB_cache& cache(); TDB_cache& cache();
TRecord_cache& rec_cache(int file); TRecord_cache& rec_cache(int file);
const TString_array& user_and_groups(); const TString_array& user_and_groups();

View File

@ -833,11 +833,11 @@ int TRelation_application::delete_mode()
long deleting = sht.checked(); long deleting = sht.checked();
TString msg; TString msg;
msg.format(FR("Confermare l'eliminazione di %d elementi"), deleting); msg.format(FR("Confermare l'eliminazione di %d elementi"), deleting);
bool can_delete = yesno_box(msg); bool can_delete = noyes_box(msg);
if (can_delete && deleting > 100) if (can_delete && deleting > 100)
{ {
msg.insert(TR("ATTENZIONE: "), 0); msg.insert(TR("ATTENZIONE: "), 0);
can_delete = yesno_box(msg); can_delete = noyes_box(msg);
} }
if (can_delete) if (can_delete)
{ {
@ -1238,7 +1238,8 @@ bool TRelation_application::relation_remove()
if (protected_record(r)) if (protected_record(r))
return message_box(TR("Elemento non eliminabile")); return message_box(TR("Elemento non eliminabile"));
if (_curr_transaction == TRANSACTION_DELETE || yesno_box(TR("Confermare l'eliminazione"))) if (_curr_transaction == TRANSACTION_DELETE ||
noyes_box(FR("Confermare l'eliminazione del record %s"), r.file().description()))
{ {
r.restore_status(); r.restore_status();
const bool ok = remove(); const bool ok = remove();

View File

@ -1,9 +0,0 @@
#include <ctype.h>
char* CUpString(char* s)
{
char* c;
for (c = s; *c; c++)
*c = toupper(*c);
return s;
}