Re: chmod 666 ///

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2008-04-06 at 18:34 -0700, Bruce Hyatt wrote:
> This is stretching my knowledge of bash. The main point about
> which I'm not sure is the brackets([]).
> 
> I'm accustomed to these being used for optional parts of a
> command but the apostrophe before and after the brackets makes
> me wonder. Plus the fact that brackets are used for "filename
> metacharacters" which it appears could be the case here.
> 
> Should I enter the brackets as part of the command?

Yes. In fact you can learn a lot by figuring it out. Take it one step at
a time:

rpm  -qa --qf '[\[ -L %{FILENAMES:shescape} \] || chmod %7.7{FILEMODES:octal} %{FILENAMES:shescape}\n]'
  A------------^
  B--------------^

A: This bracket and its matching pair mean "for each filename in the
package" (special rpm query syntax,
see /usr/share/doc/rpm-4.4.2.2/queryformat).

B: This will be printed in the output, and is the Shell "test" builtin.
'-L' means "symbolic link", and '||' is of course the sequential 'or'
operator.

So this part of the incantation means "for each filename in the package
which is not a symbolic link, change the permissions to ..."

etc.

poc

> Also, I have version 4.3.1 of rpmpopt. There's a command there
> (alias --setperms) that's identical but diverges somewhat after
> "\(none\)". Does that matter?
> 
> Thanks again,
> Bruce
> 
> --- Harald Hoyer <harald@xxxxxxxxxx> wrote:
> 
> > FYI
> > 
> > Here is a fixed version taken from
> > /usr/lib/rpm/rpmpopt-4.4.2.2:
> > 
> > # rpm  -qa --qf '[\[ -L %{FILENAMES:shescape} \] || chmod
> > %7.7{FILEMODES:octal} %{FILENAMES:shescape}\n]'
> > |grep -v \(none\) | grep '^. -L ' | sed 's/chmod .../chmod /'
> > | tee /dev/tty | sh
> > 
> > -------- Original Message --------
> > Subject: Re: chmod 666 ///
> > Date: Sat, 05 Apr 2008 12:50:37 +0200
> > From: Harald Hoyer <harald@xxxxxxxxxx>
> > Newsgroups: gmane.linux.redhat.fedora.general
> > References: <1207248867.22562.18.camel@bree>
> > <822046.81805.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> > 
> > Bruce Hyatt wrote:
> > >>> I carelessly executed "chmod 666 ///" from a terminal as
> > su 
> > >>> in a user account.
> > > 
> > > --- Patrick O'Callaghan <pocallaghan@xxxxxxxxx> wrote:
> > > 
> > >> Possibly all he needs to get X going is 'chmod +t /tmp'.
> > > 
> > > I tried this first and it didn't work.
> > > 
> > >> On Thu, 2008-04-03 at 13:12 -0400, Andrew Parker wrote:
> > >>> rpm -qa | xargs rpm ----setperms --setugids
> > > 
> > > This returned "----setperms: unknown option"
> > > So I tried it using "--setperms" and it returned
> > > "chmod: invalid mode string: '[various 7-digit numbers]'"
> > > It seemed to be looping through this with different 7 digit
> > > numbers coming back. The mode string indicates how to set
> > the
> > > permissions.
> 
> 
>       ____________________________________________________________________________________
> You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
> http://tc.deals.yahoo.com/tc/blockbuster/text5.com
> 


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux