Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 1 | // Copyright (C) 2016 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #define LOG_TAG "sdcard" |
| 16 | |
| 17 | #include <dirent.h> |
| 18 | #include <errno.h> |
| 19 | #include <fcntl.h> |
| 20 | #include <linux/fuse.h> |
| 21 | #include <pthread.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | #include <sys/inotify.h> |
| 25 | #include <sys/mount.h> |
| 26 | #include <sys/resource.h> |
| 27 | #include <sys/stat.h> |
| 28 | #include <sys/types.h> |
| 29 | #include <unistd.h> |
| 30 | |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 31 | #include <android-base/logging.h> |
Jorge Lucangeli Obes | bae15b4 | 2016-07-18 13:46:42 -0400 | [diff] [blame] | 32 | #include <android-base/macros.h> |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 33 | |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 34 | #include <cutils/fs.h> |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 35 | #include <cutils/multiuser.h> |
| 36 | #include <packagelistparser/packagelistparser.h> |
| 37 | |
Jorge Lucangeli Obes | c96f53e | 2016-07-14 14:50:14 -0400 | [diff] [blame] | 38 | #include <libminijail.h> |
| 39 | #include <scoped_minijail.h> |
| 40 | |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 41 | #include <private/android_filesystem_config.h> |
| 42 | |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 43 | // README |
| 44 | // |
| 45 | // What is this? |
| 46 | // |
| 47 | // sdcard is a program that uses FUSE to emulate FAT-on-sdcard style |
| 48 | // directory permissions (all files are given fixed owner, group, and |
| 49 | // permissions at creation, owner, group, and permissions are not |
| 50 | // changeable, symlinks and hardlinks are not createable, etc. |
| 51 | // |
| 52 | // See usage() for command line options. |
| 53 | // |
| 54 | // It must be run as root, but will drop to requested UID/GID as soon as it |
| 55 | // mounts a filesystem. It will refuse to run if requested UID/GID are zero. |
| 56 | // |
| 57 | // Things I believe to be true: |
| 58 | // |
| 59 | // - ops that return a fuse_entry (LOOKUP, MKNOD, MKDIR, LINK, SYMLINK, |
| 60 | // CREAT) must bump that node's refcount |
| 61 | // - don't forget that FORGET can forget multiple references (req->nlookup) |
| 62 | // - if an op that returns a fuse_entry fails writing the reply to the |
| 63 | // kernel, you must rollback the refcount to reflect the reference the |
| 64 | // kernel did not actually acquire |
| 65 | // |
| 66 | // This daemon can also derive custom filesystem permissions based on directory |
| 67 | // structure when requested. These custom permissions support several features: |
| 68 | // |
| 69 | // - Apps can access their own files in /Android/data/com.example/ without |
| 70 | // requiring any additional GIDs. |
| 71 | // - Separate permissions for protecting directories like Pictures and Music. |
| 72 | // - Multi-user separation on the same physical device. |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 73 | |
| 74 | #include "fuse.h" |
| 75 | |
| 76 | /* Supplementary groups to execute with. */ |
| 77 | static const gid_t kGroups[1] = { AID_PACKAGE_INFO }; |
| 78 | |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 79 | static bool package_parse_callback(pkg_info *info, void *userdata) { |
| 80 | struct fuse_global *global = (struct fuse_global *)userdata; |
Jorge Lucangeli Obes | d6d8faa | 2016-07-19 12:10:26 -0400 | [diff] [blame] | 81 | bool res = global->package_to_appid->emplace(info->name, info->uid).second; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 82 | packagelist_free(info); |
Jorge Lucangeli Obes | d6d8faa | 2016-07-19 12:10:26 -0400 | [diff] [blame] | 83 | return res; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static bool read_package_list(struct fuse_global* global) { |
| 87 | pthread_mutex_lock(&global->lock); |
| 88 | |
Jorge Lucangeli Obes | d6d8faa | 2016-07-19 12:10:26 -0400 | [diff] [blame] | 89 | global->package_to_appid->clear(); |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 90 | bool rc = packagelist_parse(package_parse_callback, global); |
Jorge Lucangeli Obes | e157b25 | 2016-07-26 15:22:31 -0400 | [diff] [blame] | 91 | DLOG(INFO) << "read_package_list: found " << global->package_to_appid->size() << " packages"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 92 | |
Jorge Lucangeli Obes | d6d8faa | 2016-07-19 12:10:26 -0400 | [diff] [blame] | 93 | // Regenerate ownership details using newly loaded mapping. |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 94 | derive_permissions_recursive_locked(global->fuse_default, &global->root); |
| 95 | |
| 96 | pthread_mutex_unlock(&global->lock); |
| 97 | |
| 98 | return rc; |
| 99 | } |
| 100 | |
| 101 | static void watch_package_list(struct fuse_global* global) { |
| 102 | struct inotify_event *event; |
| 103 | char event_buf[512]; |
| 104 | |
| 105 | int nfd = inotify_init(); |
| 106 | if (nfd < 0) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 107 | PLOG(ERROR) << "inotify_init failed"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 108 | return; |
| 109 | } |
| 110 | |
| 111 | bool active = false; |
| 112 | while (1) { |
| 113 | if (!active) { |
| 114 | int res = inotify_add_watch(nfd, PACKAGES_LIST_FILE, IN_DELETE_SELF); |
| 115 | if (res == -1) { |
| 116 | if (errno == ENOENT || errno == EACCES) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 117 | /* Framework may not have created the file yet, sleep and retry. */ |
| 118 | LOG(ERROR) << "missing \"" << PACKAGES_LIST_FILE << "\"; retrying..."; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 119 | sleep(3); |
| 120 | continue; |
| 121 | } else { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 122 | PLOG(ERROR) << "inotify_add_watch failed"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 123 | return; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /* Watch above will tell us about any future changes, so |
| 128 | * read the current state. */ |
| 129 | if (read_package_list(global) == false) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 130 | LOG(ERROR) << "read_package_list failed"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 131 | return; |
| 132 | } |
| 133 | active = true; |
| 134 | } |
| 135 | |
| 136 | int event_pos = 0; |
| 137 | int res = read(nfd, event_buf, sizeof(event_buf)); |
| 138 | if (res < (int) sizeof(*event)) { |
| 139 | if (errno == EINTR) |
| 140 | continue; |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 141 | PLOG(ERROR) << "failed to read inotify event"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 142 | return; |
| 143 | } |
| 144 | |
| 145 | while (res >= (int) sizeof(*event)) { |
| 146 | int event_size; |
| 147 | event = (struct inotify_event *) (event_buf + event_pos); |
| 148 | |
Jorge Lucangeli Obes | e157b25 | 2016-07-26 15:22:31 -0400 | [diff] [blame] | 149 | DLOG(INFO) << "inotify event: " << std::hex << event->mask << std::dec; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 150 | if ((event->mask & IN_IGNORED) == IN_IGNORED) { |
| 151 | /* Previously watched file was deleted, probably due to move |
| 152 | * that swapped in new data; re-arm the watch and read. */ |
| 153 | active = false; |
| 154 | } |
| 155 | |
| 156 | event_size = sizeof(*event) + event->len; |
| 157 | res -= event_size; |
| 158 | event_pos += event_size; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static int fuse_setup(struct fuse* fuse, gid_t gid, mode_t mask) { |
| 164 | char opts[256]; |
| 165 | |
| 166 | fuse->fd = open("/dev/fuse", O_RDWR); |
| 167 | if (fuse->fd == -1) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 168 | PLOG(ERROR) << "failed to open fuse device"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 169 | return -1; |
| 170 | } |
| 171 | |
| 172 | umount2(fuse->dest_path, MNT_DETACH); |
| 173 | |
| 174 | snprintf(opts, sizeof(opts), |
| 175 | "fd=%i,rootmode=40000,default_permissions,allow_other,user_id=%d,group_id=%d", |
| 176 | fuse->fd, fuse->global->uid, fuse->global->gid); |
| 177 | if (mount("/dev/fuse", fuse->dest_path, "fuse", MS_NOSUID | MS_NODEV | MS_NOEXEC | |
| 178 | MS_NOATIME, opts) != 0) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 179 | PLOG(ERROR) << "failed to mount fuse filesystem"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 180 | return -1; |
| 181 | } |
| 182 | |
| 183 | fuse->gid = gid; |
| 184 | fuse->mask = mask; |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
Jorge Lucangeli Obes | c96f53e | 2016-07-14 14:50:14 -0400 | [diff] [blame] | 189 | static void drop_privs(uid_t uid, gid_t gid) { |
| 190 | ScopedMinijail j(minijail_new()); |
Jorge Lucangeli Obes | bae15b4 | 2016-07-18 13:46:42 -0400 | [diff] [blame] | 191 | minijail_set_supplementary_gids(j.get(), arraysize(kGroups), kGroups); |
Jorge Lucangeli Obes | c96f53e | 2016-07-14 14:50:14 -0400 | [diff] [blame] | 192 | minijail_change_gid(j.get(), gid); |
| 193 | minijail_change_uid(j.get(), uid); |
| 194 | /* minijail_enter() will abort if priv-dropping fails. */ |
| 195 | minijail_enter(j.get()); |
| 196 | } |
| 197 | |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 198 | static void* start_handler(void* data) { |
| 199 | struct fuse_handler* handler = static_cast<fuse_handler*>(data); |
| 200 | handle_fuse_requests(handler); |
| 201 | return NULL; |
| 202 | } |
| 203 | |
| 204 | static void run(const char* source_path, const char* label, uid_t uid, |
| 205 | gid_t gid, userid_t userid, bool multi_user, bool full_write) { |
| 206 | struct fuse_global global; |
| 207 | struct fuse fuse_default; |
| 208 | struct fuse fuse_read; |
| 209 | struct fuse fuse_write; |
| 210 | struct fuse_handler handler_default; |
| 211 | struct fuse_handler handler_read; |
| 212 | struct fuse_handler handler_write; |
| 213 | pthread_t thread_default; |
| 214 | pthread_t thread_read; |
| 215 | pthread_t thread_write; |
| 216 | |
| 217 | memset(&global, 0, sizeof(global)); |
| 218 | memset(&fuse_default, 0, sizeof(fuse_default)); |
| 219 | memset(&fuse_read, 0, sizeof(fuse_read)); |
| 220 | memset(&fuse_write, 0, sizeof(fuse_write)); |
| 221 | memset(&handler_default, 0, sizeof(handler_default)); |
| 222 | memset(&handler_read, 0, sizeof(handler_read)); |
| 223 | memset(&handler_write, 0, sizeof(handler_write)); |
| 224 | |
| 225 | pthread_mutex_init(&global.lock, NULL); |
Jorge Lucangeli Obes | d6d8faa | 2016-07-19 12:10:26 -0400 | [diff] [blame] | 226 | global.package_to_appid = new AppIdMap; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 227 | global.uid = uid; |
| 228 | global.gid = gid; |
| 229 | global.multi_user = multi_user; |
| 230 | global.next_generation = 0; |
| 231 | global.inode_ctr = 1; |
| 232 | |
| 233 | memset(&global.root, 0, sizeof(global.root)); |
| 234 | global.root.nid = FUSE_ROOT_ID; /* 1 */ |
| 235 | global.root.refcount = 2; |
| 236 | global.root.namelen = strlen(source_path); |
| 237 | global.root.name = strdup(source_path); |
| 238 | global.root.userid = userid; |
| 239 | global.root.uid = AID_ROOT; |
| 240 | global.root.under_android = false; |
| 241 | |
| 242 | strcpy(global.source_path, source_path); |
| 243 | |
| 244 | if (multi_user) { |
| 245 | global.root.perm = PERM_PRE_ROOT; |
| 246 | snprintf(global.obb_path, sizeof(global.obb_path), "%s/obb", source_path); |
| 247 | } else { |
| 248 | global.root.perm = PERM_ROOT; |
| 249 | snprintf(global.obb_path, sizeof(global.obb_path), "%s/Android/obb", source_path); |
| 250 | } |
| 251 | |
| 252 | fuse_default.global = &global; |
| 253 | fuse_read.global = &global; |
| 254 | fuse_write.global = &global; |
| 255 | |
| 256 | global.fuse_default = &fuse_default; |
| 257 | global.fuse_read = &fuse_read; |
| 258 | global.fuse_write = &fuse_write; |
| 259 | |
| 260 | snprintf(fuse_default.dest_path, PATH_MAX, "/mnt/runtime/default/%s", label); |
| 261 | snprintf(fuse_read.dest_path, PATH_MAX, "/mnt/runtime/read/%s", label); |
| 262 | snprintf(fuse_write.dest_path, PATH_MAX, "/mnt/runtime/write/%s", label); |
| 263 | |
| 264 | handler_default.fuse = &fuse_default; |
| 265 | handler_read.fuse = &fuse_read; |
| 266 | handler_write.fuse = &fuse_write; |
| 267 | |
| 268 | handler_default.token = 0; |
| 269 | handler_read.token = 1; |
| 270 | handler_write.token = 2; |
| 271 | |
| 272 | umask(0); |
| 273 | |
| 274 | if (multi_user) { |
| 275 | /* Multi-user storage is fully isolated per user, so "other" |
| 276 | * permissions are completely masked off. */ |
| 277 | if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006) |
| 278 | || fuse_setup(&fuse_read, AID_EVERYBODY, 0027) |
| 279 | || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0027)) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 280 | PLOG(FATAL) << "failed to fuse_setup"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 281 | } |
| 282 | } else { |
| 283 | /* Physical storage is readable by all users on device, but |
| 284 | * the Android directories are masked off to a single user |
| 285 | * deep inside attr_from_stat(). */ |
| 286 | if (fuse_setup(&fuse_default, AID_SDCARD_RW, 0006) |
| 287 | || fuse_setup(&fuse_read, AID_EVERYBODY, full_write ? 0027 : 0022) |
| 288 | || fuse_setup(&fuse_write, AID_EVERYBODY, full_write ? 0007 : 0022)) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 289 | PLOG(FATAL) << "failed to fuse_setup"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
Jorge Lucangeli Obes | c96f53e | 2016-07-14 14:50:14 -0400 | [diff] [blame] | 293 | // Will abort if priv-dropping fails. |
| 294 | drop_privs(uid, gid); |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 295 | |
| 296 | if (multi_user) { |
| 297 | fs_prepare_dir(global.obb_path, 0775, uid, gid); |
| 298 | } |
| 299 | |
| 300 | if (pthread_create(&thread_default, NULL, start_handler, &handler_default) |
| 301 | || pthread_create(&thread_read, NULL, start_handler, &handler_read) |
| 302 | || pthread_create(&thread_write, NULL, start_handler, &handler_write)) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 303 | LOG(FATAL) << "failed to pthread_create"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | watch_package_list(&global); |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 307 | LOG(FATAL) << "terminated prematurely"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | static int usage() { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 311 | LOG(ERROR) << "usage: sdcard [OPTIONS] <source_path> <label>" |
| 312 | << " -u: specify UID to run as" |
| 313 | << " -g: specify GID to run as" |
| 314 | << " -U: specify user ID that owns device" |
| 315 | << " -m: source_path is multi-user" |
| 316 | << " -w: runtime write mount has full write access"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 317 | return 1; |
| 318 | } |
| 319 | |
| 320 | int main(int argc, char **argv) { |
| 321 | const char *source_path = NULL; |
| 322 | const char *label = NULL; |
| 323 | uid_t uid = 0; |
| 324 | gid_t gid = 0; |
| 325 | userid_t userid = 0; |
| 326 | bool multi_user = false; |
| 327 | bool full_write = false; |
| 328 | int i; |
| 329 | struct rlimit rlim; |
| 330 | int fs_version; |
| 331 | |
| 332 | int opt; |
| 333 | while ((opt = getopt(argc, argv, "u:g:U:mw")) != -1) { |
| 334 | switch (opt) { |
| 335 | case 'u': |
| 336 | uid = strtoul(optarg, NULL, 10); |
| 337 | break; |
| 338 | case 'g': |
| 339 | gid = strtoul(optarg, NULL, 10); |
| 340 | break; |
| 341 | case 'U': |
| 342 | userid = strtoul(optarg, NULL, 10); |
| 343 | break; |
| 344 | case 'm': |
| 345 | multi_user = true; |
| 346 | break; |
| 347 | case 'w': |
| 348 | full_write = true; |
| 349 | break; |
| 350 | case '?': |
| 351 | default: |
| 352 | return usage(); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | for (i = optind; i < argc; i++) { |
| 357 | char* arg = argv[i]; |
| 358 | if (!source_path) { |
| 359 | source_path = arg; |
| 360 | } else if (!label) { |
| 361 | label = arg; |
| 362 | } else { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 363 | LOG(ERROR) << "too many arguments"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 364 | return usage(); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | if (!source_path) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 369 | LOG(ERROR) << "no source path specified"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 370 | return usage(); |
| 371 | } |
| 372 | if (!label) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 373 | LOG(ERROR) << "no label specified"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 374 | return usage(); |
| 375 | } |
| 376 | if (!uid || !gid) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 377 | LOG(ERROR) << "uid and gid must be nonzero"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 378 | return usage(); |
| 379 | } |
| 380 | |
| 381 | rlim.rlim_cur = 8192; |
| 382 | rlim.rlim_max = 8192; |
| 383 | if (setrlimit(RLIMIT_NOFILE, &rlim)) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 384 | PLOG(ERROR) << "setting RLIMIT_NOFILE failed"; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | while ((fs_read_atomic_int("/data/.layout_version", &fs_version) == -1) || (fs_version < 3)) { |
Jorge Lucangeli Obes | c9e1710 | 2016-07-12 17:05:32 -0400 | [diff] [blame] | 388 | LOG(ERROR) << "installd fs upgrade not yet complete; waiting..."; |
Jorge Lucangeli Obes | c255f25 | 2016-07-12 15:13:05 -0400 | [diff] [blame] | 389 | sleep(1); |
| 390 | } |
| 391 | |
| 392 | run(source_path, label, uid, gid, userid, multi_user, full_write); |
| 393 | return 1; |
| 394 | } |