Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
# 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 ?
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.
I'm confused now. How is "the result the same as the previous" if it "let the non-root user work normally"
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:
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...
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.
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
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
Do you have busybox configured to support the su command?
What happens if you
Code:
# su hello
I guess I don't understand why you're preceding the su with "busybox" when you didn't do that with adduser.
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;
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.