Skip to content

Commit

Permalink
docs: Update example in chapter 8 to use sudo
Browse files Browse the repository at this point in the history
In chapter 8, the example code for setting permissions is as follows:
```c
static struct kobj_attribute myvariable_attribute =
    __ATTR(myvariable, 0660, myvariable_show, (void *)myvariable_store);
```
We have two options:
1. Instruct users to read/write the file with `sudo`.
2. Relax the permission setting to 0666.

This commit adopts the sudo method to maintain security constraints.
  • Loading branch information
pao0626 committed Jul 3, 2024
1 parent 1d3943a commit 019ba02
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lkmpg.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1347,14 +1347,14 @@ \section{sysfs: Interacting with your module}
What is the current value of \cpp|myvariable| ?

\begin{codebash}
cat /sys/kernel/mymodule/myvariable
sudo cat /sys/kernel/mymodule/myvariable
\end{codebash}

Set the value of \cpp|myvariable| and check that it changed.

\begin{codebash}
echo "32" > /sys/kernel/mymodule/myvariable
cat /sys/kernel/mymodule/myvariable
echo "32" | sudo tee /sys/kernel/mymodule/myvariable
sudo cat /sys/kernel/mymodule/myvariable
\end{codebash}

Finally, remove the test module:
Expand Down

0 comments on commit 019ba02

Please sign in to comment.