LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 12-22-2021, 11:54 AM   #1
ClemaX
LQ Newbie
 
Registered: Dec 2021
Posts: 4

Rep: Reputation: Disabled
Question LFS 11.0: 8.25. Shadow: Invalid /etc/shadow permissions after pwconv


After successfully installing the shadow package and running pwconv, the password cannot be set as stated in the guide.

The command
Code:
passwd root
fails with the following error:
Code:
passwd: cannot open /etc/shadow
Indeed, it seems that the default permissions set by pwconv do not include the write permission.

Code:
(lfs chroot) root:/tmp# ls -l /etc/shadow
-r-------- 1 root root 299 Dec 22 17:30 /etc/shadow
It is a simple solution to
Code:
chmod 600 /etc/shadow
But this has not been mentioned in the book AFAIK.

So I wonder if others also ran into this issue, or if I have missed an installation step and messed up some permissions.
Otherwise it seems that this should be added to the book.

Here is the relevant book page.

The script that led me to this issue:
Code:
# Prevent groups program and man-pages installation, to use coreutils.
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \;

# Use SHA-512 instead of default crypt for password encryption.
# Change the obsolete /var/spool/mail to /var/mail.
# Remove /bin and /sbin symlinks from PATH.
sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \
	-e 's:/var/spool/mail:/var/mail:'                 \
	-e '/PATH=/{s@/sbin:@@;s@/bin:@@}'                \
	-i etc/login.defs

# TODO: Think about adding cracklib support.

# Fix a programming error.
sed -e "224s/rounds/min_rounds/" -i libmisc/salt.c

touch /usr/bin/passwd
./configure \
	--sysconfdir=/etc \
	--with-group-name-max-length=32

make

make exec_prefix=/usr install

make -C man install-man

mkdir -p /etc/default
useradd -D --gid 999

# Enable shadowed passwords.
pwconv
grpconv

# Set default root password.
chpasswd <<< "root:$ROOT_PASSWORD"
 
Old 12-23-2021, 12:59 PM   #2
bryan_S
Member
 
Registered: Aug 2014
Location: N. Florida
Distribution: LinuxfromScratch, OpenSuse, Slackware
Posts: 107

Rep: Reputation: Disabled
My /etc/shadow file has permissions 400 (-r--------) and I've had no issues with setting root, then user password. Are you possibly running the script as non-root user?
 
Old 12-25-2021, 01:01 PM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
Originally Posted by bryan_S View Post
My /etc/shadow file has permissions 400 (-r--------) and I've had no issues with setting root, then user password. Are you possibly running the script as non-root user?
Confirmed, same here.
Code:
stat /etc/shadow
  File: /etc/shadow
  Size: 675       	Blocks: 8          IO Block: 4096   regular file
Device: 809h/2057d	Inode: 1115567     Links: 1
Access: (0400/-r--------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-12-25 12:48:42.326014119 +0000
Modify: 2021-12-02 21:12:48.976148736 +0000
Change: 2021-12-02 21:12:49.001148736 +0000
 Birth: 2021-12-02 21:12:48.976148736 +0000
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shadow-4.1.4 segfaults on "pwconv" Blender3D Linux From Scratch 4 08-30-2010 06:14 PM
pwconv missing lortech Linux - Software 1 08-07-2010 12:43 AM
how to convert user passwords and group passwords using pwconv? dolceinter1 Linux - Security 2 11-04-2008 10:03 PM
convert user passwords using pwconv dolceinter1 Linux - Newbie 3 11-04-2008 04:52 PM
/etc/shadow- (notice the dash after the word shadow) shellcode Linux - Security 1 09-03-2004 04:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 05:59 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