Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modif: Standardize and add missing name/hostname checks #5856

Merged
merged 6 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs: document NAME VALIDATION in firejail.txt
  • Loading branch information
kmk3 committed Jun 14, 2023
commit 6489138a5685df83b7b8ce490b7fcc64cde3fb38
2 changes: 2 additions & 0 deletions src/firejail/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,8 @@ int ascii_isxdigit(unsigned char c) {
return ret;
}

// Note: Keep this in sync with NAME VALIDATION in src/man/firejail.txt.
//
// Allow only ASCII letters, digits and a few special characters; names with
// only numbers are rejected; spaces and control characters are rejected.
int invalid_name(const char *name) {
Expand Down
24 changes: 22 additions & 2 deletions src/man/firejail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,8 @@ Print options end exit.
\fB\-\-hostname=name
Set sandbox hostname.
.br
For valid names, see the \fBNAME VALIDATION\fR section.
.br

.br
Example:
Expand Down Expand Up @@ -1180,7 +1182,9 @@ Switching to pid 1932, the first child process inside the sandbox
.TP
\fB\-\-join-or-start=name
Join the sandbox identified by name or start a new one.
Same as "firejail --join=name" if sandbox with specified name exists, otherwise same as "firejail --name=name ..."
Same as "firejail --join=name" if sandbox with specified name exists, otherwise
same as "firejail --name=name ...".
See \fB\-\-name\fR for details.
.br
Note that in contrary to other join options there is respective profile option.

Expand Down Expand Up @@ -1340,8 +1344,13 @@ $ firejail \-\-net=eth0 \-\-mtu=1492
\fB\-\-name=name
Set sandbox name. Several options, such as \-\-join and \-\-shutdown, can use
this name to identify a sandbox.
The name cannot contain only digits, as that is treated as a PID in the other options, such as in \-\-join.
The name cannot contain only digits, as that is treated as a PID in the other
options, such as in \-\-join.
.br
For valid names, see the \fBNAME VALIDATION\fR section.
.br

.br
In case the name supplied by the user is already in use by another sandbox, Firejail will assign a
new name as "name-PID", where PID is the process ID of the sandbox. This functionality
can be disabled at run time in /etc/firejail/firejail.config file, by setting "name-change" flag to "no".
Expand Down Expand Up @@ -3296,6 +3305,17 @@ Example:
$ firejail --net=eth0 --x11=xephyr --xephyr-screen=640x480 firefox
.br
#endif
.\" Note: Keep this in sync with invalid_name() in src/firejail/util.c.
.SH NAME VALIDATION
For simplicity, the same name validation is used for multiple options.
Rules:
.PP
The name must be 1-253 characters long.
The name can only contain ASCII letters, digits and the special characters
"-._" (that is, the name cannot contain spaces or control characters).
The name cannot contain only digits.
The first and last characters must be an ASCII letter or digit and the name
may contain special characters in the middle.
#ifdef HAVE_APPARMOR
.SH APPARMOR
.TP
Expand Down
Loading