Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Add chmoding to the native agent
Browse files Browse the repository at this point in the history
Summary:
The native agent is used on Lollipop and below devices. Despite documentation to the contrary, it also doesn't chmod files, but instead was relying on buck doing this through adb shell commands. When the optimization in D20242616 is turned on, this no longer happens, leading to crashes.

This diff fixes the crashes by adding chmod() calls into the native agent.

Reviewed By: IanChilds

shipit-source-id: 6cd75318a5df9d30f80daf6a171017ad9f1f9e4c
  • Loading branch information
brianduff authored and facebook-github-bot committed Mar 10, 2020
1 parent 6a74817 commit 5094f40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions android/com/facebook/buck/android/agent/native/receive-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <poll.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>

Expand Down Expand Up @@ -329,6 +330,12 @@ static int raw_receive_file(const char* path, int expected_size, int sock) {
goto error;
}

ret = chmod(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH );
if (ret != 0) {
perror("chmod");
goto error;
}

return 0;

error:
Expand Down
Binary file modified assets/android/agent.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/facebook/buck/android/agent/util/AgentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private AgentUtil() {}

// These must match the values in the agent manifest.
public static final String AGENT_PACKAGE_NAME = "com.facebook.buck.android.agent";
public static final String AGENT_VERSION_CODE = "10";
public static final String AGENT_VERSION_CODE = "11";

/** Size in bytes of the binary data use to generate the secret key for receive-file. */
public static final int BINARY_SECRET_KEY_SIZE = 16;
Expand Down

0 comments on commit 5094f40

Please sign in to comment.