You are not logged in.

#1 2022-08-13 19:01:37

sebastian-65
Member
Registered: 2021-11-08
Posts: 31

[CLOSED] New users have wrong (root) $USER and $HOME variables

My main user account (sebastian) ended up seriously crippled and I wanted to create a new user to look for differences between them, but:

    - When logged in to tty as a new non-root user (e.g. guest), echo $USER outputs root, $HOME outputs root
    - Cannot login in to GUI (xfce) either, since all user files system seeks in /root/ folder (where they dont exist), instead of the user folder, e.g.:
        - /root/.bash_profile: Permission denied
        - /root/.config/autostart failed, ignoring: Permission denied
        - /root/.config/systemd/user.control, ignoring: Permission denied
        - /root/.config/systemd/user, ignoring: Permission denied
        - /root/.local/share/systemd/user, ignoring: Permission denied
        - Invalid XDG_CONFIG_HOME directory /root/.config, program may behave incorrectly.
    - It happens to freshly created users (such as guest), while my main user is able to log into GUI (echo $USER returns correctly the user)

Where can possibly be the problem?

    - /etc/profile is default, -rw-r--r-- root root
    - /etc/bash.bashrc is default, -rw-r--r-- root root
    - id: uid=0(root) gid=0(root) groups=0(root)
    - id guest: uid=1002(guest) gid=1004(guest) groups=1004(guest)
    - getent passwd guest: guest:x:1002:1004::/home/guest:/bin/bash
    - echo $HOME: /root (account was created by useradd -m guest, folder /home/guest was created automatically)
    - grep ^guest /etc/passwd: guest:x:1002:1004::/home/guest:/bin/bash
    - ls -l /etc/passwd: -rw-r--r-- 1 root root 2002 Aug 13 15:43 /etc/passwd
    - paccheck --file-properties --quiet | grep permission: shadow: /usr/bin/newuidmap permission mismatch (expected 4755) - this Ive already corrected

Is the shadow the mechanism that assign users their $HOME and $USER variables? Can be reset/reinstalled somehow without reinstalling the whole system?

Last edited by sebastian-65 (2022-08-15 09:03:11)


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch | ZFS | systemd | XFCE | ASUS S435 | CPU: Intel 11th gen | GPU: Intel Iris Xe Graphics

Offline

#2 2022-08-13 19:13:42

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

How, exactly, did you create the "guest" user?  (edit: sorry this was covered well in the second list, I had missed it)

Last edited by Trilby (2022-08-13 22:58:53)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-08-13 22:01:27

sebastian-65
Member
Registered: 2021-11-08
Posts: 31

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

Ive been trying adduser -m guest or adduser -m -d /home/guest guest. In both cases home folder is generated and the correct home folder can be seen in /etc/passwd for a guest user.

Last edited by sebastian-65 (2022-08-13 22:01:49)


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch | ZFS | systemd | XFCE | ASUS S435 | CPU: Intel 11th gen | GPU: Intel Iris Xe Graphics

Offline

#4 2022-08-14 00:04:30

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 242

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

# cat /etc/default/useradd

?

Anything suspicious in /etc/skel/* ?

Can you login as "broken" user, then switch to root with `su` and run this:

#!/bin/bash

VAR=HOME

P=$$
while true; do
    printf "% 8i:%16s: %s\n" \
        ${P} \
        $(cat /proc/${P}/comm) \
        $(xargs -0 -L 1 -a /proc/${P}/environ | grep ^${VAR}=)

    [ "${P}" -eq 1 ] || [ -z "${P}" ] && break

    P=$(cut -d' ' -f 4 /proc/${P}/stat)
done

This may help to track if HOME variable was changed or set incorrectly by some parent process.

Offline

#5 2022-08-14 06:56:51

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

    - id: uid=0(root) gid=0(root) groups=0(root)
    - id guest: uid=1002(guest) gid=1004(guest) groups=1004(guest)

Seems the result of sudo, https://unix.stackexchange.com/question … 417_713522

https://unix.stackexchange.com/question … -root-user

paccheck --file-properties --quiet | grep permission: shadow: /usr/bin/newuidmap permission mismatch (expedted 4755)

Didn't ring an alarm?

stat /usr/bin/newuidmap

https://unix.stackexchange.com/question … 424_713522

I have compared /etc/profile and the contents of /etc/profile.d with Arco linux on my backup machine, and they seem to be identical, standard.

Are you using Arco Linux?

Offline

#6 2022-08-14 07:56:04

sebastian-65
Member
Registered: 2021-11-08
Posts: 31

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

@dimich I have switched to root with su - root, and run it with output:

   22022:            bash: HOME=/root
   21502:            bash: HOME=/root
   21479:              su: HOME=/root
   21107:            bash: HOME=/root
   20843:           login:
       1:         systemd:

@seth output of stat /usr/bin/newuidmap:

  File: /usr/bin/newuidmap
  Size: 37528         Blocks: 33         IO Block: 37888  regular file
Device: 0,25    Inode: 61095       Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-08-13 19:49:55.000000000 +0200
Modify: 2022-01-27 14:47:21.000000000 +0100
Change: 2022-08-13 19:49:55.526995637 +0200
Birth: 2022-08-13 19:49:55.503662385 +0200

And no, Im using Arch on my main laptop (which is now broken down), but I use Arco Linux on my backup laptop (which is also my girlfriend's OS, so for the sake of compatibility).


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch | ZFS | systemd | XFCE | ASUS S435 | CPU: Intel 11th gen | GPU: Intel Iris Xe Graphics

Offline

#7 2022-08-14 08:14:15

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

Please use "code" tags, https://bbs.archlinux.org/help.php#bbcode
Permissions are fine, suid is gone because of https://github.com/archlinux/svntogit-p … ow.install

When you log in as "guest" the "id" output is 1002?
What if you

chsh -s /bin/sh guest

Offline

#8 2022-08-14 08:23:37

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 242

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

sebastian-65 wrote:
   21479:              su: HOME=/root
   21107:            bash: HOME=/root
   20843:           login: 

Looks like it is set incorrectly initially by login.
I'd also check changes in /etc/pam.d/* and /etc/environment.

Is the same error if you ssh from another host?

Offline

#9 2022-08-15 09:03:46

sebastian-65
Member
Registered: 2021-11-08
Posts: 31

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

I resolved this only by reinstalling the system. Thank you guys for your help, anyway!


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch | ZFS | systemd | XFCE | ASUS S435 | CPU: Intel 11th gen | GPU: Intel Iris Xe Graphics

Offline

#10 2022-08-15 12:13:38

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [CLOSED] New users have wrong (root) $USER and $HOME variables

Please do not mark a thread [closed] -- that is used by staff when a thread is not open for further replies. If you would like a thread closed or deleted, please use the Report button.

Offline

Board footer

Powered by FluxBB