Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]/var /opt & /usr on other partitions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Johnny_Bit
Apprentice
Apprentice


Joined: 30 Aug 2005
Posts: 246
Location: Poland

PostPosted: Tue Dec 27, 2005 6:33 pm    Post subject: [SOLVED]/var /opt & /usr on other partitions Reply with quote

Hi, I have problem. Recently I moved /var /opt and /usr to different partitions than / and copied the data without -a switch, but when i found out mistake it was too late to recover any permisions because of move was done. So here I am stuck with everything in /opt /var and /usr with root:root ownership, and permisions screwed up. My question is: how to restore ownership and permissions without reinstall of system?

Last edited by Johnny_Bit on Fri Dec 30, 2005 7:59 am; edited 1 time in total
Back to top
View user's profile Send private message
pv
Tux's lil' helper
Tux's lil' helper


Joined: 25 Mar 2005
Posts: 103
Location: Russia, Yaroslavl

PostPosted: Tue Dec 27, 2005 9:27 pm    Post subject: Reply with quote

Sorry for the re-question but is your question how to restore ownership and permissions in a common way if there is one in Gentoo or what permissions the directories mentioned with the files inside them would have?

I mean would my giving you the output of the following command on my system help you?
Code:
ls -lR /opt /usr /var

Of course it will be VERY huge so if you need it I'll give you it in some shorter way.
_________________
Nothing but perfection.
Back to top
View user's profile Send private message
Johnny_Bit
Apprentice
Apprentice


Joined: 30 Aug 2005
Posts: 246
Location: Poland

PostPosted: Tue Dec 27, 2005 10:47 pm    Post subject: Reply with quote

Well, to be clear... I'd rather want info if emerge --sync && emerge -e world were not enought. For exapmle, I think that passwords and other important stuff isn't in var or usr, but some programs (xscreensaver to be clear) deny access for normal user, only root can do something to bypass the security. Others were for sample games (ut and ut2004 - my only games) switched their ownership, and therefore I couldn't play, witch made no sense since ut2k4 was the reason for creating other partitions.

But I don't think that output of ls -lR /var /usr and /opt would be helpfull enough to even bother creating one... I just need simple solutions for stupidy...
Back to top
View user's profile Send private message
ctenet
Apprentice
Apprentice


Joined: 10 Aug 2003
Posts: 156
Location: New York, USA

PostPosted: Wed Dec 28, 2005 5:35 am    Post subject: Reply with quote

if you wrote (or perhaps one already exists) a script to take the permissions found in the output from ls -lR and apply them to files on your filesystem, and ran it as root using another Gentoo user's ls output, then it would be relatively easy to get the permissions back to being close to the way they were. But there may be an easier way.
Back to top
View user's profile Send private message
Johnny_Bit
Apprentice
Apprentice


Joined: 30 Aug 2005
Posts: 246
Location: Poland

PostPosted: Wed Dec 28, 2005 8:28 am    Post subject: Reply with quote

Alright, I think that making script for it is the best and the fastest way, but ouput of ls -lRA /opt /var /usr is preety unreadable because of useless info, like date, I think I'll make script to drift all the files and output in form /fullpath/filename user:group and I think that would be enought info, if not then also permissions. Making script that would aply it wouldn't be much harder eiter, so I think I just wrote those scripts, give lister to people wanting to help me, and apply changes.
Back to top
View user's profile Send private message
Johnny_Bit
Apprentice
Apprentice


Joined: 30 Aug 2005
Posts: 246
Location: Poland

PostPosted: Wed Dec 28, 2005 2:46 pm    Post subject: Reply with quote

*bump*

The scripts are done. This one is for everyone that wants to help me:
Code:
#!/usr/bin/php -q
<?php
//sorry for script in php, but I don't like bash scripts (or don't understand)

   function strGetInfo($strFileName) //$strFileName is supossed to be full path and file name
      {
         if (file_exists($strFileName))
            {
               $arrGroup=posix_getgrgid(filegroup($strFileName));
               $arrOwner=posix_getpwuid(fileowner($strFileName));
               $strGroup=$arrGroup["name"];
               $strOwner=$arrOwner["name"];
               unset($arrGroup, $arrOwner);
               //$intPerms=decoct(fileperms($strFileName));
               return $strFileName." ".$strOwner.":".$strGroup." "."\n"; //$strFileName." ".$strOwner.":".$strGroup." ".$intPerms."\n";
            }
         else
            return false;
      }
   
   function DirSurf($strDirName, $resOFH) //basic dir name should be something like "/var/" trailing slash is important!
      {
         fwrite($resOFH, strGetInfo($strDirName));
         $arrDirs; //array of sub-dirs
         if (file_exists($strDirName) && is_dir($strDirName))
            {
               $resDir=opendir($strDirName);
               while (($strName=readdir($resDir))!==false)
                  {
                     if ( ($strName!=".") && ($strName!="..") )
                        {
                           if (is_dir($strDirName.$strName) && !is_link($strDirName.$strName) && ($strName!="tmp") && ($strName!="cache"))
                              {
                                 $arrDirs[]=$strDirName.$strName."/";
                              }
                           else
                              fwrite($resOFH, strGetInfo($strDirName.$strName));
                        }
                  }
               closedir($resDir);
               unset($resDir, $strName);
               if (is_array($arrDirs)) //just to be sure, also checks if is not empty
                  {
                     foreach ($arrDirs as $strDir)
                        DirSurf($strDir, $resOFH); //recursive... wonder how fast it'll break my system...
                  }
               unset($arrDirs); //it won't help a bit I guess...
            }
         else
            return false;
      }

   function Main($strOutFile)
      {
         clearstatcache();//needed to be sure...
         $resOFH=fopen($strOutFile, "w");
         fwrite($resOFH, "#DirSurfer v 0 generated file, don't try to understand");
         DirSurf("/var/", $resOFH);
         DirSurf("/usr/", $resOFH);
         DirSurf("/opt/", $resOFH);         
         fclose($resOFH);
      }
      
   Main($argv[1]);
?>


run as root:
Code:
./script.php dsr.txt

then
Code:
tar -cjf dsr.tar.bz2 dsr.txt


Dirs like tmp and cache are filtered out from results, so there shouldn't be any useless junk in output file, after compression archive shouldn't be bigger tah 2MB.

Compressed results please send to johnnybit(at)gmail.com with "You are idiot" as subject.

Thanks in advance

//ps. scripts on my side make sure that files witch don't exist on my system are filtered out, and any privacy voliation from my side is impossible, firstly because you see the script code (in most readable form), seconly output is too big to bother.

EDIT:

Problem is solved. I just got few results of this script, other scripts made their work, now everything's sweet as used to be.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum