Hello,

On Tue, May 18, 2021 at 11:40:38PM -0400, Greg Wooledge wrote:
> On Tue, May 18, 2021 at 11:46:38PM +0000, Andy Smith wrote:
> > I can't think of an easy way if you don't have backups. If you have
> > another system you could get a list of all its permissions like so:
> > 
> > # find /usr -xdev -printf '%p %m\0' | sort -z > good-perms
> > 
> > Then on your suspect machine:
> > 
> > # find /usr -xdev -printf '%p %m\0' | sort -z > suspect-perms
> > 
> > And then run this perl script:
> > 
> >     https://gist.github.com/grifferz/1c478ea5eb789b2a1d1a3e49d2a9345c
> 
> The serialization format you're using (pathname followed by mode) is
> not ideal for parsing.  I'd suggest putting the mode *first*, because it's
> in a known, fixed format, and then the pathname second.

I was wondering about that at the time but it seemed like the end of
each item could only ever be a space, a sequence of digits and then
\0, so I didn't think it could be a problem. But yeah, not too many
changes needed if you want to switch them around.

I also realised later that there isn't too much point in sorting the
both the file lists. I did that because I was initially going to use
the "comm" command, which needs the files to be sorted, but later
decided against it.

If you are happy with seeing the results in the order that the
"suspect-perms" find command outputs them, then just don;t bother
sorting either of them.

Cheers,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting

Reply via email to