LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-21-2017, 08:10 AM   #1
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Rep: Reputation: Disabled
Question 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?
 
Old 07-21-2017, 08:42 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 07-22-2017, 07:36 AM   #3
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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 ?
 
Old 07-22-2017, 12:03 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Quote:
Originally Posted by wumy View Post
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...

Last edited by scasey; 07-22-2017 at 05:39 PM.
 
Old 07-23-2017, 01:29 AM   #5
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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.
 
Old 07-23-2017, 01:38 AM   #6
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
After you ran
Code:
adduser username
did you
Code:
passwd username
? It sounds you created the user but never set a password
 
Old 07-23-2017, 07:47 PM   #7
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-24-2017, 02:48 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Quote:
Originally Posted by wumy View Post
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.
 
Old 07-24-2017, 07:45 PM   #9
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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".
 
Old 07-24-2017, 10:46 PM   #10
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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);
}

Last edited by wumy; 07-24-2017 at 11:52 PM.
 
Old 07-25-2017, 02:20 AM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,708

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
It looks like the user doesn't have a login shell defined, maybe. What does
Code:
grep hello /etc/passwd
show? [where "hello" is the newly created userid)
 
Old 07-25-2017, 02:45 AM   #12
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
...

Last edited by wumy; 07-25-2017 at 04:05 AM.
 
Old 07-26-2017, 03:09 AM   #13
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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?
 
Old 08-01-2017, 10:03 PM   #14
wumy
LQ Newbie
 
Registered: Jul 2017
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to login to cygwin with username (but can login as cyg_server) Tachtory Linux - General 1 01-08-2014 12:17 AM
Disabling root login and using another username for administration mrdesai Fedora 3 08-15-2006 12:08 PM
The box is not able to determine username while I login other than root on RHEL4 abhi_raj Linux - General 4 07-20-2006 12:55 PM
Cannot login without Username, help! utcltjay Linux - General 1 09-06-2005 05:18 PM
How to login w/o username and pw? liubhs02 Linux - Newbie 2 06-01-2004 08:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration