summaryrefslogtreecommitdiff
path: root/etc/default/vyatta-cfg
blob: 0a5c593af16ec2bb4427d68f18f8ed70a6a0ef78 (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
# Vyatta shell environment variables for config mode
# should be sourced from /etc/default/vyatta

# note that session environment is now handled separately.
# (see /etc/bash_completion.d/20vyatta-cfg)

{
declare -x -r VYATTA_TAG_NAME=node.tag
declare -x -r VYATTA_MOD_NAME=.modified
declare -x -r VYATTA_CFG_GROUP_NAME=vyattacfg
declare -x -r HISTIGNORE="*password*:*-secret*"
} 2>/dev/null || :

# don't set level if already set
if [ -n "$VYATTA_USER_LEVEL_DIR" ]; then
  return
fi
{
is_admin=0
is_users=0
VYATTA_LEVEL_GROUP_ADMIN=vyattacfg
VYATTA_LEVEL_GROUP_USERS=quaggavty
local -a groups=( $(id -Gn) )
for g in "${groups[@]}"; do
  if [ "$g" == "$VYATTA_LEVEL_GROUP_ADMIN" ]; then
    is_admin=1
  fi
  if [ "$g" == "$VYATTA_LEVEL_GROUP_USERS" ]; then
    is_users=1
  fi
done
# root is also admin
if [ "$(id -u)" == 0 ]; then
  is_admin=1
fi
# check level from high to low
if [ $is_admin == 1 ]; then
  declare -x -r VYATTA_USER_LEVEL_DIR=${vyatta_sysconfdir}/shell/level/admin
else
  # no need to check is_users since there are only 2 levels for now
  declare -x -r VYATTA_USER_LEVEL_DIR=${vyatta_sysconfdir}/shell/level/users
  declare -x -r LESSSECURE=1
  alias more=less
fi
} 2>/dev/null || :