Welcome back. When I was a graduate student,
we liked to play computer games.
These were all owned by root
and ran with root privileges,
so the games could maintain high score files.
We also found out you could
spawn a subshell from the game,
to do something useful,
and then return to the game.
It turned out that the subshell run with root privileges.
So to become the root user,
you started up again,
and then spawn to subshell.
Why did this happen and how is it fixed?
We'll talk about that and other things in this module.
In this module, files, subprocesses,
and race conditions, we will
demonstrate how to create a child process,
discussed the subprocess environment,
and then share design tips about working
effectively with files and subprocesses.
Then we will discuss race conditions.
We will walk through a classic example of this and
explore time of check the time
of use race conditions in detail.
Finally, we'll explain
various programming and environmental conditions
to finish this module.
The interaction between processes occurs in many ways.
Most of these are harmless.
At least to create conditions where
the interaction may cause
problems and this module covers both of them.
The parent process controls the environment of its child.
So if the parent is running with
more privileges than the child should run with,
the parent process must restrict
the subprocesses, environment, and privileges.
When two processes are active, have different privileges,
and both use a common resource,
they need to ensure the ordering of
their actions does not create a security problem.
That's what race conditions do.
This condition is a situation
in which such a security problem may occur.
By the end of this module,
you will understand how files and subprocesses interact,
and be able to create subprocesses in shell scripts.
You will also be able to identify and
prevent race conditions in your programs.