summaryrefslogtreecommitdiff
path: root/src/sh/user.h
blob: cc00e211e6315bd44dd089a9e0696d6653c710d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*************************************************************************
 *
 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
 *
 * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef USERH
#define USERH

#include <lang/env.h>
#include <mt/lookup.h>

/////////////////////////////////////////////////////////

const mstring root_tag="ROOT";
const mstring lastin_def="0.0.0.0";

const mstring USERS_tag="USERS";
const mstring PREFS_tag="PREFS";
const mstring TREE_tag="TREE";

const int user_tabs=10,user_uid=0,user_alias=4,user_email=5,user_access=9;
const mstring user_tab[user_tabs]={
  "UID","GROUP","FAIL","PIN","ALIAS","EMAIL","NAME","LAST","LASTIN","ACCESS"
};

const int prefs_tabs=8;
const mstring prefs_tab[prefs_tabs]={
  "ID","EXT","ROOM","URL","POSIT","NOTE","ABSTRACT","LASTMOD"
};

const int tree_tabs=17;
const mstring tree_tab[tree_tabs]={
  "URI","REFER","PARENT","MIME",
  "MOD","UID","GID","SIZE","LASTMOD",
  "ALIAS","BANNER",
  "X.CLEAR","X.COOKIE","X.DOMAIN","X.USER","X.CACHE",
  "XMOD"
};

int allow(const sref& s,const sref& grp,time_t now,int rootok=0);

struct user_t {
  spile list;

  user_t() : list(user_tabs) {}
  user_t(const user_t& us);

  void operator=(const user_t&);

  mstring& uid() { return list[0]; }
  mstring& group() { return list[1]; }
  mstring& fail() { return list[2]; }
  mstring& pin() { return list[3]; }
  mstring& alias() { return list[4]; }
  mstring& email() { return list[5]; }
  mstring& name() { return list[6]; }
  mstring& last() { return list[7]; }
  mstring& lastin() { return list[8]; }
  mstring& access() { return list[9]; }

  void reset();
  int allow(const sref& grp,time_t now,int rootok=0);
  int allow_list(const sref& grps,time_t now,int rootok=0);
  // rootok<0 -> ignore special root handling (new; should not interfere)
  // rootok==0 -> root not allowed here
  // rootok>0 -> root always allowed here

  void add(const sref& grp);
  void add_list(const sref& grps);
  void rem(const sref& grp);
  void rem_list(const sref& grps);
};

/////////////////////////////////////////////////////////

void envAddUser(tokmap& T) throw(merror_t);

#endif