Категорії
Solaris

Очень ограниченный профиль пользователя в Solaris

Появилась задача: создать юзера, который бы ничего не мог сделать, кроме как читать файл (в идеале только 1 )), но это оказалось невозможным, возможно пока).

В Solaris за права юзеру отвечает RBAC. Он позволяет как расширить права, так и сузить. По дефолту новому юзеру присваивается 2 профиля: All и Basic Solaris User:

$ profiles skeletor
skeletor:
Basic Solaris User
All

Создадим новый профиль Restrict User, а нужные будем добавлять по мере необходимости. Что бы читать файлы, обязательно нужны права file_read. И так:

# profiles -p "Restrict User"
profiles:Restrict User>set name=Restrict User
profiles:Restrict User>set desc=Restrict user
profiles:Restrict User>set privs=file_read
profiles:Restrict User>set defaultpriv=file_read
profiles:Restrict User>commit
profiles:Restrict User>exit

Теперь создадим юзера test и укажем нужный профиль:

# useradd -P "Restrict User" test

Пробуем переключиться на test:

# ppriv -e -D su - test
su[1992]: missing privilege "proc_exec" (euid = 60005, syscall = 59) for "/usr/bin/bash" needed at exec_common+0x392
su: Insufficient privilege to execute shell

Как видим, не хватает привелегий proc_exec, добавляем и пробуем:

# profiles -p "Restrict User"
profiles:Restrict User>add privs=proc_exec
profiles:Restrict User>add defaultpriv=proc_exec
profiles:Restrict User>commit
profiles:Restrict User>exit
# ppriv -e -D su - test
bash[1995]: missing privilege "proc_fork" (euid = 60005, syscall = 142) needed at cfork+0x72
-bash: fork: Not owner
-bash-4.1$ ls
bash[1995]: missing privilege "proc_fork" (euid = 60005, syscall = 142) needed at cfork+0x72
-bash: fork: Not owner
-bash-4.1$

Уже лучше, залогинились, но запустить ничего не можем. Добавляем proc_fork и пробуем:

# profiles -p "Restrict User"
profiles:Restrict User>add privs=proc_fork
profiles:Restrict User>add defaultpriv=proc_fork
profiles:Restrict User>commit
profiles:Restrict User>exit
# ppriv -e -D su - test
quota[1999]: missing privilege "sys_config" (euid = 60005, syscall = 54) needed at zfs_secpolicy_config+0x1a
Oracle Corporation SunOS 5.11 11.1 December 2013
-bash-4.1$ tail /var/log/syslog.1
Jul 9 20:40:41 solaris11.local sendmail[1039]: [ID 702911 mail.info] starting daemon (8.14.5+Sun): SMTP+queueing@00:15:00
Jul 26 16:08:14 solaris11.local sendmail[932]: [ID 702911 mail.warning] gethostbyaddr(10.5.5.219) failed: 1
-bash-4.1$ netcat localhost 22
nc[2008]: missing privilege "net_access" (euid = 60005, syscall = 68) needed at udp_do_open+0x38
nc[2008]: missing privilege "net_access" (euid = 60005, syscall = 68) needed at udp_do_open+0x38
nc[2008]: missing privilege "net_access" (euid = 60005, syscall = 230) needed at tcp_create_common+0x5f
netcat: failed to create socket: Permission denied
nc[2008]: missing privilege "net_access" (euid = 60005, syscall = 230) needed at tcp_create_common+0x5f
netcat: failed to create socket: Permission denied
-bash-4.1$ ls -la
total 6
drwxr-xr-x 2 test root 2 Mar 30 2013 .
drwxr-xr-x 6 root root 6 Apr 2 2013 ..
-bash-4.1$ mkdir 1
mkdir[2015]: missing privilege "file_write" (euid = 60005, syscall = 102) for "/export/home/test/1" needed at fop_mkdir+0x128
mkdir: Failed to make directory "1"; Permission denied

Своей цели мы достигли

В качестве дополнительных ограничений, можно задать юзеру оболочку “Restricted bash” – /usr/bin/rbash. Но её легко обойти, если запустить bash непосредственно из rbash’a.

Вот какие будут действовать дополнительные ограничения:

     o    changing directories with cd

     o    setting or unsetting the values of SHELL, PATH, ENV, or
          BASH_ENV

     o    specifying command names containing /

     o    specifying a file name containing a / as an argument to
          the . builtin command

     o    Specifying a filename containing a slash as an argument
          to the -p option to the hash builtin command

     o    importing function definitions from the shell  environ-
          ment at startup

     o    parsing the value of SHELLOPTS from the shell  environ-
          ment at startup

     o    redirecting output using the >, >|, <>, >&, &>, and  >>
          redirection operators

     o    using the exec builtin command  to  replace  the  shell
          with another command

     o    adding or deleting builtin commands with the -f and  -d
          options to the enable builtin command

     o    Using the enable builtin  command  to  enable  disabled
          shell builtins

     o    specifying the -p option to the command builtin command

     o    turning off restricted mode with set +r or set +o  res-
          tricted.

Залишити відповідь

Ваша e-mail адреса не оприлюднюватиметься. Обов’язкові поля позначені *

Домашняя страничка Andy
Записки молодого админа
Самостоятельная подготовка к Cisco CCNA
Самостоятельная подготовка к Cisco CCNP
Powered by Muff