se_matrix (optional) #include <stdio.h> #define SE_ARRAY_ROW 100 #define SE_ARRA
ID: 3766460 • Letter: S
Question
se_matrix (optional)
#include <stdio.h>
#define SE_ARRAY_ROW 100
#define SE_ARRAY_COL 200
#define SE_READ 0x01
#define SE_WRITE 0x02
#define SE_EXEC 0x04
/* the 2D security matrix */
unsigned int se_matrix[SE_ARRAY_ROW][SE_ARRAY_COL];
void init_se_matrix(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL])
{
sem[0][0] = SE_READ | SE_WRITE;
sem[0][1] = SE_EXEC | SE_READ;
sem[1][0] = SE_READ;
sem[16][28] = SE_READ | SE_WRITE;
sem[16][133] = SE_READ;
sem[16][149] = SE_READ;
sem[50][5] = SE_READ | SE_WRITE | SE_EXEC;
sem[50][133] = SE_READ | SE_EXEC;
sem[12][133] = SE_READ;
sem[10][0] = SE_READ;
sem[10][98] = SE_EXEC | SE_READ;
sem[27][28] = SE_READ | SE_WRITE;
sem[84][199] = SE_READ | SE_WRITE | SE_EXEC;
sem[76][55] = SE_READ | SE_WRITE;
sem[50][25] = SE_READ | SE_WRITE | SE_EXEC;
sem[66][0] = SE_READ | SE_EXEC;
sem[66][149] = SE_READ;
sem[99][25] = SE_READ | SE_WRITE;
}
unsigned int get_used_cells(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL]);
void print_acls(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL]);
void print_cls(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL]);
int main(int argc, char **argv)
{
init_se_matrix(se_matrix);
printf("There are %d cells, %d of which are used ",
SE_ARRAY_ROW*SE_ARRAY_COL, get_used_cells(se_matrix));
print_acls(se_matrix);
print_cls(se_matrix);
return 0;
}
/* ========== Do not change anything above this line =========== */
/*
* Find the number of cell that has a security policy
*/
i have to add some function in that code
You need to implement three functions:
get_used_cells : this function returns the total number of cell that has access-right.
print_acls : this function prints out all the ACLs
print_cls : this function prints out all the CLs (Capability Lists)
Output format
Add name “process” and “object” to the output
Follow the dummy output example from the code
To compile the program
gcc -o se_matrix se_matrix.c
The program provides a security matrix, which is implemented as a two-dimensional array. The array is initialized with the access-rights.
The access-rights is implemented as a bit map (see program)
Explanation / Answer
unsigned int get_used_cells(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL])
{
int row=(sizeof(sem)/sizeof(sem[0][0]))/row;
return 1;
}
void print_acls(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL])
{
int a,b;
for( a=0;a<11;a++)
for( b=0;b<10;b++)
printf("Object 0 - Process 0:RW; Process 58:RWX ");
return 0;
}
void print_cls(unsigned int sem[SE_ARRAY_ROW][SE_ARRAY_COL])
{
printf("Process 1 - Object 1:R; Object 55:RX ");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.