LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-06-2012, 12:10 PM   #1
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 302

Rep: Reputation: 61
I did chown -R root:root /usr - did I screw it up?


I just realized I have installed some packages where I was the owner of all files and folders, and now I am the owner of those folders in the system. So I tried to fix it by just chown one directory at a time to root:root, started with /usr. After I did that I realized there might have been files that should not have root as both owner and group-owner... Is there a way to find out and fix this?
 
Old 11-06-2012, 12:20 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,009
Blog Entries: 5

Rep: Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787
Yes you screwed it up.

Bad hackers sometimes try to set permissions on everything so it is globally accessible. Due to this many secure programs actually expect a certain level of permission/ownership/group and if they don't have it will fail on the theory you've been hacked.

How to fix it depends on your distro. Many of the package managers include information about what permissions/ownership/groups files within the package should have after installation.
 
Old 11-06-2012, 12:35 PM   #3
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 302

Original Poster
Rep: Reputation: 61
Is it possible to fix it if I reinstall all packages from the official repository? Is there a way to do that in one command? Or mount the iso and install those groups of packages I chosed during installation?

Which is the easiest way to fix this, or should I just reinstall from scratch?
 
Old 11-06-2012, 12:53 PM   #4
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 302

Original Poster
Rep: Reputation: 61
I'm not sure exactly which packages I have installed that I have build myself. I try to remember to save them if I need to reinstall, but I have forgotten some. Is there a way to check /var/log/packages/ and find which of those does not exist in the official repository? I miss a log-file that says what packages I have installed/upgraded/removed, and at what date... (Comming from Arch, I just loved Pacman...)
 
Old 11-06-2012, 12:59 PM   #5
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 2,457

Rep: Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886Reputation: 886
"slackpkg clean-system" will prompt you for removing your added packages (if you don't have upgraded anything provided with slackware), obviously this is only for you to have a list, not for actually removing them (I don't think you want that).
you should also use the TAG variable when building your packages (use the BUILD one when rebuilding the official slackware packages), so that they are named ...lennie, for example, and you can do a "ls -la /var/log/packages/*lennie" and see your modifications.
the log you're looking for is the folder /var/log/packages (and /var/log/scripts too).

Quote:
Which is the easiest way to fix this, or should I just reinstall from scratch?
the last thing you said

Last edited by ponce; 11-06-2012 at 01:12 PM.
 
Old 11-06-2012, 01:22 PM   #6
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 14.1 64 Multi-Lib
Posts: 435

Rep: Reputation: 138Reputation: 138
Confucius say : man who play in root, kill tree !


(don't feel bad - we've all done it at some stage :-)
 
1 members found this post helpful.
Old 11-06-2012, 01:57 PM   #7
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 302

Original Poster
Rep: Reputation: 61
I have a vague memory that I have seen other threads with similar titles, and that I used to think "How can one even think of doing such a stupid thing..." I can't understand I did this... Just laughing at it now...

So it's easier to reinstall the whole system from scratch, than try to fix it by forcing it to reinstall all packages? Shouldn't that set ownership right? *hoping someone gives another answer* But if I backup my /home and save those unofficial packages that have the right ownership, then it shouldn't be too much work to start over again.

