Cannot login with non-root username
# uname -a
Linux iis-78-79-3f 3.14.26 #2 Wed Aug 24 13:52:28 CST 2016 armv7l GNU/Linux fs: ramdisk + sysvinit + BusyBox(V1.26.2) runlevel: 5 Description: After I created a non-root user with command "adduser", I tried to login with newly created username and failed. I failed both on console and with ssh. The command 'last' shows that the newly id has login successfully but logout immediately. I manually typed in 'login', and then feed with newly created username and passwd, and a string "Killed" prompted. When i modify the UID to 0 in /etc/password for the newly created username, then the login success, so the username and password are correct. When i execute "strace su test", the last output is as following: setgroups32(1, [1000]) = 0 setgid32(1000) = 0 setuid32(1000) = 0 execve("/bin/sh", ["sh"], 0xbe910dc0 /* 14 vars */) = ? +++ killed by SIGKILL +++ Killed I searched on web but no relevant page was found. It seems that only few people uses non-root user to login embedded system. Is there something I missed? |
Does /bin/sh exist? Is it a link to another shell (e.g. /bin/bash) and if so does that exist?
What /etc and user profiles exist appropriate to the shell you're actually calling? e.g. /etc/profile, /etc/bashrc, <userhome>/.profile, <userhome>/.bash_profile etc... If you run "/bin/sh" from within a current shell does it work to open a subshell? (You can type exit to leave the subshell.). Changing uid to 0 made the user the equivalent of root so it likely got the profiles for root rather than those for itself which may be why it worked. |
Hi MensaWater,good day! thanks so much for your reply.
1. "/bin/sh" is a link of "/bin/busybox", and "/etc/profile" is exist. 2. Run "/bin/sh" on current shell can open a subshell successfully. I have written more than 10 scripts by using of "#!/bin/sh" which can be successfully run on the device. 3. I also did use another filesystem to replace my current filesystem, which can let the non-root user work normally. However, the result is the same as the previous. So, is there any collision might be existed in my "linux kernel config" that result in such phenomena ? |
Quote:
And what do you mean by "use another filesystem to replace my current filesystem"? That radical a change to what you're doing would completely muddy the waters. Suggest you start over: Create a "normal" unprivileged user. Do not tweak the new user in any way, and see if it can do what you want. Let us know what happens. PS You missed answering an important question that MensaWater asked. To wit: Quote:
|
Hi scasey, good weekend!
I'm sorry for the confused description. The so called "another filesystem" can work normally on a development board, not on my device. The profile of "/bin/sh" is "/etc/profile", which existed in my filesystem already. |
After you ran
Code:
adduser username Code:
passwd username |
Hi TheEzekielProject, thanks for your reply.
In my device, adduser and passwd are both the link of /bin/BusyBox. When run adduser, the BusyBox will run passwd automatically. # adduser hello Changing password for hello New password: Bad password: too weak Retype password: passwd: password for hello changed by root root@am335x-evm:~# busybox su hello Killed |
Quote:
What happens if you Code:
# su hello Also, it appears that you're running as root, so you won't (shouldn't) be prompted for a password when su-ing to a non-privileged user. |
Hi scasey, thanks for your reply.
"busybox" supports lots of applets, such as ls, cd, login, su, find, syslogd, tftp, and so on. All these applets are the link of /bin/busybox. Before use these applets, we should create soft link, such as "ln -s /bin/busybox ls". Otherwise should preceding the applet with "busybox", that's the reason of "busybox su hello". |
I use "login" applet from "util-linux v2.13" to replace BusyBox's "login" applet, and add two "printf" lines in main function.
When executed "execvp" line, the shell disconnected: int main(...) { ... childArgv[childArgc++] = NULL; printf("11\n"); // printed execvp(childArgv[0], childArgv + 1); printf("22\n"); // not printed errsv = errno; if (!strcmp(childArgv[0], "/bin/sh")) fprintf(stderr, _("login: couldn't exec shell script: %s.\n"), strerror(errsv)); else fprintf(stderr, _("login: no shell: %s.\n"), strerror(errsv)); exit(0); } |
It looks like the user doesn't have a login shell defined, maybe. What does
Code:
grep hello /etc/passwd |
Hi scasey, thanks for your reply.
# grep "hello" /etc/passwd hello:x:1000:1000:Linux User,,,:/home/hello:/bin/sh # ls -l /bin/sh lrwxrwxrwx 1 iis root 7 Jul 24 11:15 /bin/sh -> busybox # ls -l /home/ total 9 drwxr-sr-x 2 hello hello 1024 Jul 25 15:43 hello ... |
I added some "printk" in "fs/binfmt_elf.c" of kernel, and found the source of KILL signal:
static int load_elf_binary(struct linux_binprm *bprm) { ... error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, elf_prot, elf_flags, 0); if (BAD_ADDR(error)) { printk("kill3\n"); // printed send_sig(SIGKILL, current, 0); retval = IS_ERR((void *)error) ? PTR_ERR((void*)error) : -EINVAL; goto out_free_dentry; } ... } Does anybody know the reason? |
Hi all:
I solved this problem by modify the kernel config parameter CONFIG_DEFAULT_MMAP_MIN_ADDR from 65536 to default val 4096, which is a bug of kernel before v3.19. see:https://bugs.launchpad.net/ubuntu/+s...x/+bug/1418140 |
All times are GMT -5. The time now is 11:29 PM. |