Skip to content

Commit

Permalink
modif: clarify error messages in profile.c
Browse files Browse the repository at this point in the history
  • Loading branch information
kmk3 committed Jan 9, 2025
1 parent 92137f8 commit 5167ef8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/firejail/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,12 +1617,12 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
arg_rlimit_nofile = 1;
}
else if (strncmp(ptr, "rlimit-cpu ", 11) == 0) {
check_unsigned(ptr + 11, "Error: invalid rlimit in profile file: ");
check_unsigned(ptr + 11, "Error: invalid rlimit-cpu in profile file: ");
sscanf(ptr + 11, "%llu", &cfg.rlimit_cpu);
arg_rlimit_cpu = 1;
}
else if (strncmp(ptr, "rlimit-nproc ", 13) == 0) {
check_unsigned(ptr + 13, "Error: invalid rlimit in profile file: ");
check_unsigned(ptr + 13, "Error: invalid rlimit-nproc in profile file: ");
sscanf(ptr + 13, "%llu", &cfg.rlimit_nproc);
arg_rlimit_nproc = 1;
}
Expand All @@ -1635,7 +1635,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
arg_rlimit_fsize = 1;
}
else if (strncmp(ptr, "rlimit-sigpending ", 18) == 0) {
check_unsigned(ptr + 18, "Error: invalid rlimit in profile file: ");
check_unsigned(ptr + 18, "Error: invalid rlimit-sigpending in profile file: ");
sscanf(ptr + 18, "%llu", &cfg.rlimit_sigpending);
arg_rlimit_sigpending = 1;
}
Expand Down Expand Up @@ -1795,7 +1795,7 @@ void profile_read(const char *fname) {
// check file
invalid_filename(fname, 0); // no globbing
if (strlen(fname) == 0 || is_dir(fname)) {
fprintf(stderr, "Error: invalid profile file\n");
fprintf(stderr, "Error: invalid profile file: %s\n", fname);
exit(1);
}
if (access(fname, R_OK)) {
Expand All @@ -1806,7 +1806,8 @@ void profile_read(const char *fname) {
if (ptr && strlen(ptr) == 6 && errsv != EACCES)
return;

fprintf(stderr, "Error: cannot access profile file: %s\n", fname);
fprintf(stderr, "Error: cannot access profile file: %s: %s\n",
fname, strerror(errsv));
exit(1);
}

Expand All @@ -1832,7 +1833,8 @@ void profile_read(const char *fname) {
// open profile file:
FILE *fp = fopen(fname, "re");
if (fp == NULL) {
fprintf(stderr, "Error: cannot open profile file %s\n", fname);
fprintf(stderr, "Error: cannot open profile file %s: %s\n",
fname, strerror(errno));
exit(1);
}

Expand Down

0 comments on commit 5167ef8

Please sign in to comment.