Okay, tomorrow... Now I'm to tired. I guess I shouldn't do anything more as root now. (I can't do anything with sudo, but su still works...) And I guess I should be careful what I'm doing as user with my /home, and my Data-partition...
 
Old 11-06-2012, 04:24 PM   #8
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,377

Rep: Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088
The code snippet below is stolen to the SeTconfig script in Slackware's installer:
Code:
# These next lines are intended to clean up any permissions
# problems that could be caused by a bad package.  We don't
# intend to make any bad packages here, but it never hurts
# to be safe. :^)
( cd $T_PX ; chmod 755 ./ )
( cd $T_PX ; chmod 755 ./var )
if [ -d $T_PX/usr/src/linux ]; then
  chmod 755 $T_PX/usr/src/linux
fi
if [ ! -d $T_PX/proc ]; then
  mkdir $T_PX/proc
  chown root.root $T_PX/proc
fi
if [ ! -d $T_PX/sys ]; then
  mkdir $T_PX/sys
  chown root.root $T_PX/sys
fi
chmod 1777 $T_PX/tmp
if [ ! -d $T_PX/var/spool/mail ]; then
  mkdir -p $T_PX/var/spool/mail
  chmod 755 $T_PX/var/spool
  chown root.mail $T_PX/var/spool/mail
  chmod 1777 $T_PX/var/spool/mail
fi
In this code snippet '$T_PX' stands for /mnt which will be the root of the new Slackware distribution.

So my guess (only a guess) is if you run the 'chmod' commands with $T_PX="" you will get back the standard Slackware permissions.

This does not solve the ownership problem but I believe that
in /usr almost everything is owned by root.root. <standard disclaimer here>.

EDIT On an almost vanilla full Slackware 14 installation:
Code:
find /usr -not -user root -or -not -group root|xargs ls -l>not_root.txt
output attached file.
Attached Files
File Type: txt not_root.txt (11.2 KB, 23 views)

Last edited by Didier Spaier; 11-07-2012 at 12:45 AM. Reason: s/that/the chmod commands/
 
1 members found this post helpful.
Old 11-07-2012, 03:08 AM   #9
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Ruhr Area, Germany
Distribution: Slackware64 14.0
Posts: 1,524

Rep: Reputation: 94
http://slackware.org.uk/people/alien...om_manifest.sh

I didn't try it myself, but this script was mentioned several times before on similar occasions. It shoul be able to restore your permissions from the Manifest file that is found on the Slackware CD/DVD.
 
Old 11-07-2012, 07:52 AM   #10
688a
Member
 
Registered: Sep 2012
Location: Hong Kong
Distribution: Slackware14 (3.7)
Posts: 51

Rep: Reputation: Disabled
Just come across a question which is, when I install a library or application, I will do it as a root. Is that a right way to install a new thing?
 
Old 11-07-2012, 09:20 AM   #11
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,377

Rep: Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088Reputation: 1088
You must do that as root if you install it in the intended places, e.g. /usr/bin for binaries, as theses directories are writable only by root. If you install it in some non standard place like your home instead you can do that as a regular user depending on the ownership/permissions of that place but:
(1) some additional steps are required in that case to have the binaries or the libraries accessible.
(2) this is generally not recommended as it makes maintenance of applications and libraries problematic.

So, just use the packages management tools included in Slackware for installation and do that as root.

If asking the question you had that in mind: yes, generally speaking there is a risk in issuing a command as root, that's why you should only install packages from a trusted source: primarily packages included in the Slackware Linux distribution itself, then packages provided by one of the main Slackware contributors and packages you make yourself using a SlackBuild provided by one of the aforementioned sources or by http://slackbuilds.org.

And avoid as much as you can to install packages whose source code is not available, for safety concerns.

Last edited by Didier Spaier; 11-07-2012 at 10:38 AM.
 
Old 11-07-2012, 10:31 AM   #12
Lennie
Member
 
Registered: Aug 2012
Location: Sweden
Distribution: LFS, built with pacman
Posts: 302

Original Poster
Rep: Reputation: 61
Thank you all who tried to help me. I ended up reinstalling, it was actually the easiest and quickest way to get up and running again. Lesson learned - I hope...
 
Old 11-07-2012, 09:51 PM   #13
688a
Member
 
Registered: Sep 2012
Location: Hong Kong
Distribution: Slackware14 (3.7)
Posts: 51

Rep: Reputation: Disabled
Quote:
Originally Posted by Didier Spaier View Post
You must do that as root if you install it in the intended places, e.g. /usr/bin for binaries, as theses directories are writable only by root. If you install it in some non standard place like your home instead you can do that as a regular user depending on the ownership/permissions of that place but:
(1) some additional steps are required in that case to have the binaries or the libraries accessible.
(2) this is generally not recommended as it makes maintenance of applications and libraries problematic.
...
THANK YOU
 
Old 11-08-2012, 08:34 AM   #14
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,009
Blog Entries: 5

Rep: Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787
Quote:
Originally Posted by Lennie View Post
Thank you all who tried to help me. I ended up reinstalling, it was actually the easiest and quickest way to get up and running again. Lesson learned - I hope...
Yep. There are two types of Administrator. Those that have screwed their systems up at least once and those that lie and say they never have.

Beware "rm -rf *".

 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware 13.37 + NSS_LDAP; i can getent and su to user from root,but not usr 2 usr? pdean712 Slackware 8 08-08-2011 10:41 PM
root> chown -R 666 ~ veracity Linux - Software 10 11-06-2009 08:30 AM
cant go on chown -R root:root $LFS/tools Lolandrea Linux From Scratch 6 11-04-2008 07:36 AM
chown as non-root Rudy Vogels Linux - Security 5 06-19-2007 12:20 AM
proftpd chown as root failed john8675309 Linux - Software 2 12-06-2005 04:53 PM


All times are GMT -5. The time now is 07:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration