0
0
Operating Systemsknowledge~30 mins

Capability-based security in Operating Systems - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Capability-based Security
📖 Scenario: You are learning about how computers control access to resources like files and devices. Capability-based security is a way to manage permissions by giving specific 'capabilities' or keys to users or programs.Imagine a library where each visitor has a special card that lets them borrow certain books. This card is like a capability that grants access only to allowed books.
🎯 Goal: Build a simple model of capability-based security using a dictionary to represent users and their capabilities. Then, check if a user has permission to access a resource.
📋 What You'll Learn
Create a dictionary named user_capabilities with exact user names and their capability lists
Create a variable named resource with the exact resource name to check
Write a loop using for user, capabilities in user_capabilities.items() to find users with access to the resource
Add a final statement that stores the list of users who can access the resource in a variable named authorized_users
💡 Why This Matters
🌍 Real World
Capability-based security is used in operating systems and software to control access to files, devices, and services by giving specific permissions to users or programs.
💼 Career
Understanding capability-based security helps in roles like system administration, security engineering, and software development where managing access control is critical.
Progress0 / 4 steps
1
Create the user capabilities dictionary
Create a dictionary called user_capabilities with these exact entries: 'alice': ['read', 'write'], 'bob': ['read'], and 'carol': ['execute'].
Operating Systems
Need a hint?

Use curly braces {} to create a dictionary. Each key is a user name string, and each value is a list of capability strings.

2
Set the resource to check
Create a variable called resource and set it to the string 'read' to represent the capability you want to check.
Operating Systems
Need a hint?

Assign the string 'read' to the variable resource.

3
Find users with the capability
Use a for loop with variables user and capabilities to iterate over user_capabilities.items(). Inside the loop, check if resource is in capabilities and collect those users in a list called authorized_users.
Operating Systems
Need a hint?

Use for user, capabilities in user_capabilities.items(): to loop. Check if resource is in capabilities. If yes, add user to authorized_users.

4
Complete the authorized users list
Ensure the variable authorized_users contains the list of users who have the resource capability. This completes the capability check.
Operating Systems
Need a hint?

The list authorized_users should have all users who can 'read'. No extra code needed if previous step is correct.