Skip to content

Commit

Permalink
Fix test for multiuser kernels
Browse files Browse the repository at this point in the history
getuid() succeeds even on non-multiuser kernels. Instead
getgroups() is a valid test.

Fixes #214 on github
  • Loading branch information
mkj committed Dec 11, 2023
1 parent 383cc8c commit 9ac6504
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/common-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ void common_session_init(int sock_in, int sock_out) {
#if !DROPBEAR_SVR_MULTIUSER
/* A sanity check to prevent an accidental configuration option
leaving multiuser systems exposed */
errno = 0;
getuid();
if (errno != ENOSYS) {
dropbear_exit("Non-multiuser Dropbear requires a non-multiuser kernel");
{
int ret;
errno = 0;
ret = getgroups(0, NULL);
if (!(ret == -1 && errno == ENOSYS)) {
dropbear_exit("Non-multiuser Dropbear requires a non-multiuser kernel");
}
}
#endif

Expand Down

0 comments on commit 9ac6504

Please sign in to comment.