Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
131 changes: 130 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
# Contributor Covenant Code of Conduct

TODO: I'll add it when we have more active contributors :(
## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
<moe-hacker@outlook.com>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited
interaction with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
9 changes: 4 additions & 5 deletions build.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ void show_help(void)
printf(" -f, --force force rebuild\n");
printf(" -j, --jobs <num> number of jobs to run simultaneously\n");
printf(" -c, --core-only build core only\n");
printf(" -p, --profiling enable profiling build\n");
}
// So good brooooo, the program works with magic here.
int main(int argc, char **argv)
Expand Down Expand Up @@ -851,7 +852,7 @@ int main(int argc, char **argv)
} else {
check_and_add_cflag("-DRURI_CORE_ONLY", true);
check_and_add_cflag("-DDISABLE_LIBCAP", true);
check_and_add_cflag("-DDISABLE_SECCOMP", true);
check_and_add_cflag("-DDISABLE_LIBSECCOMP", true);
check_and_add_cflag("-DDISABLE_RURIENV", true);
}
if(profiling) {
Expand Down Expand Up @@ -1259,15 +1260,14 @@ struct cth_result *cth_exec(char **argv, char *input, bool block, bool get_outpu
* argv: The command and its arguments, NULL-terminated array of strings.
* input: The input to be passed to the command's stdin, can be NULL.
* block: If true, wait for the command to finish and return the result.
* If false, return immediately (not implemented yet).
* If false, return immediately without waiting for the command to finish.
* get_output: If true, capture stdout and stderr output.
* Returns a cth_result structure on success, NULL on failure.
* The caller is responsible for freeing the result using cth_free_result().
*/
if (argv == NULL || argv[0] == NULL) {
return NULL;
}
// For now, only blocking mode is implemented.
if (block) {
return cth_exec_block(argv, input, get_output);
}
Expand Down Expand Up @@ -1838,7 +1838,7 @@ struct cth_result *cth_exec_with_file_input(char **argv, int fd, bool block, boo
* argv: The command and its arguments, NULL-terminated array of strings.
* fd: The file descriptor to use as stdin, should be valid and open for reading.
* block: If true, wait for the command to finish and return the result.
* If false, return immediately (not implemented yet).
* If false, return immediately without waiting for the command to finish.
* get_output: If true, capture stdout and stderr output.
* progress: A callback function to report progress, can be NULL.
* The function will be called with a float value between 0.0 and 1.0,
Expand All @@ -1851,7 +1851,6 @@ struct cth_result *cth_exec_with_file_input(char **argv, int fd, bool block, boo
if (argv == NULL || argv[0] == NULL) {
return NULL;
}
// For now, only blocking mode is implemented.
if (block) {
return cth_exec_block_with_file_input(argv, fd, get_output, progress, progress_line_num);
}
Expand Down
16 changes: 2 additions & 14 deletions src/chroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,6 @@ static void setup_systemd_runtime(struct RURI_CONTAINER *_Nonnull container)
generate_machine_id(container->container_id);
mount("/dev/null", "/proc/cmdline", NULL, MS_BIND, NULL);
mount(NULL, "/proc/cmdline", NULL, MS_REMOUNT | MS_RDONLY, NULL);
// Setup getty.
/*
int fd = open("/etc/systemd/system/container-console-getty.service", O_RDWR | O_CLOEXEC | O_CREAT, 0644);
if (fd > 0) {
ftruncate(fd, 0);
char *content = "[Unit]\nDescription=Container Console Getty\nAfter=systemd-user-sessions.service\n[Service]\nExecStart=-/sbin/agetty --noclear --noissue /dev/pts/0 38400 vt100\nType=idle\nRestart=always\nRestartSec=0\n\nTTYPath=/dev/console\n\nStandardInput=null\nStandardOutput=null\nStandardError=null\n[Install]\nWantedBy=getty.target\n";
write(fd, content, strlen(content));
close(fd);
mkdir("/etc/systemd/system/getty.target.wants", S_IRWXU | S_IRWXG | S_IRWXO);
symlink("/etc/systemd/system/container-console-getty.service", "/etc/systemd/system/getty.target.wants/container-console-getty.service");
}
*/
}
// Run after chroot(2), called by ruri_run_chroot_container().
static void init_container(struct RURI_CONTAINER *_Nonnull container)
Expand Down Expand Up @@ -1398,7 +1386,7 @@ void ruri_run_chroot_container(struct RURI_CONTAINER *_Nonnull container)
if (execvp(container->command[0], container->command) == -1) {
// Catch exceptions.
ruri_pid_file_write(RURI_PID_FILE_PANIC_EXEC, 0);
ruri_error("\n{red}Failed to execute `%s`\nexecv() returned: %d\nerror reason: %s\nNote: unset $LD_PRELOAD before running ruri might fix this{clear}\n", container->command[0], errno, strerror(errno));
ruri_error("\n{red}Failed to execute `%s`\nexecvp() failed with errno: %d\nerror reason: %s\nNote: unset $LD_PRELOAD before running ruri might fix this{clear}\n", container->command[0], errno, strerror(errno));
}
ruri_error("{red}Error: execvp() returned without error, this should never happen QwQ\n");
}
Expand Down Expand Up @@ -1553,6 +1541,6 @@ void ruri_run_rootless_chroot_container(struct RURI_CONTAINER *_Nonnull containe
if (execvp(container->command[0], container->command) == -1) {
// Catch exceptions.
ruri_pid_file_write(RURI_PID_FILE_PANIC_EXEC, 0);
ruri_error("{red}Failed to execute `%s`\nexecv() returned: %d\nerror reason: %s\nNote: unset $LD_PRELOAD before running ruri might fix this{clear}\n", container->command[0], errno, strerror(errno));
ruri_error("{red}Failed to execute `%s`\nexecvp() failed with errno: %d\nerror reason: %s\nNote: unset $LD_PRELOAD before running ruri might fix this{clear}\n", container->command[0], errno, strerror(errno));
}
}
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ void ruri_correct_config(const char *_Nonnull path)
}
}
#ifdef DISABLE_RURIENV
container.use_rurienv = false;
ruri_set_flag("no_rurienv");
#endif
if (!have_key("ro_root", buf)) {
ruri_warning("{green}No key ro_root found, set to false\n{clear}");
Expand Down
2 changes: 1 addition & 1 deletion src/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ static const char *parse_mount_flags(const char *source, unsigned int *mountflag
* "SILENT:" -> MS_SILENT
* "POSIXACL:" -> MS_POSIXACL
* "LAZYTIME:" -> MS_LAZYTIME
* "BIND" -> MS_BIND
* "BIND:" -> MS_BIND
*
* The function stops processing when no recognized prefix is found at the start of 'source'.
*
Expand Down
4 changes: 2 additions & 2 deletions src/ruri.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void parse_args(int argc, char **_Nonnull argv, struct RURI_CONTAINER *_N
index++;
container->ns_pid = atoi(argv[index]);
if (container->ns_pid <= 0) {
ruri_error("{red}NS_PID should be in range 0-2\n");
ruri_error("{red}NS_PID should be a positive integer\n");
}
}
// cgroup limit.
Expand Down Expand Up @@ -1456,7 +1456,7 @@ static void parse_args(int argc, char **_Nonnull argv, struct RURI_CONTAINER *_N
index++;
container->ns_pid = atoi(argv[index]);
if (container->ns_pid <= 0) {
ruri_error("{red}NS_PID should >= 0\n");
ruri_error("{red}NS_PID should be a positive integer\n");
}
} else {
ruri_error("Invalid argument %s\n", argv[index]);
Expand Down
6 changes: 2 additions & 4 deletions test/src/catsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,14 @@ struct cth_result *cth_exec(char **argv, char *input, bool block, bool get_outpu
* argv: The command and its arguments, NULL-terminated array of strings.
* input: The input to be passed to the command's stdin, can be NULL.
* block: If true, wait for the command to finish and return the result.
* If false, return immediately (not implemented yet).
* If false, return immediately without waiting for the command to finish.
* get_output: If true, capture stdout and stderr output.
* Returns a cth_result structure on success, NULL on failure.
* The caller is responsible for freeing the result using cth_free_result().
*/
if (argv == NULL || argv[0] == NULL) {
return NULL;
}
// For now, only blocking mode is implemented.
if (block) {
return cth_exec_block(argv, input, get_output);
}
Expand Down Expand Up @@ -956,7 +955,7 @@ struct cth_result *cth_exec_with_file_input(char **argv, int fd, bool block, boo
* argv: The command and its arguments, NULL-terminated array of strings.
* fd: The file descriptor to use as stdin, should be valid and open for reading.
* block: If true, wait for the command to finish and return the result.
* If false, return immediately (not implemented yet).
* If false, return immediately without waiting for the command to finish.
* get_output: If true, capture stdout and stderr output.
* progress: A callback function to report progress, can be NULL.
* The function will be called with a float value between 0.0 and 1.0,
Expand All @@ -969,7 +968,6 @@ struct cth_result *cth_exec_with_file_input(char **argv, int fd, bool block, boo
if (argv == NULL || argv[0] == NULL) {
return NULL;
}
// For now, only blocking mode is implemented.
if (block) {
return cth_exec_block_with_file_input(argv, fd, get_output, progress, progress_line_num);
}
Expand Down
Loading