home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3575 < prev    next >
Encoding:
Text File  |  1991-07-03  |  16.1 KB  |  379 lines

  1. Newsgroups: alt.sources,comp.unix.admin
  2. From: Tom Christiansen <tchrist@convex.COM>
  3. Subject: Re: Op: A flexible Tool for Restricted Superuser Access, Part01/02
  4. Message-ID: <1991Jul02.233448.17487@convex.com>
  5. Date: Tue, 02 Jul 1991 23:34:48 GMT
  6.  
  7. From the keyboard of pmm@mips.com (Paul M. Moriarty):
  8. :This is the alpha release of op.  Op is available on Convex machines (or so
  9. :I'm told) and was described in a paper presented at USENIX LISA III by Tom
  10. :Christiansen.
  11.  
  12. Several have asked about this.  Here's the original brief paper I
  13. presented on the tool.   I wrote the spec and got someone else to write
  14. the code, except for some later enhancements and modifications on my part.  
  15.  
  16.  
  17. --tom
  18.  
  19.  
  20.         Op: A Flexible Tool for Restricted Superuser
  21.                            Access
  22.  
  23.                       _T_o_m _C_h_r_i_s_t_i_a_n_s_e_n
  24.  
  25.                 CONVEX Computer Corporation
  26.                          POB 833851
  27.                    3000 Waterview Parkway
  28.                  Richardson, TX  75083-3851
  29.  
  30.              {_u_u_n_e_t,_u_i_u_c_d_c_s,_s_u_n}!_c_o_n_v_e_x!_t_c_h_r_i_s_t
  31.                      _t_c_h_r_i_s_t@_c_o_n_v_e_x._c_o_m
  32.  
  33.                           _A_B_S_T_R_A_C_T
  34.  
  35.           The _o_p tool provides  a  flexible  means  for
  36.      system   administrators  to  grant  trusted  users
  37.      access to certain root operations  without  having
  38.      to give them full superuser privileges.  Different
  39.      sets of users may access different operations, and
  40.      the  security-related  aspects  of  environment of
  41.      each operation can be carefully controlled.
  42.  
  43.      One sure way to render a UNIX  system  unstable  is  to
  44. distribute  the  root  password  to everyone who thinks they
  45. need it.  Well-meaning and experienced though  these  people
  46. may  be,  they will inevitably introduce anomalies into your
  47. system that will cause it to malfunction in mysterious ways.
  48. You  may  spend  hours or even days trying to determine what
  49. was changed, by whom, and for  what  reason.   This  problem
  50. occurs even when all parties involved are experienced system
  51. administrators.
  52.  
  53.      Furthermore, large sites often have computer  operators
  54. who  attend  to  the routine tasks of system administration,
  55. such as dumps and restores, tape handling, system  shutdown,
  56. and  so  on.   These people may not be sophisticated and you
  57. may not wish them to have complete system privileges  to  do
  58. their  jobs.  Denying the superuser password to your cowork-
  59. ers or management is difficult,  if  not  impossible.   This
  60. difficulty  is  particularly true in a technical environment
  61. where programmers may be competent, but insensitive  to  the
  62. management of a complex system.
  63.  
  64.      The _o_p program, a standard utility provided by  CONVEX,
  65. is  specifically  designed  to address this problem.  The _o_p
  66. program gives the system manager a means to grant a user  or
  67.  
  68.                         July 2, 1991
  69.  
  70.                            - 2 -
  71.  
  72. group of users limited access to specific superuser commands
  73. without granting access to all superuser privileges.   Care-
  74. ful control of the environment provides both flexibility and
  75. security.
  76.  
  77.      To set up your system, the _o_p  program,  you  begin  by
  78. finding  out  the specific tasks for which system privileges
  79. are deemed necessary when  a  user  requests  the  superuser
  80. password.  Complete access to every command on the system is
  81. usually not required.  Using  _o_p,  the  system  manager  can
  82. designate  a set of privileged commands and access lists for
  83. these commands; the system manager,  in  effect,  can  grant
  84. limited system privileges beyond those normally available to
  85. a normal user without giving away full superuser privileges.
  86.  
  87.      The _o_p program is not interactive; it  functions  as  a
  88. prefix  command,  similar to _t_i_m_e or _n_i_c_e, whose side-effect
  89. is to alter the user's  environment  in  some  fashion.  The
  90. functions  (or  mnemonics)  understood by the _o_p program are
  91. listed in the configurable ascii data  file  /_e_t_c/_o_p._a_c_c_e_s_s.
  92. This file describes what commands can be performed by the _o_p
  93. program, how they are to be performed, and who is allowed to
  94. perform  them.   For  security  reasons, this file should be
  95. owned and readable only by the superuser.   Each  invocation
  96. of  _o_p  is logged using _s_y_s_l_o_g(3) with the LOG_AUTH facility
  97. class.
  98.  
  99.      The restrictions can be made  as  tight  as  each  site
  100. demands,  as determined by the system administrator who cus-
  101. tomizes the _o_p._a_c_c_e_s_s file.  This file contains a mapping of
  102. mnemonics,  or  operator functions, to the full pathnames of
  103. programs that should be invoked and the arguments  that  are
  104. allowed,  if any.  The arguments to the executed program can
  105. be a combination of literal and variable arguments, and res-
  106. trictions  can be placed on which values are valid substitu-
  107. tions for the variable arguments.   Because  some  syntactic
  108. checking  of the command arguments is possible, running com-
  109. mands under _o_p can be safer than running them directly  from
  110. a  superuser's  shell.  This safety feature can prevent pit-
  111. falls like accidentally transposing the file system and tape
  112. device  arguments  to  the  _d_u_m_p  program  (eg.  dump  0uf /
  113. /dev/rmt16), which would destroy the file system.
  114.  
  115.      The following set of attributes can be  controlled  for
  116. each mnemonic by the _o_p program:
  117.  
  118. o+    the user id to set
  119.  
  120. o+    the group vector to set
  121.  
  122. o+    the directory to _c_h_d_i_r(2) to
  123.  
  124. o+    the root directory to set with _c_h_r_o_o_t(2)
  125.  
  126.                         July 2, 1991
  127.  
  128.                            - 3 -
  129.  
  130. o+    the umask to set
  131.  
  132. o+    a list of groups allowed to execute this function
  133.  
  134. o+    a list of users allowed to execute this function
  135.  
  136. o+    the range of valid arguments for the command,  both  in
  137.      number and value
  138.  
  139. o+    any environment variable settings
  140.  
  141.      The fields of the entries in _o_p._a_c_c_e_s_s are separated by
  142. white  space.  Each entry may span several lines and contin-
  143. ues until the next  alphanumeric  string  is  found  at  the
  144. beginning of a line (which is taken to be the next _m_n_e_m_o_n_i_c,
  145. and thus the beginning of a new  entry).   Comments  may  be
  146. embedded  beginning  with  a  #  character.   Each  entry in
  147. _o_p._a_c_c_e_s_s has the following form:
  148.  
  149.      _m_n_e_m_o_n_i_c     _c_o_m_m_a_n_d  [ _a_r_g ... ]  ;  [ _o_p_t_i_o_n ... ]
  150.  
  151. where the fields are interpreted in the following manner:
  152.  
  153. _m_n_e_m_o_n_i_c    a  unique,  alphanumeric  identifier  for   each
  154.             operator function.
  155.  
  156. _c_o_m_m_a_n_d     the full pathname of the executable to be run by
  157.             _o_p when the associated _m_n_e_m_o_n_i_c is chosen.
  158.  
  159. _a_r_g(s)      any  arguments,  either  literal  or   variable,
  160.             needed by _c_o_m_m_a_n_d.  Literal arguments are simply
  161.             specified  directly,   like   specific   command
  162.             options  (0Gun) or files (/dev/rmt20).  Variable
  163.             arguments are specified here as $1, $2  ...  $_n;
  164.             these  are  described  more fully in the options
  165.             section below.  $* indicates any number trailing
  166.             arguments.
  167.  
  168. _o_p_t_i_o_n(s)   a set of optional parameters to specify settings
  169.             or  restrictions  for  the  particular _m_n_e_m_o_n_i_c,
  170.             define variable arguments specified for the _c_o_m_-
  171.             _m_a_n_d,  and define environment variable settings.
  172.             Options are separated by white space and are  of
  173.             the   form  _k_e_y_w_o_r_d=_v_a_l_u_e.   The  absence  of  a
  174.             specific option means the default is sufficient.
  175.             The  _v_a_l_u_e  can  be  a single value or a list of
  176.             values separated by commas,  where  appropriate.
  177.             There  should  be no white space in each element
  178.             of the _v_a_l_u_e string unless quoted.  The  _k_e_y_w_o_r_d
  179.             is any of the following types:
  180.  
  181.             uid     Set the user id to the value  specified.
  182.                     The  value can be a numeric user ID or a
  183.  
  184.                         July 2, 1991
  185.  
  186.                            - 4 -
  187.  
  188.                     login name.  The default is root.
  189.  
  190.             gid     Set the group ids to the  values  speci-
  191.                     fied.  Each value can be a numeric group
  192.                     ID or a group name.
  193.  
  194.             dir     Change the current working directory  to
  195.                     the path specified.
  196.  
  197.             chroot  Change the root directory  to  the  path
  198.                     specified using _c_h_r_o_o_t.
  199.  
  200.             umask   Set the file creation umask to the octal
  201.                     value  specified.  The default is to set
  202.                     it to 022.
  203.  
  204.             groups  Allow any user who belongs  to  a  group
  205.                     listed here to execute this _o_p function.
  206.                     The default is not to allow any specific
  207.                     group.
  208.  
  209.             users   Allow any user listed  here  to  execute
  210.                     this _o_p function.  The default is not to
  211.                     allow any specific users.  You  may  use
  212.                     the  regular  expression  .* to indicate
  213.                     that all users may use this mnemonic.
  214.  
  215.             $_n      defines the _nth variable argument speci-
  216.                     fied in the command _a_r_g list.  The value
  217.                     for this type may be  a  comma-separated
  218.                     list   of   regular   expressions  using
  219.                     _r_e_g_e_x(3).  option defines the  range  of
  220.                     values  allowed  for  the variable argu-
  221.                     ments.  A variable argument specified as
  222.                     a  command  _a_r_g but not described in the
  223.                     _o_p_t_i_o_n_s section may take on  any  value.
  224.                     If an argument does not match any of its
  225.                     permitted values, then a  diagnostic  is
  226.                     printed and the command is not executed.
  227.  
  228.             $*      is used in the _o_p_t_i_o_n_s section to  place
  229.                     restrictions  on  the trailing arguments
  230.                     specified as $* in the _a_r_g_s section.  If
  231.                     any  of  these (possibly many) arguments
  232.                     do  not  match,  then  a  diagnostic  is
  233.                     printed,  and  the  command  is not exe-
  234.                     cuted.
  235.  
  236.             $_V_A_R    where _V_A_R is the name of an  environment
  237.                     variable.    The  specified  environment
  238.                     variable  is  set  to  the  value  given
  239.                     before  the  command  is executed.  As a
  240.                     special case, simply using $_V_A_R with  no
  241.                     =  part  (as  in  $USER) means that this
  242.  
  243.                         July 2, 1991
  244.  
  245.                            - 5 -
  246.  
  247.                     environment   variable   is    inherited
  248.                     unchanged from the caller's shell.
  249.  
  250.      There can also be a special entry in the file beginning
  251. at the first non-comment line that can define default values
  252. to override the builtin defaults listed here, yet  still  be
  253. overridden  by  any  entry that wants to redefine any of the
  254. keyword fields described above.  It should have the  follow-
  255. ing format:
  256.  
  257.      DEFAULT      _k_e_y_w_o_r_d__o_p_t_i_o_n ...
  258. where _k_e_y_w_o_r_d__o_p_t_i_o_n is a  _k_e_y_w_o_r_d=_v_a_l_u_e  strings  mentioned
  259. above under _o_p_t_i_o_n_s.
  260.  
  261.      It should be noted that if any regular  _m_n_e_m_o_n_i_c  entry
  262. defines  its own _o_p_t_i_o_n, the value given for that entry must
  263. explicitly include the item from the  DEFAULT  line  if  the
  264. default  value  is  to  be  included.   That is, the _o_p_t_i_o_n_s
  265. definitions completely override any defaults;  they  do  not
  266. add  to  them.   In  this  way,  if a value specified on the
  267. DEFAULT line for users or groups (for example) needs  to  be
  268. "erased"  without redefining new values (that is, we want no
  269. users or groups to be allowed to run  this  mnemonic),  then
  270. the  default  value  must  be overridden with nothing (as in
  271. users=).  For the users and groups fields, such a null  set-
  272. ting  has  the effect of setting the list of allowable users
  273. or groups to be empty.  For the other  keywords  (uid,  gid,
  274. dir,  chroot,  and umask), a null setting leaves that attri-
  275. bute as it is upon invocation of the _o_p program,  overriding
  276. any defaults.
  277.  
  278.      This file format may seem complex at first glance,  but
  279. is  actually  intuitive  and flexible.  An example _o_p._a_c_c_e_s_s
  280. file might look like:
  281.  
  282.                         July 2, 1991
  283.  
  284.                            - 6 -
  285.  
  286. # first, define the site defaults we want to use here
  287. # we would like the people in `operator' group to be able to execute
  288. # almost everything, so it is easier to put it here than on every line...
  289. # set up default envariables
  290. #
  291. DEFAULT groups=operator $USER $TERM $PATH=/usr/ucb:/usr/bin:/bin
  292. #
  293. #    find out who's filled up the disk; anyone may do this
  294. #
  295. full            /usr/etc/quot $1; users=.*
  296. #
  297. #    filesystem backups
  298. #
  299. daily           /etc/dump 5Gun $1; $1=/,/usr[0-9]*,/project
  300. weekly          /etc/dump 0Gun $1; $1=/,/usr[0-9]*,/project
  301. #
  302. #    tape handling commands
  303. #    must include `operator' if we want them to be allowed as well
  304. #
  305. tape            /etc/tpc $1 $2; groups=tapeopers,operator users=boss
  306.                 $1=enable,disable,stop,restart $2=all,unit[01]
  307. #
  308. mounted         /etc/tpc mounted unit$1 $2; $1=[0-3]
  309. #
  310. #    taking the system down
  311. #    $1 shows a good use of regular expressions;
  312. #    $2 can be anything, but is required; no instant shutdowns
  313. #
  314. shutdown        /etc/shutdown -h $1 $2; $1=+[1-9][0-9]*,[0-9]*:[0-9]*
  315. reboot          /etc/shutdown -r $1 $2; $1=+[1-9][0-9]*,[0-9]*:[0-9]*
  316. #
  317. #    start up disco daemon
  318. disco           /etc/opbin/start_disco; uid=disco gid=proj dir=/scratch
  319.                         umask=027 groups=geo,disco users=snoopy,linus
  320.                         $USER=disco $SHELL=/bin/shell
  321. #
  322. #    let certain people mount and unmount the removable drive
  323. #
  324. rdsmount        /etc/mount $1 $2; groups=operator,swdev,disco users=bob,steve $1=/dev/dd0[a-g] $2=/.*
  325. rdsumount       /etc/umount $1; groups=operator,swdev,disco users=bob,steve $1=/dev/dd0[a-g]
  326. #
  327. #    allow operators to give files away; notice that they
  328. #    they must give at least two args, but may give more
  329. #
  330. chown            /etc/chown $1 $2 $*; $1=[a-z0-9][a-z0-9]*
  331. #
  332. #    permit development personnel to run install
  333. #
  334. inst            /usr/bin/install -o root -g system $1 $2; groups=devel
  335.                         $2=/bin,/usr/bin,/usr/ucb,/usr/new,/usr/local
  336. #
  337. nfsmount        /etc/mount -o timeo=100,hard,intr $1 $2; groups=devel,operator
  338.                         $1=\([a-zA-Z0-9_]*\):\(.*\) $2=/remote/\1\2
  339.  
  340.                         July 2, 1991
  341.  
  342.                            - 7 -
  343.  
  344.      Some example command lines using _o_p,  given  the  above
  345. _o_p._a_c_c_e_s_s file, might be:
  346.  
  347.      % op full /usr1
  348.      % op weekly /usr1
  349.      % op tape disable unit0
  350.      % op reboot 17:30 "We have to fix our network."
  351.      % op disco
  352.      % op rdsmount  /dev/dd0c  ~/mystuff
  353.      % op mounted 3 8688
  354.      % op chown jim  /tmp/bill/*
  355.      % op inst less  /usr/local
  356.      % op nfsmount  convexs:/usr/src  /remote/convexs/usr/src
  357.  
  358.      Note that the following commands would not work because
  359. they  would  not  match the back-reference specifications in
  360. the _n_f_s_m_o_u_n_t mnemonic:
  361.  
  362.      op nfsmount convexs:/usr/src /remote/foobar/usr/src
  363.      op nfsmount convexs:/usr/src /remote/convexs/src
  364.  
  365.      In summary, the _o_p program allows the system manager to
  366. give  out limited system privileges without compromising the
  367. root password.  The system can be easily tuned to the  needs
  368. of a specific site.  The environment in which these commands
  369. execute  can  be  tightly  controlled  and  their  arguments
  370. checked  for  valid  values.  For security reasons, a log is
  371. kept of all commands run.  Careful  application  of  the  _o_p
  372. program can result in a stabler system.
  373.  
  374.                         July 2, 1991
  375.  
  376. --
  377. Tom Christiansen        tchrist@convex.com    convex!tchrist
  378.         "So much mail, so little time."  
  379.