Skip to content

Commit

Permalink
chore: better error handling print on chdir
Browse files Browse the repository at this point in the history
  • Loading branch information
javalsai committed Sep 7, 2024
1 parent ed80b4b commit 2ba4904
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/auth.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <security/pam_misc.h>
Expand Down Expand Up @@ -61,10 +60,9 @@ void *shmalloc(size_t size) {
}

void moarEnv(char *user, struct session session, struct passwd *pw) {
if (chdir(pw->pw_dir) == -1) {
fprintf(stderr, "can't change directory to %s: %s\n", pw->pw_dir,
strerror(errno));
}
if (chdir(pw->pw_dir) == -1)
print_errno("can't chdir to user home");

setenv("HOME", pw->pw_dir, true);
setenv("USER", pw->pw_name, true);
setenv("SHELL", pw->pw_shell, true);
Expand Down

0 comments on commit 2ba4904

Please sign in to comment.