LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-12-2019, 10:53 PM   #1
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
Validating ownership against /etc/passwd and /etc/group


Looking for ideas for how to validate ownerships against /etc/passwd and /etc/group.

I had to rebuild a server and then restore selected files from backups. All went well.

Except I noticed the /etc/passwd and /etc/group files no longer match the other similar servers or the same files from backups. Makes some sense because the rebuild was performed with a more recent ISO of the system.

For example:

Old /etc/passwd:
sshd:x:105:65534::/var/run/sshd:/usr/sbin/nologin

New /etc/passwd:
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin

Because of the selective backups, I want to validate that the ownerships of all restored files match the newer /etc/passwd|group files. I could restore those same files from backups, but I don't know what will break.

I am not noticing anything in the logs, but I would be more comfortable with some kind of validation.

Thanks again.
 
Old 01-13-2019, 12:33 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Selectively update the contents of /etc/passwd, /etc/shadow and /etc/group from the backups to the new server.

That is, make the passwd, shadow and group files match...don't try to tweak the files themselves.

I typically do that as early in the build as possible.

Last edited by scasey; 01-13-2019 at 12:35 AM.
 
Old 01-13-2019, 05:36 PM   #3
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
Quote:
That is, make the passwd, shadow and group files match...don't try to tweak the files themselves.
Hmm. I'm feeling a bit dense and am not followwing you.
 
Old 01-13-2019, 05:57 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by upnort View Post
Hmm. I'm feeling a bit dense and am not followwing you.
You set up new server, user sshd is UID 106, was UID 105 in backup data.
Change UID to 105 in /etc/passwd on the new server to match the backup data.
Repeat for all non-matching UIDs on new server.
 
Old 01-13-2019, 09:22 PM   #5
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
OK.

My focus though is discovering whether there are any files/directories created from within the new install that are using the new UIDs/GIDs. I suppose I could run 'find / -user $NewUID', 'find / -group $NewGID', etc. That way I would know what files/directories are affected before restoring the old UIDs/GIDs.

Perhaps also the reverse -- using the old UIDs/GIDs. Then there is discovering any files/directories that are not using the installed or backed up UIDs/GIDs. I was hoping for some kind of automated method, but I can manually run one command at a time. Time consuming but doable.
 
Old 01-13-2019, 11:04 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If this is an rpm based system, see https://linux.die.net/man/8/rpm (rpm -V) & https://www.cyberciti.biz/tips/reset...ermission.html
 
  


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
[SOLVED] Legacy Account in /etc/passwd, /etc/shadow and/or /etc/group lalit singhania Linux - Newbie 4 06-07-2012 06:33 AM
Problem with /etc/passwd and /etc/passwd- files linuxravindra414 Linux - Newbie 2 01-15-2011 05:17 AM
[SOLVED] /etc/passwd- & /etc/shadow- & /etc/group- Mr. Alex Linux - Newbie 1 12-31-2010 05:19 AM
Doubt when creating a user and checking /etc/group and /etc/passwd rosepower Slackware 9 04-18-2007 05:56 PM
/etc/passwd, /etc/shadow, /etc/group? Educate me :)! nutnut Linux - General 4 06-11-2005 07:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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