Browse Source

Revert "updater: Remove some obsoleted functions for file-based OTA."

This reverts commit 63d786cf22.

These functions will be used for third party OTA zips, so keep them.

Change-Id: I24b67ba4c86f8f86d0a41429a395fece1a383efd
Tom Marshall 3 years ago
parent
commit
0b32177caa
2 changed files with 474 additions and 0 deletions
  1. 113
    0
      tests/component/updater_test.cpp
  2. 361
    0
      updater/install.cpp

+ 113
- 0
tests/component/updater_test.cpp View File

@@ -255,6 +255,119 @@ TEST_F(UpdaterTest, file_getprop) {
255 255
     expect("", script6.c_str(), kNoCause);
256 256
 }
257 257
 
258
+TEST_F(UpdaterTest, delete) {
259
+    // Delete none.
260
+    expect("0", "delete()", kNoCause);
261
+    expect("0", "delete(\"/doesntexist\")", kNoCause);
262
+    expect("0", "delete(\"/doesntexist1\", \"/doesntexist2\")", kNoCause);
263
+    expect("0", "delete(\"/doesntexist1\", \"/doesntexist2\", \"/doesntexist3\")", kNoCause);
264
+
265
+    // Delete one file.
266
+    TemporaryFile temp_file1;
267
+    ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file1.path));
268
+    std::string script1("delete(\"" + std::string(temp_file1.path) + "\")");
269
+    expect("1", script1.c_str(), kNoCause);
270
+
271
+    // Delete two files.
272
+    TemporaryFile temp_file2;
273
+    ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file2.path));
274
+    TemporaryFile temp_file3;
275
+    ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file3.path));
276
+    std::string script2("delete(\"" + std::string(temp_file2.path) + "\", \"" +
277
+                        std::string(temp_file3.path) + "\")");
278
+    expect("2", script2.c_str(), kNoCause);
279
+
280
+    // Delete already deleted files.
281
+    expect("0", script2.c_str(), kNoCause);
282
+
283
+    // Delete one out of three.
284
+    TemporaryFile temp_file4;
285
+    ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file4.path));
286
+    std::string script3("delete(\"/doesntexist1\", \"" + std::string(temp_file4.path) +
287
+                        "\", \"/doesntexist2\")");
288
+    expect("1", script3.c_str(), kNoCause);
289
+}
290
+
291
+TEST_F(UpdaterTest, rename) {
292
+    // rename() expects two arguments.
293
+    expect(nullptr, "rename()", kArgsParsingFailure);
294
+    expect(nullptr, "rename(\"arg1\")", kArgsParsingFailure);
295
+    expect(nullptr, "rename(\"arg1\", \"arg2\", \"arg3\")", kArgsParsingFailure);
296
+
297
+    // src_name or dst_name cannot be empty.
298
+    expect(nullptr, "rename(\"\", \"arg2\")", kArgsParsingFailure);
299
+    expect(nullptr, "rename(\"arg1\", \"\")", kArgsParsingFailure);
300
+
301
+    // File doesn't exist (both of src and dst).
302
+    expect(nullptr, "rename(\"/doesntexist\", \"/doesntexisteither\")" , kFileRenameFailure);
303
+
304
+    // Can't create parent directory.
305
+    TemporaryFile temp_file1;
306
+    ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file1.path));
307
+    std::string script1("rename(\"" + std::string(temp_file1.path) + "\", \"/proc/0/file1\")");
308
+    expect(nullptr, script1.c_str(), kFileRenameFailure);
309
+
310
+    // Rename.
311
+    TemporaryFile temp_file2;
312
+    std::string script2("rename(\"" + std::string(temp_file1.path) + "\", \"" +
313
+                        std::string(temp_file2.path) + "\")");
314
+    expect(temp_file2.path, script2.c_str(), kNoCause);
315
+
316
+    // Already renamed.
317
+    expect(temp_file2.path, script2.c_str(), kNoCause);
318
+
319
+    // Parents create successfully.
320
+    TemporaryFile temp_file3;
321
+    TemporaryDir td;
322
+    std::string temp_dir(td.path);
323
+    std::string dst_file = temp_dir + "/aaa/bbb/a.txt";
324
+    std::string script3("rename(\"" + std::string(temp_file3.path) + "\", \"" + dst_file + "\")");
325
+    expect(dst_file.c_str(), script3.c_str(), kNoCause);
326
+
327
+    // Clean up the temp files under td.
328
+    ASSERT_EQ(0, unlink(dst_file.c_str()));
329
+    ASSERT_EQ(0, rmdir((temp_dir + "/aaa/bbb").c_str()));
330
+    ASSERT_EQ(0, rmdir((temp_dir + "/aaa").c_str()));
331
+}
332
+
333
+TEST_F(UpdaterTest, symlink) {
334
+    // symlink expects 1+ argument.
335
+    expect(nullptr, "symlink()", kArgsParsingFailure);
336
+
337
+    // symlink should fail if src is an empty string.
338
+    TemporaryFile temp_file1;
339
+    std::string script1("symlink(\"" + std::string(temp_file1.path) + "\", \"\")");
340
+    expect(nullptr, script1.c_str(), kSymlinkFailure);
341
+
342
+    std::string script2("symlink(\"" + std::string(temp_file1.path) + "\", \"src1\", \"\")");
343
+    expect(nullptr, script2.c_str(), kSymlinkFailure);
344
+
345
+    // symlink failed to remove old src.
346
+    std::string script3("symlink(\"" + std::string(temp_file1.path) + "\", \"/proc\")");
347
+    expect(nullptr, script3.c_str(), kSymlinkFailure);
348
+
349
+    // symlink can create symlinks.
350
+    TemporaryFile temp_file;
351
+    std::string content = "magicvalue";
352
+    ASSERT_TRUE(android::base::WriteStringToFile(content, temp_file.path));
353
+
354
+    TemporaryDir td;
355
+    std::string src1 = std::string(td.path) + "/symlink1";
356
+    std::string src2 = std::string(td.path) + "/symlink2";
357
+    std::string script4("symlink(\"" + std::string(temp_file.path) + "\", \"" +
358
+                        src1 + "\", \"" + src2 + "\")");
359
+    expect("t", script4.c_str(), kNoCause);
360
+
361
+    // Verify the created symlinks.
362
+    struct stat sb;
363
+    ASSERT_TRUE(lstat(src1.c_str(), &sb) == 0 && S_ISLNK(sb.st_mode));
364
+    ASSERT_TRUE(lstat(src2.c_str(), &sb) == 0 && S_ISLNK(sb.st_mode));
365
+
366
+    // Clean up the leftovers.
367
+    ASSERT_EQ(0, unlink(src1.c_str()));
368
+    ASSERT_EQ(0, unlink(src2.c_str()));
369
+}
370
+
258 371
 TEST_F(UpdaterTest, package_extract_dir) {
259 372
   // package_extract_dir expects 2 arguments.
260 373
   expect(nullptr, "package_extract_dir()", kArgsParsingFailure);

+ 361
- 0
updater/install.cpp View File

@@ -634,6 +634,67 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt
634 634
   return nullptr;
635 635
 }
636 636
 
637
+// rename(src_name, dst_name)
638
+//   Renames src_name to dst_name. It automatically creates the necessary directories for dst_name.
639
+//   Example: rename("system/app/Hangouts/Hangouts.apk", "system/priv-app/Hangouts/Hangouts.apk")
640
+Value* RenameFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
641
+  if (argv.size() != 2) {
642
+    return ErrorAbort(state, kArgsParsingFailure, "%s() expects 2 args, got %zu", name,
643
+                      argv.size());
644
+  }
645
+
646
+  std::vector<std::string> args;
647
+  if (!ReadArgs(state, argv, &args)) {
648
+    return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name);
649
+  }
650
+  const std::string& src_name = args[0];
651
+  const std::string& dst_name = args[1];
652
+
653
+  if (src_name.empty()) {
654
+    return ErrorAbort(state, kArgsParsingFailure, "src_name argument to %s() can't be empty", name);
655
+  }
656
+  if (dst_name.empty()) {
657
+    return ErrorAbort(state, kArgsParsingFailure, "dst_name argument to %s() can't be empty", name);
658
+  }
659
+  if (!make_parents(dst_name)) {
660
+    return ErrorAbort(state, kFileRenameFailure, "Creating parent of %s failed, error %s",
661
+                      dst_name.c_str(), strerror(errno));
662
+  } else if (access(dst_name.c_str(), F_OK) == 0 && access(src_name.c_str(), F_OK) != 0) {
663
+    // File was already moved
664
+    return StringValue(dst_name);
665
+  } else if (rename(src_name.c_str(), dst_name.c_str()) != 0) {
666
+    return ErrorAbort(state, kFileRenameFailure, "Rename of %s to %s failed, error %s",
667
+                      src_name.c_str(), dst_name.c_str(), strerror(errno));
668
+  }
669
+
670
+  return StringValue(dst_name);
671
+}
672
+
673
+// delete([filename, ...])
674
+//   Deletes all the filenames listed. Returns the number of files successfully deleted.
675
+//
676
+// delete_recursive([dirname, ...])
677
+//   Recursively deletes dirnames and all their contents. Returns the number of directories
678
+//   successfully deleted.
679
+Value* DeleteFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
680
+  std::vector<std::string> paths;
681
+  if (!ReadArgs(state, argv, &paths)) {
682
+    return nullptr;
683
+  }
684
+
685
+  bool recursive = (strcmp(name, "delete_recursive") == 0);
686
+
687
+  int success = 0;
688
+  for (const auto& path : paths) {
689
+    if ((recursive ? dirUnlinkHierarchy(path.c_str()) : unlink(path.c_str())) == 0) {
690
+      ++success;
691
+    }
692
+  }
693
+
694
+  return StringValue(std::to_string(success));
695
+}
696
+
697
+
637 698
 Value* ShowProgressFn(const char* name, State* state,
638 699
                       const std::vector<std::unique_ptr<Expr>>& argv) {
639 700
   if (argv.size() != 2) {
@@ -689,6 +750,288 @@ Value* SetProgressFn(const char* name, State* state,
689 750
   return StringValue(frac_str);
690 751
 }
691 752
 
753
+// symlink(target, [src1, src2, ...])
754
+//   Creates all sources as symlinks to target. It unlinks any previously existing src1, src2, etc
755
+//   before creating symlinks.
756
+Value* SymlinkFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
757
+  if (argv.size() == 0) {
758
+    return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1+ args, got %zu", name, argv.size());
759
+  }
760
+  std::string target;
761
+  if (!Evaluate(state, argv[0], &target)) {
762
+    return nullptr;
763
+  }
764
+
765
+  std::vector<std::string> srcs;
766
+  if (!ReadArgs(state, argv, &srcs, 1, argv.size())) {
767
+    return ErrorAbort(state, kArgsParsingFailure, "%s(): Failed to parse the argument(s)", name);
768
+  }
769
+
770
+  size_t bad = 0;
771
+  for (const auto& src : srcs) {
772
+    if (unlink(src.c_str()) == -1 && errno != ENOENT) {
773
+      PLOG(ERROR) << name << ": failed to remove " << src;
774
+      ++bad;
775
+    } else if (!make_parents(src)) {
776
+      LOG(ERROR) << name << ": failed to symlink " << src << " to " << target
777
+                 << ": making parents failed";
778
+      ++bad;
779
+    } else if (symlink(target.c_str(), src.c_str()) == -1) {
780
+      PLOG(ERROR) << name << ": failed to symlink " << src << " to " << target;
781
+      ++bad;
782
+    }
783
+  }
784
+  if (bad != 0) {
785
+    return ErrorAbort(state, kSymlinkFailure, "%s: Failed to create %zu symlink(s)", name, bad);
786
+  }
787
+  return StringValue("t");
788
+}
789
+
790
+struct perm_parsed_args {
791
+  bool has_uid;
792
+  uid_t uid;
793
+  bool has_gid;
794
+  gid_t gid;
795
+  bool has_mode;
796
+  mode_t mode;
797
+  bool has_fmode;
798
+  mode_t fmode;
799
+  bool has_dmode;
800
+  mode_t dmode;
801
+  bool has_selabel;
802
+  const char* selabel;
803
+  bool has_capabilities;
804
+  uint64_t capabilities;
805
+};
806
+
807
+static struct perm_parsed_args ParsePermArgs(State * state,
808
+                                             const std::vector<std::string>& args) {
809
+  struct perm_parsed_args parsed;
810
+  int bad = 0;
811
+  static int max_warnings = 20;
812
+
813
+  memset(&parsed, 0, sizeof(parsed));
814
+
815
+  for (size_t i = 1; i < args.size(); i += 2) {
816
+    if (args[i] == "uid") {
817
+      int64_t uid;
818
+      if (sscanf(args[i + 1].c_str(), "%" SCNd64, &uid) == 1) {
819
+        parsed.uid = uid;
820
+        parsed.has_uid = true;
821
+      } else {
822
+        uiPrintf(state, "ParsePermArgs: invalid UID \"%s\"\n", args[i + 1].c_str());
823
+        bad++;
824
+      }
825
+      continue;
826
+    }
827
+    if (args[i] == "gid") {
828
+      int64_t gid;
829
+      if (sscanf(args[i + 1].c_str(), "%" SCNd64, &gid) == 1) {
830
+        parsed.gid = gid;
831
+        parsed.has_gid = true;
832
+      } else {
833
+        uiPrintf(state, "ParsePermArgs: invalid GID \"%s\"\n", args[i + 1].c_str());
834
+        bad++;
835
+      }
836
+      continue;
837
+    }
838
+    if (args[i] == "mode") {
839
+      int32_t mode;
840
+      if (sscanf(args[i + 1].c_str(), "%" SCNi32, &mode) == 1) {
841
+        parsed.mode = mode;
842
+        parsed.has_mode = true;
843
+      } else {
844
+        uiPrintf(state, "ParsePermArgs: invalid mode \"%s\"\n", args[i + 1].c_str());
845
+        bad++;
846
+      }
847
+      continue;
848
+    }
849
+    if (args[i] == "dmode") {
850
+      int32_t mode;
851
+      if (sscanf(args[i + 1].c_str(), "%" SCNi32, &mode) == 1) {
852
+        parsed.dmode = mode;
853
+        parsed.has_dmode = true;
854
+      } else {
855
+        uiPrintf(state, "ParsePermArgs: invalid dmode \"%s\"\n", args[i + 1].c_str());
856
+        bad++;
857
+      }
858
+      continue;
859
+    }
860
+    if (args[i] == "fmode") {
861
+      int32_t mode;
862
+      if (sscanf(args[i + 1].c_str(), "%" SCNi32, &mode) == 1) {
863
+        parsed.fmode = mode;
864
+        parsed.has_fmode = true;
865
+      } else {
866
+        uiPrintf(state, "ParsePermArgs: invalid fmode \"%s\"\n", args[i + 1].c_str());
867
+        bad++;
868
+      }
869
+      continue;
870
+    }
871
+    if (args[i] == "capabilities") {
872
+      int64_t capabilities;
873
+      if (sscanf(args[i + 1].c_str(), "%" SCNi64, &capabilities) == 1) {
874
+        parsed.capabilities = capabilities;
875
+        parsed.has_capabilities = true;
876
+      } else {
877
+        uiPrintf(state, "ParsePermArgs: invalid capabilities \"%s\"\n", args[i + 1].c_str());
878
+        bad++;
879
+      }
880
+      continue;
881
+    }
882
+    if (args[i] == "selabel") {
883
+      if (!args[i + 1].empty()) {
884
+        parsed.selabel = args[i + 1].c_str();
885
+        parsed.has_selabel = true;
886
+      } else {
887
+        uiPrintf(state, "ParsePermArgs: invalid selabel \"%s\"\n", args[i + 1].c_str());
888
+        bad++;
889
+      }
890
+      continue;
891
+    }
892
+    if (max_warnings != 0) {
893
+      printf("ParsedPermArgs: unknown key \"%s\", ignoring\n", args[i].c_str());
894
+      max_warnings--;
895
+      if (max_warnings == 0) {
896
+        LOG(INFO) << "ParsedPermArgs: suppressing further warnings";
897
+      }
898
+    }
899
+  }
900
+  return parsed;
901
+}
902
+
903
+static int ApplyParsedPerms(State* state, const char* filename, const struct stat* statptr,
904
+                            struct perm_parsed_args parsed) {
905
+  int bad = 0;
906
+
907
+  if (parsed.has_selabel) {
908
+    if (lsetfilecon(filename, parsed.selabel) != 0) {
909
+      uiPrintf(state, "ApplyParsedPerms: lsetfilecon of %s to %s failed: %s\n", filename,
910
+               parsed.selabel, strerror(errno));
911
+      bad++;
912
+    }
913
+  }
914
+
915
+  /* ignore symlinks */
916
+  if (S_ISLNK(statptr->st_mode)) {
917
+    return bad;
918
+  }
919
+
920
+  if (parsed.has_uid) {
921
+    if (chown(filename, parsed.uid, -1) < 0) {
922
+      uiPrintf(state, "ApplyParsedPerms: chown of %s to %d failed: %s\n", filename, parsed.uid,
923
+               strerror(errno));
924
+      bad++;
925
+    }
926
+  }
927
+
928
+  if (parsed.has_gid) {
929
+    if (chown(filename, -1, parsed.gid) < 0) {
930
+      uiPrintf(state, "ApplyParsedPerms: chgrp of %s to %d failed: %s\n", filename, parsed.gid,
931
+               strerror(errno));
932
+      bad++;
933
+    }
934
+  }
935
+
936
+  if (parsed.has_mode) {
937
+    if (chmod(filename, parsed.mode) < 0) {
938
+      uiPrintf(state, "ApplyParsedPerms: chmod of %s to %d failed: %s\n", filename, parsed.mode,
939
+               strerror(errno));
940
+      bad++;
941
+    }
942
+  }
943
+
944
+  if (parsed.has_dmode && S_ISDIR(statptr->st_mode)) {
945
+    if (chmod(filename, parsed.dmode) < 0) {
946
+      uiPrintf(state, "ApplyParsedPerms: chmod of %s to %d failed: %s\n", filename, parsed.dmode,
947
+               strerror(errno));
948
+      bad++;
949
+    }
950
+  }
951
+
952
+  if (parsed.has_fmode && S_ISREG(statptr->st_mode)) {
953
+    if (chmod(filename, parsed.fmode) < 0) {
954
+      uiPrintf(state, "ApplyParsedPerms: chmod of %s to %d failed: %s\n", filename, parsed.fmode,
955
+               strerror(errno));
956
+      bad++;
957
+    }
958
+  }
959
+
960
+  if (parsed.has_capabilities && S_ISREG(statptr->st_mode)) {
961
+    if (parsed.capabilities == 0) {
962
+      if ((removexattr(filename, XATTR_NAME_CAPS) == -1) && (errno != ENODATA)) {
963
+        // Report failure unless it's ENODATA (attribute not set)
964
+        uiPrintf(state, "ApplyParsedPerms: removexattr of %s to %" PRIx64 " failed: %s\n", filename,
965
+                 parsed.capabilities, strerror(errno));
966
+        bad++;
967
+      }
968
+    } else {
969
+      struct vfs_cap_data cap_data;
970
+      memset(&cap_data, 0, sizeof(cap_data));
971
+      cap_data.magic_etc = VFS_CAP_REVISION | VFS_CAP_FLAGS_EFFECTIVE;
972
+      cap_data.data[0].permitted = (uint32_t)(parsed.capabilities & 0xffffffff);
973
+      cap_data.data[0].inheritable = 0;
974
+      cap_data.data[1].permitted = (uint32_t)(parsed.capabilities >> 32);
975
+      cap_data.data[1].inheritable = 0;
976
+      if (setxattr(filename, XATTR_NAME_CAPS, &cap_data, sizeof(cap_data), 0) < 0) {
977
+        uiPrintf(state, "ApplyParsedPerms: setcap of %s to %" PRIx64 " failed: %s\n", filename,
978
+                 parsed.capabilities, strerror(errno));
979
+        bad++;
980
+      }
981
+    }
982
+  }
983
+
984
+  return bad;
985
+}
986
+
987
+// nftw doesn't allow us to pass along context, so we need to use
988
+// global variables.  *sigh*
989
+static struct perm_parsed_args recursive_parsed_args;
990
+static State* recursive_state;
991
+
992
+static int do_SetMetadataRecursive(const char* filename, const struct stat* statptr, int /*fileflags*/,
993
+                                   struct FTW* /*pfwt*/) {
994
+  return ApplyParsedPerms(recursive_state, filename, statptr, recursive_parsed_args);
995
+}
996
+
997
+static Value* SetMetadataFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
998
+  if ((argv.size() % 2) != 1) {
999
+    return ErrorAbort(state, kArgsParsingFailure, "%s() expects an odd number of arguments, got %zu",
1000
+                      name, argv.size());
1001
+  }
1002
+
1003
+  std::vector<std::string> args;
1004
+  if (!ReadArgs(state, argv, &args)) {
1005
+    return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name);
1006
+  }
1007
+
1008
+  struct stat sb;
1009
+  if (lstat(args[0].c_str(), &sb) == -1) {
1010
+    return ErrorAbort(state, kSetMetadataFailure, "%s: Error on lstat of \"%s\": %s", name,
1011
+                      args[0].c_str(), strerror(errno));
1012
+  }
1013
+
1014
+  struct perm_parsed_args parsed = ParsePermArgs(state, args);
1015
+  int bad = 0;
1016
+  bool recursive = (strcmp(name, "set_metadata_recursive") == 0);
1017
+
1018
+  if (recursive) {
1019
+    recursive_parsed_args = parsed;
1020
+    recursive_state = state;
1021
+    bad += nftw(args[0].c_str(), do_SetMetadataRecursive, 30, FTW_CHDIR | FTW_DEPTH | FTW_PHYS);
1022
+    memset(&recursive_parsed_args, 0, sizeof(recursive_parsed_args));
1023
+    recursive_state = NULL;
1024
+  } else {
1025
+    bad += ApplyParsedPerms(state, args[0].c_str(), &sb, parsed);
1026
+  }
1027
+
1028
+  if (bad > 0) {
1029
+    return ErrorAbort(state, kSetMetadataFailure, "%s: some changes failed", name);
1030
+  }
1031
+
1032
+  return StringValue("");
1033
+}
1034
+
692 1035
 Value* GetPropFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) {
693 1036
   if (argv.size() != 1) {
694 1037
     return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size());
@@ -1077,8 +1420,25 @@ void RegisterInstallFunctions() {
1077 1420
   RegisterFunction("format", FormatFn);
1078 1421
   RegisterFunction("show_progress", ShowProgressFn);
1079 1422
   RegisterFunction("set_progress", SetProgressFn);
1423
+  RegisterFunction("delete", DeleteFn);
1424
+  RegisterFunction("delete_recursive", DeleteFn);
1080 1425
   RegisterFunction("package_extract_dir", PackageExtractDirFn);
1081 1426
   RegisterFunction("package_extract_file", PackageExtractFileFn);
1427
+  RegisterFunction("symlink", SymlinkFn);
1428
+
1429
+  // Usage:
1430
+  //   set_metadata("filename", "key1", "value1", "key2", "value2", ...)
1431
+  // Example:
1432
+  //   set_metadata("/system/bin/netcfg", "uid", 0, "gid", 3003, "mode", 02750, "selabel",
1433
+  //                "u:object_r:system_file:s0", "capabilities", 0x0);
1434
+  RegisterFunction("set_metadata", SetMetadataFn);
1435
+
1436
+  // Usage:
1437
+  //   set_metadata_recursive("dirname", "key1", "value1", "key2", "value2", ...)
1438
+  // Example:
1439
+  //   set_metadata_recursive("/system", "uid", 0, "gid", 0, "fmode", 0644, "dmode", 0755,
1440
+  //                          "selabel", "u:object_r:system_file:s0", "capabilities", 0x0);
1441
+  RegisterFunction("set_metadata_recursive", SetMetadataFn);
1082 1442
 
1083 1443
   RegisterFunction("getprop", GetPropFn);
1084 1444
   RegisterFunction("file_getprop", FileGetPropFn);
@@ -1091,6 +1451,7 @@ void RegisterInstallFunctions() {
1091 1451
 
1092 1452
   RegisterFunction("read_file", ReadFileFn);
1093 1453
   RegisterFunction("sha1_check", Sha1CheckFn);
1454
+  RegisterFunction("rename", RenameFn);
1094 1455
   RegisterFunction("write_value", WriteValueFn);
1095 1456
 
1096 1457
   RegisterFunction("wipe_cache", WipeCacheFn);