Answer the following questions about the lecture material for this week.
Suppose we create a library with a function foo:
int foo(int x);
This function is declared in a header file bar.h
and the library implementation is linked into a file
libbar.so
.
If we modify the function foo to have the prototype
int foo(double x);
and update bar.h
and libbar.so
accordingly, we find that
executables that use the library and used to work now crash
(even though there are no relevant bugs in the library itself).
Which of the following would either fix this issue or have avoided this issue in the first place? Select all that apply.
Consider the following erroneous Makefile.
all: executable
foo.c: foo.h
gcc -Wall -c foo.c
main.c: foo.h
gcc -Wall -c main.c
executable: foo.c main.c
gcc -Wall -o executable foo.c main.c
clean:
rm --force main.o foo.o executable
(Assume the commands in each rule are prefixed by tab characters.)
Which of the following is true about this erroneous Makefile? Select all that apply.
Suppose a program displays its logo when it starts. Rather than store that logo in a separate data file, the program includes it in its executable. To do this, multiple steps are used:
First a program converts the logo file from SVG format in the file logo.svg
into
BMP format in the file logo.bmp
:
svg2png logo.svg logo.bmp
Then, the BMP file logo.bmp
is converted to a file logo.h
file that defines
an array of unsigned chars logo
using the xxd
utility:
xxd -i logo.bmp logo.h
The file logo.h is included by main.c
, along with the utility header file graphics.h
and the C standard library headers <stdlib.h>
and <stdio.h>
.
Consider the following incomplete Makefile that implements this scheme, including
building the final executalbe program
. In this incomplete Makefile
,
lines or partial lines of code that are not yet complete are replaced by ### BLANK X ###
where X
is some number:
all: program
### BLANK 1 ###
svg2png logo.svg logo.bmp
### BLANK 2 ###
xxd -i logo.bmp logo.h
main.o: ### BLANK 3 ###
graphics.o: graphics.h
%.o: %.c
clang -c $^
program: main.o graphics.o
clang -o program main.o graphics.o
(Assume the commands in each rule are prefixed by tab characters.)
What would be appropriate to put in place of ### BLANK 2 ###
?
What would be appropriate to put in place of ### BLANK 3 ###
?
Suppose the file "first.txt" has the following access control list:
user:A:rw-
user:B:r--
group:C:rw-
group:D:r--
other::---
and the file "second.txt" has the following access control list:
user:B:rw-
group:C:rw-
other::---
(The other::...
lines provide default permissions for cases where other entries of
the access control list do not apply.)
It's possible for a running program to be able to read and write "second.txt" but not to be able to both read and write "first.txt". Which of the following is a sufficient condition for this to be true? Select all that apply.
Suppose we wanted to allow users to collaborate on a shared system like the department machines (portal, etc.)
In particular, one student A wants to collect comments from their collaborator students B and C and then reply to those comments. Students B and C should not be able to see each other's comments or the replies intended for the other student. But no one else should be able to read those comments.
Suppose to implement this scheme, we have separate files for B's comments and the corresponding replies and for C's comments and the corresponding replies.
Suppose we want to set the permissions on these files to restrict access appropriately, but instead of being able to use full access control lists (where we can specify read/write/execute access individually for arbitrary numbers of users and groups), we have to use more limited chmod-style permissions (where we can only specify read/write/execute access for a single user and for a single group).
We would need to create some groups of users to enable this. (When we say a "group contains users", we mean that everytime one of those users runs a program it runs as part of that group.) What sets of new groups could enable this? Select all that apply.