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 <az...@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. > + > + if test -d "$dir"; then > + # Change the ownership of the top level directory and the first > + # level files below it. > + chown "$OVS_USER":"$OVS_GROUP" "$dir" > + find "$dir" -maxdepth 1 -type f -exec chown "$OVS_USER":"$OVS_GROUP" > {} \; > + else > + install -d -m 775 -o "$OVS_USER" -g "$OVS_GROUP" "$dir" > + fi > +} > + > start_daemon () { > priority=$1 > wrapper=$2 [snip] _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev