Because of the above issues the answer is not Alice or Bob the answer is Bob

Because of the above issues the answer is not alice

This preview shows page 9 - 12 out of 110 pages.

9
suid can be turned on or off for a file using chmod – with u+s or u-s respectively. Again, this only applies to binary files - not scripts! Let’s test out the way SUID works. Execute the following commands: cd ~/ac_test echo "Alice’s secret" > ./alice_secret.txt sudo chown alice ./alice_secret.txt sudo chgrp characters ./alice_secret.txt sudo chmod og-rwx ./alice_secret.txt cp /bin/ cat . sudo chown alice ./ cat sudo chgrp characters ./ cat sudo chmod a+x ./ cat cp /bin/ cat ./cat_suid sudo chown alice ./cat_suid sudo chgrp characters ./cat_suid sudo chmod a+x ./cat_suid sudo chmod u+s ./cat_suid ls -l The output should look something like the below: Take a moment to guess the output of the following commands: su bob fixit #when prompted for password ./ cat alice_secret.txt ./cat_suid alice_secret.txt The call using cat fails, because it runs with Bob’s permissions and he does not have read permissions for alice secret.txt . The call with cat suid succeeds, because due to suid being on, it runs with Alice’s permissions. 6 Linux File Descriptors A lot of things in Linux are files. Directories are files. Hard disks are files. Processes are files. Internet connections are files. Files are files . 10
We’ve seen how to work with files on Linux: creating files, modifying the contentsof files, copying and moving files. It’s a pretty intuitive API, so of course it’s the resultof an abstraction on top of an abstraction on top of thirty other abstractions. Let’s askthe question bluntly: The command line shell we are using,bash, was written in Clanguage – so how did its author createbashwithout already havingbashto handleall the file operations?The answer is that C (and assembly) programs use a filesystem API which is a layerof abstraction down frombash. Consider the following C program:#include<stdio.h>#include<unistd.h>#include<fcntl.h>intmain() {intfd;intpid;pid = getpid();printf("Process id is: %d\n", pid);printf("Press return to open new file descriptor.");getchar();fd = open("testing.txt",O_CREAT);if(fd == -1) {printf("Failed to open file.\n");return1;}printf("Press return to close file descriptor and exit.");getchar();close(fd);return0;}Every process in Linux (and Windows, too) has a number which is its process id(pid). This number uniquely identifies the process. The above program, when launched,will display the pid of its own process. Launch the program, then on a different terminalexecute the following command:ls -la /proc/<pid>/fdwhere<pid>should be replaced with the actual pid that theprocess reported. The output should look something like this:

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture