Remove rstsmack and use factory-reset's instead 86/249586/2
authorKichan Kwon <k_c.kwon@samsung.com>
Tue, 15 Dec 2020 05:58:25 +0000 (14:58 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Tue, 15 Dec 2020 07:18:29 +0000 (16:18 +0900)
- NOTICE : rstsmack is provided by Public factory-reset
           please consider it when you migrate this package

Change-Id: I9c77bb3b81973b2531f33fd8ee58e5ae5ee025c6
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
CMakeLists.txt
packaging/system-rw-update.spec
rstsmack/CMakeLists.txt [deleted file]
rstsmack/rstsmack.c [deleted file]

index d2e8a78763c988915fa663622d01e0f642cd62c7..fdf84fd634eb76b9c22a7e13507e691eb8552277 100755 (executable)
@@ -7,6 +7,3 @@ CONFIGURE_FILE(upgrade/update.sh.in            upgrade/update.sh            @ONL
 CONFIGURE_FILE(upgrade/record-version.sh.in    upgrade/record-version.sh    @ONLY)
 CONFIGURE_FILE(units/udev-sdb-init.service.in  units/udev-sdb-init.service  @ONLY)
 CONFIGURE_FILE(units/offline-update.service.in units/offline-update.service @ONLY)
-
-#add sub directory
-ADD_SUBDIRECTORY(rstsmack)
index 070f222f675d78d48a885b4055c4ed10c2af450c..a6387a6b277d013d3fa19c7c44ac5ac0b6e372d1 100644 (file)
@@ -11,6 +11,10 @@ BuildRequires: cmake
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(libtzplatform-config)
 
+# rstsmack is provided by Public factory-reset
+# Please consider it when you migrate this package
+Requires:      %{_bindir}/rstsmack
+
 %description
 This package provides files for RW update
 which is implemented by using systemd offline update.
@@ -29,7 +33,6 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 %__make %{?_smp_mflags}
 
 %install
-%make_install
 
 %define upgrade_dir %TZ_SYS_UPGRADE
 mkdir -p %{buildroot}%{upgrade_dir}
@@ -62,9 +65,6 @@ else
        mkdir -p /usr/lib/udev/rules.d
        ln -s /opt/data/update/99-sdb-switch.rules /usr/lib/udev/rules.d
 fi
-if [ ! -e %{_bindir}/rstsmack ]; then
-       ln -s %{_bindir}/rstsmack-for-update %{_bindir}/rstsmack
-fi
 
 %files
 %manifest %{name}.manifest
@@ -73,4 +73,3 @@ fi
 %{_unitdir}/offline-update.service
 %{_unitdir}/system-update.target.wants
 %{_unitdir}/udev-sdb-init.service
-%{_bindir}/rstsmack-for-update
diff --git a/rstsmack/CMakeLists.txt b/rstsmack/CMakeLists.txt
deleted file mode 100755 (executable)
index edfbb89..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(rstsmack-for-update C)
-
-SET(SRCS rstsmack.c)
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED libsmack)
-
-FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
-
-ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -pie)
-
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME} DESTINATION bin)
diff --git a/rstsmack/rstsmack.c b/rstsmack/rstsmack.c
deleted file mode 100644 (file)
index e17d696..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * rstsmack - Restore smack attributes on files
- *
- * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: MyoungJune Park <mj2004.park@samsung.com>
- *   Created by Wonil Choi <wonil22.choi@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <linux/limits.h>
-#include <sys/smack.h>
-
-#ifdef DEBUG
-#  define LOGINFO(fmt, arg...) printf(fmt, ##arg)
-#else
-#  define LOGINFO(fmt, arg...)
-#endif
-
-void print_help(const char *cmd)
-{
-       printf("Usage: %s <INPUT FILE>\n", cmd);
-       printf("       INPUT FILE should be same format as generated by"
-                       " chsmack.\n\n");
-       printf("       Ex) # chsmack /usr/bin/* > /tmp/rstsmack_input.txt\n");
-}
-
-static inline int abandonqm(char *label)
-{
-       int ret = 0;
-       /* ignore last character which must be a quotation mark */
-       ret = (int) strlen(label);
-       ret--;
-       if (ret > SMACK_LABEL_LEN || ret <= 0)
-               return -1;
-       label[ret] = '\0';
-       return 0;
-}
-
-static void set_label(const char *pathname, char *label, int type)
-{
-       int ret = -1;
-
-       if (abandonqm(label) == 0) {
-               ret = smack_lsetlabel(pathname, label, type);
-               if (ret < 0)
-                       perror(pathname);
-       } else
-               fprintf(stderr, "The input file has wrong format, %s\n",
-                               pathname);
-}
-
-static int parse_and_set(const char *srcfile)
-{
-       /* We assume the text format of input file is same as chsmack output */
-       FILE *fp;
-       int ret = 0;
-       char linebuf[PATH_MAX + 5 * SMACK_LABEL_LEN], pathname[PATH_MAX];
-       char label[SMACK_LABEL_LEN + 1];
-       char *plabel; /* pointer of beginning smack label */
-       fp = fopen(srcfile, "r");
-       if (fp == NULL)
-               return -1;
-
-       while (fgets(linebuf, sizeof(linebuf), fp)) {
-               plabel = strstr(linebuf, " access=");
-
-               if (plabel && strlen(plabel) >= SMACK_LABEL_LEN) { // handling "The maximum input length is not specified"
-                       fclose(fp);
-                       return -1;
-               }
-               if (plabel && linebuf != plabel) {
-                       *plabel = '\0';
-                       strncpy(pathname, linebuf, sizeof(pathname));
-                       pathname[sizeof(pathname) - 1] = '\0';
-                       plabel++;
-               } else {
-                       linebuf[strlen(linebuf) - 1] = '\0';
-                       LOGINFO("no label, set label: %s, access=\"_\"(floor)\n", linebuf);
-                       strncpy(label, "_\"", SMACK_LABEL_LEN);
-                       set_label(linebuf, label, SMACK_LABEL_ACCESS);
-                       /* TODO: If file name contains " access=" then it would
-                        * not be processed */
-                       continue;
-               }
-
-               LOGINFO("set label: %s,", pathname);
-
-               ret = sscanf(plabel, "access=\"%s", label);
-               if (ret > 0) {
-                       LOGINFO(" access: \"%s", label);
-                       set_label(pathname, label,  SMACK_LABEL_ACCESS);
-                       plabel = plabel + sizeof(" access=\"") + strlen(label);
-               }
-
-               ret = sscanf(plabel, "execute=\"%s", label);
-               if (ret > 0) {
-                       LOGINFO(", exec: \"%s", label);
-                       set_label(pathname, label, SMACK_LABEL_EXEC);
-                       plabel = plabel + sizeof(" execute=\"") + strlen(label);
-               }
-
-               ret = sscanf(plabel, "mmap=\"%s", label);
-               if (ret > 0) {
-                       LOGINFO(", mmap: \"%s", label);
-                       set_label(pathname, label, SMACK_LABEL_MMAP);
-                       plabel = plabel + sizeof(" mmap=\"") + strlen(label);
-               }
-
-               ret = sscanf(plabel, "transmute=\"%s", label);
-               if (ret > 0) {
-                       LOGINFO(", transmute: \"%s", label);
-                       strncpy(label, "1\"", SMACK_LABEL_LEN);
-                       set_label(pathname, label, SMACK_LABEL_TRANSMUTE);
-               }
-               LOGINFO("\n");
-
-       }
-
-       fclose(fp);
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       if (argc < 2) {
-               print_help(argv[0]);
-               return -1;
-       }
-       if (parse_and_set(argv[1]) < 0) {
-               print_help(argv[0]);
-               return -1;
-       }
-       return 0;
-}