Skip to content

Commit

Permalink
Remove spammy "file not found" warning
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Apr 4, 2024
1 parent df5cb60 commit 7586c3d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions session.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,29 +838,26 @@ safe_user_file(const char *filename, struct passwd *pw)
struct stat st;
char *path;

if (stat(filename, &st) == -1) {
fprintf(stderr, "User file %s not found, ignoring.\n",
filename);
if (stat(filename, &st) == -1)
return 0;
}

path = realpath(filename, NULL);
if (strncmp(path, pw->pw_dir, strlen(pw->pw_dir)) == 0) {
if (st.st_uid != pw->pw_uid) {
fprintf(stderr, "Bad owner on %s, ignoring.\n",
filename);
path);
return 0;
}
if ((st.st_mode & 077) != 0) {
fprintf(stderr,
"Permissions too open (%3o) on %s, ignoring.\n",
st.st_mode & 0777u, filename);
st.st_mode & 0777u, path);
return 0;
}
return 1;
}
if (st.st_uid != 0) {
fprintf(stderr, "%s not root-owned, ignoring.\n", filename);
fprintf(stderr, "%s not root-owned, ignoring.\n", path);
return 0;
}
return 1;
Expand Down

0 comments on commit 7586c3d

Please sign in to comment.