The first seven lesson introduce you to some of the simpler constructs and capabilities of Privilege Manager for Unix's policies. Each lesson builds upon the precepts of the last lesson. By the end of the seventh lesson you will have sufficient knowledge to start building your own policies.
These are the introductory lessons:
This lesson introduces the basic concept of running a command at a privileged level. For a given list of users (in this case, dan and your defined LESSON_USER), run the command as root.
Here is the relevant policy code:
if (user=="dan" || user==PMLESSON_USER) { runuser="root"; accept; }
If the policy server evaluates the policy without reaching an explicit "accept" statement, the request is rejected.
Be sure to:
Text in bold represents commands you enter; the resulting output is shown in normal font. The command output for the pmrun commands below has been slightly modified for brevity.
# LESSON_USER=demo; export LESSON_USER # LESSON=1; export LESSON # su demo $ whoami demo $ pmrun whoami root $ exit
As you can see the result of the whoami command without a pmrun prefix shows that you are logged in as user demo. Repeating the command with a pmrun prefix, shows that you ran the command as root.
Here is the policy code that implements this behavior:
if (user=="dan" || user==PMLESSON_USER) { runuser="root"; accept; }
If the user who submitted the pmrun request matches either "dan" or the PMLESSON_USER variable, the runuser is set to "root" and the request is accepted.
The exit command at the end returns you to the root shell before proceeding to the next lesson.
Refer to Lesson 1 Sample: Basic policy to see the sample policy used in this lesson.
This lesson builds upon the previous lesson by narrowing the conditions under which you can run the commands as root. It introduces the use of a policy variable, dayname, and the function, timebetween(), to ensure that you can only run commands within the predetermined time frame of typical office hours (weekdays, between 8:00 a.m. and 5:00 p.m.).
The dayname variable and the timebetween() policy function are used to reject requests outside office hours:
if(dayname=="Sat" || dayname=="Sun" || !timebetween(800,1700)) reject;
This lesson assumes that the current date and time are within this time frame.
# LESSON=2; export LESSON # su demo
Now, change the system date and attempt the command again using the following commands:
$ pmrun date mmdd2100 Thu Feb 26 21:00:00 EDT 2012 $ pmrun date mmdd2100 Request Rejected by pmmasterd on UPMhost $ exit
where:
The output shown above illustrates that the first attempt to set the date succeeded because the system date was within normal office hours. The second attempt fails because the time is now set outside of normal office hours.
Remember to reset the correct time on your system by running the date command as the root user.
Refer to Lesson 2 Sample: Conditional privilege to see the sample policy used in this lesson.
This lesson narrows the scope of which commands you can run with root privilege. The permitted list of commands is ls, hostname, and kill. Any other attempt to run a privileged command is rejected.
The "command" variable stores the command name issued by pmrun:
if (command == "ls" || command == "hostname" || command == "kill") { runuser = "root"; accept; }
# LESSON=3; export LESSON # su demo $ pmrun shutdown Request Rejected by pmmasterd on <UPMhost> $ pmrun hostname UPMhost $ exit
where <UPMhost> is the host name
Refer to Lesson 3 Sample: Specific commands to see the sample policy used in this lesson.
© 2024 One Identity LLC. ALL RIGHTS RESERVED. 이용 약관 개인정보 보호정책 Cookie Preference Center