From: Sungbae Yoo Date: Thu, 22 Sep 2016 02:49:34 +0000 (+0900) Subject: Add to wait for lazymount when user is krate X-Git-Tag: accepted/tizen/3.0/common/20161114.110006~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F89061%2F2;p=platform%2Fcore%2Fsecurity%2Fkrate.git Add to wait for lazymount when user is krate Signed-off-by: Sungbae Yoo Change-Id: If8427749f902ad78088644772cc3c26e5ff8a444 --- diff --git a/module/krate.cpp b/module/krate.cpp index ff21670..b81a901 100644 --- a/module/krate.cpp +++ b/module/krate.cpp @@ -14,6 +14,7 @@ * limitations under the License */ +#include #include #include #include @@ -31,7 +32,11 @@ #include #include +#define KRATE_UID_MIN 60001 +#define KRATE_UID_MAX 60100 + #define LAZYMOUNT_EXTERN extern +#define LAZYMOUNT_LIB "/usr/lib/liblazymount.so.0" std::string buildKrateManifestPath(const std::string& name) { @@ -49,6 +54,45 @@ std::string getKrateName(pam_handle_t* handle) return static_cast(retItem); } +static int wait_condition(void) +{ + int r; + void *h; + + int (*wait_mount_user)(void); + + r = access(LAZYMOUNT_LIB,F_OK); + if (r < 0){ + fprintf(stderr, "cannot find lazymount module - No support lazymount\n"); + return 0; + } + + h = dlopen(LAZYMOUNT_LIB, RTLD_LAZY); + if (!h) { + fprintf(stderr, "lazymount module dlopen error\n"); + return -1; + } + + do{ + wait_mount_user = (int (*)())dlsym(h,"wait_mount_user"); + if (!wait_mount_user) { + fprintf(stderr, "dlsym wait_mount_user error\n"); + dlclose(h); + return -1; + } + } while (0); + + r = wait_mount_user(); + if (r < 0) { + fprintf(stderr, "wait_mout_user failed\n"); + dlclose(h); + return r; + } + + dlclose(h); + return 0; +} + extern "C" { LAZYMOUNT_EXTERN __attribute__((visibility("default"))) int container_preprocess(char* id) { @@ -63,6 +107,10 @@ int container_preprocess(char* id) { builder.unshareNamespace(); }; createSession(user, sessionBuilder); + + if (user.getUid() >= KRATE_UID_MIN && user.getUid() <= KRATE_UID_MAX ) { + wait_condition(); + } } catch (runtime::Exception& e) { std::cerr << "krate error : " << e.what() <