Fix some option in vconftool 51/119851/1
authorJiwoong Im <jiwoong.im@samsung.com>
Tue, 14 Mar 2017 02:12:01 +0000 (11:12 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Mon, 20 Mar 2017 09:32:43 +0000 (18:32 +0900)
- Enable force option for 2.4 compatibility.
  Disable Smack option because buxton's access control is based on
  privilege.

Change-Id: I9acee5b0ca8a38e12316e0beb032fe2547ce8c51
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
vconf-compat/vconftool

index a0110a5..ad2808e 100755 (executable)
@@ -7,8 +7,8 @@ OPT_DIRECT=""
 OPT_TYPE=""
 OPT_RECUR=0
 OPT_INIT=""
-OPT_LABEL=""
 OPT_DEBUG=0
+OPT_FORCE=0
 
 usage() {
        COMM=`basename $0`
@@ -24,8 +24,8 @@ cat << EOF
    -u, --uid=UID                       User ID (for compatibility, ignored)
    -g, --gid=GID                       Gourp ID (for compatibility, ignored)
    -i, --install                       Install memory type key
-   -s, --smack=LABEL                   Set a SMACK label
-   -f, --force                         Overwrite by force (for compatibility, ignored)
+   -s, --smack=LABEL                   Set a SMACK label (for compatibility, ignored)
+   -f, --force                         Overwrite by force
 
    ex)
      $COMM set -t string db/testapp/key1 "This is test"
@@ -117,9 +117,9 @@ do_create() {
        [ -z "${TYPE}" ] && echo "Type '${OPT_TYPE}': Invalid type" && usage
 
        dbg ${BUXTONTOOL} ${OPT_DIRECT} create-${TYPE} \
-               ${LAYER} ${OPT_KEY} \"${OPT_VAL}\" \"\" \"${OPT_LABEL}\"
+               ${LAYER} ${OPT_KEY} \"${OPT_VAL}\" \"\" \"\"
        RES=`${BUXTONTOOL} ${OPT_DIRECT} create-${TYPE} \
-               ${LAYER} ${OPT_KEY} "${OPT_VAL}" "" "${OPT_LABEL}" 2>&1`
+               ${LAYER} ${OPT_KEY} "${OPT_VAL}" "" "" 2>&1`
        [ $? -ne 0 ] && echo "Error: $RES" && exit 1
        exit 0
 }
@@ -131,6 +131,14 @@ do_set() {
        TYPE=`get_type ${OPT_TYPE}`
        [ -z "${TYPE}" ] && echo "Type '${OPT_TYPE}': Invalid type" && usage
 
+       RES=`${BUXTONTOOL} ${OPT_DIRECT} get ${LAYER} ${OPT_KEY} 2>&1`
+       if [ $? -eq 0 ]; then
+               if [ ${OPT_FORCE} -eq 0 ]; then
+                       echo "Key already exist. Use -f option to force update"
+                       exit 1
+               fi
+       fi
+
        dbg ${BUXTONTOOL} ${OPT_DIRECT} ${OPT_INIT} set-${TYPE} \
                ${LAYER} ${OPT_KEY} \"${OPT_VAL}\"
        RES=`${BUXTONTOOL} ${OPT_DIRECT} ${OPT_INIT} set-${TYPE} \
@@ -146,13 +154,6 @@ do_set() {
                exit 1
        fi
 
-       [ -z "${OPT_LABEL}" ] && exit 0
-
-       dbg ${BUXTONTOOL} ${OPT_DIRECT} set-write-priv \
-               ${LAYER} ${OPT_KEY} \"${OPT_LABEL}\"
-       RES=`${BUXTONTOOL} ${OPT_DIRECT} set-write-priv \
-               ${LAYER} ${OPT_KEY} "${OPT_LABEL}" 2>&1 `
-       [ $? -ne 0 ] && echo "Error: $RES" && exit 1
        exit 0
 }
 
@@ -188,7 +189,11 @@ while [ "$1" != "--" ]; do
                # ignore
                shift 2
                ;;
-       -f|--force|-v|--verbose|-q|--quiet)
+       -f|--force)
+               OPT_FORCE=1
+               shift
+               ;;
+       -v|--verbose|-q|--quiet)
                # ignore
                shift
                ;;
@@ -197,7 +202,7 @@ while [ "$1" != "--" ]; do
                shift
                ;;
        -s|--smack)
-               OPT_LABEL="$2"
+               # ignore
                shift 2
                ;;
        -d|--debug)