免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3303 | 回复: 0
打印 上一主题 下一主题

solaris下将关机权限赋予普通用户 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-29 13:27 |只看该作者 |倒序浏览

这里使用的是solaris10的RBAC,也可以使用sudo实现,下面是RBAC的实例:
建立一个关机角色,并设置密码:
[root@node01 /]#roleadd –m –d /export/home/norshut norshut
[root@node01 /]#passwd norshut
定义角色的权限配置(right profile):
这里要编辑/etc/security/prof_attr文件。
[root@node01 /]#echo "shutdown:suser:::This role can execute shutdown">>/etc/security/prof_attr
定义权限配置的可用特权:
这里编辑/etc/security/exec_attr文件.
[root@node01 /]#echo "shutdown:suser:cmd:::/usr/sbin/shutdown:uid=0">>/etc/security/exec_attr
  把权限配置和角色关联:
[root@node01 /]# rolemod –P “shutdown” norshut
注:在创建新用户的同时可用指定-R参数直接指定新用户帐号的角色。
添加新用户并把角色赋予新用户:
[root@node01 /]#useradd –g student –m –d /export/home/usrer01 –R norshut user01
[root@node01 /]#passwd user01
如果在添加新用户时没有使用-R参数可以使用下面的命令将角色赋予新用户:
[root@node01 /]# usermod –R norshut user01
测试新角色:
[root@node01 /]# su - user01
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
-bash-3.00$ cat /etc/user_attr
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# /etc/user_attr
#
# execution attributes for profiles. see user_attr(4)
#
#ident  "@(#)user_attr  1.1     07/01/31 SMI"
#
#
adm::::profiles=Log Management
lp::::profiles=Printer Management
postgres::::type=role;profiles=Postgres Administration,All
root::::auths=solaris.*,solaris.grant;profiles=Web Console Management,All;lock_after_retries=no;min_label=admin_low;clearance=admin_high
shutadmin::::type=role;profiles=shutdown
user01::::type=normal;roles=norshut
这个文件会多出如上斜体部分.
-bash-3.00$ profiles
Basic Solaris User
All
-bash-3.00$ roles
norshut
-bash-3.00$ /usr/sbin/shutdown
/usr/sbin/shutdown:  Only root can run /usr/sbin/shutdown   //普通用户不能执行shutdown命令
-bash-3.00$ su – norshut      //切换到norshut角色
Password:
$ id
uid=100(norshut) gid=1(other)
$ /usr/ucb/whoami
norshut
$ profiles           //查看norshut有哪些rights profile
shutdown
Basic Solaris User
All
$ profiles –l        //查看当前的rights profiles能执行哪些命令
      shutdown:
          /usr/sbin/shutdown    uid=0
      All:
          *   
$ /usr/sbin/shutdown -y -g0 -i5
Shutdown started.    Fri Nov 27 21:25:02 CST 2009
Changing to init state 5 - please wait
Broadcast Message from root (pts/2) on node01 Fri Nov 27 21:25:02...
THE SYSTEM node01 IS BEING SHUT DOWN NOW ! ! !
Log off now or risk your files being damaged


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/36549/showart_2106698.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP