Remove bind-user-contents.service 28/188528/2 accepted/tizen_5.0_unified tizen_5.0 accepted/tizen/5.0/unified/20181102.020500 accepted/tizen/unified/20180906.054623 submit/tizen/20180905.233241 submit/tizen_5.0/20181101.000004
authorINSUN PYO <insun.pyo@samsung.com>
Wed, 5 Sep 2018 23:25:31 +0000 (08:25 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Wed, 5 Sep 2018 23:28:15 +0000 (08:28 +0900)
bind-user-contents.service moved to system-plugin-featuer-session-bind package.

Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I1101b985d622f16430a3ff8947daf11c1a3b0da2

packaging/session-utils.spec
src/systemd-user-helper/systemd-user-helper.c
units/bind-user-contents.service [deleted file]

index 078c028ec1ae90f03513da18867a0082813d65f4..82c35e56a1c345463b6baaf46659a00ea618b59b 100644 (file)
@@ -29,8 +29,6 @@ rm -rf %{buildroot}
 %make_install
 
 mkdir -p %{buildroot}%{_userunitdir}/basic.target.wants
-install -m 644 units/bind-user-contents.service %{buildroot}%{_userunitdir}/
-ln -sf ../bind-user-contents.service %{buildroot}%{_userunitdir}/basic.target.wants/bind-user-contents.service
 install -m 644 units/container_postprocess.service %{buildroot}%{_userunitdir}/
 #ln -sf ../container_postprocess.service %{buildroot}%{_userunitdir}/basic.target.wants/container_postprocess.service
 
@@ -38,8 +36,6 @@ install -m 644 units/container_postprocess.service %{buildroot}%{_userunitdir}/
 %license LICENSE.Apache-2.0
 %manifest session-utils.manifest
 %{_bindir}/systemd-user-helper
-%{_userunitdir}/bind-user-contents.service
-%{_userunitdir}/basic.target.wants/bind-user-contents.service
 %{_userunitdir}/container_postprocess.service
 #%{_userunitdir}/basic.target.wants/container_postprocess.service
 
index 653144776c4ab279af26620f178ca25242a8fa6b..763d5c0983d8aef84ea174622dc6d60d9c4325fc 100644 (file)
 #include <dlfcn.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
-#include <limits.h>
-#include <sys/stat.h>
-
-#include <sched.h>
-#include <sys/mount.h>
-
-#include <tzplatform_config.h>
-
-#include <sys/types.h>
-#include <grp.h>
 #include <string.h>
 
-#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
-#define PIDFILE_PATH ".systemd.pid"
 
-// For compatibility, Using hard-coded path
-#define LEGACY_CONTENTS_DIR "/opt/usr/media"
-#define LEGACY_APPS_DIR "/opt/usr/apps"
-
-#define LAZYMOUNT_LIB LIBDIR"/liblazymount.so.0"
 #define CONTAINER_LIB LIBDIR"/security/pam_krate.so"
 
 #define LOAD_SYMBOL(handle, sym, name) \
                } \
        } while (0);
 
-#define MOUNT_SIZE  "10000k"
-#define MAX_GRP_BUF_SIZE (1024 * 4)
-#define GRP_NAME_SYSTEM_SHARE    "system_share"
-
-static void *container_handle = NULL;
-
-static const char *systemd_arg[] = {
-       "/usr/lib/systemd/systemd",
-       "--user",
-       NULL
-};
-
-static int stop_process(char *username)
-{
-       int r;
-
-       r = umount2(tzplatform_getenv(TZ_USER_CONTENT), MNT_DETACH);
-       if (r < 0) {
-               fprintf(stderr, "Warning : Failed to umount user content\n");
-       }
-
-       r = umount2(tzplatform_getenv(TZ_USER_APP), MNT_DETACH);
-       if (r < 0) {
-               fprintf(stderr, "Warning : Failed to umount application content\n");
-       }
-       return 0;
-}
 
-static int normal_user_postprocess(char *username)
+static int container_postprocess(char *username)
 {
        int r;
-       r = mount(tzplatform_getenv(TZ_USER_CONTENT),
-                       LEGACY_CONTENTS_DIR, NULL, MS_BIND, NULL);
-       if (r < 0) {
-               fprintf(stderr, "user content bind mount failed - %d\n", errno);
-               return r;
-       }
-
-       r = mount(tzplatform_getenv(TZ_USER_APP),
-                       LEGACY_APPS_DIR, NULL, MS_BIND, NULL);
-       if (r < 0) {
-               fprintf(stderr, "user app bind mount failed - %d\n", errno);
-               return r;
-       }
-
-       return 0;
-}
+       static void *container_handle;
+       int (*handle_postprocess)(char *);
 
-static int container_open(void)
-{
-       if (container_handle)
+       /* not support container */
+       if (access(CONTAINER_LIB, F_OK))
                return 0;
 
        container_handle = dlopen(CONTAINER_LIB, RTLD_LAZY);
@@ -120,41 +58,6 @@ static int container_open(void)
                fprintf(stderr, "container module dlopen error\n");
                return -1;
        }
-       return 0;
-}
-
-static int container_preprocess(char *username)
-{
-       int r;
-       int (*handle_preprocess)(char *);
-
-       r = container_open();
-       if (r < 0)
-               return r;
-
-       LOAD_SYMBOL(container_handle, handle_preprocess, "container_preprocess");
-
-       r = handle_preprocess(username);
-       if (r < 0) {
-               fprintf(stderr, "container module preprocess error\n");
-               return r;
-       }
-
-       return 0;
-}
-
-static int container_postprocess(char *username)
-{
-       int r;
-       int (*handle_postprocess)(char *);
-
-       /* not support container */
-       if (access(CONTAINER_LIB, F_OK))
-               return 0;
-
-       r = container_open();
-       if (r < 0)
-               return r;
 
        LOAD_SYMBOL(container_handle, handle_postprocess, "container_postprocess");
 
@@ -167,84 +70,8 @@ static int container_postprocess(char *username)
        return 0;
 }
 
-static int make_pid_file(int pid, char* user_id)
-{
-       FILE *fp;
-       char pidpath[PATH_MAX];
-       int r = 0;
-
-       snprintf(pidpath, PATH_MAX, "/run/user/%s/%s", user_id, PIDFILE_PATH);
-
-       fp = fopen(pidpath, "w+");
-       if (fp != NULL) {
-               fprintf(fp, "%d", pid);
-               fclose(fp);
-       } else
-               r = -1;
-
-       return r;
-}
-
-static int change_smack_for_user_session()
-{
-       FILE *fp;
-       int r = 0;
-
-       fp = fopen("/proc/self/attr/current", "w");
-
-       if (fp == NULL) {
-               r = -errno;
-               return r;
-       }
-       r = fputs("User", fp);
-       if (r == EOF) {
-               fclose(fp);
-               r = -errno;
-               return r;
-       }
-       fclose(fp);
-
-       return 0;
-}
-
-int run_child(int argc, const char *argv[], char* user_id)
-{
-       pid_t pid;
-       int r = 0;
-       int i;
-
-       if (!argv)
-               return -EINVAL;
-
-       pid = fork();
-
-       if (pid < 0) {
-               fprintf(stderr, "failed to fork");
-               r = -errno;
-       } else if (pid == 0) {
-               r = change_smack_for_user_session();
-               if (r != 0) {
-                       fprintf(stderr, "failed to change smack\n");
-                       return r;
-               }
-
-               for (i = 0; i < _NSIG; ++i)
-                       signal(i, SIG_DFL);
-
-               r = execv(argv[0], (char **)argv);
-               /* NOT REACH */
-       } else{
-               make_pid_file(pid, user_id);
-               r = pid;
-       }
-
-       return r;
-}
-
 int main(int argc, char *argv[])
 {
-       int r = 0;
-       int support_container = 0;
        char *operation;
        char *username;
 
@@ -255,38 +82,12 @@ int main(int argc, char *argv[])
        operation = argv[1];
        username = argv[2];
 
-       if (strcmp(operation, "stop") == 0)
-               return stop_process(username);
-       else if (strcmp(operation, "start") == 0)
-               ; /* do main code */
-       else if (strcmp(operation, "bind-user-contents") == 0)
-               return normal_user_postprocess(username);
-       else if (strcmp(operation, "container_postprocess") == 0)
+       if (strcmp(operation, "container_postprocess") == 0)
                return container_postprocess(username);
        else {
                fprintf(stderr, "option is invalid(%s)\n", operation);
                return -2;
        }
 
-       /* If container supports below funcs, below line should be enabled. */
-       support_container = (access(CONTAINER_LIB, F_OK) == 0) ? 1 : 0;
-       if (support_container) {
-               r = container_preprocess(username);
-               if (r < 0) {
-                       fprintf(stderr, "container preprocess failed\n");
-                       return r;
-               }
-       }
-
-       r = run_child(ARRAY_SIZE(systemd_arg), systemd_arg, username);
-       if (r < 0) {
-               fprintf(stderr, "systemd user execution failed\n");
-               return r;
-       } else{
-               fprintf(stderr, "success = pid = %d\n", r);
-       }
-
        return 0;
 }
-
-
diff --git a/units/bind-user-contents.service b/units/bind-user-contents.service
deleted file mode 100644 (file)
index 19c21e8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Bind Mount user contents for UID %U
-DefaultDependencies=no
-Wants=wait-mount@opt-usr.service
-After=wait-mount@opt-usr.service
-Before=basic.target
-ConditionPathExists=!/usr/bin/session-bind
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/usr/bin/systemd-user-helper bind-user-contents %U