Skip to content

xsetuser 'root': Function not implemented #595

Description

@imycroft

I am building a minimal Linux system, I was trying with busybox and everything worked fine, I decided to try toybox, so I used its init file and included getty as well. When I tried to login I got the error message :
xsetuser 'root': Function not implemented
so, I searched that function, I found it in login.c, I searched its implementation and it is in xwrap.c
xwrap.c

void xsetuser(struct passwd *pwd) { if (initgroups(pwd->pw_name, pwd->pw_gid) || setgid(pwd->pw_gid) || setuid(pwd->pw_uid)) perror_exit("xsetuser '%s'", pwd->pw_name); }

I think it fails when trying to initgroups, even though I do have an /etc/group, so what I did is changing the code to :
xwrap.c modified

void xsetuser(struct passwd *pwd)
{
    int res;

    res = initgroups(pwd->pw_name, pwd->pw_gid);

    // tolerate ENOSYS if UID matches current UID
    if (res != 0) {
        if (errno == ENOSYS && pwd->pw_uid == getuid()) {
            // skip, assume single-user system
        } else {
            perror_exit("xsetuser '%s'", pwd->pw_name);
        }
    }

    if (setgid(pwd->pw_gid) < 0 || setuid(pwd->pw_uid) < 0)
        perror_exit("xsetuser '%s'", pwd->pw_name);
}

almost similar to busybox's and it is working fine.
NB: I enabled the multiuser on my kernel, so the problem does not come from there
So I don't know where the failure is coming from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions