[ovs-dev] [rhel --user v2 5/7] ovs-lib: add directory_check()

Ben Pfaff blp at ovn.org
Mon Nov 30 00:20:04 UTC 2015


On Thu, Nov 26, 2015 at 02:12:51PM +0900, Simon Horman wrote:
> Hi Andy,
> 
> On Fri, Nov 20, 2015 at 03:33:18AM -0800, Andy Zhou wrote:
> > Rafactor common directory existence check and ownership check into
> > a common function. Move daemon's default directory to $RUNDIR, since
> > the process may not able to write core file to "/" anymore after the
> > user change.
> > 
> > Signed-off-by: Andy Zhou <azhou at ovn.org>
> > 
> > ---
> > v1->v2:  * Drop using 'stat -c"
> >          * ADD $OVS_GROUP != root in addition to $OVS_USER != root check
> > ---
> >  utilities/ovs-lib.in | 37 ++++++++++++++++++++++++++++---------
> >  1 file changed, 28 insertions(+), 9 deletions(-)
> > 
> > diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
> > index ad223c0..ad9c9f4 100644
> > --- a/utilities/ovs-lib.in
> > +++ b/utilities/ovs-lib.in
> > @@ -70,8 +70,6 @@ ovs_ctl () {
> >  
> >  VERSION='@VERSION@'
> >  
> > -DAEMON_CWD=/
> > -
> >  LC_ALL=C; export LC_ALL
> >  
> >  ## ------------- ##
> > @@ -154,6 +152,23 @@ pid_comm_check () {
> >      [ "$1" = "`cat /proc/$2/comm`" ]
> >  }
> >  
> > +# Make sure the directory '$1' exits. If not, crate it. If yes, make sure
> > +# its group ownership agrees with $OVS_GROUP. If not, chown on all files
> > +# within it.  We don't enforce $OVS_USER to allow for multiple users that
> > +# shares $OVS_GROUP.
> > +directory_check() {
> > +    dir=$1
> 
> Some care has been taken to always quote $dir below,
> and it seems that the same care has been taken by callers
> regarding the parameter passed to directory_check.
> 
> However, in order for things to hold together I think that $1 also needs to
> be quoted when assigning dir above.

There's no word splitting on the right side of an assignment in shell,
so it's OK in this case.



More information about the dev mailing list