MuntashirAkon/AppManager · warning
Warning: chown failed: %s\n
Error message
Warning: chown failed: %s\n
What it means
After resolving am.jar, chown(exec_jar_path, uid, gid) failed, so the copied jar could not be given the app user's ownership. This is non-fatal — the binary prints a warning and continues, but the app process may later fail to read/execute the jar.
Source
Thrown at app/src/main/cpp/run_server.c:163
uid_t uid = getuid();
gid_t gid = getgid();
printf("Starting %s as %d:%d...\n", SERVER_NAME, uid, gid);
// Copy am.jar as /data/local/tmp/am.jar
const char *resolved_am_jar_path = NULL;
for (int i = 0; i < 4; i++) {
if (copy_file(am_jar_fallbacks[i], exec_jar_path) == 0) {
resolved_am_jar_path = am_jar_fallbacks[i];
break;
}
}
if (resolved_am_jar_path == NULL) {
fprintf(stderr, "Error! %s could not be found or copied.\n", am_jar_name);
return 1;
}
// Fix ownership
if (chown(exec_jar_path, uid, gid) != 0) {
fprintf(stderr, "Warning: chown failed: %s\n", strerror(errno));
// Although it failed, still proceed
}
// Copy main.jar as /data/local/tmp/main.jar
const char *resolved_main_jar_path = NULL;
for (int i = 0; i < 4; i++) {
if (copy_file(main_jar_fallbacks[i], main_jar_path) == 0) {
resolved_main_jar_path = main_jar_fallbacks[i];
break;
}
}
if (resolved_main_jar_path == NULL) {
fprintf(stderr, "Error! %s could not be found or copied.\n", main_jar_name);
return 1;
}
// Fix ownership
if (chown(main_jar_path, uid, gid) != 0) {
fprintf(stderr, "Warning: chown failed: %s\n", strerror(errno));View on GitHub (pinned to 0152f468fc)
Solutions
- Run the binary as root (su) so chown succeeds
- Manually verify/fix ownership with adb: chown <uid>:<gid> /data/local/tmp/am.jar
- Confirm the jar is readable by the target app uid even without chown (chmod 644)
- Ignore if execution still works — this is a warning, not fatal
Defensive patterns
Strategy: fallback
Try / catch
Process p = Runtime.getRuntime().exec(new String[]{"su","-c", cmd});
String err = readStream(p.getErrorStream());
if (err.contains("chown failed")) {
// proceed, but ensure jar is world-readable instead
exec("chmod 644 " + jarPath);
} Prevention
- Run the binary as root so chown succeeds
- chmod 644 staged jars so app uid can read them regardless of ownership
- Confirm SELinux policy permits chown on /data/local/tmp
- Treat as benign when execution succeeds
When it happens
Trigger: The process running run_server lacks permission (not root / wrong uid) to chown the file at /data/local/tmp/<am_jar_name>, or the file lives on a filesystem that does not support chown (some emulated/FUSE mounts).
Common situations: Running without root on a non-rooted device; SELinux policy blocking chown on /data/local/tmp; FUSE-backed sdcard paths not supporting ownership changes.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Could not delete the selected backups
- Could not create package staging directory
- Could not create directory ${dataSourceFile}
- Failed to restore ownership info for index ${index}.
- EBADF
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/8aafabae44abbf0b.
Report an issue: GitHub.