You are not logged in.

#1 2011-03-08 23:11:29

babylonian13
Member
Registered: 2009-07-06
Posts: 6

Can't login non-root user

Hi!
I'm having trouble to login with a user I created with:
useradd -g users -G wheel,daemon,audio,video,power,storage,optical,scanner -m toni

Afterwards I installed slim.
I can't login as toni. Only as root.

When I enter toni and then it's password the screen hangs for a few saconds, goes black and then returns to slim.

Then I tried this command from root:
'login -p toni'

It prints the Last Login MOTD of the toni user than it hangs for a few seconds and returns to the root session.
But when I press Ctrl+C after it has printed the Last Login MOTD than it logs immediately in the toni account.

This is a transcript of the commands:

[root@hp-arch ~]# login -p toni
Password: 
Last login: Tue Mar  8 23:56:58 CET 2011 on pts/2
[root@hp-arch ~]# login -p toni
Password: 
Last login: Tue Mar  8 23:57:28 CET 2011 on pts/2
^C[toni@hp-arch ~]$ whoami
toni
[toni@hp-arch ~]$ 

This is the output of 'strace login -p toni':

... -- output cropped -- ...
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77f8000
read(5, "root:x:0:root\nbin:x:1:root,bin,d"..., 4096) = 556
close(5)                                = 0
munmap(0xb77f8000, 4096)                = 0
fchown32(0, 1000, 5)                    = 0
fchmod(0, 0600)                         = 0
rt_sigaction(SIGINT, {SIG_IGN, [INT], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7659728) = 7586

wait4(-1, NULL, 0, NULL)                = 7586                             // This is where it hangs for a few seconds

--- SIGCHLD (Child exited) @ 0 (0) ---
getuid32()                              = 0
time(NULL)                              = 1299625337
send(3, "<86>Mar  9 00:02:17 login[7578]:"..., 86, MSG_NOSIGNAL) = 86
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=495, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77f8000
read(5, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 495
close(5)                                = 0
munmap(0xb77f8000, 4096)                = 0
gettimeofday({1299625337, 778461}, NULL) = 0
access("/var/log/wtmpx", F_OK)          = -1 ENOENT (No such file or directory)
open("/var/log/wtmp", O_WRONLY|O_LARGEFILE) = 5
alarm(0)                                = 0
rt_sigaction(SIGALRM, {0xb7793f70, [], 0}, {0x8049ab0, [ALRM], SA_RESTART}, 8) = 0
alarm(10)                               = 0
fcntl64(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
_llseek(5, 0, [191616], SEEK_END)       = 0
write(5, "\10\0\0\0\232\35\0\0pts/1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384) = 384
fcntl64(5, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
alarm(0)                                = 10
rt_sigaction(SIGALRM, {0x8049ab0, [ALRM], SA_RESTART}, NULL, 8) = 0
close(5)                                = 0
close(4)                                = 0
munmap(0xb780a000, 8160)                = 0
munmap(0xb7808000, 7220)                = 0
munmap(0xb7642000, 91200)               = 0
munmap(0xb7804000, 12676)               = 0
munmap(0xb7800000, 14444)               = 0
munmap(0xb7616000, 92104)               = 0
munmap(0xb77fd000, 11876)               = 0
munmap(0xb77f9000, 13724)               = 0
munmap(0xb7640000, 6584)                = 0
munmap(0xb763c000, 14804)               = 0
munmap(0xb7639000, 10720)               = 0
munmap(0xb7636000, 11796)               = 0
munmap(0xb75fd000, 12424)               = 0
munmap(0xb7634000, 6580)                = 0
munmap(0xb7631000, 9700)                = 0
munmap(0xb762e000, 11904)               = 0
munmap(0xb75c0000, 247036)              = 0
exit_group(0)                           = ?
[root@hp-arch bin]# 

And this is the output of 'ltrace login -p toni':

... -- output cropped -- ...
getdef_bool(0x804d36a, 0xb75f918d, 4, 0x8e81b08, 0)  = 0
getpwnam("toni")                                     = 0xb76d2c20
malloc(28)                                           = 0x08e8ed48
realloc(NULL, 256)                                   = 0x08e92128
__errno_location()                                   = 0xb7552688
getpwnam_r(0x8e81c38, 0x8e8ed48, 0x8e92128, 256, 0xbf80f64c) = 0
__pw_dup(0x8e8ed48, 0x8e8ed48, 0x8e92128, 256, 0xbf80f64c) = 0x8e81c48
free(0x08e92128)                                     = <void>
free(0x08e8ed48)                                     = <void>
setgid(100)                                          = 0
initgroups(0x8e80078, 100, 0x8e81c48, 0x8e8ed48, 0x8e81c38) = 0
pam_setcred(0x8e81a28, 2, 0xbf8118bc, 0xbf8119bc, 0) = 0
alarm(0)                                             = 0
getenv("IFS")                                        = NULL
getdef_str(0x804d780, 0x8e81c38, 0xbf80f668, 0x804d4a8, 1) = 0x8e81460
__errno_location()                                   = 0xb7552688
strtoll(0x8e81460, 0xbf80f62c, 10, 0xb76ed0f4, 0x8e81c48) = 0
malloc(16)                                           = 0x08e8eed8
realloc(NULL, 256)                                   = 0x08e92128
__errno_location()                                   = 0xb7552688
getgrnam_r(0x8e81460, 0x8e8eed8, 0x8e92128, 256, 0xbf80f5ec) = 0
__gr_dup(0x8e8eed8, 0x8e8eed8, 0x8e92128, 256, 0xbf80f5ec) = 0x8e8eef0
free(0x08e92128)                                     = <void>
free(0x08e8eed8)                                     = <void>
fchown(0, 1000, 5, 0x804d4a8, 1)                     = 0
getdef_num(0x804d789, 384, 5, 0x804d4a8, 1)          = 384
fchmod(0, 0600)                                      = 0
signal(2, 0x00000001)                                = NULL
fork()                                               = 7616
wait(NULL <unfinished ...>                                           // This is where it hangs for a few seconds
--- SIGCHLD (Child exited) ---
<... wait resumed> )                                 = 7616
pam_close_session(0x8e81a28, 0, 0xbf8118bc, 0xbf8119bc, 0) = 0
pam_end(0x8e81a28, 0, 0xbf8118bc, 0xbf8119bc, 0)     = 0
exit(0 <unfinished ...>
+++ exited (status 0) +++
[root@hp-arch bin]# 

Afterwards I tried adding another test user with the 'adduser' command and it logged without any problem.

Can anyone tell me where is the problem that I can't log in the toni user?
How can I fix it?

Thanks in advance

Offline

#2 2011-03-08 23:28:00

SS4
Member
From: !Rochford, Essex
Registered: 2010-12-05
Posts: 699

Re: Can't login non-root user

It looks like you didn't set a shell when using useradd

It would probably be easier to remove your user and add it again if toni has no data


Rauchen verboten

Offline

#3 2011-03-08 23:33:45

babylonian13
Member
Registered: 2009-07-06
Posts: 6

Re: Can't login non-root user

SS4 wrote:

It looks like you didn't set a shell when using useradd

It would probably be easier to remove your user and add it again if toni has no data

Yes I know the easy way.
I just want to know if there is anyway to fix it?

Offline

#4 2011-03-08 23:43:56

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: Can't login non-root user

Something to try:

If the lack of a shell is your problem, try "vipw" as root and add ":/bin/bash" to the end of "toni's" line in "/etc/passwd".

e.g.:

toni:x:1000:1000:Your Name,,,:/home/toni:/bin/bash

You may have to reboot.

Edit:  You're editor is likely to be "vim".  Can't tell how much experience you have in Linux so beware.

Last edited by whatshisname (2011-03-08 23:45:46)

Offline

#5 2011-03-08 23:46:38

babylonian13
Member
Registered: 2009-07-06
Posts: 6

Re: Can't login non-root user

I checked /etc/passwd and /bin/bash is already there.

Offline

#6 2011-03-09 17:13:07

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: Can't login non-root user

Then the problem may be in your having used "useradd" instead of "adduser".

From the man pages on an Ubuntu machine at work, not my Arch box:

"useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead."

I've mixed up those commands before myself.

At this point, I would take SS4's advice and delete the user.

Then use "adduser" to put him back.

Offline

#7 2011-03-09 18:05:26

babylonian13
Member
Registered: 2009-07-06
Posts: 6

Re: Can't login non-root user

Ok. That's what I'm going to do. Thanks for the answers. smile

Offline

Board footer

Powered by FluxBB