Back to index

texmacs  1.0.7.15
Functions | Variables
tmfs_permissions.cpp File Reference
#include "tmfs.hpp"

Go to the source code of this file.

Functions

string property_append (property p)
string tmfs_create_user (string name)
collection tmfs_search_user (string name)
void tmfs_set_user (string user)
string tmfs_get_user ()
bool tmfs_allows (string id, string type, string user)
bool tmfs_allows_via (string id, string type, string user, string via)
bool tmfs_allows_compute (string id, string type, string user)
bool tmfs_allows (string id, string type)
bool tmfs_allows (property p, string type)
bool tmfs_allows (solution sol, string type)
strings tmfs_filter (strings ss, string type)
void tmfs_set_attributes (string ressource, properties ps)
properties tmfs_get_attributes (string ressource)
void tmfs_add_attributes (string ressource, properties add_ps)
void tmfs_remove_attributes (string ressource, properties sub_ps)
void tmfs_change_attributes (string ressource, properties mod_ps)
solutions tmfs_query (property query)
collection tmfs_query (property query, string unknown)

Variables

static string tmfs_user = "root"
static hashmap< string, bool > empty_map (false)
static hashmap< string,
hashmap< string, bool > > 
tmfs_permissions (empty_map)
static hashmap< string, bool > tmfs_cycle_table (false)

Function Documentation

Definition at line 71 of file properties.cpp.

                             {
  if (N(p) == 0) return "";
  string r= copy (p[0]);
  for (int i=1; i<N(p); i++) r << ',' << p[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmfs_add_attributes ( string  ressource,
properties  add_ps 
)

Definition at line 180 of file tmfs_permissions.cpp.

                                                          {
  properties ps= tmfs_get_attributes (ressource);
  ps= reset (ps, add_ps);
  ps << add_ps;
  tmfs_set_attributes (ressource, ps);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool tmfs_allows ( string  id,
string  type,
string  user 
)

Definition at line 87 of file tmfs_permissions.cpp.

                                                  {
  string s= property_append (seq (id, user));
  if (!tmfs_permissions[type]->contains (s)) {
    //cout << "Allows? " << id << ", " << type << ", " << user << INDENT << LF;
    if (!tmfs_permissions->contains (type))
      tmfs_permissions (type)= hashmap<string,bool> (false);
    if (tmfs_cycle_table[s]) {
      //cout << UNINDENT << "Aborted" << LF;
      return false;
    }
    tmfs_cycle_table(s)= true;
    bool ok= tmfs_allows_compute (id, type, user);
    tmfs_permissions[type](s)= ok;
    tmfs_cycle_table(s)= false;
    //cout << UNINDENT << "Allows? " << id << ", " << type << ", " << user
    //<< " -> " << tmfs_permissions[type][s] << LF;
  }
  return tmfs_permissions[type][s];
}

Here is the call graph for this function:

bool tmfs_allows ( string  id,
string  type 
)

Definition at line 112 of file tmfs_permissions.cpp.

                                     {
  return tmfs_allows (id, type, tmfs_user);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool tmfs_allows ( property  p,
string  type 
)

Definition at line 117 of file tmfs_permissions.cpp.

                                      {
  for (int i=0; i<N(p); i++)
    if (is_identifier (p[i]) && !tmfs_allows (p[i], type))
      return false;
  return true;
}

Here is the call graph for this function:

bool tmfs_allows ( solution  sol,
string  type 
)

Definition at line 125 of file tmfs_permissions.cpp.

                                        {
  iterator<string> it= iterate (sol);
  while (it->busy ()) {
    string s= sol[it->next ()];
    if (is_identifier (s) && !tmfs_allows (s, type))
      return false;
  }
  return true;
}

Here is the call graph for this function:

bool tmfs_allows_compute ( string  id,
string  type,
string  user 
)

Definition at line 75 of file tmfs_permissions.cpp.

                                                          {
  if (user == "root") return true;
  property query= seq (type, id, "?user");
  solutions sols= tmfs_get_solutions (query);
  strings a= as_strings (as_collection (sols, query));
  for (int i=0; i<N(a); i++)
    if (tmfs_allows_via (id, type, user, a[i]))
      return true;
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool tmfs_allows_via ( string  id,
string  type,
string  user,
string  via 
)

Definition at line 65 of file tmfs_permissions.cpp.

                                                                  {
  (void) id;
  //cout << "Allows? " << id << ", " << type << ", " << user
  //<< " via " << via << LF;
  if (user == via) return true;
  if (is_identifier (via)) return tmfs_allows (via, type, user);
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmfs_change_attributes ( string  ressource,
properties  mod_ps 
)

Definition at line 195 of file tmfs_permissions.cpp.

                                                             {
  properties ps= tmfs_get_attributes (ressource);
  ps= reset (ps, widen (mod_ps));
  ps << mod_ps;
  tmfs_set_attributes (ressource, ps);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 26 of file tmfs_permissions.cpp.

                               {
  if (N (tmfs_search_user (name)) != 0) return "";
  string user= tmfs_create_ressource ();
  string home= tmfs_create_file (name * " - home", "", user);
  properties ps;
  ps << seq ("user", user)
     << seq ("name", user, name)
     << seq ("owner", user, user)
     << seq ("in", user, user)
     << seq ("read", user, user)
     << seq ("write", user, user)
     << seq ("home", user, home);
  tmfs_save_ressource (user, "", ps);
  return user;
}

Here is the call graph for this function:

Here is the caller graph for this function:

strings tmfs_filter ( strings  ss,
string  type 
)

Definition at line 136 of file tmfs_permissions.cpp.

                                      {
  strings r;
  for (int i=0; i<N(ss); i++)
    if (tmfs_allows (ss[i], type))
      r << ss[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file tmfs_permissions.cpp.

                                       {
  if (tmfs_allows (ressource, "read"))
    return tmfs_load_ressource_properties (ressource);
  return properties ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 54 of file tmfs_permissions.cpp.

                 {
  return tmfs_user;
}

Here is the caller graph for this function:

Definition at line 207 of file tmfs_permissions.cpp.

                            {
  if (!tmfs_allows (query, "read")) return solutions ();
  solutions sols= tmfs_get_solutions (query);
  return tmfs_filter (sols, "read");
}

Here is the call graph for this function:

Here is the caller graph for this function:

collection tmfs_query ( property  query,
string  unknown 
)

Definition at line 214 of file tmfs_permissions.cpp.

                                            {
  return as_collection (tmfs_query (query), unknown);
}

Here is the call graph for this function:

void tmfs_remove_attributes ( string  ressource,
properties  sub_ps 
)

Definition at line 188 of file tmfs_permissions.cpp.

                                                             {
  properties ps= tmfs_get_attributes (ressource);
  ps= reset (ps, sub_ps);
  tmfs_set_attributes (ressource, ps);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file tmfs_permissions.cpp.

                               {
  properties ps; ps << seq ("name", "?user", name) << seq ("user", "?user");
  return as_collection (tmfs_get_solutions (ps), "?user");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmfs_set_attributes ( string  ressource,
properties  ps 
)

Definition at line 167 of file tmfs_permissions.cpp.

                                                      {
  if (tmfs_allows (ressource, "owner"))
    tmfs_save_ressource (ressource, tmfs_load_ressource_file (ressource), ps);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmfs_set_user ( string  user)

Definition at line 49 of file tmfs_permissions.cpp.

                            {
  tmfs_user= user;
}

Here is the caller graph for this function:


Variable Documentation

hashmap<string,bool> empty_map(false) [static]
hashmap<string,bool> tmfs_cycle_table(false) [static]
string tmfs_user = "root" [static]

Definition at line 14 of file tmfs_permissions.cpp.